¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

SPI interfacing - How long can external connections be?


 

Hi Guys,

Having lost enough hair trying to get i2C working with BASCOM, I
dropped it and switched to the SPI interface. Got that working
within a couple of minutes as opposed to countless hours getting
nowhere with i2C.

Anyway, being new to SPI, I don't know what the limitations are for
it. I would like to have the SPI master in a sepperate cabinet from
some of the SPI slaves. I am guessing the total cable length would
be about 3 feet - shielded cable if that maters.

I will try a test on the breadboard (yes, I am doing this on a
breadboard :-)). But I would also like to hear if there are any
cautions etc.

Thanks guys

Chris


Leon Heller
 

----- Original Message -----
From: "lcdpublishing" <lcdpublishing@...>
To: <Electronics_101@...>
Sent: Saturday, April 29, 2006 9:31 PM
Subject: [Electronics_101] SPI interfacing - How long can external connections be?


Hi Guys,

Having lost enough hair trying to get i2C working with BASCOM, I
dropped it and switched to the SPI interface. Got that working
within a couple of minutes as opposed to countless hours getting
nowhere with i2C.

Anyway, being new to SPI, I don't know what the limitations are for
it. I would like to have the SPI master in a sepperate cabinet from
some of the SPI slaves. I am guessing the total cable length would
be about 3 feet - shielded cable if that maters.

I will try a test on the breadboard (yes, I am doing this on a
breadboard :-)). But I would also like to hear if there are any
cautions etc.
It depends on the speed, of course. I'd use RS-422 drivers and receivers with twisted pair cables for fast transfers.

Leon

---
[This E-mail has been scanned for viruses but it is your responsibility to maintain up to date anti virus software on the device that you are
currently using to read this email. ]


 

--- In Electronics_101@..., "lcdpublishing"
<lcdpublishing@...> wrote:

Hi Guys,

Having lost enough hair trying to get i2C working with BASCOM, I
dropped it and switched to the SPI interface. Got that working
within a couple of minutes as opposed to countless hours getting
nowhere with i2C.

Anyway, being new to SPI, I don't know what the limitations are for
it. I would like to have the SPI master in a sepperate cabinet from
some of the SPI slaves. I am guessing the total cable length would
be about 3 feet - shielded cable if that maters.

I will try a test on the breadboard (yes, I am doing this on a
breadboard :-)). But I would also like to hear if there are any
cautions etc.

Thanks guys
SPI as implemented by the micro is still a 5v logic signal although it
does have active pull-up. Cable capacitance didn't improve with the
change in protocol so I wouldn't expect it to run at longer distances,
at least not a lot longer. The thing with SPI is that it wants to run
a lot faster than I2C. This is going in the wrong direction for using
long lines.

So, you will have to watch the speed and look at the signals with a
scope. Long rise times will be just as much of a problem with SPI as
it is with I2C.

I2C can be a bear to debug. However, there are bus buffers available
- at least one of which will extend I2C to one mile. But, it is
another component, more board space, etc.

I haven't implemented it but I do like the ROBIN protocol for RS485
over at BDMicro - That may be out
of the question for Basic. It's probably not a coincidence that both
of the current BD Micro boards have RS485 drivers with ATmega128 chips.

Richard





Chris


 

Well, I know for sure what won't work!

I had a 100' spool of 24 gauge solid core wire handy with both ends of
the cable exposed. I stripped off some conductors, spliced it into the
bread board circuit for the SPI wires. No-go, so, now I know!

100 feet - too long for SPI ;-)

Chris


Roy J. Tellason
 

On Sunday 30 April 2006 04:55 pm, lcdpublishing wrote:
Well, I know for sure what won't work!

I had a 100' spool of 24 gauge solid core wire handy with both ends of
the cable exposed. I stripped off some conductors, spliced it into the
bread board circuit for the SPI wires. No-go, so, now I know!

100 feet - too long for SPI ;-)
A bunch of wire on a spool is also going to have some inductance, there,
much more so than just a wire run to somewhere...

