| Author |
Message |
therion
Guest
|
Posted:
Fri Sep 23, 2005 12:15 am Post subject:
RS485 CSMA/CD protocol |
|
|
Hi, I would need to implement an CSMA/CD L1 protocol code for RS485 in my
new AVR project for home automation.
Any link, hint or help for the similar source code? |
|
| Back to top |
|
 |
Guest
|
Posted:
Fri Sep 23, 2005 6:46 am Post subject:
Re: RS485 CSMA/CD protocol |
|
|
My hint would be...Don't.
I've been curious about this sort of thing myself, and as far as I can
tell from web research no one out there has ever got it working
satisfactorily for real, as opposed to demonstration projects.
AFAIK it's just not feasible to reliably detect collisions on a
real-world bus with "standard" UART and RS485 hardware.
This is what CANBus is for. |
|
| Back to top |
|
 |
Henrik Johnsson
Guest
|
Posted:
Fri Sep 23, 2005 6:53 am Post subject:
Re: RS485 CSMA/CD protocol |
|
|
Steve at fivetrees <steve@nospamtafivetrees.com> wrote:
| Quote: | richardlang@my-deja.com> wrote in message
news:1127439995.520337.174470@g44g2000cwa.googlegroups.com...
My hint would be...Don't.
I've been curious about this sort of thing myself, and as far as I can
tell from web research no one out there has ever got it working
satisfactorily for real, as opposed to demonstration projects.
AFAIK it's just not feasible to reliably detect collisions on a
real-world bus with "standard" UART and RS485 hardware.
Hmmm. It is possible, but you have to enable both Tx and Rx, and monitor
that Tx = Rx. If not, back off and try again later.
|
That kind of setup doesn't work reliably in my experience. What you
can do is to only drive one level actively and have the termination of
the bus define the other level. Then you connect outgoing data to the
output enable of the RS485 driver. But then we're not within the RS485
spec any more. I have seen this work for synchronous communication at
megabit speeds. At least some members of the QUICC/PowerQUICC family
from Freescale has a mode called HDLC Bus that can be used for
this. It is really designed for a direct connection between MCUs but
with a few tricks it can be used to work with RS485 drivers.
/Henrik
-- |
|
| Back to top |
|
 |
Steve at fivetrees
Guest
|
Posted:
Fri Sep 23, 2005 7:19 am Post subject:
Re: RS485 CSMA/CD protocol |
|
|
<richardlang@my-deja.com> wrote in message
news:1127439995.520337.174470@g44g2000cwa.googlegroups.com...
| Quote: | My hint would be...Don't.
I've been curious about this sort of thing myself, and as far as I can
tell from web research no one out there has ever got it working
satisfactorily for real, as opposed to demonstration projects.
AFAIK it's just not feasible to reliably detect collisions on a
real-world bus with "standard" UART and RS485 hardware.
|
Hmmm. It is possible, but you have to enable both Tx and Rx, and monitor
that Tx = Rx. If not, back off and try again later.
Steve
http://www.fivetrees.com |
|
| Back to top |
|
 |
Paul Keinanen
Guest
|
Posted:
Fri Sep 23, 2005 8:15 am Post subject:
Re: RS485 CSMA/CD protocol |
|
|
On 22 Sep 2005 21:37:02 -0700, richardlang@my-deja.com wrote:
| Quote: | CANBus drivers only actively drive one signal level, relying on
termination resistors to passively assert the other level in absence of
any other nodes trying to actively drive the bus. This allows CAN's
non-destructive collision arbitration mechanism.
Some early CAN systems used RS485 drivers, but with the TTL Tx. signal
from the higher level controller wired to the drivers chip enable line
rather than the Tx. input.
|
This could work quite reliable.
However, you would need a XOR gate between the TTL level Rx and Tx
signals to detect coincidence, but you would still have some spikes at
each bit transition due to the limited rise and fall times and
possibly due to reflections. You would have to filter out these
spikes, but how do set the threshold, in order to quickly detect when
two transmitters starts to send the same character at say 1/4 bit time
after each other.
If the collision is done purely in software after the UART, much more
timing information is lost, especially if a FIFO is used on Rx and Tx.
If the protocol always starts with the same character, say STX, how do
you know, if that STX you got from the Rx FIFO is from your
transmission or not.
Starting the message with _your_ address (not the destination address
as in Modbus) would at least get some assurance that you got your own
ID back, get the ID of an other station or a garbled character
signifying collision, but still there would be false triggering due to
time shifts by 2, 4 or 6 bits. On way around this would be to limit
the number of stations to 8 and have station addresses with only one 0
bit, i.e. EF, DF, BF, 7F, FE, FD, FB, F7 (hex).
With low expected collision rates, it might even be acceptable to
detect collisions from failing CRCs at the end of frame.
Paul |
|
| Back to top |
|
 |
