Introduced the basic concepts and information of serial communication protocols RS-232, RS-422 and RS-485.

This article introduces the basic concepts of serial communication protocols RS-232, RS-422 and RS-485, including baud rate, data bits, stop bits, parity bits and handshake information.

1. What is a serial port?

The concept of serial communication is very simple. The serial port sends and receives bytes in bits. Although slower than parallel communication by byte transfer, the serial port is simple and enables long-distance communication. For example, when the IEEE 488 specification defines parallel communication, it is pointed out that the total length of the line between devices must not exceed 20 meters, and the distance between any two devices must not exceed 2 meters; and the length of serial communication can reach 1200 meters.

分别介绍了串口通信协议RS-232、RS-422和RS-485的基本概念和信息

Typically, the serial port is used to transfer ASCII data. Communication is done using three wires: (1) ground, (2) send line, and (3) receive line. Since serial communication is asynchronous, a port can receive data on one line while receiving data on another line. This method is called full duplex transmission. Other lines are used for handshaking, but they are not required. The most important parameters for serial communication are the baud rate, data bits, stop bits, and parity bits. For two ports that communicate, these parameters must match:

The baud rate is a parameter that measures the speed of communication. It represents the number of bits transmitted per second. For example, 300 baud means that 300 bits are sent per second. When we refer to the clock cycle in the serial port, we mean the baud rate. For example, if the protocol requires 4800 baud, then the clock is 4800 Hz. This means that the serial communication has a sampling rate of 4800 Hz on the data line. Typically, the telephone line has baud rates of 14400, 28800, and 36600. The baud rate can be much larger than these values, but the baud rate is inversely proportional to the distance. High baud rates are often used for communication between instruments that are close together.

The data bits are parameters that measure the actual data bits in the communication. When a computer sends a packet, the actual data may not be 8-bit, and the standard values ​​are 5, 7, and 8. How to set it depends on the information you want to transfer. For example, the standard ASCII code is 0 to 127 (7 bits). The extended ASCII code is 0 to 255 (8 bits). If the data uses simple text (standard ASCII), then each packet uses 7-bit data. Each packet refers to one byte, including start/stop bits, data bits, and parity bits. Since the actual data bits depend on the communication protocol selected, the term "package" refers to the case of any communication.

The stop bit is used to represent the last bit of a single packet. Typical values ​​are 1, 1.5 and 2 bits. Since the data is timed on the transmission line and each device has its own clock, it is likely that there is a small out-of-synchronization between the two devices in the communication. The stop bit therefore not only indicates the end of the transmission, but also provides the opportunity for the computer to correct the clock synchronization. The more bits that apply to the stop bit, the greater the tolerance of different clock synchronizations, but the slower the data transfer rate.

The parity bit is a simple error detection method for serial communication. There are four ways to detect errors: even, odd, high, and low. Of course, there is no check digit. For the case of even and odd parity, the serial port will set the parity bit (one bit after the data bit), and use a value to ensure that the transmitted data has an even or odd logic high. For example, if the data is 011, then for even parity, the parity bit is 0, and the number of bits that guarantee the logic high is an even number. If it is odd parity, the parity bit is 1, so there are 3 logic highs. The high and low bits do not really check the data, simply set the logic high or the logic low check. This allows the receiving device to know the status of a bit and has the opportunity to determine if there is noise that interferes with the communication or whether the transmitted and received data are out of sync.

2. What is RS-232?

RS-232 (ANSI/EIA-232 standard) is a serial connection standard on IBM-PC and its compatible machines. It can be used in a wide range of applications, such as connecting a mouse, printer or modem, as well as industrial instrumentation. For the improvement of driving and wiring, the transmission length or speed of RS-232 in practical applications often exceeds the standard value. RS-232 is limited to point-to-point communication between the PC serial port and the device. The maximum distance for RS-232 serial communication is 50 feet.

data
TXD (Pin 3) Serial Data Output
RXD (Pin 2) Serial Data Input
shake hands
RTS (Pin 7) Send Request
CTS (pin 8) clear send
DSR (Pin 6) Data Transmit Ready
DCD (Pin 1) Data Carrier Detection
DTR (Pin 4) Data Terminal Ready
Ground wire
GND (pin 5) ground
other
RI (pin 9) ringing indication

Table 1: RS-232 pin function

3. What is RS-422?

See Through Display

Kindwin Technology (H.K.) Limited , https://www.ktl-led.com