Go Down

Topic: Need a bit of help with I2C (Read 598 times) previous topic - next topic

steveo1984

Aug 25, 2008, 03:51 am Last Edit: Aug 25, 2008, 03:53 am by steveo1984 Reason: 1
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.

John_Ryan

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?


steveo1984

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.

John_Ryan

#3
Aug 25, 2008, 06:13 am Last Edit: Aug 25, 2008, 06:15 am by John_Ryan Reason: 1
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

kg4wsv

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


John_Ryan

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.


Go Up