Off the Board I2C Communication Problem

Thread Starter

Johnny1010

Joined Jul 13, 2014
96
Hi guys,

I am interfacing my microcontroller to an IMU (accelerometer + gyroscope) via i2c. Now when I have the microcontroller and the IMU mounted on the same PCB or on the same breadboard everything works nicely, the distance of the track or the wire length doesn't matter. But when the microcontroller is on one PCB board and the IMU is on another PCB board connected with wires I get a lot of noise in the data with the i2c also hanging a few times. Same is the case when I place the controller and IMU on different breadboards.

Can't seem to figure out the issue. Thanks in advance for the help.

Regards.
 

JohnInTX

Joined Jun 26, 2012
4,787
Did you use pull up resistors on the i2c lines?
+1
Things to consider also:
Make sure you have a good power/ground between the two boards with enough current carrying capacity to avoid voltage offsets between the two boards. Be sure you don't have excessive voltage drop over the power lines.

If you are running a single supply for both, be sure to add a decent sized electrolytic capacitor on the remote board (maybe 10uF || 1uF ceramic) to stiffen the local power busses and provide decoupling for the I2C device(s).

If each board has its own supply, you still need a good ground reference between the boards. Remember that power AND signal grounds share that wire. Make sure that the separate supplies are within tolerance.

If the connection between the boards is lengthy and you are running high speed I2C, you might have to reduce the value of the pullups to compensate for increased cable capacitance. For slower speeds sometimes increasing the pullup value will roll off the sharp switching edges, reducing reflections - it just depends on what you are trying to do, how you are hooked up and what you see on the scope. Basic I2C is single ended comms so it can be noise-sensitive.

If you have other things on the IMU board, consider dedicated power/ground for the IMU chip so that its I2C signals don't have to share noise with those other devices. Connect the dedicated power/ground close to the supply regulator on the main board and add decoupling there as well.

Try the comms at a slower speed.

I2C lockup can be caused by cable noise and reflections that cause the slave I2C to misread SCL line, getting it out of sync. The usual procedure when this happens is to send up to 9 SCL and inspect SDA each time. When SDA goes high, send a stoP condition to resync the slave.

These are guesses of course. Without more info, scope shots etc, it's hard to offer a specific solution but hopefully its food for thought. A detailed sketch of what you are trying to do would help including which uC you are using, distances, pullup values, etc.

Good luck.
 
Last edited:

Thread Starter

Johnny1010

Joined Jul 13, 2014
96
+1
Things to consider also:
Make sure you have a good power/ground between the two boards with enough current carrying capacity to avoid voltage offsets between the two boards. Be sure you don't have excessive voltage drop over the power lines.

If you are running a single supply for both, be sure to add a decent sized electrolytic capacitor on the remote board (maybe 10uF || 1uF ceramic) to stiffen the local power busses and provide decoupling for the I2C device(s).

If each board has its own supply, you still need a good ground reference between the boards. Remember that power AND signal grounds share that wire. Make sure that the separate supplies are within tolerance.

If the connection between the boards is lengthy and you are running high speed I2C, you might have to reduce the value of the pullups to compensate for increased cable capacitance. For slower speeds sometimes increasing the pullup value will roll off the sharp switching edges, reducing reflections - it just depends on what you are trying to do, how you are hooked up and what you see on the scope. Basic I2C is single ended comms so it can be noise-sensitive.

If you have other things on the IMU board, consider dedicated power/ground for the IMU chip so that its I2C signals don't have to share noise with those other devices. Connect the dedicated power/ground close to the supply regulator on the main board and add decoupling there as well.

Try the comms at a slower speed.

I2C lockup can be caused by cable noise and reflections that cause the slave I2C to misread SCL line, getting it out of sync. The usual procedure when this happens is to send up to 9 SCL and inspect SDA each time. When SDA goes high, send a stoP condition to resync the slave.

These are guesses of course. Without more info, scope shots etc, it's hard to offer a specific solution but hopefully its food for thought. A detailed sketch of what you are trying to do would help including which uC you are using, distances, pullup values, etc.

Good luck.
Thanks for a detailed answer. Yes, I am using pull up resistors. I was originally using 4.7k and then brought the values down to almost 1k to get rid of the noise it helped a little bit but the problem wasn't solved. Even tried slowing the i2c speed didn't work as well. I am running both the boards at a 3.3V single supply and my i2c speed is 400kHz. My original thought was that the length of the wires that I am using was the issue. I am using 70 cm long wires.
But then I shifted all of my circuit on a breadboard to try different wire lengths and see that at what length the problem begins. When I used the 70 cm long wires to connect my IMU and controller on the same breadboard, there was no problem. But as soon as I shifted my IMU to another breadboard I was getting noise even at 10 cm length of wire.
I'll try the capacitors and the other suggestions to see if it works and also try to get my hands on a few scope shots.
 

shteii01

Joined Feb 19, 2010
4,644
What is the supply range on your 3.3V chips?
Normally for 5V chip they would say 4.75 to 5.25 volts. What is the normal for 3.3V chip?
 

Papabravo

Joined Feb 24, 2006
21,225
You're kinda on your own here, since AFAIK I2C was never designed for offboard applications. You might want to try open collector line drivers and receivers or even RS485 transceivers. This research is not for the faint of heart however and there are numerous challenges. The trick with RS-485 transmitters is that you hold the input high and send the data to transmit enable. This makes the transmitter drive A & B apart or let the passive devices move the differential lines back together.
 

Thread Starter

Johnny1010

Joined Jul 13, 2014
96
What is the supply range on your 3.3V chips?
Normally for 5V chip they would say 4.75 to 5.25 volts. What is the normal for 3.3V chip?
I am using an nrf51822 chip with 1.8 -3.6 V range and the IMU is has a 2.375V-3.46V range. I have tested the supply, I am getting stable voltages of 3.28V on both the chips.
 

jpanhalt

Joined Jan 18, 2008
11,087
Definitely be sure your supply lines are decoupled. As just an anecdote, not a recommended procedure, I have used I2C between two solderless breadboards. The connecting wires were at least 4"; pull-ups were 4.7K.

John
 
Top