This article introduces the basic concepts of the serial communication protocols RS-232, RS-422, and RS-485, including baud rate, data bits, stop bits, parity bits, and handshaking information.
The concept of serial communication is quite simple. Serial ports send and receive bytes one bit at a time. Although it is slower than parallel communication, which transmits by bytes, serial communication is simple and can achieve long-distance communication. For example, the IEEE 488 specification states that the total wire length between devices in parallel communication must not exceed 20 meters, and the distance between any two devices must not exceed 2 meters; while serial communication can reach up to 1200 meters.
Typically, serial ports are used to transmit ASCII data. Communication is completed using three wires: (1) Ground, (2) Transmit, (3) Receive. Since serial communication is asynchronous, a port can send data on one line while receiving data on another. This method is known as full-duplex transmission. Other lines are used for handshaking but are not mandatory. The most important parameters for serial communication are baud rate, data bits, stop bits, and parity bits. For two communicating ports, these parameters must match:
Baud rate is a parameter that measures the speed of communication. It indicates the number of bits transmitted per second. For example, 300 baud means sending 300 bits per second. When we refer to clock cycles in serial ports, we mean baud rate. For instance, if the protocol requires a baud rate of 4800, then the clock is 4800Hz. This means the sampling rate of serial communication on the data line is 4800Hz. Typical baud rates for telephone lines are 14400, 28800, and 36600. Baud rates can be much higher than these values, but baud rate and distance are inversely proportional. High baud rates are often used for communication between devices that are very close together.
Data bits are a parameter that measures the actual data bits in communication. When a computer sends a packet, the actual data may not be 8 bits; standard values are 5, 7, and 8 bits. How to set this depends on the information you want to transmit. For example, standard ASCII code ranges from 0 to 127 (7 bits). Extended ASCII code ranges from 0 to 255 (8 bits). If the data uses simple text (standard ASCII code), then each data packet uses 7 bits. Each packet refers to a byte, including start/stop bits, data bits, and parity bits. Since the actual data bits depend on the selected communication protocol, the term