--
Member of the toughest, meanest, deadliest, most unrelenting -- and
ablest -- form of life in this section of space, a critter that can
be killed but can't be tamed. --Robert A. Heinlein, "The Puppet Masters"
-
Information is more dangerous than cannon to a society ruled by lies. --James
M Dakin


 

HI ROy,

In reality, I would have been very surprised had it worked! When I
was first working out some serial communications software about 20
years ago, I used all short cables and PC-PC for testing. Then to
find the distance limitation with RS232, I had four, 1000 foot
spools of cable on hand. I started out with one spool, then two,
then on the third one it failed. At the time I had no idea why, but
I was aware that having the cable on the spool was a "worst case"
situation.

Today's test I am going to cut off about a 25 foot section of the
cable I tried for SPI, and see if that works. If not, I will keep
cutting it down till it does.




--- In Electronics_101@..., "Roy J. Tellason"
<rtellason@...> wrote:

On Sunday 30 April 2006 04:55 pm, lcdpublishing wrote:
Well, I know for sure what won't work!

I had a 100' spool of 24 gauge solid core wire handy with both
ends of
the cable exposed. I stripped off some conductors, spliced it
into the
bread board circuit for the SPI wires. No-go, so, now I know!

100 feet - too long for SPI ;-)
A bunch of wire on a spool is also going to have some inductance,
there,
much more so than just a wire run to somewhere...

--
Member of the toughest, meanest, deadliest, most unrelenting -- and
ablest -- form of life in this section of space, a critter that
can
be killed but can't be tamed. --Robert A. Heinlein, "The Puppet
Masters"
-
Information is more dangerous than cannon to a society ruled by
lies. --James
M Dakin


 

It does appear that 20 feet of cable will work for SPI. The length
is approximate, but I think it is close to 20'.

The speed at which I am communicating at though is a bit confusing
based on the documentation I am working with in the BASCOM manual.
If I am interpreting it correctly, I am communicating at 1/16 clock
speed. So 18.432 Mhz xtal 18,432,000 / 16 = 1,152,000 bits per
second.

If I understand everything correctly, this is very good news for
this project! Things just got a lot faster and better.

CHris



--- In Electronics_101@..., "lcdpublishing"
<lcdpublishing@...> wrote:

HI ROy,

In reality, I would have been very surprised had it worked! When
I
was first working out some serial communications software about 20
years ago, I used all short cables and PC-PC for testing. Then to
find the distance limitation with RS232, I had four, 1000 foot
spools of cable on hand. I started out with one spool, then two,
then on the third one it failed. At the time I had no idea why,
but
I was aware that having the cable on the spool was a "worst case"
situation.

Today's test I am going to cut off about a 25 foot section of the
cable I tried for SPI, and see if that works. If not, I will keep
cutting it down till it does.




--- In Electronics_101@..., "Roy J. Tellason"
<rtellason@> wrote:

On Sunday 30 April 2006 04:55 pm, lcdpublishing wrote:
Well, I know for sure what won't work!

I had a 100' spool of 24 gauge solid core wire handy with both
ends of
the cable exposed. I stripped off some conductors, spliced it
into the
bread board circuit for the SPI wires. No-go, so, now I know!

100 feet - too long for SPI ;-)
A bunch of wire on a spool is also going to have some
inductance,
there,
much more so than just a wire run to somewhere...

--
Member of the toughest, meanest, deadliest, most unrelenting --
and
ablest -- form of life in this section of space, a critter that
can
be killed but can't be tamed. --Robert A. Heinlein, "The Puppet
Masters"
-
Information is more dangerous than cannon to a society ruled by
lies. --James
M Dakin


Roy J. Tellason
 

On Monday 01 May 2006 09:02 am, lcdpublishing wrote:
It does appear that 20 feet of cable will work for SPI. The length
is approximate, but I think it is close to 20'.
<...>

