EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

SPI noise, shielded cable required?

Started by dohzer March 22, 2008
Paul Urbanus wrote:
> Tim Wescott wrote: >> On Sat, 22 Mar 2008 06:12:42 -0500, dohzer wrote: >> >>> I've got an SPI master/slave test circuit set up between two Atmel >>> ATmega8 microcontrollers, with the master on an STK500 development board >>> and the slave on a breadboard. >>> >>> I noticed that sometimes I would get noisy communications and other >>> times I would not get any noise at all, but it seems to depend on how >>> the wires are positioned. The cables I'm using to connect master and >>> slave are some "random" ones I've ripped out of an old computer (used to >>> link the motherboard to the LEDs and switches on the front of the case). >>> There's a pair of wires for 5V and 0V, and four SPI data wires. They're >>> only about 30cm long. >>> >>> One time when I held all the cables tightly I noticed that the noise >>> stopped, and when I moved them apart, the noise returned. I thought this >>> may have been something to do with external noise, so I wrapped some >>> aluminium foil around the six wires (all together) and the >>> communications be came error free. >>> >>> Doing this has solved my problem, but I was still curious, so I removed >>> the foil and tied all the wires tightly together with string. The errors >>> disappeared again. >>> The errors only seem to appear when the data cables are separated from >>> the power cables. Shielding the data and power cables separately (rather >>> than together in one sheet of foil) results in the errors returning. >>> >>> Does anyone know the reason for this? Is it something to do with the >>> coupling between the ground and data lines? >>> Thanks for any suggestions. >> >> It has lots to do with coupling between the ground and data lines. >> When you send a pulse down a data line from one board to another, >> there has to be a return path for the current. When that return path >> (the lone ground wire, and to some extent the power wire if it is >> capacitively coupled in a correct manner) is close to the data lines >> the pulses you send down the wire have the best chance of retaining >> their shape. >> >> If you really had to use SPI at those distances, you'd want to use >> twisted pair wire for each data port, with one wire to ground at each >> end and the other carrying your data. These wires would be acting >> like transmission lines, so you'd want to properly terminate them. If >> you were _really_ serious about SPI over long distances you'd use >> RS-422, but if you were getting to that point you'd probably be wiser >> to use some other means of interprocessor communication. >> >> If you're doing a prototype, and if bundling up the wires is >> sufficient, then do it and be happy. >> > I agree with Tim that using a twisted pair for each signal, where the > signal is on one wire and the ground on the other in pair, is the way to > go. This is standard practice for any custom cable I make. > > CAT5 cable is perfect for short SPI runs, as the 4 pairs will > accommodate CS, CLK, MOSI, MISO. The SPI interface should run fairly > fast over this cable, given the speed rating for CAT5. >
That way I ran an SPI link over 3ft or 1m. Default at 4MHz because one of the devices couldn't do more than 5MHz SCLK. But once I stepped on it and revved it to 20MHz since all the other parts could go that high. It worked fine.
> If the slave is powered from the master, then power can be wired > separately.
-- Regards, Joerg http://www.analogconsultants.com/
"dohzer" <dohzer@hotmail.com> wrote in message 
news:rcOdnS-4VZE3dHnanZ2dnUVZ_hisnZ2d@giganews.com...
> I've got an SPI master/slave test circuit set up between two Atmel ATmega8 > microcontrollers, with the master on an STK500 development board and the > slave on a breadboard. > > I noticed that sometimes I would get noisy communications and other times > I would not get any noise at all, but it seems to depend on how the wires > are positioned. The cables I'm using to connect master and slave are some > "random" ones I've ripped out of an old computer (used to link the > motherboard to the LEDs and switches on the front of the case). There's a > pair of wires for 5V and 0V, and four SPI data wires. They're only about > 30cm long. > > One time when I held all the cables tightly I noticed that the noise > stopped, and when I moved them apart, the noise returned. > I thought this may have been something to do with external noise, so I > wrapped some aluminium foil around the six wires (all together) and the > communications be came error free. > > Doing this has solved my problem, but I was still curious, so I removed > the foil and tied all the wires tightly together with string. The errors > disappeared again. > The errors only seem to appear when the data cables are separated from the > power cables. Shielding the data and power cables separately (rather than > together in one sheet of foil) results in the errors returning. > > Does anyone know the reason for this? > Is it something to do with the coupling between the ground and data > lines? > Thanks for any suggestions. > >
I agree with the comment on cat5 cable. For a test jig we used hand made twisted pairs where one wire was signal the other ground. It made a lot of difference. Our data rate was fairly low, around 1 Mbs if I remember right. Our cable was also short, only about 6 - 8 inches. The actual application used a board to board connector, so the effective length was only about 2 inches from cpu to peripheral. You might also trying to foil wrap your existing cable and grounding the foil. As others have said, SPI is not meant for cabled board to board interfaces. Scott
dohzer wrote:
> I've got an SPI master/slave test circuit set up between two Atmel ATmega8 > microcontrollers, with the master on an STK500 development board and the > slave on a breadboard. > > I noticed that sometimes I would get noisy communications and other times > I would not get any noise at all, but it seems to depend on how the wires > are positioned. The cables I'm using to connect master and slave are some > "random" ones I've ripped out of an old computer (used to link the > motherboard to the LEDs and switches on the front of the case). There's a > pair of wires for 5V and 0V, and four SPI data wires. They're only about > 30cm long. > > One time when I held all the cables tightly I noticed that the noise > stopped, and when I moved them apart, the noise returned. > I thought this may have been something to do with external noise, so I > wrapped some aluminium foil around the six wires (all together) and the > communications be came error free. > > Doing this has solved my problem, but I was still curious, so I removed > the foil and tied all the wires tightly together with string. The errors > disappeared again. > The errors only seem to appear when the data cables are separated from the > power cables. Shielding the data and power cables separately (rather than > together in one sheet of foil) results in the errors returning. > > Does anyone know the reason for this? > Is it something to do with the coupling between the ground and data > lines? > Thanks for any suggestions. > >
You don't say what data rate you are running at, but keeping circuit impedances low via the use of 1 or 2 k pullups may help. Use ribbon cable to carry the signals and interleaving gnd wires with each signal line will help as well. Open wires are a waste of time at anything above a few khz data rate. 1/2 to 1 foot at should be possible at a 1 meg data rate with the above techniques, but you really need to look at the signals on a scope to see what's really happening and to make sure data sheet setup and hold times are being met... Chris -- ---------------------- Greenfield Designs Ltd Electronic and Embedded System Design Oxford, England (44) 1865 750 681
ChrisQuayle wrote:
> dohzer wrote: >> I've got an SPI master/slave test circuit set up between two Atmel >> ATmega8 >> microcontrollers, with the master on an STK500 development board and the >> slave on a breadboard. >> >> I noticed that sometimes I would get noisy communications and other times >> I would not get any noise at all, but it seems to depend on how the wires >> are positioned. The cables I'm using to connect master and slave are some >> "random" ones I've ripped out of an old computer (used to link the >> motherboard to the LEDs and switches on the front of the case). There's a >> pair of wires for 5V and 0V, and four SPI data wires. They're only about >> 30cm long. >> >> One time when I held all the cables tightly I noticed that the noise >> stopped, and when I moved them apart, the noise returned. >> I thought this may have been something to do with external noise, so I >> wrapped some aluminium foil around the six wires (all together) and the >> communications be came error free. >> >> Doing this has solved my problem, but I was still curious, so I removed >> the foil and tied all the wires tightly together with string. The errors >> disappeared again. >> The errors only seem to appear when the data cables are separated from >> the >> power cables. Shielding the data and power cables separately (rather than >> together in one sheet of foil) results in the errors returning. >> >> Does anyone know the reason for this? >> Is it something to do with the coupling between the ground and data >> lines? >> Thanks for any suggestions. >> >> > > > You don't say what data rate you are running at, but keeping circuit > impedances low via the use of 1 or 2 k pullups may help. Use ribbon > cable to carry the signals and interleaving gnd wires with each signal > line will help as well. Open wires are a waste of time at anything above > a few khz data rate. > > 1/2 to 1 foot at should be possible at a 1 meg data rate with the above > techniques, but you really need to look at the signals on a scope to see > what's really happening and to make sure data sheet setup and hold times > are being met... >
You can go a lot faster and longer on SPI. But there comes a point where line impedance begins to matter. A wee AC termination can't hurt although I did 3ft without it. -- Regards, Joerg http://www.analogconsultants.com/

The 2024 Embedded Online Conference