DarkD
Guest
|
Posted:
Fri Sep 23, 2005 8:15 am Post subject:
Re: RS485 CSMA/CD protocol |
|
|
"therion" <therion0@yahoo.com> wrote in message
news:dgv8ou$smm$1@sunce.iskon.hr...
| Quote: | Hi, I would need to implement an CSMA/CD L1 protocol code for RS485 in my
new AVR project for home automation.
Any link, hint or help for the similar source code?
|
How many devices and how much comms? I have seen people implement servers
which poll all devices and end up with just as good throughput |
|
| Back to top |
|
 |
Rene Tschaggelar
Guest
|
Posted:
Fri Sep 23, 2005 8:15 am Post subject:
Re: RS485 CSMA/CD protocol |
|
|
therion wrote:
| Quote: | Hi, I would need to implement an CSMA/CD L1 protocol code for RS485 in my
new AVR project for home automation.
Any link, hint or help for the similar source code?
|
This collision protocol only makes sense with multiple
masters, not in a master-slave setup. And if you have
multiple masters, then better implement a token protocol.
IMO, this collision protocol was one of the biggest
mistakes in history of IT.
Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net |
|
| Back to top |
|
 |
rziak
Guest
|
Posted:
Fri Sep 23, 2005 8:15 am Post subject:
Re: RS485 CSMA/CD protocol |
|
|
| Quote: | My hint would be...Don't.
I've been curious about this sort of thing myself, and as far as I can
tell from web research no one out there has ever got it working
satisfactorily for real, as opposed to demonstration projects.
AFAIK it's just not feasible to reliably detect collisions on a
real-world bus with "standard" UART and RS485 hardware.
This is what CANBus is for.
|
I got to the same conclusion.
Btw. what are the differences between RS485 / CAN2.0 on physical layer
?
However, here is a thought:
1. sender waits until bus is idle and then sends SOF (say 0) and
bit-bangs message ID at low speed with software CD.
2. if no collision is detected, the sender continues sending the
content at desired speed using HW UART.
Even with simple mechanism of pulling bus active before sending the
message and checking for idle before doing so decreses the probability
of later collision substantially so the bit-banged priority is just a
fail-safe mechanism in rare case multiple senders decide to pul bus
active within same microsecond.
If system does not need 100% bandwidth and can withstand latency of
occasional 1-2 retries, you may succeed with the active start symbol
and random back-off timer. |
|
| Back to top |
|
 |
Guest
|
Posted:
Fri Sep 23, 2005 8:15 am Post subject:
Re: RS485 CSMA/CD protocol |
|
|
Yeah, yeah, that's how you would do it *in theory*
In practice I'm not at all confident that "standard" RS485 drivers &
UART Rx. hardware will reliably detect and report the effects of
another RS 485 driver at the other end of a sub-optimal (long, heavily
loaded) real-world bus trying to drive to a conflicting signal level |
|
| Back to top |
|
 |
Guest
|
Posted:
Fri Sep 23, 2005 8:15 am Post subject:
Re: RS485 CSMA/CD protocol |
|
|
rziak wrote:
| Quote: | My hint would be...Don't.
I've been curious about this sort of thing myself, and as far as I can
tell from web research no one out there has ever got it working
satisfactorily for real, as opposed to demonstration projects.
AFAIK it's just not feasible to reliably detect collisions on a
real-world bus with "standard" UART and RS485 hardware.
This is what CANBus is for.
I got to the same conclusion.
Btw. what are the differences between RS485 / CAN2.0 on physical layer
?
|
CANBus drivers only actively drive one signal level, relying on
termination resistors to passively assert the other level in absence of
any other nodes trying to actively drive the bus. This allows CAN's
non-destructive collision arbitration mechanism.
Some early CAN systems used RS485 drivers, but with the TTL Tx. signal
from the higher level controller wired to the drivers chip enable line
rather than the Tx. input. |
|
| Back to top |
|
 |
