Shop OBEX P1 Docs P2 Docs Learn Events
I2C cable length versus keypad cable length — Parallax Forums

I2C cable length versus keypad cable length

Ron CzapalaRon Czapala Posts: 2,418
edited 2014-05-15 07:10 in General Discussion
I am working on an alarm system using a Parallax 4x4 keypad along with an I2C MCP23008 I/O expander chip (@ 3.3v) using a Propeller board.

I would like to position the keypad about 15-20 feet from the Propeller.

Would it be best to put the MCP23008 close to the keypad an have I2C signal travel 20 feet or
just extend the 8 keypad wires 20 feet and put the MCP23008 close to the propeller.

I read that I2C over Cat5 cable at speeds up to 10khz should work.

Not sure how fast the i2cObject code is running on a 80MHz propeller.

Any suggestions?

Thanks,
- Ron

Comments

  • T ChapT Chap Posts: 4,223
    edited 2014-05-13 14:36
    At lower speeds using basic i2c drivers and such in spin, it is unlikely you will have issues with cat5 at those lengths, I have many systems at 25' with spin i2c drivers and never had a problem. There are i2c extender ic's, but honestly I have put then on (3$ on each end = 6$) and there is no benefit for these lengths of 20' or so. The exception may be some very noisy environment.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-13 14:51
    T Chap wrote: »
    At lower speeds using basic i2c drivers and such in spin, it is unlikely you will have issues with cat5 at those lengths, I have many systems at 25' with spin i2c drivers and never had a problem. There are i2c extender ic's, but honestly I have put then on (3$ on each end = 6$) and there is no benefit for these lengths of 20' or so. The exception may be some very noisy environment.

    Thanks for your feedback. I know there is no simple answer but I was hoping to hear from someone based on their experience. There will not be any heavy data transfers in my situation but since the keypad will be used to disarm the system, I need it to be reliable.

    Guess I cut a 20 ft length off my spool and try it.

    Were you using 5V or 3.3V? I wonder if using 5V for the MCP23008 and stick 1k resistors on the SDA and SCL lines would be better than 3.3 volts.
  • T ChapT Chap Posts: 4,223
    edited 2014-05-13 15:15
    I use SCL with on a pair with 5V to power the remote device. SDA is on a pair with VSS. 4.7K pullup to 3v3. Use filters in the code to ignore anything illegal. In my experience this method is very reliable. I never used shielded cat5 but it doesn't hurt, you would see less noise on a scope.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-13 16:39
    T Chap wrote: »
    I use SCL with on a pair with 5V to power the remote device. SDA is on a pair with VSS. 4.7K pullup to 3v3. Use filters in the code to ignore anything illegal. In my experience this method is very reliable. I never used shielded cat5 but it doesn't hurt, you would see less noise on a scope.

    Thanks again. My first attempt using SDA/SCL as a pair at 3.3V and no pullups failed. I'll try your scenario or maybe just resort to putting everything in one box...
  • TCTC Posts: 1,019
    edited 2014-05-13 16:56
    I use to work with and install fire and burglar alarm systems about 7-8 years ago. I have dealt with DSC and ademco (honeywell, ADT). They all used 4 wires for keypads, zone expanders, cell backups, etc.. The wire was a 24/4 wire, no shielding, no twisted pairs, no cat5. Just a red, black, white, and green wire. I do not know the protocol but someone out there on Google knows. I use to run over 500ft of wire to a keypad in a warehouse, and never had problems.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-13 17:15
    TC wrote: »
    I use to work with and install fire and burglar alarm systems about 7-8 years ago. I have dealt with DSC and ademco (honeywell, ADT). They all used 4 wires for keypads, zone expanders, cell backups, etc.. The wire was a 24/4 wire, no shielding, no twisted pairs, no cat5. Just a red, black, white, and green wire. I do not know the protocol but someone out there on Google knows. I use to run over 500ft of wire to a keypad in a warehouse, and never had problems.

    Interesting. I installed a wired DSC system with two keypads and an expansion board in my house. I wondered what protocol it used.
    It is amazing how many parameters and settings there are.
    I figured it was proprietary and embedded on a chip...
  • T ChapT Chap Posts: 4,223
    edited 2014-05-13 17:29
    I am not sure you can get away without any pullups. Which driver?
  • william chanwilliam chan Posts: 1,326
    edited 2014-05-13 17:30
    If you share SCL and SDA pins with the EEPROM, the Propeller chip might not be able to read the EEPROM at boot time.
    This is due to the faster than Spin I2C access during boot and the capacitance in the longer cable skewing the I2C signals.
    I reduced the SDA pullup resistance to 1K to achieve 20 feet distance on typical 4 wire "alarm cable".
  • TCTC Posts: 1,019
    edited 2014-05-13 17:44
    Interesting. I installed a wired DSC system with two keypads and an expansion board in my house. I wondered what protocol it used.
    It is amazing how many parameters and settings there are.
    I figured it was proprietary and embedded on a chip...

    DSC had the most parameters for there systems. But what do you expect from a DSC 864. 8 zones out of the box, expandable to 64 zones. Each zone expander had 8 zones on it. That was 8 expander boards, on two wires (red and black are power). I don't remember what it used for a chip, but at the time everything was through hole.
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2014-05-13 18:35
    I did have a bad experience with I2C over even 10 feet of 4-wire flat telephone cable. Initially, I was using green and yellow for sda and scl, and black and red for power. No good. The issue was that green and yellow run side by side in telephone cable, and the capacitance between them led to crosstalk. The high-to-low transition coupled a spike into the opposite wire and the i2c device often interpreted that as an extra clock pulse. Decreasing the pullup resistance did not improve the situation; it increased the dV/dt of the coupling.

    Keeping the signal on the outside pair solved the problem completely. The outside pair is black/yellow and the inside pair is green/red. One more step: I ended up with some nice plenum cable with two individually shielded pairs, and ran it with one signal and one power on each shielded pair, shield to ground. That worked fine at 50 feet and I tested it out to 80 feet, running i2c from Spin at ~20kHz. If you are using unshielded CAT5 cable, try to use pairs that are far apart and ground any unused pairs.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-13 19:11
    T Chap wrote: »
    I am not sure you can get away without any pullups. Which driver?

    I am using two drivers actually - Mike Green's for the EEPROM and the ic2Object for the MCP23008.

    I might try using a different set of pins instead of 28 & 29 as William Chan mentioned and use pullup resistors.
  • T ChapT Chap Posts: 4,223
    edited 2014-05-13 19:13
    I don't find that object. Can you post it? Have you seen the object work even with short wires?
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-13 19:21
    I did have a bad experience with I2C over even 10 feet of 4-wire flat telephone cable. Initially, I was using green and yellow for sda and scl, and black and red for power. No good. The issue was that green and yellow run side by side in telephone cable, and the capacitance between them led to crosstalk. The high-to-low transition coupled a spike into the opposite wire and the i2c device often interpreted that as an extra clock pulse. Decreasing the pullup resistance did not improve the situation; it increased the dV/dt of the coupling.

    Keeping the signal on the outside pair solved the problem completely. The outside pair is black/yellow and the inside pair is green/red. One more step: I ended up with some nice plenum cable with two individually shielded pairs, and ran it with one signal and one power on each shielded pair, shield to ground. That worked fine at 50 feet and I tested it out to 80 feet, running i2c from Spin at ~20kHz. If you are using unshielded CAT5 cable, try to use pairs that are far apart and ground any unused pairs.

    I bought a 500ft roll of this cable from HomeDepot a couple of years back http://www.homedepot.com/p/Cerrowire-500-ft-22-4-Stranded-Overall-Shield-Security-Alarm-Wire-Grey-225-0024J2/202206432

    It has 4 conductor 22 gauge stranded wire with a plastic/foil sort of shield along with an uninsulated ground wire. I could run two cables and with SDA in one and SCL in the other.
    I can use the other wires for the LCD and piezo speaker.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-13 19:24
    T Chap wrote: »
    I don't find that object. Can you post it? Have you seen the object work even with short wires?

    This is Mike Green's http://obex.parallax.com/object/155 and this is i2cObject http://obex.parallax.com/object/26

    It works great with 12" wires

    Here is a video https://www.youtube.com/watch?v=plLQFZlsKHA

    And a link to the Project Forum thread http://forums.parallax.com/showthread.php/155592-Alarm-System-video-Propeller-keypad-(w-MCP23008)-LCD
  • T ChapT Chap Posts: 4,223
    edited 2014-05-13 20:02
    The i2cobject mentions a mode for "correct pullups" but also a mode without. I would use the pullups on whatever pins you choose.
  • MrBi11MrBi11 Posts: 117
    edited 2014-05-13 20:18
    DSC uses it own protocol it's a single ended RS485 that transmits and receives (to the panel) one direction on the rising edge and one on falling edge.@ 100KHz

    the 4 daya bus wires are 12VDC, ground, clock & data
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-14 07:16
    MrBi11 wrote: »
    DSC uses it own protocol it's a single ended RS485 that transmits and receives (to the panel) one direction on the rising edge and one on falling edge.@ 100KHz

    the 4 daya bus wires are 12VDC, ground, clock & data

    I suspected it might be a RS485 variant but figured it would use encryption or something since it is utilized in security systems.

    I'm sure someone has used a logic analyzer to check it out.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-14 07:58
    T Chap wrote: »
    The i2cobject mentions a mode for "correct pullups" but also a mode without. I would use the pullups on whatever pins you choose.

    I did read something about pullups making I2C more reliable for longer distances - guess it has something to do with thresholds.

    The schematic for the Propeller protoboards shows 10K pullups on pins 28 and 29 (for the EEPROM) so adding additional 4.7k resistors in parallel would actually lower the combined resistance, right?
    Or is that the goal?
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-14 11:03
    Just for the heck of it I tried extending the keypad wires to the MCP23008 using 20ft of CAT5.
    The MCP23008 detected buttons being pushed using the Interrupt-on-change method but it was almost always the same value regardless of which button I pressed.
    Capacitance issue I assume.

    Oh well.

    I am surprised that no one has a I2C/RS485 converter available.
  • SapphireSapphire Posts: 496
    edited 2014-05-14 15:39
    I think one should keep in mind the original intent of I2C (IIC, Inter-Integrated Circuit) was for chip-to-chip communication on a PC board with a common ground connection. Of course, people have tried to extend the capabilities, and some short distances might work, but I would not design a circuit using I2C that goes outside the product. To much potential for noise, spikes, way out of spec capacitance, etc. that could cause problems. If you want RS-485, that can be easily done with inexpensive line drivers.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-14 18:35
    Sapphire wrote: »
    I think one should keep in mind the original intent of I2C (IIC, Inter-Integrated Circuit) was for chip-to-chip communication on a PC board with a common ground connection. Of course, people have tried to extend the capabilities, and some short distances might work, but I would not design a circuit using I2C that goes outside the product. To much potential for noise, spikes, way out of spec capacitance, etc. that could cause problems. If you want RS-485, that can be easily done with inexpensive line drivers.

    I tend to agree with you - I2C is not a long distance runner - sprints only!

    I added 4.7k pullups to SDA and SCL, 5V to the MCP23008 (along with 1k inline resistors on SDA, SCL and INT pins). Also tried pins 14&15 for I2C.

    Works great with 1 foot wires but no joy using 20ft of CAT5.

    I have some MAX485 chips and even considered using a PICAXE to handle the I2C to RS485 but decided that was adding too much complexity.

    Guess I'll put everything in one box along with the 12V gell cell and charger.

    Thanks to all for your tips and suggestions.

    - Ron
  • Clive WakehamClive Wakeham Posts: 152
    edited 2014-05-14 18:38
    P82B715.pdf

    Hi.

    The NXP P82B715 I2C extender chip is designed to allow transmission of I2C signals up to 50 metres.
    Of course that means running the signal between the two extender chips at 12 volts.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-14 19:20
    P82B715.pdf

    Hi.

    The NXP P82B715 I2C extender chip is designed to allow transmission of I2C signals up to 50 metres.
    Of course that means running the signal between the two extender chips at 12 volts.

    I looked into those a little. T Chap mentioned extender chips in post #2 but said he did not see much benefit.

    Have you used them and had satisfactory results? Supposedly they can use 3v to 12v.
  • T ChapT Chap Posts: 4,223
    edited 2014-05-14 19:26
    To clarify, the extenders work great. When I say there was no benefit, I meant that NOT using the extenders works perfectly for me, so there is no point adding a 3$ chip at each end if what you have works well. You should easily run a spin i2c driver at 25' on cat 5.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-14 19:36
    T Chap wrote: »
    To clarify, the extenders work great. When I say there was no benefit, I meant that NOT using the extenders works perfectly for me, so there is no point adding a 3$ chip at each end if what you have works well. You should easily run a spin i2c driver at 25' on cat 5.

    Ah - I misunderstood. I wasn't able to get it working as I mentioned in post #22. I suppose it could be a difference in what I2C device you are using and what propeller driver code you use.

    The last thing I want is to have an alarm system blaring and not be able to disarm it because the keypad won't respond...

    And I agree - $3 a chip seems high. I saw them at Jameco so I might get some the next time I order from there.
  • T ChapT Chap Posts: 4,223
    edited 2014-05-15 04:31
    The spin drivers are pretty slow. I would suspect there are problems other than the cable length in your case. You may want to provide a more detailed schematic for how you wired it including pullups, photos, code,etc. A scope will likely identify signal degradation in a matter of a few minutes of testing. The parallax logic analyzer will show the i2c transmissions.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-05-15 07:10
    T Chap wrote: »
    The spin drivers are pretty slow. I would suspect there are problems other than the cable length in your case. You may want to provide a more detailed schematic for how you wired it including pullups, photos, code,etc. A scope will likely identify signal degradation in a matter of a few minutes of testing. The parallax logic analyzer will show the i2c transmissions.

    I appreciate your help and suggestions but the whole CAT5 approach seems a little finicky. Since it is going in the garage, the easiest approach would be to move the alarm panel next to the door and put the keypad right on the alarm panel.

    I may still order some I2C extender chips to study and play around with.

    Thanks for your help. I'll chalk this up as a learning experience.
Sign In or Register to comment.