Reliability measures for RS-485 bus communication systems
2026-04-06 08:00:38··#1
Introduction One of the most commonly used networks in industrial control and measurement is the industrial control equipment network composed of an RS-485 communication interface at the physical layer. This communication interface can easily connect many devices into a control network. From the analysis of various solutions for medium-to-long-distance communication between microcontrollers, the RS-485 bus communication mode is widely used in instrumentation, intelligent sensor distributed control, building control, monitoring and alarm fields due to its simple structure, low cost, and suitable communication distance and data transmission rate. However, the RS485 bus has drawbacks such as weak self-adaptive and self-protection functions. If some details are not carefully handled, communication failures or even system paralysis often occur. Therefore, improving the operational reliability of the RS-485 bus is crucial. Issues to Consider in Hardware Circuit Design Basic Circuit Principle: The hardware circuit design of a certain node is shown in Figure 1. In this circuit, an RS-485 interface chip SN75LBC184 is used. It uses a single power supply Vcc and can operate normally within the voltage range of +3 to +5.5 V. Compared to ordinary RS-485 chips, it not only resists lightning strikes but also withstands electrostatic discharge surges up to 8 kV. It integrates four transient overvoltage protection transistors, capable of withstanding transient pulse voltages up to 400 V. Therefore, it significantly improves the reliability of preventing lightning damage. In harsh environments, it can be directly connected to the transmission line without any external protection components. The chip also features a unique design: when the input is open-circuited, its output is high-level, ensuring that an open-circuit fault in the receiver input cable does not affect the normal operation of the system. Furthermore, its input impedance is twice that of the standard RS485 input impedance (≥24 kΩ), allowing up to 64 transceivers to be connected on the bus. The chip incorporates a slope-limiting drive to prevent excessively steep output signal edges, thus minimizing high-frequency components on the transmission line and effectively suppressing electromagnetic interference. In Figure 1, the four-in-one optocoupler TLP521 completely eliminates electrical connection between the microcontroller and the SN75LBC184, improving operational reliability. The basic principle is as follows: When P1.6 of the microcontroller is 0, the LED of the optocoupler emits light, the phototransistor conducts, and outputs a high voltage (+5V), selecting the DE terminal of the RS485 interface chip, allowing transmission. When P1.6 of the microcontroller is 1, the LED of the optocoupler does not emit light, the phototransistor does not conduct, and outputs a low voltage (0V), selecting the RE terminal of the RS485 interface chip, allowing reception. The principle of the R terminal (receiver) and D terminal (transmitter) of the SN75LBC184 is similar to the above. Figure 1 shows the schematic diagram of the RS-485 communication interface and the design of the DE control terminal of RS-485 . In a half-duplex communication system built on an RS-485 bus, only one node in the entire network can be in the transmitting state at any given time and send data to the bus; all other nodes must be in the receiving state. If two or more nodes send data to the bus simultaneously, all data transmissions will fail. Therefore, in the hardware design of each node in the system, the primary goal should be to avoid bus data conflicts caused by abnormal conditions leading to data transmission from the node to the bus. Taking the MCS51 series microcontroller as an example, since its I/O ports output a high level during system reset, if the I/O port is directly connected to the enable pin (DE) of the RS-485 interface chip driver, DE will be high during CPU reset, putting the node in a transmitting state. If other nodes on the bus are transmitting data at this time, the data transmission will be interrupted and fail, or even cause the entire bus to be blocked due to the failure of a node, thus affecting the normal operation of the entire system. Considering the stability and reliability of communication, in the design of each node, the transmit pin of the RS485 bus interface chip should be designed with the reverse logic of the DE pin, that is, when the control pin is logic "1", the DE pin is "0"; when the control pin is logic "0", the DE pin is "1". In Figure 1, the CPU's pin P1.6 is driven by an optocoupler to drive the DE terminal. This ensures that the SN75LBC184 is always in receive mode when the control pin is high or during an abnormal reset, effectively preventing the impact of node malfunctions on the entire system. This lays the foundation for reliable communication throughout the system. Furthermore, the circuit includes a MAX813L watchdog timer, which automatically resets the program and relinquishes RS-485 bus control when a node experiences an infinite loop or other fault. This ensures that the entire system will not be paralyzed due to a single node's failure monopolizing the bus. Design to Avoid Bus Conflicts When a node needs to use the bus, to ensure reliable bus communication, it listens for data before transmitting. In the hardware interface, the data receive pin of the RS-485 interface chip is inverted and connected to the CPU's interrupt pin INT0. In Figure 1, INT0 is connected to the output of the optocoupler. When data is being transmitted on the bus, the data receiver (R terminal) of the SN75LBC184 displays a changing high or low level. Using the CPU falling edge interrupt generated by this level (or polling), it can be determined whether the bus is "busy," i.e., whether any node is communicating on the bus. If it is "idle," then access to the bus is granted, thus effectively resolving bus conflicts. Furthermore, various message priorities can be defined, allowing high-priority messages to be sent first, further improving system real-time performance. With this operating mode, there is no longer a master/slave node distinction; all nodes have equal access to the bus, effectively avoiding situations where individual nodes have excessive communication loads. Bus utilization and system communication efficiency are greatly improved, thus enhancing system real-time response. Even if individual nodes fail, it will not affect the normal communication and operation of other nodes. This disperses the system's "risks," enhancing its reliability and stability to some extent. Design of RS-485 Output Circuit In Figure 1, VD1 to VD4 are signal limiting diodes. Their voltage regulation values should meet the RS-485 standard. VD1 and VD3 are 12V, and VD2 and VD4 are 7V to ensure that the signal amplitude is limited to -7V to +12V, further improving overvoltage resistance. Considering special circumstances of the line (such as a short circuit in the RS-485 chip at a certain node), to prevent the communication of other extensions on the bus from being affected, two 20Ω resistors R1 and R2 are connected in series at the signal output terminal of the SN75LBC184. This way, a hardware failure of this unit will not affect the communication of the entire bus. In the field construction of the application system engineering, since the communication carrier is twisted pair, its characteristic impedance is about 120Ω. Therefore, in the line design, a 120Ω matching resistor (R3 in Figure 1) should be connected at the beginning and end of the RS485 network transmission line to reduce signal reflection on the line. System Power Supply Selection For a measurement and control network built using a microcontroller and RS-485, a scheme where each node has its own independent power supply should be preferred. The power supply line should not share the same multi-core cable as the RS-485 signal line. The RS-485 signal line should preferably be a twisted-pair cable with a cross-sectional area of 0.75 mm² or higher, rather than a straight cable. A linear power supply (TL750L05) is more suitable than a switching power supply. The TL750L05 must have an output capacitor. Without an output capacitor, the output voltage will be a sawtooth wave, with the rising edge varying with the input voltage. Adding an output capacitor can suppress this phenomenon. Software programming of the SN75LBC184: In receive mode, A and B are inputs, and R is the output; in transmit mode, D is the input, and A and B are outputs. When the transmission direction changes once, if the input remains unchanged, the output will be in a random state until the input state changes once, at which point the output state will be determined. Obviously, after switching from transmit to receive mode, if R is low before the A and B states change, and R is still low when sending the first data start bit, the CPU will assume there is no start bit and will only start receiving the first data when the first falling edge appears, leading to a reception error. Similarly, after switching from receive to transmit mode, if there is a low voltage between A and B before D changes, and the voltage is still low when sending the first data start bit, the A and B pins will have no start bit, also resulting in a transmission error. The solution to overcome this is for the host to continuously send two synchronization words, each containing multiple edge changes (e.g., 55H, 0AAH), and send them twice (the first one might be received incorrectly and ignored). Once the receiver receives the synchronization word, it can transmit data, thus ensuring correct communication. For more reliable operation, an appropriate delay is needed during RS-485 bus state switching before data transmission and reception. The specific approach is to first set the control terminal to "1" in the data transmission state, delay for about 0.5 ms, then send valid data. After the data transmission is completed, delay again for 0.5 ms, and then set the control terminal to "0". This process ensures a stable working process for the bus during state switching. The basic flowchart of the data communication program is shown in Figure 2. The microcontroller communication node program can be basically divided into six main parts: the predefined part, the initialization part, the main program part, the device status detection part, the frame receiving part, and the frame sending part. The predefined part mainly defines the handshake signals used in communication, the buffer for storing device information, and the variable for storing the device number of this node. The device status detection part should be able to react appropriately when a hardware failure occurs after program initialization. The main program part should be able to receive command frames and respond accordingly based on the content of the commands. To save space, only the code for the main program part is given here. As shown below: /* Main program flow */ while (1) { // Main loop if (recv_cmd(&type) == 0) // Frame error occurs or frame address does not match local address, discard the current frame and return continue; switch (type) { case __ACTIVE_: // Master queries slave for existence send_data(__OK_, 0,dbuf); // Send response information break; case __GETDATA_: len = strlen(dbuf); send_data(__STATUS_, len,dbuf); // Send status information break; default: break; // Command type error, discard the current frame and return } } Conclusion RS-485 uses differential level transmission signal, and the transmission distance is longer than RS-232, up to 3000 m, so it is very suitable for industrial applications. However, compared to more advanced fieldbuses like CAN, its error handling capabilities are slightly inferior. Therefore, special design is required in the software to avoid data errors. Furthermore, the system has a relatively large data redundancy, making the RS-485 bus unsuitable for applications with high speed requirements. Although the RS-485 bus has some drawbacks, its simple wiring design, low cost, and convenient control mean it can still play a good role in certain engineering applications if the details are handled properly. In short, the key to ensuring reliability lies in comprehensively considering all possible measures before construction begins. This is the only way to fundamentally solve problems, rather than trying to fix them after the fact.