I am trying to understand differences between RS-232 & RS-485. I just don't grasp what is the core principle behind RS-422 inteference resistance? Is it number of wires (4 instead of 3)? Is it because these wires are twisted?
Electronic – Why is RS-422 interface interference insensitive
interfaceinterferencers232serial
Related Solutions
There are two issues with crosstalk between conductors of a cable: capacitive coupling and inductive coupling.
Inductive coupling happens because current flowing thru a wire creates a circular magnetic field around that wire. This also works in reverse. If a wire is subjected to a changing circular magnetic field around it, a voltage will be induced. Therefore, if one wire is carrying a changing current and another wire is close enough so that part of the resulting circular magnetic field also surrounds this second wire, then a voltage is induced in the second wire.
The most effective way to combat this problem is to make sure a equal and opposite return current flows such that the magnetic fields from the two currents cancel out. The best way to ensure this is coaxial cable. Outside the cable, the two equal and opposite currents cancel and there is no net magnetic field.
Inside a multi-wire cable like you describe, this is usually done with twisted pair. At any one point, the two conductors are next to each other. Far enough away the two currents cancel, but up close they don't. Another wire running closer to one wire of the pair will preferentially pick up signal from that wire. This is why the wires are twisted together. A straight wire next to a twisted pair will alternately be nearer one conductor then the other of the twisted pair. Each induces the opposite voltage since the direction of current is opposite in the two wires of the twisted pair. However, these average out to zero over any whole number of twists. In a long enough cable they usually average out well enough.
There is another problem with twisted pair though. Suppose you have multiple twisted pair in the same cable, which is probably the case in the cable you describe. If the twists of one pair are in sync with the twists of another pair, then the induced voltage no longer cancels out in the long run. This is why cables with multiple twisted pair usually have a different twist pitch for each pair. Let's say one pair has 11 twists/foot and another 13 twists/foot. Over any one foot the induced coupled voltage cancells out again. Take a look at the CAT5 cable spec and you will see the different twist pitches for each of the four pairs are carefully specified.
Capacitive coupling is because there is some finite capacitance between every two conductors in the universe. For things far enough apart this can usually be ignored. However, different conductors in a multi-conductor cable are up against each other for a long distance such that capacitive coupling can't be ignored. The best defense against capacitive coupling is a shield, but those are expensive and you say your cable doesn't have any internal shields. Twisted pair again helps here. There will still be capacitive coupling between pairs, but with the right twisting strategy as described above there won't be much preferential coupling to one conductor of the pair. In other words, twisting will cause all the coupling to be common mode with the differential mode mostly cancelling out.
So to finally get to some kind of answer, make sure each signal is carried by a separate twisted pair with the forward and return current of that signal all being carried by that pair. Then treat any signal as differential. Realize there will be common mode noise added to each pair and deal with it accordingly. The external world will also have noise, and due to twisting, this noise will show up as common mode on each pair. 10 base-T and later ethernet, for example, is transformer coupled at each end partly for this reason and also to avoid ground loops.
All that said, I think running stepper motor coil currents thru the same cable as signals is just nuts. This is going to cause trouble. I would seriously look into sending control signals and power for the steppers, but put the stepper drivers close to the stepper motors. That also allows for a local power reservoir cap to make the supply low impedance again after the long cable run. Having the resistance and inductance of the cable between the stepper driver and the stepper motor is asking for more trouble.
The Due, which is really a Atmel AT91SAM3X8E, only has 4 full hardware serial interfaces (though there is an additional UART which may work).
The first thing I'd strongly reccomend is to stop thinking of the board as an "Arduino". The Arduino tools just paper over the actual device. It's a AT91SAM3X8E dev board.
That said, the first place to start is to read the product page and datasheet(pdf).
Functionally, RS-422 looks like a differential asynchronous serial bus. Depending on the implementation, it can be half-duplex (e.g. data can only go one way at a time), or full-duplex (e.g. data can go both directions at the same time). This mode is determined by the hardware, as full-duplex takes more physical wires. Half duplex is one differential pair (and ground), full duplex requires two diff-pairs (and one ground).
For full-duplex on a non-bus topology (e.g. only two devices), the hardware required to interface the bus can be as simple as just sticking a differential line driver/receiver in between your MCU's USART and the other device.
For bus-topologies or half-duplex connexions, it gets more complex, as you need to be able to turn off the line-driver to allow the other device(s) to talk over the shared connections.
Also, one note is you'll see lots of "RS-422/RS-485" line drivers, etc... This is because the physical layer specifications for the two are the same, so a driver that works for RS-422 will generally work for RS-485, and vice versa. In fact, there are often devices that support both protocols.
Fortunately, RS-422 looks exactly like RS-232, simply with different physical signaling levels (and one is differential). As such converting RS232 to RS422 is as simple as just sticking in a converter. (RS485 is more involved).
This means you can probably use the 5th UART in the AT91SAM3X8E for your 5th channel without issue (or you could just use it for the RS232 connection anyways).
With regard to how to actually make your device talk RS-422, you will need a RS422 driver IC. Fortunately, there are lots of options. There are even options available in DIP for easy prototyping.
Breakout boards are harder to come by, as RS-422 is pretty unusual in anything hobbyist grade. I found one, but it looks pretty poorly designed (no ground terminal!). It would probably work fine for experimentation, though.
Related Topic
- Electronic – When do we use all pins in RS-232 cable
- Electronic – RS-232 signal level inversion
- Electronic – Purpose of this oscillator (74HCT14-based) on RS-232 to RS-485 converter
- Electronic – standard describing the UART data frame protocol
- Electronic – RS-232 interface chip problem – why is the voltage level so wrong
- Electronic – How far can 3.3V UART go at 38400 baud
Best Answer
Summary
In a balanced signal both wires carry the signal, with one wire the negative of the other. In the receiver both are subtracted, giving the double of the positive wire's signal. If both wires pick up a disturbance this will be cancelled by the subtraction.
Twisted wires reduce the inductance because the field inverts with each half twist. An inductive disturbance induced in one half twist will therefore be cancelled by the next half twist.
See this answer for more details.