Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 20:22 29 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Yes, another I2C cable length question...

Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 04:19am 25 Apr 2015
Copy link to clipboard 
Print this post

I know, I know - you are all about to say this has been covered many times, by many members, on many forums.

However, one issue I am having, is in trying to decide who is right and who is wrong.

The generally accepted data on I2C is that it should IDEALLY be kept within the physical limitations of the physical PCB and it's associated chips - that is after-all, what I2C was designed for.

In my case, I don't need much length - 3 meters TOPS, probably 2.5 meters or so.

With that in mind, I intend to run some tests in the next few days, with a few meters of cable.

Now, some forum posts say you should use TCP(twisted copper pair) like network cable, and others are saying shielded cable such as stereo audio cable.

Other post again are saying just use four-core security wire for shorter runs.

I am a little confused an in a bit indecisive on cable type - I have all of those, so I guess I will start with the cat5 cables, only cos I have heaps of short ones for use on patch-panels, so this would make daisy-chaining I2C PCB's nice and easy.

I also have shielded stereo audio cable, and 4-core security wire.

...which to use? ...which is best?

The shielded audio wire is making me think twice, as the capacitance of the sheild could upset the I2C bus lines, yes?

In my case, I2C speed is NOT important, so a speed of 10kHz will be the one I use, as I only need to transfer a few bytes as positional sensor data.(the slaves send data when the sensors are tripped, but spend 99% of their life sitting idle)

I write all this guff, so you can see what I am trying to do, and can thusly advise if you think this is do-able in a reliable way with I2C, or if I should be looking at another bus for this.

I am aware of RS485, and could use this too, but expansion of I2C would make things very simple for me to build around. 485 requires extra interfacing chips.

Suggestions?
Thoughts?
Opinions?

Smoke makes things work. When the smoke gets out, it stops!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8584
Posted: 04:34am 25 Apr 2015
Copy link to clipboard 
Print this post

I've got non-twisted 4 core + shield running perfectly happily over 4m. I terminate the shield to GND just at the master (standard practice for audio)

The important bit is to use low value pullups - I use 1K2 and slowish speed.

You don't want twisted pair cable unless it is just +ve and GND that are twisted
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 04:58am 25 Apr 2015
Copy link to clipboard 
Print this post

I2c does not use a balanced signal so you better use non twisted wires.
For connecting mcu's i prefer rs485.
I2C can get confused and lock up especially when signal levels transitions are getting less square.
This happens easily when you use longer cables and more modules on the same i2c lines.
Ask me how i know. On second though, better not as it will remind me of a few months lost time trying to connect modules over i2c on a back plane and lengths within 1 meter.

You mentioned speed is not important, what about reliability?
It would be such a pain if you decided later to add another module and the i2c stops working.
No such risk with rs485.
Another concern would be earth loops. When cables get longer you are going to create them.
With rs485 you just choose another driver, one that is isolated. With i2c it is game over.



Edited by TZAdvantage 2015-04-26
Microblocks. Build with logic.
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 07:26am 25 Apr 2015
Copy link to clipboard 
Print this post

There are a few different types of i2c bus extender chips out there, but doing the differential type of signaling for longer distances is the way to go. I've always thought that this redesigned with cat5 or 6 female rj45 in and out connectors for easy plug and play for i2c would be a great idea. I also agree that rs485 is a smart way to go, but the i2c setup and commands work so well that it would be great if it was easily and reliably extended. Just my opinion.

Here is a video of it in action.

To answer your question, I have "gotten away with" about 3 feet with standard 22 ga. cable non shielded and at 100 speed 4.7k pull-ups with no problems at all.Edited by viscomjim 2015-04-26
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 761
Posted: 07:47am 25 Apr 2015
Copy link to clipboard 
Print this post

Agree Tz...

The driver/receiver chips take care of the problems of getting data across the wires on medium size runs... I think worth the hassle of doing it... Uart transfers are fast and you can use the 9bit addressing mode if wanted... However, you don't have to just use Uart based comms with this hardware. You could also use it with the SPI interface as well... Maybe it's time to spin up a 2 channel isolated Rs-422/285 transceiver board... I'm sure you could get different kinds of boards online that would just "plug-in" to the vector board for doing prototypes... WW has some of my 28 pin boards with Rs-485 built in also...
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 01:04pm 25 Apr 2015
Copy link to clipboard 
Print this post

Gday Grogs,

The easy way is to TRY IT!!!
What have you got to lose?

Personally I would use one pair of a UTP (Unshielded Twisted Pair) Cat5/6 cable.

It is a little known fact that Unshielded twisted pair cables are better at noise rejection than Shielded types.

I would leave the other pairs `free'.. You might be amazed at how far you could actually transmit an I2C connection over UTP.

I will be very interested to hear your results..

I also concur with using RS485, in fact I have recently designed an add-on for work that uses 485 (4 wire) chips.. It would be my pleasure to send you a few PCBs if you desire.. They are designed to directly plug into MuP, I know I sent you a few of those some time ago..

Of course that would mean using a COM port instead of I2C and that may not suit your application.

Regards,

Mick




Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 02:44pm 25 Apr 2015
Copy link to clipboard 
Print this post

Thank you all for your replies.

I was unsure if I would get any - the "I2C cable length" topic has been covered so many times, by so many people, on so many forums, if you know what I mean.......

Thank you for your advise on 485 - I will take it under advisement.

Opinion seems quite evenly divided between those who report success using I2C on cables vs those in favour of a differential setup like 485. Therefore, I still intend to try my method with some tests over the next few days.

@ Mick - Yes, I currently use about 70 meters of CAT6 cable with transformer bulans from Altrononics, I think it was, to send stereo audio from my mixer to the FM transmitter in the garage outside. This cable is standard CAT6 with no shield, and the link is totally hum-less and silent, despite no shield. The tranny's are high-quality HiFi types, and become a 600-ohm differential link. The CAT6 cable is arranged as two-pair per channel, solid colour wire is the + or - for each channel, and the trace colour for each is a ground. Works far better then I ever thought it would, and no need for expensive balanced audio cable. I only built one as a test, and it worked so well, that I installed it like that!

EDIT: Successful tests using CAT6 cables and 4k7 pull-ups. I am using the green and orange pairs for the I2C. Orange is SDA, Orange/White is ground. Green is SCL, Green/White is ground. This gives both the data and clock lines a ground wire to reduce crosstalk. Tests are 100% integrity at more then 10 meters and 400kHz speed.(not that I will be running it that fast, as 10kHz is plenty) Brown and blue pairs are unconnected, but the brown pair will become the 5v supply for each of the slave nodes on the same cable.
Edited by Grogster 2015-04-27
Smoke makes things work. When the smoke gets out, it stops!
 
boss

Senior Member

Joined: 19/08/2011
Location: Canada
Posts: 268
Posted: 05:41am 27 Apr 2015
Copy link to clipboard 
Print this post

@Grogster

In the old good days before RS485 was born we were used optically an isolated RS232 up to 3000ft @9600Bd (19200 at 1000ft).

\



 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024