UARTs Ensure Reliable Long-Haul Industrial Communications Over RS-232, RS-422, and RS-485 Interfaces

By Art Pini

Contributed By Digi-Key's North American Editors

Industrial sensing and control poses many challenges for a communications bus. For example, cabling runs of hundreds or thousands of feet are common while the industrial environment itself is noted for often harsh operating conditions. Industrial equipment can be exposed to a wide range of temperatures, high electrical noise on both power supply and data lines, and fault events like electromagnetic interference (EMI), electrostatic discharge (ESD), or short circuits.

The solution to these problems is to use a robust serial interface based on a universal asynchronous receiver/transmitter (UART), also called an asynchronous communications element (ACE) by some suppliers. UARTs are available as standalone devices, such as the Texas Instruments TL16C752D, or may be within a microcontroller like the Microchip Technology PIC16F688T-I/SL.

With appropriate line drivers, a UART can work over long distances: from 15 meters (m) for the RS-232 serial data bus to 1000 m for RS-485 or RS-422 interfaces. All three of these protocols serve to provide control to remote machines and controllers in factory automation applications and are designed to minimize the effects of EMI and ESD in the harshest settings.

This article will provide background on these commonly used industrial control interface protocols and show how they can be implemented using UARTs and line drivers.

RS-232

The RS-232 serial communications standard is also known currently as EIA/TIA-232-F, which is an Electronic Industries Association/Telecommunications Industries Association standard. The letter F indicates the latest revision. The standard is identical to the International Telecommunications Union (ITU) standards V.24 and V.28. This interface was the original serial bus on personal computers. It was used originally to connect the computer—termed data terminal equipment (DTE)—to a modem, referred to as data communications equipment (DCE).

EIA/TIA-232-F defines a physical layer standard, including signal levels and timing, control signals, connectors, and connector wiring. It does not define character encoding, framing, and other aspects of the protocol level. A typical asynchronous serial bus will include a UART or ACE, line drivers, connectors, and cables (Figure 1).

Diagram of Texas Instruments basic RS-232 system

Figure 1: A basic RS-232 system includes data terminal equipment (DTE) such as a computer, and data communications equipment (DCE) like a modem. A UART/ACE interfaces the parallel computer backplane with the serial RS-232 interface. (Image source: Texas Instruments)

The UART/ACE converts the internal parallel bus of the computer into a serial data stream. It also supplies the input and output first in first out (FIFO) memory buffering, an interface clock (generally referred to as a baud rate generator), and interface timing and handshaking signals. The UART/ACE analog input and output may be buffered by a line driver. The output of the DTE is referred to as the transmitter signal (TX), while the input is called the received signal (RX). The interface cable is limited to a maximum length of 15 m. The length of the cable determines the maximum data rate that can be reliably used over the interface bus.

The RS-232 interface connects two devices with a full duplex connection, meaning that each device can transmit and receive simultaneously. The RS-232 serial data packet consists of a start bit, anywhere from 5 to 8 data bits, 1/1.5/2 stop bits, and a parity bit (Figure 2).

Diagram of RS-232 data packet (click to enlarge)

Figure 2: An RS-232 data packet consists of a start bit, 5 to 8 data bits (8 shown), a parity bit (optional), and 1, 1.5, or 2 stop bits. (Image source: Digi-Key Electronics)

The minimum cable requirement for RS-232 is for three wires: one for transmit, one for receive, and the signal ground. Ground is the return for both signal conductors.

Many of the characteristics of RS-232 are tied to its original application in telecommunications. It uses negative logic with a high state, referred to as a space, and a low state being called a mark. The neutral or rest state is high so the interconnection can be verified remotely. At the transmitter side a 0 state, or space, is a voltage between +5 and +15 volts. The logical 1, or mark state, is a voltage between -5 and -15 volts. At the receiving end, a level of from 3 to 15 volts is a 0, and -3 to -15 volts represents a 1.

The transfer is termed asynchronous because no clock signal is transmitted. RS-232 depends on both sides of the bus being set up for a specific clock or baud rate. Baud rate is a measure of the number of symbols transferred per second; for RS-232 it is approximately the clock rate. Common baud rates are 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, and 921600 baud.

The higher the clock rate the more limited the cable length. For example, at 9600 baud, the full 15 m maximum cable length can be used. At higher baud rates the maximum cable length will be reduced.

