Long distance SPI: Lessons learned

Protocols like SPI, I2C, and UART are intended for chips sharing a PCB, lots of problems crop up when you try to send them over long distances. Michu designed individually controllable LED modules controlled by SPI signals sent over long lengths of cable. Initially he had lots of noise and buggy control. After some debugging and rewiring he got the system to work by eliminating ground voltage differences and buffering the signal. The link has a great writeup of the problem diagnosis and various solutions.

Via the forum.

Join the Conversation

13 Comments

  1. I think problems would be encountered due to the capacitance of the trace – the longer it goes the badder it becomes. – for I2C ide try a stronger pullup

    1. im not acquainted with CAN – but SPI and I2C are good, lots of libraries and stuff. they just need to fan out the driving capability of the pin by using a digital buffer or having stronger pull ups

      1. I2C and SPI are just naive approach to this problem and are only good for IC to IC connections onto the same PCB, not over 11m length cables.

        There are 3 main reasons to that:
        – as you get longer cables, you will approach the wavelength distance, so you will stumble upon stationary/progressive wave problems if your cable is not impedance-matched correctly
        – there will be a significant voltage drop with such distances with low absolute 3V3 voltages
        – the cable will be subject to differential and common mode interference, making the whole thing unreliable

        Having stronger drive and/or pullups will not solve the problems.

        The only good way to go is to use differential signaling and impedance-matched cable, like the one used with CAN or RS485 busses.

      2. I2C and SPI are just naive approach to this problem and are only good for IC to IC connections onto the same PCB, not over 11m length cables.

        Not necessarily. We use 10+ metre cables using multi-slave I2C, but using a P82B96 Dual bidirectional bus buffer. This can split the Bi-directional I2C signals into uni-directional signals, allowing things like opto-isolation, and allows our signalling to run at a much higher voltage (12V, so noise is not such an issue). Load capacitance restrictions are almost completely elimitated. Plus I2C has lots of libraries and devices!

    1. Do you have advice on how to implement this using an addressing scheme? Also what hardware do you suggest?

  2. I second Rangerbob. Have used I2C for a temp sensor over a 6 feet coax for a ultrasound probe. The constraint for I2C to work is load capacitance and not distance. It is very forgiving and there is NO need for any controlled impedance and impedance matching. At least not that I know of and I have implemented I2C on Rigid FR4, Flex and Co-Ax cable just for the record.

  3. I guess if you succeed with your project, its fine. I know that using non-twisted cables is not ideal, I know (now) that rs485 would be the best choice. However not the simplest nor the cheapest.

    And I agree with philip, its very easy to work with SPI/I2C… with an Arduino. As long as your update speed is not very fast, its fine.

    Thanks for your input!

  4. Use a strong pull-up and add a weaker pull-down, especially at the END of a cable run. Sometimes this can help a lot to terminate reflections on long cable runs by ensuring a direct HF path to ground at the termination point. As this implementation is single-ended, use very robust ground cabling to reduce the build-up of ground potential. Finally, the way you’ve got the grounding set up lends itself to ground loops (Google it).

    I would try to find a balanced, not single-ended solution for something like this where there are high current low-voltage loads over a long cable run. But sometimes that’s just not possible. Case in-point is putting a -48VDC powered long-range microwave radio transceiver at the top of a very tall tower. Getting the signal and (most importantly) grounding system correct (where it not only works, but keeps on working) on installations of this type is as much art as engineering.

  5. @Drone: yes i know that I have ground loops, but I see no other solution than ground loops when I use those pixel modules. or do you have an idea? Cheers

Leave a comment

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.