SPI Communication Over Length Of Cable - Question On Signal Booster/Amplifier & Cables

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
Hey guys, I hope this is the correct spot for my question!

I have a microcontroller that is communicating with a number of different sensors using a SPI bus. If you are unfamiliar, this is basically a communication protocol where you send digital signals through 4 wires (clock, data in, data out, and a select). Similar to this image shown below (only difference is that my slave select (SS) is all connected together as well - not important for my question though):


Each sensor has 2x cable ports so that the sensors can be daisy chained together (everything is connected in parallel basically). I found this image which gives you an example/idea on what I mean by daisy chaining the devices:


Now for my questions:
1. It seems that I should use some kind of a signal booster/amplifier. The microcontrollers all communicate with a digital signal (0 to 3.3 volts) and I'm almost certain I can't just put that directly on the line. I am imagining that I run this digital signal into something that will turn it into like a 0 - 12 volt signal before sending it down the cable. Would I just use something like a transistor or an opto-coupler? Then on the other side do the opposite, take that signal back down to 0 to 3.3 volts and then into the sensors microcontroller. Are there any chips out there already for specifically this purpose? Is there anything else I should take into consideration?

2. Is it ok for me to use RJ45 cables, or USB cables? Both cables can handle a decent amount of current in the wires, both are shielded, and both have enough wires in them. What is the best way to handle the twisted pairs? Would I just ignore the fact that there are twisted pairs in the cable, or should I utilize them somehow?

Thanks guys and any help is greatly appreciated!
 

Papabravo

Joined Feb 24, 2006
21,158
SPI was never designed to be a long haul device interface. There are problems with your approach, not the least of which is that each device requires it's own chip select signal, and an RJ11 connector has exactly four wires which is good for one device. The other problem is the MISO (Master In Slave Out) line needs to be tri-stated so all the salve devices can have their data out lines connected together, but only the selected device will drive the line. Where did you get the notion that this was possible? Have you ever used SPI before?
 

JohnInTX

Joined Jun 26, 2012
4,787
Are you sure its SPI??
According to the Poseidon 2250 manual, you have your choice of 1-wire (30m short haul) or RS485 'Industrial Bus' as they call it (I think its ModBus see pp8) for daisy chained long haul configurations. see pp15. Neither is SPI so... not sure what you are trying to do??
 

Thread Starter

Mahonroy

Joined Oct 21, 2014
406
What SPI transmission speed does the micro use?
What's the length of the connection cable?
I am currently using a 5Mhz clock for the SCK of the SPI. This is way to fast for a length of cable, so I was assuming something like 9600 bps. Its such a small amount of data at a small interval so I figured I could go with a really low baud rate if need be. I was hoping the cable lengths could be at most 20-30 feet.

SPI was never designed to be a long haul device interface. There are problems with your approach, not the least of which is that each device requires it's own chip select signal, and an RJ11 connector has exactly four wires which is good for one device. The other problem is the MISO (Master In Slave Out) line needs to be tri-stated so all the salve devices can have their data out lines connected together, but only the selected device will drive the line. Where did you get the notion that this was possible? Have you ever used SPI before?
There are ways you can share the slave select pin, and have the MISO be connected to the MOSI on each device like this below:


Is there a better method for this?
 

Papabravo

Joined Feb 24, 2006
21,158
The daisy chain cable you have drawn in post #1 won't implement the diagram in post #5. For each of the slaves draw BOTH connectors. Remember, on each connector all four wires must go in and out because all the cables are identical. I don't think it will work the way you think it will. How are you going to implement the level shifting at each connector?
 
Top