0
\$\begingroup\$

I have an I2C design question.

I currently use an I2C connection with 4.5 m cables (the system is initially planned to use 1.5 m cables). It works surprisingly well so far. Recently I had short data loss.

I have 2 questions:

  • Can the use of abnormally long I2C cable damage the electronic card (because of the resistance, or something else)?
  • What is the most probable cause of these data losses? (I read that the cables act as antennas) it's a controller I2C pulled-up by 1.8 kΩ for information.
\$\endgroup\$
3
  • \$\begingroup\$ At low data rates it can work. \$\endgroup\$
    – Andy aka
    Commented Aug 30, 2023 at 19:06
  • \$\begingroup\$ I confirm it works must of the time, but can it damage the electronic card ? \$\endgroup\$
    – looping
    Commented Aug 30, 2023 at 19:07
  • 4
    \$\begingroup\$ Does this answer your question? How should I optimize I2C communication over a 10 to 25 meter cable? \$\endgroup\$
    – pipe
    Commented Aug 30, 2023 at 19:30

4 Answers 4

1
\$\begingroup\$

I2C is a communication protocol designed for communications within a PCB assembly. It was not designed to be used over long cables*.

"I2C ..., is a synchronous, multi-master/multi-slave (controller/target), packet switched, single-ended, serial communication bus... It is widely used for attaching lower-speed peripheral ICs to processors and microcontrollers in short-distance, intra-board communication." Source

Can the use of abnormally long I2C cable damage the electronic card

Yes. Due to the wires acting as antennas picking up 50 Hz and high-frequency noise.

What is the most probable cause of these data losses?

Interference and badly misshapen waveshapes.

(*) Despite that, it has been included in some carefully designed cable interfaces.

\$\endgroup\$
7
  • 3
    \$\begingroup\$ If it is not a protocol intended to be used for cables, why do so many intefaces, such as VGA, DVI and HDMI, use it over cables? \$\endgroup\$
    – Justme
    Commented Aug 30, 2023 at 19:17
  • 1
    \$\begingroup\$ Can this cause irreparable hardware damage or only data loss? \$\endgroup\$
    – looping
    Commented Aug 30, 2023 at 19:22
  • \$\begingroup\$ "Can this cause irreparable hardware damage or only data loss?" I believe I already answered: "Yes. Due to the wires acting as antennas picking up 50 Hz and high-frequency noise." \$\endgroup\$ Commented Aug 30, 2023 at 19:23
  • 2
    \$\begingroup\$ @DavideAndrea You are leaving the important detail away from the quote - "It is widely used .. for intra-board communication". Not limited to it, which is apparent from the list of buses which use I2C with long cables between devices. So it is, quite succesfully, used over cables. \$\endgroup\$
    – Justme
    Commented Aug 30, 2023 at 19:33
  • 1
    \$\begingroup\$ At best, high error rate. At worst, blown ICs. \$\endgroup\$ Commented Aug 30, 2023 at 19:42
1
\$\begingroup\$

When properly designed and engineered, I2C can go many meters over a cable succesfully, as is proven by billions of cables used in homes, offices, meeting rooms and classrooms - for example each and every modern analog VGA, DVI and HDMI cables successfully use I2C for negotiating supported resolutions between source devices such as computers, video disc players, gaming consoles and displays such as TVs, monitors and projectors.

So I2C is really nothing more than a specific kind of open-collector bus and open-collector buses have been in general used over cables just fine.

  1. Yes. Always the case with long wires. Any nearby source of disturbance may affect the long wires. ESD, nearby voltage or current surges, RF signals from antennas. Lightning, huge motors, arc welding in a factory, etc. are always possible. Even just flipping a light switch in your home may cause a bad system to lock up.

  2. Any glitch on the bus can cause any problem. Either your I2C hardware gets into a state it cannot handle or your software does not handle errors that may happen.

\$\endgroup\$
4
  • \$\begingroup\$ thank you, can you elaborate what are the consequences of point 1 please? what failure can this cause? Do we have similar issues with network cables? \$\endgroup\$
    – looping
    Commented Aug 30, 2023 at 19:34
  • 1
    \$\begingroup\$ Well consequence of point 1 is that long wires tend to see electrical spikes and they can damage the chip and then it is damaged and won't work. Any external interface, e.g. USB with 1 meter cable or Ethernet with 100 meter cable needs protection components so it does not damage when users plug in cables while being charged with static electricty or there's a lightning strike nearby a long 100 meter cable. Ethernet is a transformer isolated interface with requirement to withstand more than 1000 volts between devices so it does not really compare with I2C. \$\endgroup\$
    – Justme
    Commented Aug 30, 2023 at 19:43
  • \$\begingroup\$ thank you, it's clear \$\endgroup\$
    – looping
    Commented Aug 30, 2023 at 19:58
  • \$\begingroup\$ @Justme Thank you for your input, which I have taken to heart and used to correct my answer. \$\endgroup\$ Commented Aug 30, 2023 at 20:11
1
\$\begingroup\$

If you are worried about noise coming down the cable and damaging your electronics, or data loss due to misshapen wave forms, you can place an I2C buffer at either end of the cable. Something like the Texas Instruments TCA4307 https://www.ti.com/product/TCA4307

Here is an example from page 13 of the data sheet for a long distance bus https://www.ti.com/lit/ds/symlink/tca4307.pdf

We

Note that "long distance" isn't defined in the datasheet. It might be because the output properties depend on cable capacitance and voltage levels.

The buffers have many nice features, but for your application, the buffers do two things:

  • Protect your micro controller from electrostatic discharge (ESD) coming down the line.
  • Add more current to the I2C signals to allow them to travel further.

As an example, we had no problems communicating between a Raspberry Pi 4B and a Maxim Integrated MAX7300 over 1 m twisted pair cable. When we went to 2 m cable, approximately 5 % of our messages sent were received incorrectly (or not at all). After adding the TCA4307 buffers to either end of the cable, we sent 500,000 messages without error.

\$\endgroup\$
1
\$\begingroup\$

The risk of damage comes from ESD (static discharge) and EMF (inductive coupling from nearby circuits).

You can guard in two ways:

  1. shielded cables, with appropriately grounded connectors
  2. surge suppression diodes

You will still experience data loss during ESD/EMF events, but will be able to avoid catastrophic damage. Another source of data errors will be the difference in ground potential between the two devices. This difference is dynamic, ie, it changes as the load at the two endpoints changes; suppose you turn on a vacuum cleaner or microwave plugged into the same or nearby outlet as one of the two devices. The local ground level will move up by some non-negligible amount.

To minimize data loss, you have two possibilities:

  1. transceivers which typically incorporate protection, as well as transmit the signal over a differential connection to eliminate common-mode transients.
  2. lower data rates in the 100Kbps range or less

Update to caution about "long range drivers": Other answers suggest use of buffers or drivers meant for "long range", but you should mind whether the two sides of the bus have a common ground or not. Such buffers are suitable in applications where both ends of the bus reference the same ground, like automotive or instrumentation, but not in residential or commercial applications where each end uses a separate power supply, and thus a different ground reference.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.