Jim Granville
Guest
|
Posted:
Fri Sep 23, 2005 8:15 am Post subject:
Re: RS485 CSMA/CD protocol |
|
|
richardlang@my-deja.com wrote:
| Quote: | My hint would be...Don't.
I've been curious about this sort of thing myself, and as far as I can
tell from web research no one out there has ever got it working
satisfactorily for real, as opposed to demonstration projects.
AFAIK it's just not feasible to reliably detect collisions on a
real-world bus with "standard" UART and RS485 hardware.
This is what CANBus is for.
|
However, you can use CAN bus Transcievers, and UART uC, especially if
it is all your own network.
RS485 drivers have LowZ outputs, and so with real cable impedances, you
cannot reliably sense contentions.
CAN drivers are open-collector, so OR tie, and can detect collisions
within the transit times of cables.
So a vanilla uC can send, checking the RX to verify no differences, and
if it detects a difference, it has to go to collision mode.
UART systems will take longer to detect/respond to a collision than CAN,
but in a simple network, with low traffic, the lower cost of devices
might make that worthwhile.
Since most uC UARTS have 9 bit modes, you can still use the CAN_Txcvr &
collide detect, but have a master that allocates timeslots, if you need
deterministic performance.
-jg |
|
| Back to top |
|
 |
Anne & Lynn Wheeler
Guest
|
Posted:
Fri Sep 23, 2005 4:15 pm Post subject:
Re: Ethernet, Aloha and CSMA/CD - |
|
|
Roberto Waltman <usenet@rwaltman.net> writes:
| Quote: | May be, but it also may have been an unavoidable mistake - I can not
think of a better approach for Hawaii's original ALOHA radio network
on which Ethernet/CSMA/CD where partially based. (Especially when
you consider the technology available at the time.)
Each station in the Aloha network could not listen to the others,
both because of the terrain of the island and because the antennas
were directed to the "common medium", the satellite, so they had to
broadcast blindly and wait for the satellite to echo it back to all
the stations + acknowledge, as an indication that there was not
collision.
|
one of the things we did in the hsdt
http://www.garlic.com/~lynn/subnetwork.html#hsdt
in the 80s was design and deploy tdma earth stations ... we got a
transponder on sbs-4 ... and even got to go to the launch party
at the cape (complicated by the scrubs):
http://www-pao.ksc.nasa.gov/kscpao/chron/sts41-d.htm
slightly related post (at the very bottom mentioning AT&T)
http://www.garlic.com/~lynn/2005n.html#25 Data communications over telegraph circuits
we were getting into some fancy dynamic bandwidth re-allocation on
superframe boundary. the stations were also capable of agile frequency
hopping.
a little topic drift ... may wife is listed as co-author on
early token-passing patent
http://www.garlic.com/~lynn/2000e.html#14 internet preceeds Gore in office.
http://www.garlic.com/~lynn/2004p.html#55 IBM 3614 and 3624 ATM's
http://www.garlic.com/~lynn/2005d.html#11 Cerf and Kahn receive Turing award
http://www.garlic.com/~lynn/2005h.html#12 practical applications for synchronous and asynchronous communication
http://www.garlic.com/~lynn/2005i.html#43 Development as Configuration
there is even a tie-in between the rios chip design work going on
in austin and the lsm & eve out in the valley
http://www.garlic.com/~lynn/subtopic.html#801
for even more drift:
http://www.garlic.com/~lynn/2002d.html#3 Chip Emulators - was How does a chip get designed?
http://www.garlic.com/~lynn/2002g.html#55 Multics hardware (was Re: "Soul of a New Machine" Computer?)
http://www.garlic.com/~lynn/2002j.html#26 LSM, YSE, & EVE
http://www.garlic.com/~lynn/2003.html#31 asynchronous CPUs
http://www.garlic.com/~lynn/2003k.html#14 Ping: Anne & Lynn Wheeler
http://www.garlic.com/~lynn/2004j.html#16 US fiscal policy (Was: Bob Bemer, Computer Pioneer,Father of ASCII,Invento
http://www.garlic.com/~lynn/2004o.html#25 CKD Disks?
http://www.garlic.com/~lynn/2004o.html#65 360 longevity, was RISCs too close to hardware?
http://www.garlic.com/~lynn/2005c.html#6 [Lit.] Buffer overruns
--
Anne & Lynn Wheeler | http://www.garlic.com/~lynn/ |
|
| Back to top |
|
 |
