View previous topic :: View next topic |
Author |
Message |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
Abusing I2C |
Posted: Mon Apr 08, 2019 12:02 pm |
|
|
Hi,
I have a project where because of *Reasons*... I need to use an I2C device over "long" cables - about 100ft max.
I have seen the differential i2c Extenders but, see above reasons.
I have several projects using Dallas 1-wire products at +100ft at 3.3V which give me enough reasonable doubt to try the following:
Preface:
i2C supports clock stretching.
its Synchronous comms.
I do not need fast
Idea:
Running the I2C bus at a ludicrously low speed to help mitigate the effects of cable capacitance and strong pull ups.
From my readings, i have not found any limitation on how slow you can run the bus (except if SMBUS). Most problems related to distance I've seen is because people want to run the bus at 100khz or higher.
Is there any limit on how slow i can set up the i2c Peripheral on a PIC?
What would this setup look like on CCS?
Is it unreasonable to think this might work?
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 08, 2019 12:21 pm |
|
|
What is the wire gauge of the cable conductors ? How many conductors
for ground ? |
|
|
dluu13
Joined: 28 Sep 2018 Posts: 395 Location: Toronto, ON
|
|
Posted: Mon Apr 08, 2019 1:10 pm |
|
|
I seem to recall temtronic saying that he had connected some rs232 over several miles running at a couple hundred baud or something. Maybe he knows something... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Mon Apr 08, 2019 1:22 pm |
|
|
Have you considered a pair of I2C<PIC>RS485 'repeater' module ? One on each end of the '100' of wire'.
Probably less than $10 in parts these days. Easy hardware and simple software if you use a PIC with HW UART and I2C. Since speed isn't an issue, a PIC with internal oscillator could be used..saves xtal and 2 caps.
You'ld have to weigh the R&D time versus bench/field testing 'long range I2C' but I'm thinking the repeaters might win out.
Just food for thought
BTW my long distance serial communications that dluu13 commented on was 24 baud, direct wire,22 bits with interlaced send/rcv data and tri level. Over the winter I got a $1 PIC to replace the $10,000 computer that did the controls.
Jay |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Apr 08, 2019 2:39 pm |
|
|
4 conductors, multi strand 22awg, unshielded - HOWEVER, thats cause its what i have on hand. Im not against using a different cable if it helps getting this to work, like CAT5 and the likes, i just hate how brittle CAT5 is.
i would be sending 3.3V, SLC, SDA and GND to possibly 1 but upto 3 I2C humidity sensors on a single bus.
i do not want to add/change existing hardware. like i said ive been looking at this: https://www.sparkfun.com/products/14589 but im trying to avoid it. for 10 bucks this is obviously not a cost issue. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9269 Location: Greensville,Ontario
|
|
Posted: Mon Apr 08, 2019 4:52 pm |
|
|
I had a quick read of the SF device and, yeah, I'd probably buy 5 and try them out. At $10 a point that's pretty cheap AND it's already made. Cat5 cable with premade ends is fairly robust. The problems I encounter center on corrosion on the connectors. The 'gold plating' is mighty THIN. For 'industrial' use or reliable communications I use terminal blocks. A lot has to do with what the environment is. Heat, humidity, chemicals, vibration, rats....... In one install I ran CAT5 inside BX armored jacket. You can actually buy the 'BX' without conductors, kinda pricey but man it was a real blessing.
For testing be sure to lay the cable out the full 100' NOT just coiled up on the bench !
I'd also be concerned about IR drop, though I suspect your sensors don't draw a lot of power, again the 'Real World' test will tell.
I didn't see how they (SF) wire the device, but if possible double up on the conductors. |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Mon Apr 08, 2019 6:10 pm |
|
|
So.... how can i set i2c to go super slow? _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Apr 09, 2019 12:43 am |
|
|
Gabriel wrote: | So.... how can i set i2c to go super slow? |
1. Tell us your PIC, oscillator frequency, and compiler version.
2. Also, are you using hardware i2c ? If so, is that a requirement ?
3. Also, is this a 5v system ?
4. What value resistor are you using for pull-ups ?
5. Is your i2c bus going from PIC to PIC, or are there NXP i2c buffers ? |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Tue Apr 09, 2019 6:35 am |
|
|
I did a project where I needed to use I2C on a cable that is 35' long. I tried using the standard I2C functions but they would always hang. After banging my head until I couldn't think I started bit-banging the signals and put a scope on the slave end of the cable. I adjusted the delays, in the master program, until I had the signal wave forms I needed. I made a routine for each I2C function and called each function like I would the standard functions, I just named them with an extra letter at the end so it was easy to remember what I had called them. This has worked for the past 13 years now.
Ronald |
|
|
|