RS-232 control signals

RS-232 has a number of specified control signals. They report the status of the DTE and DCE devices as well as implement a hardware-based handshake to pace the transfer of data (Table 1).

Signal Name Mnemonic Function
Data Terminal Ready DTR Turned on by the DTE when it is ready to transmit data. This line must be on before the DCE can turn on DSR.
Data Set Ready DSR Turned on by the DCE to indicate that the DCE is online.
Carrier Detect DCD Turned on by the DCE when it is receiving a carrier from a remote DCE.
Ring Indicator RI Turned on by the DCE when remote telephone line is ringing.
Request To Send RTS Turned on by the DTE when it is ready to send data.
Clear To Send CTS Turned on by the DCE in response to a received RTS command. Held on until RTS is turned off and the last data bit is received.
Receive Data Line RX Receive data.
Transmit Data Line TX Transmit data.

Table 1: The RS-232 control and handshake signals. (Table source: Digi-Key Electronics)

The hardware handshake is implemented using the Request to Send (RTS) and Clear to Send (CTS) flow control signals to ensure that both devices are ready to transfer data and that data has been received by the receiving device. Hardware handshaking is implemented using the following actions:

  1. The data terminal equipment pulls the RTS line down to the “1” or “Mark” state
  2. The data communications equipment pulls the CTS line into the “1” or “Mark” state
  3. The data terminal equipment pulls the Data Terminal Ready (DTR) line to the “1” or “Mark” state for the duration of the data transfer
  4. At the end of the transfer the data terminal equipment restores the DTR and RTS lines to the “0” or “Space” state
  5. The data communications equipment restores the CTS line to the “0” or “Space” state

RS-232 can also use a software handshake to control data flow where the XON (ASCII DC1, hex 11) and XOFF (ASCII DC3, hex 13) characters, sent in the data stream, perform a similar synchronization of transferred data.

UART functional block diagram

The Texas Instruments TL16C752D is a dual UART with 64-byte receive and transmit FIFOs capable of data rates up to 3 megabits per second (Mbits/s) (Figure 3).

Functional block diagram of the 3 Mbit/s Texas Instruments TL16C752D dual UART

Figure 3: The functional block diagram of the 3 Mbit/s Texas Instruments TL16C752D dual UART shows the 64-byte FIFOs and interface lines. (Image source: Texas Instruments)

Each section of the UART has its own software-controlled baud rate generator. The data bus interface performs the parallel-to-serial data conversion and feeds both sections of the dual UART. Each section has independent control lines. The TL16C752D operates from supply voltages of from 1.8 volts to 5.5 volts over a temperature range of from -40°C to 85°C.

Microcontroller based UARTs

Many microcontrollers, such as the Microchip Technology PIC16F688T-I/SL, include serial data interfaces for communicating with monitors, external analog-to-digital converters (ADCs) and digital-to-analog converters (DACs), or other microcontrollers (Figure 4).

Diagram of Microchip Technology PIC16F688T-I/SL CMOS microcontroller

Figure 4: The Microchip Technology PIC16F688T-I/SL CMOS microcontroller includes a serial interface using an enhanced universal synchronous/asynchronous receiver/transmitter (EUSART). (Image source: Microchip Technology)

The EUSART, sometimes called a serial communications interface (SCI), can be configured as either a full-duplex asynchronous or a half-duplex synchronous serial data link. The EUSART in the PIC16F688T-I/SL contains all of the shift registers, clock generators, and data buffers necessary to perform an input or output serial data transfer independent of microcontroller program execution. It has a two-character receive buffer and a single-character transmit buffer. The full-duplex asynchronous interface is useful for communicating with external peripherals like a display monitor, which is the primary application for this interface in the microcontroller.

Line drivers

Line drivers augment the operation of UARTs by buffering the transmit and receive signals. They are useful because they operate over the full RS-232 voltage level specification. One example of such a device is the Texas Instruments MAX232DR dual RS-232/TIA/EIA-232-F transceiver (Figure 5).

Diagram of Texas Instruments MAX232DR dual driver/receiver to buffer a TL16C752D dual UART

Figure 5: Applying the MAX232DR dual driver/receiver to buffer a TL16C752D dual UART. The MAX232DR can tolerate input voltages up to ±30 volts, while outputs are protected against shorts to ground. (Image source: Texas Instruments)

