Pages: [1]   Go Down
Author Topic: Need a bit of help with I2C  (Read 533 times)
0 Members and 1 Guest are viewing this topic.
Calgary, Alberta, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 22
arduin00b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I have read a lot of useful information on this forum, and it has all helped me in creating my first project. http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1217730619/15#15

Now, I need your help figuring out this little problem im having with I2C. I will mention that I am successfully using two devices on the I2C bus and it is working perfectly on the rover, a wii nunchuck and an ultrasonic sensor. I am now interested in adding a second atmega168, eventually standalone, but for now on another iDuino board, and I wish to communicate via I2C between the two atmegas.

I have it all wired up, with a shared ground between the two iDuinos and SDA and SCL connected together on both, and I am successfully receiving data from the rover's main iDuino as a I2C master on the I2C slave iDuino, viewing the data by printing it to serial. So this part is good, no problems here at all. However, the problem is now my wii nunchuck data becomes corrupt, the rover will not even start up because I cannot read the buttons and the gyro data is all wrong. The code I am using is straight from the master_writer and slave_receiver examples in the Wire library...and I am simply sending one byte to the slave at a time.

Has anyone ever run into this kind of problem with adding a new slave device to the I2C bus? Or with connecting two atmegas together along with other devices on the bus?

One thing I was wondering is do I have to share the resonator/crystal for this to work? I have seen this approach mentioned here http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1205243372/0

Thanks for any insight you can provide.
« Last Edit: August 24, 2008, 08:53:54 pm by steveo1984 » Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 731
skcor oniudrA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, the sharing of the resonator was simply a result of not needing two for 2 168's on the same board.

Prior to the dualCore, I'd run successful i2c tests using two Lilypad's and had no problems sending data from one (master) to the other (slave).

Are you using 2 x 4.7k resistors?

Logged

Calgary, Alberta, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 22
arduin00b
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, I am not using any resistors... I was under the impression that the Wire library activates the internal resistors on the I2C bus and it wasnt needed. Is this incorrect?

My other devices have been functioning correctly without resistors on the sda and scl lines.

Thanks.
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 731
skcor oniudrA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
No, I am not using any resistors... I was under the impression that the Wire library activates the internal resistors on the I2C bus and it wasnt needed. Is this incorrect?

My other devices have been functioning correctly without resistors on the sda and scl lines.

Thanks.

Personally I had no luck getting i2c to work without 2 x 1.8k (not 4.7) resistors.

Here's the pic of the setup from an old post of mine.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1201476854/5#5
« Last Edit: August 24, 2008, 11:15:01 pm by John_Ryan » Logged

0
Offline Offline
Faraday Member
**
Karma: 8
Posts: 2526
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I was under the impression that the Wire library activates the internal resistors on the I2C bus and it wasnt needed.
In general, this is true.  I've used I2C with a few peripherals, and never needed external pullups.

Some peripherals, or perhaps a long bus, could require a stronger pullup than the internals, but I've never hit that situation.

-j

Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 731
skcor oniudrA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Internal resistors activated or not, it would be cheap and especially quick to put a couple of resistors on A4 & A5. The issue ("my wii nunchuck data becomes corrupt") sounds like logic levels floating too erratically to hold a "clean and consistent data stream", and the solution if thats the problem, is a couple of pull ups.

I've read of people using 1.8, 4.7 and 10k on a wide range of different devices, so if you've got them handy you've got nothing to lose by trying.

Logged

Pages: [1]   Go Up
Jump to: