I2C over twisted pair

sniper887

Member
I have been working on a multiple RGB LED project, with an 08M2 I2C master, sending signals over 4 conductor cable to TLC59108 LED drivers on separate boards, daisy-chained together. The problem I'm having is on the LED board furthest from the master. It usually works but occasionally will stop working, and i'll have to disconnect and reconnect power to restore it. I'll post schematics later, but the I2C master board is just the 08M2, the download circuit and jack, power jack for a wall wart, 22uF capacitor for filtering, a 4 pin connector to hook to the LED boards with +, -, SDA, and SCL. The two 4K7 pull up resistors are also on the I2C master board. IIRC I also have a decoupling cap for the 08M2. On the LED boards is two 4 pin connectors, the RGB LEDs, TLC59108 and the necessary components to make the TLC59108 work. I'm thinking there's an issue with capacitance on the SCL and SDA wires, or possibly crosstalk. I currently have SCL and SDA on one twisted par, and the two power on the other twisted pair. (wires pulled out of cat5 cable)
 

Buzby

Senior Member
See the spec for I2C here : www.cs.unc.edu/Research/stc/FAQs/.../I2C-BusSpec-V2.1.pdf

Max bus capacitance is 400pF.

As you will see when you look at the spec, I2C was designed for connecting IC's together, in things like TV's and HiFi's, not long distance stuff.

Hope this helps,

Buzby

EDIT : Section 17.4 talks about long lines ( over 10cm ! ), and how to use twisted pair cables.

Another EDIT : Just found this site : http://www.i2c-bus.org/videos/

Scroll down to see 'STARLIGHT RGB LEDs'
 
Last edited:

jedynakiewicz

Senior Member
The reference that I use for I2C is www.nxp.com/documents/user_manual/UM10204.pdf . NXP originated as Philips semiconductors, the chaps who originally designed the I2C system. This manual is most helpful and gives the wiring pattern for the extended bus lines, together with the details of the appropriate pull-up resistors etc. needed for proper operation. As Buzby points out, as far as I2C is concerned, a long line is anything over 100mm. The manual advises that if the bus lines are twisted pairs, each bus line must be twisted with a Vss return. Alternatively, the SCL line can be twisted with a Vss return and the SDA line twisted with a Vdd return. With the second option capacitors are needed to decouple the Vdd line to the Vss line at BOTH ends of the twisted pairs. Interference can be minimised by using shielded cable with the shield connected to Vss, but there must be low capacitive coupling between the SDA and SCL lines to minimise crosstalk.

I think you may need to rewire....
 

sniper887

Member
About 12 feet total, about 8 feet from the last working LED board to the one not working. Apparently too far. I also switched the pairs out to have one twisted pair for SDA and +, another for SCL and -, now it hardly works at all. Now I've heard of active pull-ups or constant current pull ups. Would they help with this situation?
 

SAborn

Senior Member
Change your pullup resistors to a lower value and it will all work, i would use a resistor somewhere from 1K to 4K7.
 

inglewoodpete

Senior Member
Did someone mention my name?:eek:

If you are just having trouble with the last station on the bus, I suggest you simply slow down the signalling speed. It's a lot easier than rewiring or adding chips etc.

If you are running the i2c master at 4MHz, instead of using "i2cslow_4" in the setup command, use "i2cslow_8". This will give longer signalling pulses and help to overcome the capacitance of the long cable. Similarly, if running at 8MHz, configure with "i2cslow_16".

Give it a try, it's the simplest solution!
 

SAborn

Senior Member
On further thought, i think i went much lower on the pullup resistors and 330 ohm comes to mind now, it was 10 x I2C temperature sensors on the bus with over 15m of cable, with the sensors dasiy changed together using RJ12 connectors (phone connectors) and the cable used was the flat 4 core phone cables.

OK i can hear the forum experts rustling in their views about now, although its been working for several years without a problem. (as i brace for an attack of thats to low for a I2C pullup!!)

I do remember dropping the pullup resistor values and testing over the cable length till it returned 100% reliable data, with the view a picaxe pin can sink 20ma the 330 ohm is still within the limit. (its still in operation years on logging temp on a constant loop)

Worth a try if the other solutions offered dont fix it.
 

Buzby

Senior Member
The document referred to in #9 has a really good description of how to calculate the correct value for pullups, and exactly what they do.
 

sniper887

Member
Did someone mention my name?:eek:

If you are just having trouble with the last station on the bus, I suggest you simply slow down the signalling speed. It's a lot easier than rewiring or adding chips etc.

If you are running the i2c master at 4MHz, instead of using "i2cslow_4" in the setup command, use "i2cslow_8". This will give longer signalling pulses and help to overcome the capacitance of the long cable. Similarly, if running at 8MHz, configure with "i2cslow_16".

Give it a try, it's the simplest solution!
I was wondering if it were possible to do that. I'll give it a try. Thanks for the info!
 

sniper887

Member
I tried to slow down the speeds, still problems. Then I remembered hearing on here the importance of decoupling capacitors. I first installed one on the farthest away board, and a closer one stopped working, that is until I put a decoupling cap on that one also. So far all 3 boards work. Any more boards I make I'll incorporate decoupling caps into. I'm thinking of power spikes or something causing the LED driver to reset. Since the code doesn't repeatedly send out the set up bytes for the driver, it just doesn't light the LEDs until I disconnect power and reconnect it.
 

JimPerry

Senior Member
I tried to slow down the speeds, still problems. Then I remembered hearing on here the importance of decoupling capacitors. I first installed one on the farthest away board, and a closer one stopped working, that is until I put a decoupling cap on that one also. So far all 3 boards work.
Cables are like radio aerials - they receive and transmit lots of electrical "noise" - small value capacitors help filter it out - as you have discovered :)
 
Top