SX RS485 Communications
![william chan](https://forums.parallax.com/uploads/userpics/RBTCEMRWP85K/nQFR9OII9OM33.jpg)
Hi,
Has anybody implemented RS-485 differential communications using the built it comparator in the SX?
Seems like I can use the same UART assembly code with very little modifications to make it work with RS-485.
How many meters can it go if the SX directly drives the copper wires?
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
Has anybody implemented RS-485 differential communications using the built it comparator in the SX?
Seems like I can use the same UART assembly code with very little modifications to make it work with RS-485.
How many meters can it go if the SX directly drives the copper wires?
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
Comments
a rs485 driver chip because of the 120 ohm termination resistor.
This means a current of 5V/120ohm = 42mA. The sx I/O pins
cannot deliver this current.
regards peter
Even if the SX IO pins cannot source 45mA, it can still talk to standard RS-485 devices because the only thing that happens is that the voltage across the 2 wires will drop to much less than 5V but still within readable levels.
Can I ask you about the behavior of the SX built-in comparator.
Will the comparator still work correctly if the input pin's voltage is near 5V or near ground?
I have had experiences with TL082 and TL084 op-amps where if both inputs were near the power supply rails, the comparator does not compare the 2 values properly.
For example, if the non-inverting input voltage is at 0.02 volts and the inverting input is at 0.03 volts, the output may incorrectly swing high.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
http://www.sxlist.com/techref/ubicom/lib/io/dev/video/hsync-ng.htm
lowest level input voltage for the comparator is 0.4V
You state the output voltage drops if the output cannot supply
enough current. I think there is a real change the pin gets damaged
if you sink/source more than 25mA per pin, or 50mA per port
(sum of 8 pins), whichever comes first.
Just use a max487 driver chip (which is available in DIP8) and you will have no·trouble.
regards peter
Thanks for the 0.4v tip. I really needed it.
I think if there is a 10 ohm resistor on each IO pin before connecting to the wires will keep the pins alive.
Do you think I should put 5.1v zeners on each wire to ground to prevent EMI pickup on the longish wire from re-starting the SX?
or should i use MOVs?
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
I reckon the SX's comparator is a good one, as they go, but it's not a precision comparator.
http://www.linear.com/pc/downloadDocument.do?navId=H0,C1,C1007,C1017,P1352,D3197
It also shows AC coupling to reduce DC currents. And it shows the effects when
termination is incorrect.
regards peter
This message has results of tests I made on the SX comparator. I found that the common mode range went much lower than 0.4 volts. On a 5 volt supply it worked from 0.05 volts up to 4.9 volts, although above 4 volts the accuracy (offset) was degraded. The propagation delay degrades below 0.1 volt and above 3.8 volts.
While I agree that in general a qualified RS485 driver is a good bet, it is also true that short, local RS485 connections seldom use the 120 ohm termination. When that is the case, the SX could drive the line with no problem. There are other reasons for using the qualified parts. They can operate into an extended common mode voltage, (like -7 to + 12 volts), as might occur if the ground potentials are different at the two ends. Some modern drivers can survive large ESD spikes or accidental connection to power lines as might occur in an industrial environment. Isolated drivers can operate into and survive huge insults to the RS232 line. But if none of those considerations are going to apply to what you are doing, and you have short and well controlled RS485 with >1000 ohm termination, then the SX direct. could hack it.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Also, you don't need to terminate your lines with a pure resistance. A 120-ohm resistor in series with a 0.01uF cap wil provide 120 ohms of dynamic impedance for edges, without the DC loading that just a resistor would provide.
I actually tried this scheme years ago. It worked, but the tradeoff in complexity, as compared to a cheap RS485 transceiver chip, just wasn't worth it.
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 10/12/2007 5:50:14 PM GMT
If I were to use a slow 2400 baud rate, would I need to increase the termination capacitance to 0.1 uF?
If the cable is short, termination becomes unnecessary right?
If I use CAT-5e cables, would the impedance still be 120 ohms?
I still like the idea of using only 1 pair of pins and let the software switch between input and output modes.
What is the usual protocol used to decide whose turn to talk?
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
0.1 uF and 120 ohms is adequate for cables up to 4000 feet.
CAT-5 cable characteristic impedance is around 100 ohms. 120 is close enough.
In a one master-many slave scenario, the master sends a command or a request for data, then it turns to input mode, and the slave takes control and sends back a packet, then repeat. Some devices have a configuration parameter for how long the slave will delay before returning its packet, to allow for turnaround. One can imagine other schemes, token passing etc., but RS485 and RS422 are a physical layer spec only, no protocol implied.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
-Phil