Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Reading a SPI sensor over a long distance

Status
Not open for further replies.

nickagian

Member
Hi folks and Merry Christmas!

Attached is my schematic. As you can see I use the uC SN250 as SPI master for reading data on the same bus, both from an SPI memory (M25P128) and a SPI pressure sensor (MS5540C). The 74AHC1G126 3-state buffer is because the sensor does not have any CS# line. When GPIO3 is LOW, then the flash memory is enabled for communication and the buffer is in high-Z, whereas when GPIO3 is HIGH, then the buffer is enabled and communication with the sensor an be performed. The SG303LC oscillator provides a clock necessary for the operation of the integral ADC of the sensor. All components are included on the same PCB except for the sensor, which is 3m away. The problem I experience is that the SPI bus seems not to be working correctly, when this long twisted and shielded 3m cable is connected. On the contrary, if the sensor is put very close to the PCB (20cm cables) everything works fine.. When the sensor is connected so far away, I can neither read from the sensor neither read from the memory correctly. Is it possible that the long cables by their own produce such a serious problem? Are you aware of any maximum distance for the SPI bus? Do you have anything else to propose as the reason for this problem?

Thanks!
 

Attachments

  • SPI_connections_v2.PNG
    SPI_connections_v2.PNG
    12 KB · Views: 679
It is probably the fast rising and falling edges from the processor that are bouncing on the unterminated lines to the sensor.

Slow the edges with resistors and capacitors. If needed, slow down the data rate. Decoupling capacitors near the sensor might help.
 
It is probably the fast rising and falling edges from the processor that are bouncing on the unterminated lines to the sensor.

Slow the edges with resistors and capacitors. If needed, slow down the data rate. Decoupling capacitors near the sensor might help.

Thank you for answering my post!

Actually, I have already slown down the SPI clock. I usually operate it at 1.5MHz, but for these tests I have changed it down to around 300Hz, but with no success. Moreover, I have indeed used a 47uF cap right next to the sensor.

Regarding the resistors and capacitors that you're talking about.. do you mean to put low-pass filters on the SPI lines? What cut-off frequency (more or less) would you recommend me to put?
 
hi Nick,
This pdf may help.
 

Attachments

  • Class 13-14.pdf
    65.8 KB · Views: 510
Regarding the resistors and capacitors that you're talking about.. do you mean to put low-pass filters on the SPI lines? What cut-off frequency (more or less) would you recommend me to put?

It doesn't really matter if the edges of the data lines are noisy, because the data lines should have plenty of time to settle before the clock changes.

I suspect that the clock line is bouncing, so the slave devices see some edges as multiple ones. The clock line only goes from the master to the slave, so you can buffer it. A buffer should stop the long line affecting the memory that is nearer the master.

If you put a low pass filter on the clock line, you want to filter out anything with a rise time less than twice the propagation time down the line and back. I think that a cut-off could be at 10 MHz or more for a couple of meters of line.

The limit is how slow a rise and fall the clock inputs can stand. If they have schmitt trigger, there is no limit, as long as you can get the clock frequency through. You could always add a schmitt trigger near the remote sensor.
 
You should have a ground return wire for each signal line. You should also have proper terminations on each line. Perhaps series R at the source and shunt RC at the load. Also verify your timing with a scope.
 
Another possible solution ist to Use symetrical Signals.

There ist e.g. the SN 75176 Transceiver that generates symetrical signals of an unsymetrical signal.
One of these Outputs needs 1 twistet Pair in an Network Cable best.
The begin and the end must be terminated with an 120Ohm Resistor.

In DMX 512 are Ranges of 500m at 250kBit/s possible with 32 connected Receivers.

To get further Informations about this solution, look for RS485 in an serarching machine or wikipedia.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top