The MAX232DR line driver/receiver has advantages in industrial applications where higher voltages are required. It can sustain input voltages of up to ±30 volts. The device includes a capacitive voltage generator using four external capacitors to supply RS-232 voltage levels of -5 to -7 volts and +5 to +7 volts at the outputs from a single 5 volt supply.

Differential signaling

RS-232 uses single-ended connections for the transmit and receive line. With such single-ended connections, signal voltages are measured from the line to ground. In the industrial environment there is a lot of noise that gets picked up by the RS-232 signal lines, which limits the length of the bus runs. A classic way around this limitation is to use differential signaling.

A differential bus consists of two wires for each signal, where signals are measured by taking the voltage difference between the two wires. Since noise and crosstalk are generally common to both signal lines, the difference measurement subtracts these nearly identical signals, significantly reducing their amplitude. Additionally, differential cables are also shielded to further reduce noise and interference pickup.

There are two common data bus standards that use differential signal lines: RS-422 (TIA/EIA-422) and RS-485 (TIA/EIA-485), with the latter being the most commonly encountered industrial serial bus. These standards use twisted pair transmission lines where connected devices can be up to 1200 m (4000 feet) apart. Both standards have maximum data rates of up to 10 Mbits/s. A comparison of all three serial buses is shown (Table 2).

Standard RS-232 RS-422 RS-485
Line configuration Single ended Differential Differential
Type of transfer Full duplex Full duplex Half duplex (2 wire)
Full duplex (4 wire)
Signals used TX, RX, RTS, CTS, DTR, DSR, DCD, Ground TXA, TXB, RXA, RXB, Ground Data A, Data B, Ground
Bus topology Point-to-point Point-to-point Multi-point
Maximum connected devices 1 10 (in receive mode) 32
Maximum length 15 meters at 9600 bits/s 1.2 km at 100 Kbits/s 1.2 km at 100 Kbits/s
Maximum data rate 1 Mbit/s 10 Mbits/s 10 Mbits/s
Receiver sensitivity ±3 volts ±200 millivolts ±200 millivolts

Table 2: A comparison of the characteristics of the RS-232, RS-422, and RS-485 standards. (Table source: Digi-Key Electronics)

RS-422 and RS-485 differ in that RS-485 can work with up to 32 transceivers (more can be added using bus extenders) while RS-422 is limited to just 10 receivers on the bus. RS-485 in full duplex mode requires four wires compared to two for half-duplex operation and RS-422 (Figure 6).

Diagram of full duplex (left) and half duplex topologies of an RS-485 interface

Figure 6: The full duplex (left) and half duplex topologies of an RS-485 interface. The computer or master device is shown in red; other devices are in blue. (Image source: Texas Instruments)

The differential bus wiring uses two conductors for each transmit or receive signal line as shown in the figure. Full duplex operation requires four wires, while half duplex requires only two. Due to the higher speed of both RS-422 and RS-485, the transmission lines must be terminated at each end. For twisted pair, the termination resistors RT are 120 ohms (Ω). As might have been surmised by the dual UART configuration of the TL16C752D interface IC, it has an RS-485 mode. This is why many UARTs and related line drivers employ the dual configuration.

Voltage levels at the transmitter side for RS-422 are ±6 volts while those for RS-485 are -7 to +12 volts. At the receiver the sensitivity is ±200 millivolts (mV) for both standards.

Conclusion

The three serial interfaces RS-232, RS-422, and RS-485 offer a range of choices for robust serial communications over both short and long distances. UARTs form the basis for all three standards and make it easy to add serial communications to designs, especially those for challenging industrial environments.

Disclaimer: The opinions, beliefs, and viewpoints expressed by the various authors and/or forum participants on this website do not necessarily reflect the opinions, beliefs, and viewpoints of Digi-Key Electronics or official policies of Digi-Key Electronics.

About this author

Art Pini

Arthur (Art) Pini is a contributing author at Digi-Key Electronics. He has a Bachelor of Electrical Engineering degree from City College of New York and a Master of Electrical Engineering degree from the City University of New York. He has over 50 years experience in electronics and has worked in key engineering and marketing roles at Teledyne LeCroy, Summation, Wavetek, and Nicolet Scientific. He has interests in measurement technology and extensive experience with oscilloscopes, spectrum analyzers, arbitrary waveform generators, digitizers, and power meters.

About this publisher

Digi-Key's North American Editors