RS232 serial communication is not going away anytime soon. Despite the innovations in serial communication that have introduced other protocols such as USB, WiFi, and Ethernet, RS232 communication is still in wide use. There are several reasons for the longevity of the RS232 protocol. One is better resistance to line noise than other protocols. The RS232 communication protocol is also better-suited for transmitting signals over longer distances than signals generated from I2C or TTL devices. It is also compatible as a standard with many computers and peripheral hardware manufacturers.
Table of contents:
- What is the RS232 Protocol?
- Standards of RS232
- RS232 pinout
- Protocol format
- Handshaking in RS232
What is the RS232 Protocol?
The formal specification of the RS232 protocol defines it as a serial binary data transmission interface between DTE equipment and DCE equipment. A DTE or Data Terminal Equipment such as a computer is at one end of the RS232 serial connection. Data Communication Equipment (DCE) such as a modem is at the other end of the connection.
This diagram illustrates the connection between an RS232 DTE (computer) and an RS232 DCE (modem). In the example, the DTE sends binary data “11011101” to DCE and the DCE transmits the binary sequence “11010101” to the DTE device.
RS232 defines the electrical standards, operational modes, common voltage levels, and the number of bits that are transferred between a DTE and DCE. This is the standard transmission protocol used over land-based telephone lines.
Standards of RS232
The electrical specifications of the RS232 interface were defined in 1969. They describe the electrical voltages, baud rate, operational modes, line impedance, and slew rate used by the protocol.
RS232 Voltage Levels
The line voltages of RS232 range from -25V to +25V. They are defined as signal voltages and control voltages.
A signal voltage between -3V and -25V represents a logical ‘1’ with voltages between +3V to +25V representing a logical ‘0’. Control voltage signals use negative logic where logical ‘1’ indicates -3V to -25V and a logical ‘0’ indicates +3V to +25V. A voltage reading between -3V and +3V is considered to be indeterminate.
The baud rate describes the number of binary bits that are transmitted per second. In the RS232 protocol, baud rates of 110 to 230400 are supported. Baud rates of 1200, 4800, 9600, and 115200 are most commonly seen. The baud rate determines the speed at which the transmission occurs and needs to be the same for both sides of the communication.
Mode of Operation
RS232 devices use single-ended signaling (two-wire) to conduct data transmission. In this type of cabling, one wire is grounded while the other is used to transmit a variable voltage. They can be impacted by the noise produced from differences in ground voltage of the driver and receiver circuits. An advantage of the single-ended method is that fewer wires are needed to enable communication.
The impedance bridging between the RS232 driver and the receiver is in the range of 3KΩ to 7KΩ and is intended to maximize the voltage transfer between devices.
The rate at which the RS232 driver responds is known as the slew rate. It is determined by the input voltage changes registered by the driver. The RS232 protocol defines a minimum slew rate with slow rise and fall times. This is designed to minimize cross-talk between adjacent signals. The normal maximum slew rate allowed is 30V/µsec.
Communication between the DTE and DCE using the RS232 protocol employs either DB9 or DB25 connectors. Both types of D-sub connectors have male and female terminals. DB25 connectors employ 25 pins and DB9 uses 9 with each pin on an RS232 pinout having a specific function. Diagrams of the DB9 pinout and the DB25 pinout can be seen below.
The RS232 serial interface has nine pins and can be obtained in male or female type models.
The RS232C serial communication interface is an updated version of RS232. It retains all of the features of the original standard but employs 25 pins. Of the 25 or 9 pins on a connector, only three are used to connect terminal devices.
In addition to specifying the electrical characteristics, the RS232 protocol defines the functions of each signal used in the interface. These include control and timing signals, common ground, and data signals. Here is a chart of the signals and functions that comprise the RS232 pinout.
RS232 also provides secondary signals that complement the primary signals described above. These include secondary TxD, TxD, DTE, RTS, and DCD signals which can be used to configure connections between DCE and DTE equipment.
A message delivered via the RS232 protocol begins by sending a Start bit ‘0’. This is followed by seven bits of ASCII data with a parity bit appended for verification purposes. The parity bits determine the validity of the message. Transmission is terminated with a stop bit of a binary ‘1’. Either one or two stop bits are usually sent.
In the above diagram, the ASCII character ‘A’ is transmitted with a serial binary stream of ‘1’s and ‘0’s. There is a preset delay between the transmission of each bit when the line is considered to be inactive.
Handshaking in RS232
The process of interchanging information signals between a sender and receiver is known as handshaking. A communication link is constructed between the transmitter and receiver by these signals. There are two types of RS232 handshaking: hardware and software handshaking.
DB9 and DB25 connectors are used for RS232 handshaking. Only the TxD (Transmitter) and RxD pins are cross-coupled if there is no handshaking implemented. The other pins such as RTS, CTS, DSR, and DTR are connected in a loopback manner.
When handshaking is in effect, the RTS and CTS signals are cross-coupled as are the DTR and DSR pins.
There are multiple advantages of the RS232 protocol which have made it a widely used standard in serial communication. Among them are:
- The simple design of the protocol.
- Reduced hardware overhead when compared to parallel communication.
- Compatibility with DTE and DCE communication.
- An inexpensive protocol for development.
- Highly recommended for short-distance applications.
The RS232 protocol does have certain disadvantages and limitations. You cannot use full-duplex communication with the standard. The fact that it is a single-ended protocol can shift the ground potential. RS232 is not recommended for long-distance communication, as longer cables introduce cross-talk that impacts serial transmission.