I am developing a dolly-pan-tilt system, where an Arduino is connected via I2C to three independent rotary encoders for positioning. Having read a few posts on this site and elsewhere, I am aware that I2C has a limitation regarding distance of the cables for correct signal transmission. My issues/questions are the following:

SDA and SCL wires ought to be twisted, although some think they don't need to? I am thinking of using a twisted SDA/SCL for each function, dolly, pan and tilt movement, which sit very close to each other on a 24pole flat ribbon cable. So, twisting is probably adequate as well as an I2C repeater, as the distance between the Arduino controller for the dolly encoder is around 2.20m, the distance for the panning encoder is about 1.80m and the tilt encoder is closer with 0.60-0.70cm.

However, I have seen mention of I2C repeaters as well as extenders: which one is better suited as they seem to both be doing the same?

I2C extender: P82B715

I2C repeater: CPC5902G by Clare

What is truly the difference and advantages between the two ICs? Also, I read somewhere, that the overall distance between the master and his I2C slaves ought to be considered, in my case: adding up the above mentioned distances 2.20m+1.80m+0.70m for all three movements, and not consider them independently towards the microcontroller; —is this valid?

As unfortunately all three I2C cable pairs are right next to each other (distance between each line is 1.26mm) on the ribbon cable followed by the GND line, it can still get noisy as thereafter are the cables driving the DC motors +/- @ 12V and up to 2A. I did my calculations regarding wire capacitance concerning the ribbon cable AWG (28), based on this website and ended up with 38.51pF for 2.5m of cable.

The datasheet of my encoders demands though to remain below 10pF, in order to ensure correct operation!

  • 7
    \$\begingroup\$ The I2C SCL and SDA wires should certainly NOT be twisted together! Twiosting them each with a ground wire might be good, but keep an eye on the to-ground capacitance. \$\endgroup\$ – Wouter van Ooijen Jun 11 '12 at 10:29

Where did you get the idea that SDA and SCL lines should be twisted?

This is the second worst thing you can do to I2C communication next to cutting the wires.

Twisting is suitable for differential lines such as CAN or RS485/422.

With slow enough communication you probably won't even need repeater/extender on 2.5m. Especially, if this a 5V system. Just untwist those I2C lines.

If you have some spare lines on the ribbon cable try to put some GND lines in between I2C (non-twisted )pairs or even between SDA and SCL of same channel.

EDIT: there is a way where twisted-pair might come in handy for I2C. It is where each of the two signals is transmitted differentialy (some kind of 4-wire I2C).

Driving I2C-bus signals over twisted pair cables with PCA9605 transmits SDA bidirectionally over a twisted pair of wires.

Sending I2C-bus signals via long communications cables with P82B96 or PCA9600 explains the advantages of transmitting SDA using a unidirectional "4-wire driving method".

| improve this answer | |
  • \$\begingroup\$ Thought it was a bit strange, but since the manufacturer of the encoders had also already twisted the wires of a length of about 12cm, —but, probably to separate them getting confused with the Uart Rx/Tx, it kind of seemed adequate to follow what had been already 'implied'. Thanks for clearing this up for me! I have already separated the digital signals from the motor lines by a GND line, but not in between each pair as you mention, but between the signal side of all three pairs and the other side driving the DC motors. Perhaps this is not enough. \$\endgroup\$ – AndreasB Jun 12 '12 at 9:08
  • \$\begingroup\$ It should probably be enough - but probably is a strong word :) Usually when one is laying out these lines on PCB one would also put a ground track between SDA and SCL - if there's enough space, of course. If you can drive DC motors trough separate cable that would probably be the best way to go. or cut the ribbon cable between motor lines and communication lines & put a shield around the communication lines. But first try to check the I2C signal quality&shape with oscilloscope if possible. \$\endgroup\$ – Rok Jarc Jun 12 '12 at 9:12
  • 1
    \$\begingroup\$ Yes, that's probably best, as I have constructed most of it already, and am faced with the I2C issues as explained in the datasheet which I have pasted below (in my answer to Ben Voigt) …the document seems to be either wrong, or misleading as regards repeaters etc. Thanks again! \$\endgroup\$ – AndreasB Jun 12 '12 at 18:18

Don't twist SDA and SCL together. Do put a ground wire between motor supply and digital signals. If possible, put the digital signals inside a shield. You may need to run two cables in parallel -- one for digital signals and one for the motor. Also make sure you are using separate digital and analog ground. I2C is VERY sensitive to noise.

A repeater will not help, since it just makes the good signal stronger, without making the noise weaker. If the noise is strong enough to cause false edges, it will also be strong enough for the repeater to detect edges and amplify them.

| improve this answer | |
  • \$\begingroup\$ Thanks for pointing this out. Still, is the length of almost 2m not an issue, as the datasheet of the encoders mentions the following: \$\endgroup\$ – AndreasB Jun 12 '12 at 9:07
  • \$\begingroup\$ "The I2C standard dictates that bus capacitance for each line should be kept below 10pF. Bus capacitance is important for correct bus operation. For the wiring of the SDA and SCL lines a twisted-pair configuration is recommended to ensure minimum bus capacitance. If the overall length of an I2C bus induces a higher bus capacitance than 10pF correct operation cannot be ensured. In that case an I2C repeater is recommended. As a rule of thumb I2C is adequate for bus lengths of up to 1m and should be avoided without the use of repeaters for longer buses." \$\endgroup\$ – AndreasB Jun 12 '12 at 9:16

Having a long cable has two effects. The first is additional capacitance on the bus. The second is propagation delay. As an example a CAT-5 cable adds about 18pF/ft of capacitance, and has a propagation delay of about 0.6ft/ns.

Compared to other types of digital busses I2C is pretty slow. The added capacitance of a few meters of cable is probably negligible given that Table-6 of the I2C specification 3.0 says you can have as much as 400pF on each line SDA/SCL.

The propagation delays introduced by a few meters of cable is also probably negligible given that Table-6 of the I2C specification 3.0 allows the rise times of the SDA/SCL signals to be up to 1us.

Overall you probably don't need to add a repeater.

You may be misreading your encoder datasheet. 10pF is the maximum pin capacitance allowed for someone designing a chip that connects to the bus. In your case since you are constructing the bus itself not a chip you probably just need to keep the total on each line under 400pF.

I certainly would not twist SDA and SCL together since they are completely separate digital signals, not a differential pair. Twisting them together will capacitively couple them and cause cross-talk that will make your communications less reliable (meaning clock pulses showing up in your data and data bits in your clock).

You may however twist SDA and SCL each to their own separate ground wire if you wish. This will improve noise immunity at the expense of a little extra bus capacitance.

Shielding SDA and SCL may also be helpful.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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