In reality, I would have been very surprised had it worked! When
I was first working out some serial communications software about 20
years ago, I used all short cables and PC-PC for testing. Then to
find the distance limitation with RS232, I had four, 1000 foot
spools of cable on hand. I started out with one spool, then two,
then on the third one it failed. At the time I had no idea why,
but I was aware that having the cable on the spool was a "worst case"
situation.

Today's test I am going to cut off about a 25 foot section of the
cable I tried for SPI, and see if that works. If not, I will keep
cutting it down till it does.

--- In Electronics_101@..., "Roy J. Tellason"

<rtellason@> wrote:
On Sunday 30 April 2006 04:55 pm, lcdpublishing wrote:
Well, I know for sure what won't work!

I had a 100' spool of 24 gauge solid core wire handy with both
ends of the cable exposed. I stripped off some conductors, spliced it
into the bread board circuit for the SPI wires. No-go, so, now I
know!

100 feet - too long for SPI ;-)
A bunch of wire on a spool is also going to have some
inductance, there,
much more so than just a wire run to somewhere...
You might find it informative to put a scope on that signal, without the wire
and then with it, both at the source end and at the other end as well...

--
Member of the toughest, meanest, deadliest, most unrelenting -- and
ablest -- form of life in this section of space, a critter that can
be killed but can't be tamed. --Robert A. Heinlein, "The Puppet Masters"
-
Information is more dangerous than cannon to a society ruled by lies. --James
M Dakin


 

Roy, I will do when I get the cable in that I plan on using for
this. By chance, can you give me a hint as to what sort of good and
bad things I should be looking for?

Right now, my technique on the scope is more or less, if I see two
horizontal lines - spaced apart at the voltage and duration I think
they should be - I am happy.

Chris



--- In Electronics_101@..., "Roy J. Tellason"
<rtellason@...> wrote:

On Monday 01 May 2006 09:02 am, lcdpublishing wrote:
It does appear that 20 feet of cable will work for SPI. The
length
is approximate, but I think it is close to 20'.
<...>

In reality, I would have been very surprised had it worked!
When
I was first working out some serial communications software
about 20
years ago, I used all short cables and PC-PC for testing.
Then to
find the distance limitation with RS232, I had four, 1000 foot
spools of cable on hand. I started out with one spool, then
two,
then on the third one it failed. At the time I had no idea
why,
but I was aware that having the cable on the spool was
a "worst case"
situation.

Today's test I am going to cut off about a 25 foot section of
the
cable I tried for SPI, and see if that works. If not, I will
keep
cutting it down till it does.

--- In Electronics_101@..., "Roy J. Tellason"

<rtellason@> wrote:
On Sunday 30 April 2006 04:55 pm, lcdpublishing wrote:
Well, I know for sure what won't work!

I had a 100' spool of 24 gauge solid core wire handy with
both
ends of the cable exposed. I stripped off some conductors,
spliced it
into the bread board circuit for the SPI wires. No-go,
so, now I
know!

100 feet - too long for SPI ;-)
A bunch of wire on a spool is also going to have some
inductance, there,
much more so than just a wire run to somewhere...
You might find it informative to put a scope on that signal,
without the wire
and then with it, both at the source end and at the other end as
well...

--
Member of the toughest, meanest, deadliest, most unrelenting -- and
ablest -- form of life in this section of space, a critter that
can
be killed but can't be tamed. --Robert A. Heinlein, "The Puppet
Masters"
-
Information is more dangerous than cannon to a society ruled by
lies. --James
M Dakin


Roy J. Tellason
 

On Monday 01 May 2006 10:48 am, lcdpublishing wrote:
Roy, I will do when I get the cable in that I plan on using for
this. By chance, can you give me a hint as to what sort of good and
bad things I should be looking for?
Nope, I just know that the signal _will_ change and that it might be
instructive to see how it changes...

--
Member of the toughest, meanest, deadliest, most unrelenting -- and
ablest -- form of life in this section of space, a critter that can
be killed but can't be tamed. --Robert A. Heinlein, "The Puppet Masters"
-
Information is more dangerous than cannon to a society ruled by lies. --James
M Dakin


 

