The plain man’s guide to serial communications
This article was originally written in the period 1995-2000
Steve Elliott of Field Electronics explains a few of the mysteries and provides some helpful tips for getting serial communications to work first time.
If you regularly configure, wire and test serial communications links, this article is not for you. If, like most of us, you are frustrated and confused when industrial instruments have RS485 or RS422 ports while the PC that you want to connect to has an RS232 port, read on!
So what are RS232 and RS485 anyway? They are the most common standards for the electrical connections between industrial serial communications devices. The bad news is that there are quite a few more standards, the good news is that you are unlikely to meet most of them. Notice, RS232 and RS485 define electrical platforms; these are not the communications protocols – protocols are quite another bag of worms.
Briefly, RS232 is a dc voltage signalling standard that includes handshaking, designed for one to one communication over short distances with maximum security. PCs use RS232 for communication with printers and modems etc. because it is secure, simple and cheap. RS485, a low voltage current signalling standard using balanced signals, is designed for one to many (master and n slaves) connections over long distances. Data acquisition modules such as Field Electronics Series 1000 and Series 2000 tend to use RS485 to allow multiple units to share the same communications links (multi drop) and to allow physical distribution over often quite large industrial sites. The standard connection mode for RS485 is three wire, but for industrial data acquisition systems in a one to many configuration, the alternative two and four wire connections are most common. In four wire mode, all the remote receivers are connected in parallel to the PC’s transmitter, and all the remote transmitters re paralleled to the PC’s receiver. This has the advantage of allowing simultaneous transmit and receive with the PC, but remote devices can only talk to the PC, not to each other. Four wire mode is also compatible with RS422. Two wire mode is used where only half duplex communication is required. In this mode all transmitters are connected in parallel with all receivers. The advantages are flexibility and cable cost saving, but only one transmission can take place at a time. Three wire RS485 configuration operates in the same way as four wire, but the transmit and receive return connections are commoned, resulting in extra current in the return path with can cause problems.
To allow multi-drop configurations, RS485 has a tri-state condition where the transmitter section disconnects itself from the communications link when not active. This prevents the transmitters with their comparatively low source impedance from conflicting with each other and allows up to 32 devices to share a single cable. Field Electronics’ implementation of RS485 improves on this specification and can support up to 99 units on a single cable.
Connecting RS485 devices to PCs
I’m sorry, but you can’t, the two standards are not compatible! Actually, by some miracle of tolerance, it is sometimes possible to make some RS485 devices work with some RS232 ports by using cunning wiring, resistor chains and accepting no noise immunity, but I’m not going to tell you how or you will blame me when it fails! To do the job properly, you need a communications adapter such as the Field Series 912. This takes the voltage signals of RS232 and generates balanced four wire signals of RS485 (and vice-versa of course). It also provides electrical isolation, very important in complex installations where many devices, possibly from many makers, are connected together via the link and any one could inject high voltages or earth faults. See connection diagram. The converter should be as close to the PC as possible.
A full specification RS485 link can support up to 32 units at up to 4km, though Field Electronics implementation will support 99 units at up to 1km. The addition of a line driver (such as the Field 905) will enable greater distances to be covered. Beware of the term RS485 compatible, this usually means the device will only work with other RS485 devices under a limited set of conditions. Typical problems would be limited speed, limited length of communications cable run or limited ability to drive large numbers of other devices on the link. Another common compatibility problem is termination marking. Most vendors use Rx+, Rx-, Tx+ and Tx-, however some markers label as A, A, B and B, so check connections carefully.
Cabling
For an industrial data acquisition system, using master and n slaves mode, connect in four wire using a two pair plus overall screen cable and connect the screen to communications 0V at the converter end. Suitable cable is Belden 9502. Wire into and out of each unit to avoid spurs which, being unterminated lines, will cause reflections and reduce noise immunity. If you must have spurs, try to keep them to less than 300mm or use a line driver. At the end of the cable run furthest from the PC, add a 330 ohm terminating resistance to the pair carrying the transmit signal from the PC. The RS232/485 converter will terminate the other pair.
Routing is also very important. For new installations, keep well away from power cable runs and other sources of electrical noise. Large variable-speed motor drives and their cables are amongst the worst. It is sometimes tempting to run the communications cable along the power cable wiring trays. Don’t do it! Cabling is a costly exercise and doing it once properly is preferable to doing it twice. However, it is worth looking at the economics of using the power cable trays for convenience and running fibre-optic communications to guarantee electrical noise immunity. Field Electronics’ 950 series fibre-optic communications modules interface easily with RS232 and RS485 links and although more expensive, often produce overall savings by reducing installation labour. Fibre optics are also useful for entering or even crossing hazardous areas.
Communications speed
How fast do you need to go? For a rule of thumb assessment, add the number of digital data channels on the communications link to 16 times the number of analogue channels to give the total number of data bits to be acquired. For small systems (say 500 bits or fewer), double this number to allow for addressing, parity, data requests etc. For larger systems with longer data streams, a multiplier of 1.5 is sufficient. Divide this number by the number of seconds acceptable as an update time and you have your baud rate. e.g. 10 digital signals and 2 analogue values at each of 6 locations gives (10 x 6) + (2 x 6 x 6) = 252 bits. 252 x 2 for communications overhead = 504. One update per second gives roughly 500 baud. Any speed faster than this would suit our hypothetical system. Since noise susceptibility increases markedly with speeds above about 9600 baud, there is no good reason to run quicker than that and 2400 baud would do the job. As you can see, quite a lot of data can be moved quite quickly via one RS485 link.
PCs typically communicate satisfactorily at up to 9600 baud. Many PC software packages and communicating instruments allow for speeds greatly in excess of this, but watch out for the specification of the UART (universal asynchronous receiver/transmitter) chip in the PC. This is important because there are actually two serial links in operation, the external one linking the devices around the plant and another, linking the PC’s serial port to the processor bus. This serial link inside the PC communicates via the UART mentioned above. For a standard 8250 UART, 9600 baud normally works fine, but to use speeds of 19200 baud or higher, a 16550A UART is needed or the system will be limited by a bottleneck inside the PC. If in doubt, run MSD.EXE (usually found in your DOS or Windows director) from the DOS prompt, not from inside Windows, and it will tell you what is fitted. With a bit of luck, the UART chip will be in a socket and you can change it if you need to.
- Field Electronics
- Tel: 01273 729361
- Fax: 01273 726595