Memoirs of an overgrown I2C bus
In 2009, I worked on a instrument which had a large and complex I2C bus.
- Four PIC microcontrollers: one is a master, three slaves. "Dumb" peripherals too: EEPROMs, I/O expander, digital potentiometer.
- 1.8m [6ft] cable. One of the slave PICs was at the end of the cable. The cable is hot-pluggable.
- AC power going through the same cable at the same time as I2C communication. 500kHz sine wave. 300W power. High voltage in some modes of operation, high current in others. That’s interference from the I2C’s perspective.
- A section of the I2C bus was galvanically isolated.
Yes, we were able to make all those complications work reliably. But, was the I2C the right communication bus for that instrument?
I2C is not intended to operate over cables, and it's not intended to operate in presence of EMI. Differential buses, such as RS-485 or CAN, are better suited for this kind of scenario. Such bus is inherently more EMI-resistant. It would work well for communication across the cable and between the boards, while I2C could provide convenient short range communication within the immediate neighborhood of each microcontroller.
Related
Sending I2C bus signals via long communications cables. Application note AN10658 by NXP (2008).
Very large I2C bus systems and long buses. Application note AN11084 by NXP (2011).
These app notes were helpful. At the same time, instead of stretching I2C way beyond its intended use, one should consider switching to a communication bus that's actually intended for longer range.