[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.
[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
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.
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?)
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.
https://www.ni.com/support/serial/resinfo.htm
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
[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 ![]()
[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 ![]()
[Pito – Wed Jul 25, 2018 8:53 am] –[mrburnette – Wed Jul 25, 2018 1:43 am] –
TI whitepaper on extending SPI bus… PDFYea, 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
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
.

