I wrote an answer to an Arduino Stack Exchange question about the different common standards for serial communications, and their inter-compatibility:
I repeat it here for edification.
Voltages
There are a number of different serial hardware solutions, to solve different problems.
- TTL:
All microcontroller’s serial connection (TXandRX) are at “TTL levels”, which means 0V to “Hi” (where “Hi” is 5V, or 3.3V, or whatever the microcontroller uses).RXneeds to be within this range to be detected, andTXwill only be 0V or “Hi” volts – 0V for “off”, and “Hi” for “on”. Each of the alternatives below use dedicated chips to convert TTL to their own voltages – but the same “off” and “on” concepts exist, so the microcontroller can fully communicate using TTL with them through these chips. - RS-232:
The problem with TTL is that it won’t travel far on a cable – and it is easily affected by noise produced by motors and other electrical appliances in the vicinity. Therefore, the TTL levels are often converted to RS-232 levels, which are as high as 25V(!) But even weirder, the other side isn’t 0V, but actually as much as negative 25V (yes, -25V). “Off” is anywhere from +3V to +25V, while “on” is -3V to -25V. That means that if you connect to a true RS-232 appliance, you need to deliver at least ±3V, but need to accept at least ±25V. Needless to say, that’s a problem for microcontrollers, without support circuitry. Also, RS-232 is specified to allow only one receiver perTX– although I’ve put two on a short cable at 9,600 baud with no problem. - RS-423:
RS-423 is a compromise between RS-232 and RS-422. Like RS-232, it only uses one wire each forRXandTX– although maxing out at ±6V. But unlike RS-232, theTXspecification is strong enough, and theRXspecification is sensitive enough (±0.2V), to allow up to 10 receivers on oneTXline. Because RS-423 is so similar to RS-232, I’ll refer to RS-232/RS-423 from now on, unless they’re different. - RS-422:
The problem with RS-232/RS-423 is that they’re not great in (electrically) noisy environments either. To help this, RS-422 has a two-wire pair for each ofRXandTX. RS-232/RS-423 referenceRXandTXfrom a third wire,GND. RS-422 references the sense of the signal between the two-wire pair – if one wire has a higher voltage than the other, it’s “on”, while if it’s the other way around it’s “off”. This is known as a “differential” system, and the two halves of the signal pair are labelled+and-. Electrically, if an interfering signal alters the voltage on the cable, it will affect both wires in the pair the same way – but not change the relative voltage difference between them. This increases the cable’s resistance to external noise. For this reason, the voltages don’t need to be as high – in fact, they’re only ±6V. Note that forTX, the two RS-422 signals could be created by powering one wire of the pair with 0V&”Hi”, the other with “Hi”&0V – and always making sure they were opposite each other. This would create a ±”Hi” differential, which would be detected by the receiver perfectly. But this is not the way it is usually done; it’s usually done with a true differential (isolated) transmitter. - RS-485:
This variant came about when two things were realised:- Most serial communications were half-duplex: one side would transmit, then the opposite side would answer – both sides wouldn’t be transmitting at the same time.
- With one master and multiple slaves, you’d need lots of separate wires between them. Was there a way of “bussing” them all together so that they could all share the same wires? This is called “multi-drop”. Stringing multiple wires between them all was a waste, since the same pair of wires could hold the traffic in either direction (and yes, RS-485 uses the same differential standard as RS-422). Of course, this meant that all sides couldn’t be “powering” the wires at the same time – but that’s OK, each side would “know” when to power their side:
- The master would power its side while it was transmitting the request to a particular slave, then de-power its side to listen for the answer;
- The slave wouldn’t power its side until it had heard a request for itself and was ready to transmit the answer, so it would power its side, reply, then de-power again.
Compatibility
The different voltages above indicate, superficially, that they are not electrically compatible – for example, you can’t plug any directly into TTL (unless you want smoke!). However, there are some circumstances where they can work together – but you have to be lucky!
- RS-232/RS-423 and RS-422:
Because RS-422 is differential, and RS-232/RS-423 work as low as ±3V, you might be able to fool the two into working together – as long as the RS-232TXsignal is no more than ±6V! RS-423 is already limited to that.- RS-232/RS-423
TXis easy: it is already a differential voltage relative toGND, and so can be directly wired to the RS-422RX+andRX-– as long as you realise that due to the different specifications, you wireGNDtoRX+andTXtoRX-(no, that’s not a typo: just the way it is!) - RS-422
TX+andTX-is usually a differential transmitter, and if you tie one wire of the pair to actual ground, then the other will “swing” above and below that one with the required ±3V differential – perfect for RS-232/RS-423. If you connectTX+toGND, andTX-to RS-232/RS-423RX(again, no typo!), and the RS-422 transmitter is truly differential, you can get the two sides to inter-operate.
- RS-232/RS-423
- RS-422 and RS-485:
Because these both use the same voltages and direction, then you could have the two work by wiring the RS-422’sTXandRXpairs together, with the RS-485’sTX/RXpair. But, this can only work if all of the below is true:- There is only one master and only one slave;
- The master controls when it powers its
TXside; - The slave can ‘handle’ hearing its own output without interpreting it as a command;
- You can wire the connections between them as follows:
- Master
TX/RX+to Slave’sTX+andRX+; - Master
TX/RX-to Slave’sTX-andRX-.
- Master
- RS-232/RS-423 and RS-485:
Sorry, no can do.- RS-232/RS-423 has no mechanism to turn off
TXfor half of the conversation; - Since RS-485 has both
TXandRXon the same pins, it implies that you’d have to tie RS-232/RS-423’sRXandTXtogether – which means that the signals are no longer differential.
- RS-232/RS-423 has no mechanism to turn off
