Electronic – Two MAX3140 (SPI to RS485) connected to one another

rs485spi

I would like to ask if anyone had experience using this kind of IC, i had this school project where i have a lot of sensors using SPIs (each is 10-20 meters away from uC) and these needs to be somehow far from the main controller (uC). I knew that SPIs don't work well when implemented too far from the SPI master or SPI co-slave, so upon searching alternatives, i bump into some ideas like:

  • use two uC and convert SPI to RS485 then convert RS485 to SPI
  • use two uC and use their UART and convert them to RS485 then vice-versa
  • use two uC and apply Ethernet/PoE between the two
  • implement long distance SPI

i would like to re-consider the latter but i would like to try out first the former, then found this IC MAX3140, I'm totally new to this kind of data protocol connection when it comes to long distances. I have this image below where i want to use the IC in this kind of setup.

enter image description here

Did i get the gist of using these IC right?

https://www.maximintegrated.com/en/products/interface/controllers-expanders/MAX3140.html

i guess i do understand this structure below based on its datasheet

enter image description here

as you can see, there's only one Max3140 IC used and that'll only be (1) SPI to RS-485 alone. What i want to know if the below structure work out same since not specified on datasheet (using the IC vice-versa also, (2) RS-485 to SPI). Can it be the one way around? how about clock, etc?

enter image description here

Best Answer

use two uC and convert SPI to RS485 then convert RS485 to SPI

Converting SPI to RS485 then back to SPI only really works in the master-to-slave forward direction. It doesn't work when trying to extract data from a slave because of the turn-around time and the immediate possibility that data coming back will gradually become out-of-sync with the forward going clock signal over longer and longer distances.

For instance I have sent 2 MHz clocked SPI converted to RS485 many tens of metres to drive remote DACs and it worked just fine - clock and data roll along to the slave and appear in-sync with each other and all is well.

use two uC and use their UART and convert them to RS485 then vice-versa

This is the obvious choice because you are creating a solution that does not require clock sync across the full cable - you have local sync at both ends and that works just fine. The MX chip appears suitable for this but, as always the devil is in the detail so read the data sheet to see if there are any gotchas.

use two uC and apply Ethernet/PoE between the two

Harder to get up and running but could be the best overall solution for a "many-user" system

implement long distance SPI

See my first answer - use 485 as a buffer and take note that slave-to-master comms will be problematic.