1

I'm using several MFRC522 modules which communicate to an arduino with the SPI protocole. The distance between the arduino and the modules will be between 1 and 2 meters.

I'm worried about the distance, I'm not sure of the quality of the SPI signal for a such distance. I would like to know your opinion about using wire like RS422 or RS485.

If I have to use this wiring, could you explain me how to convert SPI to RS422 ?

Thank you ,

FrancNovation
  • 397
  • 6
  • 12
  • RS-whatever is not a wire, it's a protocol. – Eugene Sh. Jul 27 '18 at 19:14
  • 4
    @EugeneSh. Actually, RS-422/RS485 etc are _electrical interfaces_. The specifications do _not_ define a protocol for them. – Maple Jul 27 '18 at 19:16
  • Why SPI at all? These modules have nice conventional UARTs. – Eugene Sh. Jul 27 '18 at 19:23
  • @KevHV The best way to convert SPI to other interfaces and back is... drum roll... to Google for it. A quick search gives thousands of links, including on this site: https://electronics.stackexchange.com/q/357411/187920, https://electronics.stackexchange.com/a/201993/187920 – Maple Jul 27 '18 at 19:23
  • related: [Raspberry PI's SPI over RS485](https://electronics.stackexchange.com/q/127643/7036) – Nick Alexeev Jul 27 '18 at 19:24
  • 1
    @EugeneSh. Sorry, but that is BS. SPI wiring is _not_ bi-directional. Simple full-duplex RS-485 transceiver can work just fine. The problem is timing and a need for CS lines, which makes other ports much more suitable for long-distance conversion, as you yourself pointed out. – Maple Jul 27 '18 at 19:30
  • @Maple Sorry, you are correct again. Confused with I2C. – Eugene Sh. Jul 27 '18 at 19:31
  • Yes, I2C is a bit trickier – Maple Jul 27 '18 at 19:32

2 Answers2

1

The SPI can work at 2 meters just fine, although at reduced speed. If you do not absolutely need maximum possible clock you can wire your modules and gradually increase speed to find out error-free maximum.

As a side note, SPI is not the best protocol to use off-board when you have multiple slaves, because wiring CS lines quickly makes it cumbersome.

Using I2C or dI2C simplifies wiring but requires somewhat more complicated transceiver circuits. Using I2C-to-1wire bridges simplifies this as well but at cost of greatly reduced speed.

UART also works at 2m without problems. You can extend it much further by converting UART to RS-485 or LVDS. The problem with using UART, however, is that it does not have addressing mechanism to support multiple modules. If your controller has enough UART ports for all modules then wiring them individually instead of using any bus would be best option.

Note that MFRC522 chip supports all three protocols, SPI, I2C and UART.

Maple
  • 11,755
  • 2
  • 20
  • 56
  • Thanks a lot for your information (and the other helpers too) ! I'm going the carry on my studies on conversion between RS.. and SPI. – FrancNovation Jul 27 '18 at 19:47
1

As the answer from Maple suggests, there are alternative approaches, but if you want to send SPI over RS422 wiring as mentioned in the title of the question, then there is an approach suggested by Texas Instruments in their document Extending the SPI bus for long-distance communication.

If you want a simpler circuit (and especially if you have a shared power supply between devices) then you might be able to get away without the ISO7242c isolator on the far end. In theory, this should work with other RS422 transceiver chips also as alternatives to the SN65C1167.

One reason for doing it this way is if you need to stick with SPI protocol communication (e.g. you want to extend the signal length of an IC that talks SPI, and you don't want to add your own microcontroller to translate the signals to something else).

A circuit diagram for connecting SPI over long distances using RS422 wiring

Elliot Woods
  • 113
  • 5