17
\$\begingroup\$

I have a PIC16F877 µController, connected via SPI to a MCP23S17 and the last it connected to an keypad and LCD screen, the distance between the µController and the MCP integrated circuit is 5m. My question is will it work or not? And if it does not work how can I resolve this problem. Is there a solution (like a Integrated Circuit or a trick)?

picture1

\$\endgroup\$
10
  • 2
    \$\begingroup\$ SPI is designed for on-PCB communications.. this is as terrible idea, perhaps you can find an alternative and more appropriate communication method which is designed for off-board communications or at least longer distance, like I2C \$\endgroup\$
    – KyranF
    Commented Apr 6, 2015 at 20:14
  • 7
    \$\begingroup\$ @KyranF I2C is inter-integrated circuit, it is not designed for off board or long distance. An unassisted SPI bus would be better suited for off-board communication than an unassisted I2C bus would. \$\endgroup\$
    – Samuel
    Commented Apr 6, 2015 at 20:19
  • 2
    \$\begingroup\$ @KyranF I'll second what Samuel said. Since I2C is an open-collector bus, plain I2C has more long-distance problems than plain SPI. \$\endgroup\$ Commented Apr 6, 2015 at 20:33
  • \$\begingroup\$ I2C has many great additions that allow it to go quite a fair way. It's also voltage-invariant, making you able to chose higher and more noise-resistant voltage levels. \$\endgroup\$
    – KyranF
    Commented Apr 6, 2015 at 20:50
  • \$\begingroup\$ If the OP has the option, going for something like RS232 or 485 (better) would beat trying to make on-PCB style comms such as SPI and I2C do something they aren't meant to.. \$\endgroup\$
    – KyranF
    Commented Apr 6, 2015 at 20:54

3 Answers 3

19
\$\begingroup\$

In an answer on a Microchip forum, Jan Axelson, author of 'Serial Port Complete', claims a maximum cable length of 10' for the SPI bus. Other posts have mentioned the same figure. So your distance of 5m may or may not work since it is just a little longer.

Another answer on the same forum recommends using 120- ohm terminating resistors on the lines.

There are several recommendations in discussion of this topic that say a big factor is reducing the clock speed, down to as little as 100 kHz. Then look at your signals with an oscilloscope.

One way to increase the distance way beyond your requirements is to use digital isolators and twisted pair drivers as discussed in this article: "Extending the SPI bus for long-distance communication" It claims a distance of 100m (not a typo).

\$\endgroup\$
0
7
\$\begingroup\$

It's possible with translating the data between the modules by using a trans receiver drivers ex. RS485 something like this

enter image description here

MAX3490

You need to use couple of this trans receiver, the idea is for illustration only you can use any trans driver that pack dual drivers and best suit your need

\$\endgroup\$
1
  • 2
    \$\begingroup\$ This would be my preferred solution to the probem. This is exactly the solution used by many encoder manufacturers with say biss or ssi protocols, which can be considered to be enhanced SPI. (Example: hengstler.de/en/technology/encoder/absolute/…) \$\endgroup\$
    – rob
    Commented Nov 3, 2021 at 0:41
6
\$\begingroup\$

You could use LVDS drivers and receivers to convert the single-ended logic signals into differential signals. Most reliable for a single drop setup (from the board to the external board only), and it requires the grounds to be close to each other in potential.

Use twisted pairs (for example, Cat5 cable) and make sure you use appropriate terminations or it won't work reliably, if at all.

https://www.onsemi.com/download/application-notes/pdf/an-5017.pdf

\$\endgroup\$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.