--- lcdpublishing <lcdpublishing@...> wrote:

Roy, I will do when I get the cable in that I plan
on using for
this. By chance, can you give me a hint as to what
sort of good and
bad things I should be looking for?
Transmission lines all have four basic properties
inherient to them. They are: 1) resistance 2)
inductance 3) capacitance 4) conductance.

The resistance and inductance are in series with the
load at the other end and the capacitance and
conductance are in parallel with the load. What this
means is that your transmission line will behave as a
filter when a signal is passed along it. This has
several side affects associated with it. I will
discuss these in a moment. First let me digress into
an aside about signals.

According to Fourier, any real signal can be expressed
as a sumation of an infinate combination of sines and
cosines; each with a different frequency and
amplitude. The frequencies of each "component" are
integer multiples of the fundimental frequency. This
is what people are refering to when they talk about
n-th order harmonic frequencies (i.e. the third
harmonic for example). In digital circuits, our
transmission signal is a square wave. Transforming
this into its Fourier series yeilds a combination of
sine waves with odd-numbered multiples of the
fundimental frequency. You don't really need to grasp
this fully right now but it is revelant for your case.

Getting back to the transmission line properties, let
me remind you that a transmission line will behave as
a passive filter when the line lengths get long
enough. This results in two distinct effects on a
signal that is being transmitted on it. 1) Phase
shift 2) Voltage reflection.

PHASE SHIFT -- All passive filters will create some
sort of a phase shift of any AC signal that is passed
through it. Whether or not the shift is positive or
negative will depend upon the frequency of the signal
and the type of filter it passes through. Recall that
our digital square-wave is actually composed of an
infinate combination of sine waves. When this type of
wave is sent along a transmission line the wave can
become "distorted" when it comes out the other end.
This is because the "line filter" has shifted the
phase of some of the square wave's harmonics. So what
you should be looking for on the output end of your
line will be ringing on your transitions and rounding
of your signal edges. If your line is really long, or
poorly constructed, you might even see something that
looks more like an audio signal rather than a
square-wave.

VOLTAGE REFLECTION -- The second characteristic that
must be accounted for is voltage reflection. What
this describes is the fact that that not all power
transmitted on the line will be transfered to the
load. Some of it will be reflected back to the
source. The effect is similar to the one observed
when you take a string and tie one end to a wall and
then take the other end and shake it up and down to
create a wave on the string. When the wave reaches
the wall, the wave "bounces back" towards you. This
is onset by a mismatch in impedances between the
source, transmission line, and load. When the voltage
is reflected back to the source, if the source and
line impedences don't match the wave will then be
reflected back down to the load again. This results
in what is called a "standing wave" and in "ideal"
conditions can continue forever. One effect that can
be caused by this standing wave is if the standing
wave happens to be in phase with the signal at the
load then the voltages add together. This can cause
the voltage across the load to increase greatly. The
same is true at the source. When the standing wave is
in phase with the signal at the source, the voltage at
the source can increase greatly.

