What Is RS-232 Serial Communication Protocol and What Does It Do?
Given that you are reading an article about the RS-232 serial communication protocol, you likely have recently come into contact with it. For instance, perhaps you found an alien cable or port and have no idea what it is. Or maybe you have used RS-232 before but want to learn a little more about it. In either case, read on to learn what RS-232 serial communication is, how it works, and its benefits and drawbacks.
The Basics of RS-232 Serial Communication
First introduced in 1960, RS-232 is a standard for serial data communication between devices. Despite the “RS” standing for “Recommended Standard”, the specifications of RS-232 are relatively flexible and have been repeatedly updated over the past several decades. For example, the protocol can use either a 25-pin or 9-pin D sub connector. Because of this, two devices using the same standard may not be immediately compatible because they have different physical connectors.
RS-232 communicates data one bit at a time (in series), unlike a parallel interface that sends multiple bits simultaneously. The key benefit of this is that serial communication is less complicated and requires fewer wires.
Historically, the RS-232 Serial Communication Protocol was commonly used for personal computing devices such as printers, projectors, modems, point of sale devices, and more. Today, many of these applications have switched to USB or wireless connections. However, RS-232 is still used heavily in automation, servers, networking, industrial communications, and many other applications.
Just What Is That Connector Doing, Anyway?
There are two connector sizes used for RS-232: DB9 and DB25. In both cases, RS-232 connects a Data Terminal Equipment end (DTE, the transmitter) to a Data Communication Equipment end (DCE, the receiver).
The 9 pin connector seems to be a little more common these days, so let’s take a peek at exactly how these pins are used. The table below shows the description and abbreviation for each pin. The column labeled “I/O” specifies the data direction from the male connector.
|Pin 1||Data Carrier Detect||DCD||Input||The DCE is connected to the line.|
|Pin 2||Receive Data||RXD||Input||This transmits data from the DCE end to the DTE end.|
|Pin 3||Transmit Data||TXD||Output||This transmits data from the DTE end to the DCE end.|
|Pin 4||Data Terminal Equipment Ready||DTR||Output||The DTE end is ready for transmission.|
|Pin 5||Signal Ground||GND||This carries the ground signal.|
|Pin 6||Data Communication Equipment Ready||DSR||Input||The DCE end is ready for transmission.|
|Pin 7||Request To Send||RTS||Output||The DTE end requests the DCE to prepare for transmission.|
|Pin 8||Clear To Send||CTS||Input||The DCE end gives the DTE the go-ahead.|
|Pin 9||Ring Indicator||RI||Input||This transmits an incoming ring signal to the DCE.|
Looking straight at the male connector, pins one through five are in order from left to right on the top row, and pins six through nine are left to right on the bottom row. In the female connector, they are arranged the same except that they are right to left.
The Nitty Gritty
It can sometimes be helpful, or at least interesting, to delve into some of the more nitty-gritty details. For those with curious minds, here are some specifics that are taken into account when the data is actually being transmitted across the wire.
- Data Frame: A data frame is a transmission of data that begins with a start bit and ends with a stop bit. This is necessary because of the asynchronous nature of RS-232 serial communication. Because Data transmission can start at any moment, the receiver needs some way of knowing when a transmission starts and when it ends. The data frame defines this explicitly.
- Start Bit: The start bit is identified by the space-line level (a 0 in binary). The line is in mark state (a 1 in binary) when idle. Therefore, the start bit is easy to identify.
- Data Bits: Data bits are pretty straightforward. They are the bits of data of the actual communication along RS-232.
- Parity Bits: An additional bit can be added to a data word for error-detection purposes. The receiver can compare the parity bit value against the calculated value of the data.
- Stop Bits: The stop bit isn’t an actual bit per se, but a minimum period of idle time following transmission. When that minimum idle time can be paired with a start bit, the receiver knows it has received a full data frame.
- Baud Rate: Baud rate is the data transmission speed of a serial line. Both the transmitter and the receiver must be on the same baud rate. It is measured in bits per second.
- Full-Duplex vs. Half-Duplex: Serial interfaces like RS-232 can be either full-duplex or half-duplex. In full-duplex setups, both devices can transmit data simultaneously, while in half-duplex, they must take turns.
Advantages of RS-232 Serial Communication Protocol
RS-232 is remarkable for its simplicity and low cost. It is used by many legacy devices and is favorable in many point-to-point applications when no further complexity is needed, such as in industrial control equipment.
Unlike USB, the most common modern alternative, maximum RS-232 cable lengths are dependent upon capacitance. However, a standard rule of thumb is that cables of up to 15 meters (50 feet) are generally supported. USB can support 3 to 5 meters (about 10 to 17 feet). RS-232 also handles noise better than many other protocols.
Disadvantages of RS-232 Serial Communication Protocol
The RS-232 protocol isn’t perfect, however. For starters, it has a slower baud rate, especially over long distances, and needs to use higher voltages. More significantly for everyday use, it is just less practical to set up than USB, especially for casual computer users.
From a more technical perspective, the protocol is only appropriate for system-to-system communication in the single-master-single-slave configuration. Any communication with multiple chips or sensors on one end or with a more complex configuration will not be supported by RS-232.
Using RS-232 on Your Network
Despite being replaced by USB and other protocols in many situations, RS-232 is still heavily used today. In many applications and use cases, it can be helpful (or even necessary) to connect serial devices to networks using an RS-232 to Ethernet converter, also called a device server.
NetBurner’s line of Serial to Ethernet modules is perfect for this use. They are easy to set up, robust, and offer helpful features such as custom baud rates, SSL/TLS support, and can be fully customized with development kits. Check them out today.