SPI extender module for 40 meter - Page 1
Forum section: electronics / projects

author: Prayer
author_rank: Contributor
timestamp: May 18, 2017, 07:45:36 am
content: Hello all,I need to design a extender circuit for SPI signal which is 1 MHz clock signal. I designed a circuit with SN65C1167 and it works over 40 meter but we need to add one cable more because it works with RS485. I'm looking for SPI extender which already need 3 cable which are CLK, DATA and GND.I saw some circuits as you can see links. Two designs are working with WS2811 series and CLK is 400 kHz and 800 kHz. One of that design uses opto and a IC. I try to use 6N137S opto and level shifter circuit at attached but level shifter doesn't charge cable. I'm thinking to use line driver after opto. Could you have any idea for this problem or do you know what that IC ?http://www.led-studien.de/repeater-fuer-ws2801-pixel/

author: bktemp
author_rank: Super Contributor
timestamp: May 18, 2017, 08:09:46 am
content: No wonder it doesn't work, there is alomst everything wrong in this circuit:R1 is much too large, a 24V TVS diode does not protect anything in a 3.3V/5V circuit, you can't use a 6N137 in this configuration (pin 5 needs to be connected to GND).The level shifter does not work with the driver and using a mosfet with an unprotected gate at the end of a 40m cable is a bad idea.So forget this circuit and start from scratch:For driving a long cable you need a driver that can drive the impedance of the cable. For typical cables the impedance is 50-100 ohms.So if you use 5V, your driver must be able to supply 50-100mA. Multiple gates of logic buffers in parallel with some series resistors to get the correct impedance can be used for this.The next problem is the actual cable: Using a differential signal has many advantages, because both signals are complementary and therefore the common mode signal is zero.When using a single ended signal, you need a good GND, otherwise you will have ground bounce effects, leading to crosstalk between the signals. Therefore you should use many ground wires in parallel, for example use a GND, CLK, GND, DATA, GND configuration.At the receiver end, you need a proper termination and you need to clean up the signal. Use at least a buffer with a schmitt trigger for cleaning up the edges.But I would prefer using RS422 for such length of cable. It makes everything much more reliable and there are many cheap off the shelf RS422 drivers and receivers. And you can use cheap twisted pair ethernet cables.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: May 18, 2017, 08:25:36 am
content: 1MHz RS422 over cat5 should do the trick, but as length increases, skew between channels might start to become an issue.UART protocol would probably be a better choice - convert using a $1 8 pin PIC.

author: capt bullshot
author_rank: Super Contributor
timestamp: May 18, 2017, 10:29:14 am
content: Check this neat chip:http://cds.linear.com/docs/en/datasheet/6820fb.pdfSPI over one twisted pair, up to 100 meters cable length

author: Prayer
author_rank: Contributor
timestamp: May 18, 2017, 10:47:39 am
content: Quote from: bktemp on May 18, 2017, 08:09:46 amYou are right pin5 of 6N137S is connected to GND. I forget to say Vin is 24V so SDO,CKO,SDI and CKI is 24V level. As you can see attached picture they design and produce like this and uses for range extender.As I said RS422 is working and I'm trying to decrease 4 cable (2 cable for DATA and 2 cable for CLK) to 3 cable.Quote from: capt bullshot on May 18, 2017, 10:29:14 amThank you for your suggestion. This solution is not compatible with my design. This is lighting luminarie design so I need to use 2 IC and 2 transformer for one luminaire. This solution is not cheap for this design.

author: bktemp
author_rank: Super Contributor
timestamp: May 18, 2017, 11:22:36 am
content: As I said: You will quickly run into problems when using a single ended transmission. That is why basically all modern high speed interfaces use differential signaling (USB, ethernet, SATA, HDMI/DVI, DP, PCI-E, MIPI, CAN, RS485 in all the industrial applications).At the end you will spend more time and money into the driver and receiver circuit than using a cheap twisted pair cable with off the shelf components.The easy way is the circuit described in the previous answer. But it requires a good GND connection to make it work reliable. So ideally you should use coaxial cables.If you want to use cheap cables, you must limit the slewrate of the signal into the cable as much as possible without affecting the timing too much.

author: Prayer
author_rank: Contributor
timestamp: May 18, 2017, 03:34:29 pm
content: Thank you for all answers and suggestion. I just check this and see it says 200 meter. I think it is not differential pair. Could it possible ?http://myneopixel.com/dc5-12v-spi-amplifier-repeater-for-ws2811-ws2801-ws2812b_p0935.html

author: bktemp
author_rank: Super Contributor
timestamp: May 18, 2017, 04:38:46 pm
content: It depends on the clock rate. At low clock speeds it will work, but I doubt it works reliable at >1MHz.Their circuit looks simple: 6N137 optocoupler with 240ohms resistor on the input. The ic on the output has the markings removed but my guess would be 74HC14 schmitt trigger inverter for cleaning the clock edges and correcting the polarity since the signal will be inverted by the optocoupler.

author: technix
author_rank: Super Contributor
timestamp: May 19, 2017, 01:04:54 am
content: If both ends of this SPI link are microcontrollers, you might as well get two W5500 and use TCP/IP as the wire protocol. Now the entire notion of length linitation is gone, as Ethernet cables are rated for 100m can go through infinite amount of cheap switches to extend its range, and TCP/IP packets can traverse the Internet.

author: ziplock9000
author_rank: Regular Contributor
timestamp: July 17, 2018, 06:33:02 pm
content: Does anyone know of any pre-built models/board that do this on eBay or Ali for SPI and/or I2C?

author: David Hess
author_rank: Super Contributor
timestamp: July 17, 2018, 11:12:30 pm
content: Why not move the optocouplers to the receive side like the old MIDI standard did? Then whatever is driving the optocouplers will drive the transmission line instead and the optocouplers only have to drive a receiver which is immediately adjacent so load capacitance is not a problem.This avoids the need for RS-422 or any other specialized driver IC and double termination can be used without worrying about logic levels.