Serial communication is the most basic communication method faced by electronic engineers, with RS-232 being the simplest form. However, many beginners often struggle to understand the relationship and differences between UART, RS-232, RS-422, and RS-485. This article will discuss these concepts to help clarify their relationships.
Communication issues, like traffic problems, also have various scenarios such as high speed, low speed, congestion, and interruption. If we compare serial communication to traffic, UART can be likened to a train station, while a frame of data is akin to a car. Cars on the road must adhere to traffic rules. In urban areas, the speed limit is generally 30 or 40, while on highways it can reach 120. The type of road and speed limit depend on how the protocol is defined. Common serial protocols include RS-232, RS-422, and RS-485. What are the subtle differences between them? Let’s explore this together.
If a suitable level converter such as SP3232E or SP3485 is added, UART can also be used for RS-232 or RS-485 communication, or connect to a computer’s port. UART is widely used in applications such as mobile phones, industrial control, and PCs.
UART uses asynchronous serial communication.
Serial communication refers to the sequential transmission of data one bit at a time over a single transmission line. Its characteristics include a simple communication line, allowing communication with simple cabling, reducing costs, and making it suitable for long-distance communication, although it has slow transmission speeds.
Asynchronous communication uses a character as the unit of transmission, and the time interval between two characters is variable, while the time interval between adjacent bits within the same character is fixed.
The data transmission rate is expressed in baud rate, which indicates the number of binary bits transmitted per second. For example, if the data transmission rate is 120 characters per second and each character is 10 bits (1 start bit, 7 data bits, 1 parity bit, and 1 stop bit), the baud rate would be 10×120=1200 characters per second=1200 baud.
The data communication format is as follows:
The meanings of each bit are as follows:
Start bit: sends out a logical “0” signal to indicate the beginning of the transmission character. Data bits: can be 5-8 bits of logical “0” or “1”. For example, ASCII code (7 bits), extended BCD code (8 bits). Parity bit: after adding this bit to the data bits, the number of “1” bits should be even (even parity) or odd (odd parity). Stop bit: it is a flag indicating the end of a character data, which can be 1, 1.5, or 2 bits of high level. Idle bit: in a logical “1” state, indicating that there is currently no data transmission on the line.
Note: Asynchronous communication is transmitted by character, and the receiving device can correctly receive data as long as it maintains synchronization with the sending device during the transmission time of one character after receiving the start signal. The arrival of the next character’s start bit recalibrates the synchronization (achieved by detecting the start bit for self-synchronization between the sender and receiver).
This standard specifies the use of a 25-pin DB-25 connector, defining the signal content of each pin and the voltage levels for various signals. Later, IBM simplified RS-232 to a DB-9 connector for their PC, which has become the de facto standard today. The RS-232 port in industrial control typically only uses three lines: RXD (2), TXD (3), and GND (5).
In the early days, since PCs came with RS-232 interfaces, RS-232 was the choice for UART usage. However, nowadays, personal computers, including laptops and desktops, no longer have RS-232 interfaces, and you will notice that there is no DB9 connector on the motherboard. Therefore, development boards now typically choose TTL UART or directly implement UART to USB on the development boards.
In embedded systems, the term “serial port” usually refers to the UART port, but we often confuse it with the COM port, as well as the relationships between RS-232, TTL, etc. In fact, UART and COM refer to the physical interface form (hardware), while TTL and RS-232 refer to the voltage standards (electrical signals).
UART has 4 pins (VCC, GND, RX, TX) and uses TTL levels, where low level is 0 (0V) and high level is 1 (3.3V or higher).
Under normal circumstances, the positive voltage level between the sending driver A and B is +2 to +6V, representing one logic state, while the negative voltage level is -2 to 6V, representing another logic state. Additionally, there is a signal ground C; in RS-485 there is also an “enable” terminal, which is optional in RS-422.
The electrical performance of RS-422 is identical to that of RS-485. The main difference is that RS-422 has 4 signal lines: two for transmission and two for reception. Since RS-422 separates the receiving and transmitting signals, it can receive and transmit simultaneously (full duplex). This full duplex requirement necessitates separate channels for receiving and transmitting, making RS-422 suitable for communication between two stations in star or ring networks, but not for bus networks; RS-485 only has 2 signal lines, thus it can only operate in half-duplex mode, commonly used in bus networks.
The electrical characteristics of RS-485 are as follows: Logic “1” is represented by a voltage difference of +(2-6)V between the two wires; logic “0” is represented by a voltage difference of -(2-6)V. The signal voltage levels of RS-485 are lower than those of RS-232-C, making it less likely to damage the interface circuit chips, and these levels are compatible with TTL levels, facilitating connections with TTL circuits.
The maximum data transmission rate of RS-485 is 10Mbps.
RS-485 interfaces use a combination of balanced drivers and differential receivers, enhancing the ability to resist common-mode interference and providing good noise immunity.
The maximum communication distance for RS-485 is approximately 1219M, with a maximum transmission rate of 10Mb/S. The transmission rate is inversely proportional to the transmission distance; at a transmission rate of 100Kb/S, the maximum communication distance can be achieved, and for longer distances, RS-485 repeaters are required. The RS-485 bus generally supports a maximum of 32 nodes; if special RS-485 chips are used, it can reach up to 128 or 256 nodes, with a maximum of 400 nodes supported.
1. RS-423 Unbalanced Serial Communication Interface.
Structure, signal levels, transmission distance, transmission rate, interface chips.
2. RS-422 Balanced Serial Communication Interface.
Structure, signal levels, interface chips, MC3486, MC3487, SN75154, SN75155.
Transmission rate, transmission distance.
3. RS-485 Serial Communication Bus.
Structure, signal levels, interface chip MAX485.
Transmission rate, transmission distance, application examples.
Due to the early appearance of the RS-232 interface standard, it inevitably has some shortcomings, mainly as follows:
(1) The signal voltage levels of the interface are relatively high, which can easily damage the interface circuit chips. Additionally, since the 232 levels are not compatible with TTL levels, level conversion circuits are needed to connect with TTL circuits.
(2) The transmission rate is relatively low; during asynchronous transmission, the baud rate is 20Kbps. Nowadays, due to the use of new UART chips, baud rates can reach 115.2Kbps (1.832M/16).
(3) The interface uses one signal line and one signal return line to form a common ground transmission method, which is prone to common-mode interference, resulting in weak noise immunity.
(4) The transmission distance is limited, with a maximum standard transmission distance of 50 meters, but in practice, it can only be used for about 15 meters.
(5) RS-232 only allows one-to-one communication and does not consider forming a serial bus. (This point is crucial; in many control scenarios, multiple controls are needed. If the master device needs to communicate point-to-point with each slave device, the wiring on-site becomes a spider web.)
RS-422 (EIA RS-422-A Standard) is the serial connection standard for Apple’s Macintosh computers. RS-422 uses differential signals, while RS-232 uses unbalanced reference ground signals. Differential transmission uses two wires to send and receive signals, allowing RS-422 to better resist noise and achieve longer transmission distances. In industrial environments, better noise immunity and longer transmission distances are significant advantages.
2. Transmission Distance: The maximum transmission distance for RS-485 is a standard value of 1200 meters (at 9600bps), and practically can reach up to 3000 meters. RS-232 has a limited transmission distance, with a maximum standard transmission distance of 50 meters, practically only usable around 15 meters.
3. Communication Capability: The RS-485 interface allows for connection of up to 128 transceivers on the bus, enabling users to easily establish a device network using a single RS-485 interface. RS-232 only allows point-to-point communication.
4. Transmission Rate: RS-232 has a lower transmission rate, with a baud rate of 20Kbps during asynchronous transmission. The maximum data transmission rate for RS-485 is 10Mbps.
5. Signal Lines: An RS-485 interface typically requires only two signal lines to form a half-duplex network. The RS-232 interface generally uses three lines: RXD, TXD, and GND.
6. Electrical Voltage Levels: In RS-485, logic “1” is represented by a voltage difference of + (2-6)V between the two wires; logic “0” is represented by a voltage difference of – (2-6)V. In RS-232-C, any signal line’s voltage is in a negative logic relationship, meaning: logic “1” is -5 to -15V; logic “0” is +5 to +15V.
1. RS-422 has 4 signal lines: two for transmission (Y, Z) and two for reception (A, B). Since RS-422 separates receiving and transmitting, it can receive and transmit simultaneously (full duplex).
2. RS-485 only has two data lines: A and B are used for both sending and receiving. Since RS-485 shares these two lines for both sending and receiving, it cannot do so simultaneously (half duplex).
The RS-485 standard employs balanced transmission and differential reception for data transceivers to drive the bus, with specific specifications:
The receiver’s input resistance RIN≥12kΩ
The driver can output a common-mode voltage of ±7V
The input capacitance ≤50pF
In the case of 32 nodes with 120Ω termination resistance, the driver must still be able to output a voltage of at least 1.5V (the size of the termination resistance is related to the parameters of the twisted pair used).
The input sensitivity of the receiver is 200mV (i.e., (V+) – (V-) ≥ 0.2V represents signal “0”; (V+) – (V-) ≤ -0.2V represents signal “1”).
Because of the long-distance, multi-node (32 nodes), and low transmission line costs, EIA RS-485 has become the preferred standard for data transmission in industrial applications.
(1) RS-485’s electrical characteristics: The sending end represents logic “0” with a voltage difference of + (2~6)V between the two wires; logic “1” is represented by a voltage difference of – (2~6)V. The receiving end: A being higher than B by more than 200mV is considered logic “0”; A being lower than B by more than 200mV is considered logic “1”.
(2) The maximum data transmission rate for RS-485 is 10Mbps. However, since RS-485 often needs to communicate with the RS-232 port of a PC, the practical maximum is generally 115.2Kbps. Additionally, higher rates can reduce the transmission distance for RS-485, so it is often set around or below 9600bps.
(3) The RS-485 interface uses a combination of balanced drivers and differential receivers, offering good noise immunity.
(4) The maximum transmission distance for RS-485 is a standard value of 1200 meters (at 9600bps), practically can reach up to 3000 meters. The RS-485 interface allows for connection of up to 128 transceivers on the bus, meaning RS-485 has multi-device communication capabilities, allowing users to easily establish a network using a single RS-485 interface. Since RS-485 forms a half-duplex network with just two signal lines, it typically uses twisted pair wiring. The international standard for RS-485 does not specify a connector standard, so terminal blocks or DB-9, DB-25 connectors can be used.
When using the RS-485 interface, the maximum permissible cable length for data signal transmission from the generator to the load depends on the specific cable gauge. This length is primarily limited by signal distortion and noise. The relationship between maximum cable length and signal rate is derived using 24AWG copper twisted pair telephone cable (0.51mm in diameter), with inter-wire bypass capacitance of 52.5PF/M and terminal load resistance of 100 ohms (as referenced in GB11014-89 Appendix A). When the data signal rate drops below 90Kbit/S, assuming a maximum allowable signal loss of 6dBV, the cable length is limited to 1200m. In practice, it is possible to achieve greater cable lengths. Different cable gauges yield different maximum cable lengths. For example, at a data signal rate of 600Kbit/S, using 24AWG cable, the maximum cable length is 200m; using 19AWG cable (0.91mm diameter) allows for lengths greater than 200m; while using 28AWG cable (0.32mm diameter) restricts length to less than 200m.
For long-distance communication using RS-485, it is recommended to use shielded cables and connect the shield to ground.
Impedance discontinuity occurs when the signal encounters a cable with significantly lower impedance at the end, causing reflection. This principle is similar to light reflecting when it moves from one medium to another. To eliminate such reflections, a termination resistor matching the cable’s characteristic impedance must be bridged at the end of the cable, ensuring impedance continuity. Since signals travel bidirectionally on the cable, a similarly sized termination resistor should also be bridged at the other end of the communication cable.
Theoretically, as long as a termination resistor matching the cable’s characteristic impedance is bridged at the end of the transmission cable, signal reflection should not occur. However, in practical applications, due to variations in the transmission cable’s characteristic impedance and the communication baud rate, perfect matching with the termination resistor is not always possible, leading to some degree of signal reflection.
Another cause of signal reflection is impedance mismatch between the data transceiver and the transmission cable. This type of reflection is primarily observed when the communication line is idle, causing data chaos across the network.
Signal reflection affects data transmission because it triggers the comparator at the receiver’s input, causing it to receive incorrect signals, leading to CRC errors or entire data frame errors.
In signal analysis, the parameter used to measure the strength of reflected signals is the RAF (Reflection Attenuation Factor). Its calculation formula is as follows:
RAF=20lg(Vref/Vinc) (1)
Where: Vref—voltage magnitude of the reflected signal; Vinc—voltage magnitude of the incident signal at the connection point between the cable and the transceiver or termination resistor.
The specific measurement method is shown in the diagram. For example, if the peak-to-peak value of a 2.5MHz incident signal sine wave is +5V and the reflected signal’s peak-to-peak value is +0.297V, then the reflection attenuation factor for this communication cable at 2.5MHz is:
RAF=20lg(0.297/2.5)=-24.52dB
To mitigate the impact of reflected signals on communication lines, noise suppression and bias resistors are typically employed. In practical applications, for relatively small reflected signals, the bias resistor method is often used for simplicity and convenience. This method improves communication reliability by adding bias resistors to the communication line.
2. Signal Attenuation in Communication Cables
The second factor affecting signal transmission is the attenuation of the signal during transmission through the cable. A transmission cable can be viewed as an equivalent circuit composed of distributed capacitance, distributed inductance, and resistance, as shown in the diagram.
The cable’s distributed capacitance C is primarily generated by the two parallel conductors of the twisted pair. The resistance of the conductors has minimal impact on the signal and can be ignored. Signal loss mainly arises from the LC low-pass filter formed by the cable’s distributed capacitance and inductance. The attenuation coefficients of the LAN standard two-core cables used in PROFIBUS (the standard cable selected for the DP bus by Siemens) at different baud rates are shown in Table 1.
The cable’s attenuation coefficient
3. Pure Resistive Load in Communication Cables
The third factor affecting communication performance is the size of the pure resistive load (also known as DC load). This refers to the combination of termination resistors, bias resistors, and RS-485 transceivers.
When discussing the EIA RS-485 specification, it was mentioned that the RS-485 driver can output at least 1.5V of differential voltage when configured with 32 nodes and 150Ω termination resistors. The input resistance of a receiver is 12kΩ, and the equivalent circuit of the entire network is shown in the diagram. Based on this, the load capacity of the RS-485 driver can be calculated as:
RL=32 input resistors in parallel with 2 termination resistors=(((12000/32)×(150/2))/((12000/32)+(150/2)))≈51.7Ω
Currently, commonly used RS-485 drivers include MAX485, DS3695, MAX1488/1489, and SN75176A/D used by Holley. Some of these RS-485 drivers can achieve a load capacity of up to 20Ω. Without considering many other factors, the maximum number of nodes a driver can support will far exceed 32.
When communication baud rates are relatively high, bias resistors are essential on the lines. The connection method for bias resistors is shown in the diagram. Their purpose is to pull the level away from 0V when there is no data on the bus (idle state), as shown in the diagram. This way, even if small reflected signals or interference occur in the line, the data receiver connected to the bus will not malfunction due to these signals.
Through the following example, the size of the bias resistor can be calculated:
Termination resistors Rt1=Rr2=120Ω;
Assuming the maximum peak-to-peak value of the reflected signal Vref≤0.3Vp-p, then the negative half-cycle voltage Vref≤0.15V; the reflected current Iref caused by the reflected signal on the termination resistors ≤0.15/(120||120)=2.5mA. The typical hysteresis voltage value for RS-485 transceivers (including SN75176) is 50mV, thus:
(Ibias-Iref)×(Rt1||Rt2)≥50mV
Therefore, it can be calculated that the bias current produced by the bias resistor must be ≥3.33mA
+5V=Ibias(Rup+Rdown+(Rt1||Rt2)) (2)
Using equation (2), it can be calculated that Rup=Rdown=720Ω
In practical applications, there are two methods for adding bias resistors to the RS-485 bus:
(1) Distributing bias resistors evenly to each transceiver on the bus. This method adds bias resistors to each transceiver connected to the RS-485 bus, providing a bias voltage to each transceiver.
(2) Using a pair of bias resistors on a segment of the bus. This method is particularly effective for large reflected signals or interference signals on the bus. It is important to note that adding bias resistors increases the load on the bus.
Vend=0.8(Vdriver-Vloss-Vnoise-Vbias)(3)
Where: Vend is the signal voltage at the end of the bus, which is defined as 0.2V during standard measurement; Vdriver is the output voltage of the driver (which depends on the number of loads. For 5 to 35 loads, Vdriver=2.4V; for fewer than 5 loads, Vdriver=2.5V; for more than 35 loads, Vdriver≤2.3V); Vloss is the signal loss during transmission along the bus (which depends on the specifications and length of the communication cable), calculated using the formula for attenuation coefficient b=20lg(Vout/Vin); Vloss can be calculated as Vin-Vout=0.6V (note: the communication baud rate is 9.6kbps, and the cable length is 1km; if the baud rate increases, Vloss will increase correspondingly); Vnoise is the noise margin, defined as 0.1V during standard measurement; and Vbias is the bias voltage provided by the bias resistors (typical value is 0.4V).
In equation (3), multiplying by 0.8 ensures that the communication cable does not enter a fully loaded state. From equation (3), it can be observed that the size of Vdriver is inversely proportional to the number of loads on the bus, while the size of Vloss is inversely proportional to the length of the bus; the other parameters depend solely on the type of driver used. Therefore, once the driver for the RS-485 bus is selected, the number of loads that can be supported is directly related to the maximum distance the signal can be transmitted, under a constant communication baud rate. The specific relationship is: within the permissible range of the bus, the more loads, the shorter the distance the signal can be transmitted; with fewer loads, the farther the signal can be transmitted.
The distributed effects on the bus can lead to data transmission errors, thereby degrading the overall network performance. To resolve this issue, two approaches can be taken:
(1) Reducing the baud rate of data transmission;
(2) Using cables with lower distributed capacitance to enhance the quality of the transmission line.
Simply connecting the A and B ends of each interface with a pair of twisted wires without grounding the RS-485 communication link’s signals can work under certain circumstances, but it poses risks to the system. The RS-485 interface transmits signals differentially and does not require a reference point to detect signals; it only needs to detect the potential difference between the two wires. However, it should be noted that the transceiver will only function correctly if the common-mode voltage does not exceed a certain range (-7V to +12V). When the common-mode voltage exceeds this range, it can affect communication reliability or even damage the interface. As shown in the diagram, when transmitter A sends data to receiver B, the common-mode voltage output by transmitter A is VOS. If the two systems have their respective independent grounding systems, a ground potential difference VGPD may occur, resulting in the common-mode voltage at the receiver’s input reaching VCM=VOS+VGPD. The RS-485 standard specifies that VOS≤3V, but VGPD can vary significantly (dozens of volts), possibly accompanied by strong interference signals, causing the receiver’s common-mode input VCM to exceed normal limits, generating interference current on the signal lines, disrupting normal communication or damaging devices.
Source: Network, copyright belongs to the original author.