The opposite is also true. If the standing wave is
180 degrees out of phase with the signal and the
relative amplitudes of each are similar, then the
signal will in effect be canceled out at the load (or
source depending on which end of the line you're on.)
This is why impedence matching is so important between
the source, line, and load. If the impedences match
then a standing wave will not be seen. What you
should look for to determine if this is happening is
check your voltages. If you have a dramatic increase
or decrease on either side of the line then you
probably need to adjust the length of your line.
Also, check each of the components on either side of
the line. If they are getting hot then that probably
indicates a problem as well.

I forget the exact length, but I believe these effects
start to become noticeable when the length of your
line is 1/100th that of the signal wavelength but I'll
have to look this up to be sure. At your voltages and
frequencies, you will probably have to worry more
about phase shift than voltage reflection but it never
hurts to check for both. Also, the degree in which
these effects are manifested depend upon the type of
transmission line used.

If you want more information on either the Fourier
transform or transmission line properties do a google
search. There is quite a bit of information out there
on both topics.

Hope this helps you find what you are looking for.

Shawn



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around


 

Facinating Shawn! While some (well, much) of it is over my head at
this time, I get the gist of what you are saying and describing.

I am hoping, (odd someone hopes for problems) that I will see some
of these effects when I get the cable and put a scope on this
signal. It sure would be great to actually "See" and "Measure" the
cause and effects of this sort of thing.

I will have to re-read this post a number of times to gain more from
it. So I may be back at you will questions further down the road.

Thanks!!!!

Chris






--- In Electronics_101@..., Shawn Standfast
<sstandfast@...> wrote:

--- lcdpublishing <lcdpublishing@...> wrote:

Roy, I will do when I get the cable in that I plan
on using for
this. By chance, can you give me a hint as to what
sort of good and
bad things I should be looking for?
Transmission lines all have four basic properties
inherient to them. They are: 1) resistance 2)
inductance 3) capacitance 4) conductance.

The resistance and inductance are in series with the
load at the other end and the capacitance and
conductance are in parallel with the load. What this
means is that your transmission line will behave as a
filter when a signal is passed along it. This has
several side affects associated with it. I will
discuss these in a moment. First let me digress into
an aside about signals.

According to Fourier, any real signal can be expressed
as a sumation of an infinate combination of sines and
cosines; each with a different frequency and
amplitude. The frequencies of each "component" are
integer multiples of the fundimental frequency. This
is what people are refering to when they talk about
n-th order harmonic frequencies (i.e. the third
harmonic for example). In digital circuits, our
transmission signal is a square wave. Transforming
this into its Fourier series yeilds a combination of
sine waves with odd-numbered multiples of the
fundimental frequency. You don't really need to grasp
this fully right now but it is revelant for your case.

Getting back to the transmission line properties, let
me remind you that a transmission line will behave as
a passive filter when the line lengths get long
enough. This results in two distinct effects on a
signal that is being transmitted on it. 1) Phase
shift 2) Voltage reflection.

PHASE SHIFT -- All passive filters will create some
sort of a phase shift of any AC signal that is passed
through it. Whether or not the shift is positive or
negative will depend upon the frequency of the signal
and the type of filter it passes through. Recall that
our digital square-wave is actually composed of an
infinate combination of sine waves. When this type of
wave is sent along a transmission line the wave can
become "distorted" when it comes out the other end.
This is because the "line filter" has shifted the
phase of some of the square wave's harmonics. So what
you should be looking for on the output end of your
line will be ringing on your transitions and rounding
of your signal edges. If your line is really long, or
poorly constructed, you might even see something that
looks more like an audio signal rather than a
square-wave.

VOLTAGE REFLECTION -- The second characteristic that
must be accounted for is voltage reflection. What
this describes is the fact that that not all power
transmitted on the line will be transfered to the
load. Some of it will be reflected back to the
source. The effect is similar to the one observed
when you take a string and tie one end to a wall and
then take the other end and shake it up and down to
create a wave on the string. When the wave reaches
the wall, the wave "bounces back" towards you. This
is onset by a mismatch in impedances between the
source, transmission line, and load. When the voltage
is reflected back to the source, if the source and
line impedences don't match the wave will then be
reflected back down to the load again. This results
in what is called a "standing wave" and in "ideal"
conditions can continue forever. One effect that can
be caused by this standing wave is if the standing
wave happens to be in phase with the signal at the
load then the voltages add together. This can cause
the voltage across the load to increase greatly. The
same is true at the source. When the standing wave is
in phase with the signal at the source, the voltage at
the source can increase greatly.

