Hello, is there any project with >2m spi bus line which works fine?

WindyYam
Tue Jul 24, 2018 9:43 am
I have some works to embed imus on hand and arm to catch precise movements, I’m using a stm32 spi port to collect data. However with longer wire the spi seems to become unstable to sustain, imu always stop to work but I can’t find out why. Does longer wire like 2 meters introduce some kind of elec-mag interference between clocks and miso/mosi?

stevestrong
Tue Jul 24, 2018 9:49 am
[WindyYam – Tue Jul 24, 2018 9:43 am] – Does longer wire like 2 meters introduce some kind of elec-mag interference between clocks and miso/mosi?

Yes.
You can try to shield the wires, or use 2 wire com, like RS485 for long distances.


WindyYam
Tue Jul 24, 2018 9:53 am
[stevestrong – Tue Jul 24, 2018 9:49 am] –
like RS485 for long distances.

thanks for the reply, but imu dont have rs485 interface so I suppose it would need extra stm32 boards ?:(

I’ll try to shield out the wire with tin foil first


Pito
Tue Jul 24, 2018 10:49 am
Shielding does not help much.
You MUST provide the impedance matching of your spi bus line.
The OUTPUT impedance of the SPI driver == LINE impedance == INPUT impedance of the SPI receiver..

For example:
You need a ~100ohm SPI driver, 100ohm line impedance, ~100ohm input receiver impedance.


ag123
Tue Jul 24, 2018 10:50 am
at high frequencies what is intended to be square waves may become curved square waves
this would likely be cause by the parasitic resistance + capacitance on the bus
the longer the wires i’d guess the bigger the problem
i’d guess you may need a scope to check that you if are pushing for higher frequencies/speed
or the cheaper way without a scope is to try to use shorter wires, use better low resistance wires
and to find out if there is some ways to reduce parasitic capacitance (i’m not sure how though, separating wires?)

Pito
Tue Jul 24, 2018 10:58 am
As I wrote above the parasitic capacitances/inductances play no role when the transmiter->line->receiver is matched properly.
I saw several meters long flat cables (not shielded) for SCSI and other high-speed stuff, no problem..

Figure 13:
http://www.ti.com/lit/an/scaa034c/scaa034c.pdf

For example, the CAT5 twisted pair is 90-120ohm, flat ribbon cables (with GND between signals) are also around 110ohm.
You need to add an output driver (ie 3.3V logic versions of the famous 74xxx125/244/245) to get the ~110ohm output impedance, and, at the receiver’s side simply terminate the line with 1 or 2 resistors such the line’s end sees 110ohm.


ag123
Tue Jul 24, 2018 11:09 am
thanks pito, i’m not too sure if putting terminating resistors would actually help e.g.
https://www.ni.com/support/serial/resinfo.htm

Pito
Tue Jul 24, 2018 11:13 am
i’m not too sure if putting terminating resistors would actually help
Yes, it will help. SPI bus is NOT a differential bus. So do it simply as described in the TI doc above..

I would use a 74LVC125 driver, a ~120ohm line, and 2x240ohm (the Thevenin version above) termination at the receiver’s side (3.3V VCC — 240ohm — line/signal — 240ohm — GND, at each signal input).

http://www.ti.com/lit/ds/symlink/sn74lvc125a.pdf

The ~120ohm flat gray ribbon cable (aka floppy or ATA disk cable), you may try 10 wires with 10pins connectors, with gnd and signals ordered ie.:

gnd CLK gnd CS gnd MISO gnd MOSI gnd gnd


WindyYam
Wed Jul 25, 2018 1:08 am
[Pito – Tue Jul 24, 2018 11:13 am] –
SPI CABLE MATCHING 74LVC125_.jpg

thats really help, i think i’ve got some time to digest all of this :D


mrburnette
Wed Jul 25, 2018 1:43 am
TI whitepaper on extending SPI bus… PDF

Pito
Wed Jul 25, 2018 8:53 am
[mrburnette – Wed Jul 25, 2018 1:43 am] –
TI whitepaper on extending SPI bus… PDF

Yea, for ~100m cable lengths that TI’s bus extension may work much better :)


mrburnette
Wed Jul 25, 2018 1:33 pm
[Pito – Wed Jul 25, 2018 8:53 am] –

[mrburnette – Wed Jul 25, 2018 1:43 am] –
TI whitepaper on extending SPI bus… PDF

Yea, for ~100m cable lengths that TI’s bus extension may work much better :)

The “beauty” of the solution is that it will work at any length, thus it is a stable solution for the issue of SPI extension. Stable (engineered) solutions are often the best recourse since >2m really is not definitive.

Ray


heisan
Wed Jul 25, 2018 1:55 pm
The ~100m limit is the delay limit, at which MISO and MOSI must have forwarded clocks…

This is functional, but far from ideal. SPI was designed for on-board comms. You can extend it off-board with solutions like this, but it is still more of a hack than an engineered solution.

I would say the best solution would be to have the smallest/cheapest arduino board you can find at each sensor to handle the SPI comms, and then do the ‘long distance’ comms with a dedicated off-board standard, like RS-485. Or for even more fun, a small lithium battery and some NRF24L01 boards ;) .


Leave a Reply

Your email address will not be published. Required fields are marked *