asking for solutions of SPI communications over long cable

Go To Last Post
22 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, guys,

I got a problem, i want to connect two 16MHz AVRs by SPI or USART over upto 5m distance, and i want this interface running at the full speed. I let the master generate 8MHz clk through the Ribbon cable and check the waveform at the receiver side, and it was just so ugly. I connected then a coax (similar length) and the waveform was still bad. So do I need some special cable termination circuits or ICs to let the waveform back to sharp?

Any suggestions would be appreciated.

Cheng

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you better of using UART. I had about 3 m cable without any special stuff and everything worked allright at 2400 baud. 8 Mhz is very high even for a short length of line! I would check out something on CAN networks, as they are designed to run in noisy inviroments and quite fast

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why not try using RS-485 bus transcievers? These are designed for both speed and long distance.

The SN65HVD56 from Texas Instruments is good up to 25MBit per second. You will need to use twisted pair cable (CAT5) with 100 Ohm termination resistors at each end.

Cheers!
Edwin

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wire your ribbon cable so that every other wire is ground. Run your signals on the other lines. Place a 22 ohm resistor on each AVR output pin that drives the cable. You might not make 8MHz this way, but you should get close. If the SPI clock overshoots on the receiving end, you might try increasing the resistor values to 33 ohms.

The clock line is the only one you must get very clean. The other lines can look ugly, so long as they are stable on the active edge of the clock.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, for 8 MHz and 5 meters, you definately need special cable and transceivers. You need 3 sets of transceivers, for clock, data in and data out. The faster the SPI clock, the more trouble. Can you use 1 MHz? 50 KHz?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Special cable might just be normal ribbon cable with every other pin as GND, so every signal wire is between two GND wires. Or maybe twisted pair cables if you have to. Coaxial would propably be too expensive. You'll need SCK, MISO, MOSI, and /SS at minimum.

More important is to match source and termination impedances with cable impedance. This is something that you can only experiment. I think most popular method is to have at least some series resistors (from 10 ohms to 100 ohms, depends of course your speed/cable/etc) at the transmitter end, and in the receiving end some 10-100pF of capacitance either directly or via a resistor (10..100 ohms) to GND.

To protect AVR from the big bad external world, and make sure you can drive the cables with enough power to achieve that kind of speeds, you can use 74HC/HCT244 or 74AC/ACT244 bus drivers at both ends.

Note that when AVR is a slave SPI device, your maximum speed is one fourth of the oscillator speed, and as master SPI device, one half of the oscillator speed (on mega8).

- Jani

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, guys,
I have been checking the datasheet for RS485 and LVDS transcievers, yes, they are fast, but they just consume too much power. Then I checked optical trnascievers, they are fast and save battery, but I can only find single fiber cable between them, so how can I convert SPI communication onto a single fiber cable??
And are there any other ways to have 4 to 8MHz speed and consume less power than RS485?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
so how can I convert SPI communication onto a single fiber cable?

not with SPI, but
as suggested before:
Quote:
I think you better of using UART

Klaus
********************************
Look at: www.megausb.de (German)
********************************

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i need spi or rs232 or 1 wire for 3km wire... what should i do.....? can you help me with schematic of wire filter.

thanks in advance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You shouldn't hijack a thread like that!

Leon Heller G1HSM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

threads is about data-transmision,
i made the wire distance longer?

apologize if i interrupt.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

q:so how can I convert SPI communication onto a single fiber cable??

a: SPI IS comunication with clk,miso,mosi link ...
thats define 3 link+1gnd for cable.
single fiber =means 1 link.
so, converting 'already have spi system' into kind of 1wire connection is undeniable, for 1 link cable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

long wire generate ripple,distortion,even leak to the gnd,
thats why we need filter... to get our valuable data.

if only i have oscilloscope, i could see whats happen to our data on the end of cable...
right now i could only imagine.

but the point is we would need higher voltage for long distance transmission.BUT lower in watt. example phone modem. but i could not find any schematic of phone modem anyware..... any help?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

alex7street wrote:
i need spi or rs232 or 1 wire for 3km wire... what should i do.....? can you help me with schematic of wire filter.
Try "current loop" (or, more precise "digital current loop").
"Long, long, long years ago" (back to PDP-11) it was widely used as "physical layer" for UART communication. My experience is 1.5..2.5km at 19200..9600 in noisy environment (faсtory) using "telephone" pairs borrowed from factory phone network.

wbr, ReAl

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

...very interesting. i'll go dig little more about it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

darthvader wrote:
I got a problem, i want to connect two 16MHz AVRs by SPI or USART over upto 5m distance, and i want this interface running at the full speed. I let the master generate 8MHz clk through the Ribbon cable and check the waveform at the receiver side, and it was just so ugly. I connected then a coax (similar length) and the waveform was still bad. So do I need some special cable termination circuits or ICs to let the waveform back to sharp?
At 5m and 8 MHz+harmonics,
you are definitely in the range where the speed of light is significant.
Termination is in order, but I don't know the formulas.
Intermediate buffers, especially Schmidt triggers might also help.

BTW can the receiver listen at 8 MHz?
ATmega168's will only listen at

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Above a certain delay you will not be able to read back data from the slave correctly, as the answer bit arrives way too late and misses the clock edge. As a result the answer is shifted to the right by a bit.

For this to happen the total delay needs to be longer then half the clock period (minus the setup time required on the input).

I've seen this happen with a project once that demanded 20MHz fdx comms over several meters of ribbon cable that went through multiple connectors too. I had to reduce the frequency to 10MHz or so. Luckily most time was spent waiting for a Flash device to complete programming.

In another version of this project the customer pumped up the spec to 66MHz. This was an FPGA based system so it was relatively easy to add a separate slave clock input to compensate for all the delays. But it took an extra wire.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had a similar problem many years ago.
After trying many things, I finally ended up using ethernet "portions" (I think it was called physical layer 0 or 1).
In those days the silicon behind the transformators was made up of discrete parts, so that's where I tapped in.

For my project I bought cheap off the shelf network cards and used their interface part only.

Without using manchester or NRZ coding I achieved a (data) bitrate of 12Mbit over a distance of ca. 15 m.

I see many old style ethernet cards on ebay, so maybe this is still an option for you.
Depending how many you need etc....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As noted elsewhere, a 16 MHz AVR won't listen at 8 Mbps.
Even 4 Mbps is stretching it.
If you have the port available, byte-banging might do what you want.
The slave could perform an IN at every clock transition.
For 8 Mbps, no wire would need more than 1 Mtps.
You'll have 16 cycles per byte. Spend them wisely.
You'll still need termination.
It still takes light nearly 17 ns to go 5 m.
Maybe 50 ns RC's would do the trick.

It might be useful to toggle the clock a few
cycles after the data has been put on the port.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Delay, maybe with loopback test it would be bad is we use the same one uC.... it would be nice if we using 2 uC for the loopback test. 1 for tx and 1 for rx. so delay would not be really problem.

interresting...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What if i use 2 phone modem.... and simulate phone company signal/voltage behavior...

i could use AT command.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hah, i just answer it.