0
\$\begingroup\$

I'm trying to understand how to connect a SPI device (a mifare RC522 RFID board) over long distance to my RPi via SPI.

I searched and find I could connect those via SPI over RS485 using a MAX490. (http://forum.arduino.cc/index.php/topic,93234.0.html)

Could anyone explain, maybe with a schematic, how to connect those devices? And do I need some software changes?

\$\endgroup\$
7
  • 2
    \$\begingroup\$ It's good that you've done preliminary research. But, if you found that you can connect "SPI over RS485 using a max485", then please post a link to where you've found that. \$\endgroup\$ – Nick Alexeev Sep 3 '14 at 16:57
  • \$\begingroup\$ Sorry, I meant MAX490: forum.arduino.cc/index.php/topic,93234.0.html \$\endgroup\$ – bitbang Sep 3 '14 at 18:07
  • \$\begingroup\$ The MAX490 is not stateful, you would just be using it to drive/receive balanced signals and would need several to cover all of the SPI signals. You might also consider using asynchronous serial over RS485 to talk to a small microcontroller (/barebone `duino) and have that talk to the board via SPI. It's also entirely possible that with sound electrical design and slow clock rates, your SPI device would simply work at your distance. How long is "long"? \$\endgroup\$ – Chris Stratton Sep 3 '14 at 20:34
  • \$\begingroup\$ About 10 meters \$\endgroup\$ – bitbang Sep 3 '14 at 21:30
  • 1
    \$\begingroup\$ What is the SPI clock - if you are trying to read remote devices then you might have a problem due to the data received being delayed too much. \$\endgroup\$ – Andy aka Sep 3 '14 at 22:13
2
\$\begingroup\$

The single-ended SPI signals can be converted to differential pairs, which are more robust in presence of EMI and can go the distance. Then the differential pairs can be converted back to single-ended SPI signals, and connected directly to peripherals (ADC, I/O expanders, and such). That's what the original forum post is proposing.

MAX490 has 2 different sub-circuits.
One sub-circuits is a differential bus transmitter. It can convert a normal single-ended SPI signal to a differential signal.
The other sub-circuit is a differential bus receiver. It can convert a differential signal back to single-ended.

enter image description here (fig. 2 in the datasheet)
enter image description here

In order to connect the SPI bus this way, 3x MAX490 would be required on each side. Something like this.

enter image description here

Clock delay

The above approach has a clock delay problem. So it has limitation in bus length and bit rate. This is what @Andy was referring to in his comment.

Here's an application note that further explores clock delay and proposed a solution (and this one too). However, that solution requires 2 separate SPI peripherals on the microcontroller.

Here's another app note on clock delay in the context of high speed SPI.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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