Tim Shoppa
Guest
|
Posted:
Fri Sep 23, 2005 4:15 pm Post subject:
Re: Ethernet, Aloha and CSMA/CD - |
|
|
| Quote: | If you used Ethernet in a hard RT system and
did not design it properly, thats your fault, not
the protocols.....
|
Ethernet is used in hard RT vital safety-critical systems all the time.
It's a matter of system design to make sure that collisions or a
network failure doesn't result in unsafe conditions. Of course, if a
Token advocate designed a CSMA/CD system you would end up with a
disaster, because they would take the simplicity of working collision
detection/backoff algorithms that work and layer on all sorts of crap
to guarantee timeslots etc and end up with a system that doesn't work.
In fact I would be very critical of a safety-critical system where a
network failure (here I'm lumping "excessive collisions" in with
"network failure" which isn't too far off for Ethernet but of course
the Token advocates will jump all over me for this) results in unsafe
conditions.
Of course, I work in an industry where we take pride in our vital
relays and vital processors having to meet more stringent failsafe
standards than the detonation systems in thermonuclear weapons :-).
But unlike say aerospace or road vehicle systems, my industry has the
advantage that setting all signals to stop, dropping speed commands,
and applying full-service brakes is the failsafe condition. It's hard
to claim that shutting down an airplane's engines or applying full
braking on a road vehicle is a failsafe condition...!
Tim. |
|
| Back to top |
|
 |
Rene Tschaggelar
Guest
|
Posted:
Fri Sep 23, 2005 4:15 pm Post subject:
Re: RS485 CSMA/CD protocol |
|
|
Grant Edwards wrote:
| Quote: | On 2005-09-23, Rene Tschaggelar <none@none.net> wrote:
therion wrote:
Hi, I would need to implement an CSMA/CD L1 protocol code for RS485 in my
new AVR project for home automation.
Any link, hint or help for the similar source code?
This collision protocol only makes sense with multiple
masters, not in a master-slave setup. And if you have
multiple masters, then better implement a token protocol.
IMO, this collision protocol was one of the biggest
mistakes in history of IT.
Why? It works brilliantly for Ethernet. In my experience,
token passing is horribly complex.
|
No it doesn't work brilliant. It is crap. It doesn't have a
deterministic responsetime. The token protocol such as in
Arcnet is much better. Each node gets a slot time every 150ms
or so.
At the time the two battled, the Ethernet was 10MBit, and
ARCNet was 2.5MBit. But under load Arcnet performed much
better. While Arcnet was standing at somewhat below 2.5MBit
over the bus, independent on the number of nodes and traffic,
Ethernet went right down to zero with increasing load.
But the marketing guys just saw the 10MBit vs 2.5MBit.
Too bad. Ethernet improved the bandwidth but the responsetime
is still not deterministic, unless all nodes are connect
to a switch. The switch avoids collisions, of course.
Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net |
|
| Back to top |
|
 |
Rene Tschaggelar
Guest
|
Posted:
Fri Sep 23, 2005 4:15 pm Post subject:
Re: Ethernet, Aloha and CSMA/CD - |
|
|
Tim Shoppa wrote:
| Quote: | And if you have
multiple masters, then better implement a token
protocol. IMO, this collision protocol was one of
the biggest mistakes in history of IT.
The token ring advocates always pointed out how certain circumstances
could lead to collision detection not working nicely. They were also
extremely unconfortable with the lack of guaranteed bandwidth for each
master etc.
|
The point is the behaviour under load. A token protocol doesn't
require a token ring. A bus is sufficient, ARCnet works on
twisted pair and over coax.
Tokenring failed for commercial reasons. It was single source
and the price was beyond reasonable.
When you have a network and it should work under heavy load,
eg all nodes want to transfer huge binaries at the same time,
then a token protocol distributes the bandwidth of the medium
over the nodes while the colision detect system just detects
endless collisions and does endless retries.
It is less that the tokenring advocates were uncomfortable.
A realtime system requires a defined response time that suits
the physical installation this system should control.
A car control system requires responsetimes in the millisecond
region and you wouldn't want your cars cpu to retry some bullshit
while you want the car to stop. Realtime response has nothing
to do with being comfortable, it has to do with lives.
Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net |
|
| Back to top |
|
 |
|
|
|
|