The opposite is also true. If the standing wave is
180 degrees out of phase with the signal and the
relative amplitudes of each are similar, then the
signal will in effect be canceled out at the load (or
source depending on which end of the line you're on.)
This is why impedence matching is so important between
the source, line, and load. If the impedences match
then a standing wave will not be seen. What you
should look for to determine if this is happening is
check your voltages. If you have a dramatic increase
or decrease on either side of the line then you
probably need to adjust the length of your line.
Also, check each of the components on either side of
the line. If they are getting hot then that probably
indicates a problem as well.

I forget the exact length, but I believe these effects
start to become noticeable when the length of your
line is 1/100th that of the signal wavelength but I'll
have to look this up to be sure. At your voltages and
frequencies, you will probably have to worry more
about phase shift than voltage reflection but it never
hurts to check for both. Also, the degree in which
these effects are manifested depend upon the type of
transmission line used.

If you want more information on either the Fourier
transform or transmission line properties do a google
search. There is quite a bit of information out there
on both topics.

Hope this helps you find what you are looking for.

Shawn



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around


 

I have a suggestion:

- try with a short wire, note results on scope.
- try with a very long wire, compare results on scope with short wire
results.

If it matches, hurray!

Robert
:)

-----Message d'origine-----
De : Electronics_101@...
[mailto:Electronics_101@...] De la part de lcdpublishing
Envoy¨¦ : mai 1 2006 10:48
? : Electronics_101@...
Objet : [Electronics_101] Re: SPI interfacing - How long can
external connections be?


Roy, I will do when I get the cable in that I plan on using for
this. By chance, can you give me a hint as to what sort of good and
bad things I should be looking for?

Right now, my technique on the scope is more or less, if I see two
horizontal lines - spaced apart at the voltage and duration I think
they should be - I am happy.

Chris


 

That is somewhat what I plan to do. However, if storage worked on
my scope - this would all be much easier to see! I guess I could
get a series of identical characters passing between the two chips.
I believe letter N was the one that adds up to 01010101 binary. If
I can get a repeating pattern it should be pretty easy to watch and
compare - I hope :-)

Chris


--- In Electronics_101@..., Robert Hedan
<robert.hedan@...> wrote:

I have a suggestion:

- try with a short wire, note results on scope.
- try with a very long wire, compare results on scope with short
wire
results.

If it matches, hurray!

Robert
:)


-----Message d'origine-----
De : Electronics_101@...
[mailto:Electronics_101@...] De la part de
lcdpublishing
Envoy¨¦ : mai 1 2006 10:48
? : Electronics_101@...
Objet : [Electronics_101] Re: SPI interfacing - How long can
external connections be?


Roy, I will do when I get the cable in that I plan on using for
this. By chance, can you give me a hint as to what sort of good
and
bad things I should be looking for?

Right now, my technique on the scope is more or less, if I see
two
horizontal lines - spaced apart at the voltage and duration I
think
they should be - I am happy.

Chris


 

Chris,



Robert
:)

-----Message d'origine-----
De : Electronics_101@...
[mailto:Electronics_101@...] De la part de lcdpublishing
Envoy¨¦ : mai 1 2006 15:52
? : Electronics_101@...
Objet : [Electronics_101] Re: SPI interfacing - How long can
external connections be?


That is somewhat what I plan to do. However, if storage worked on
my scope - this would all be much easier to see! I guess I could
get a series of identical characters passing between the two chips.
I believe letter N was the one that adds up to 01010101 binary. If
I can get a repeating pattern it should be pretty easy to watch and
compare - I hope :-)

Chris


 

Thanks buddy! I was off by a couple - it's capital U

Chris



--- In Electronics_101@..., Robert Hedan
<robert.hedan@...> wrote:

Chris,



Robert
:)


-----Message d'origine-----
De : Electronics_101@...
[mailto:Electronics_101@...] De la part de
lcdpublishing
Envoy¨¦ : mai 1 2006 15:52
? : Electronics_101@...
Objet : [Electronics_101] Re: SPI interfacing - How long can
external connections be?


That is somewhat what I plan to do. However, if storage worked
on
my scope - this would all be much easier to see! I guess I
could
get a series of identical characters passing between the two
chips.
I believe letter N was the one that adds up to 01010101 binary.
If
I can get a repeating pattern it should be pretty easy to watch
and
compare - I hope :-)

Chris