Among various solutions for medium to long-distance communication between MCUs, RS-485 is widely used in factory automation, industrial control, community monitoring, and water resources automatic reporting due to its simple hardware design, ease of control, and low cost. However, the RS-485 bus still has defects in anti-interference, adaptability, and communication efficiency. Improper handling of some details often leads to communication failures or even system paralysis. Therefore, improving the operational reliability of the RS-485 bus is crucial.
1. Hardware Design of RS-485 Interface Circuit
1. Bus Matching
There are two methods for bus matching: one is to add matching resistors. A differential port located at both ends of the bus
VA and VB should be connected with a 120Ω matching resistor to reduce reflections and absorbed noise caused by mismatching, effectively suppressing noise interference. However, matching resistors consume a significant amount of current, making them unsuitable for systems with strict power consumption limitations. Another more power-efficient matching scheme is RC matching, which uses a capacitor C to block the DC component, saving most of the power, but the value of capacitor C is a challenge, requiring a compromise between power consumption and matching quality. Besides the two methods mentioned above, there is also a matching scheme using diodes. Although this scheme does not achieve true matching, it utilizes the clamping effect of diodes to quickly weaken reflected signals, improving signal quality and achieving significant energy savings.
2. Pull-up Resistors Configuration for RO and DI Ends
Asynchronous communication data is transmitted in bytes, and before each byte transmission, a low-level start bit is used for handshake. To prevent interference signals from erroneously triggering RO (Receiver Output) to produce negative transitions, causing the receiving MCU to enter the receiving state, it is recommended to connect a 10kΩ pull-up resistor externally to RO.
3. Ensure RS-485 Chip is in Receive Input State During Power-Up
For the transceiver control end TC, it is recommended to use MCU pins controlled through an inverter rather than directly controlling MCU pins to prevent interference on the bus during MCU power-up.
4. Bus Isolation
The RS-485 bus is a parallel two-wire interface. If one chip fails, it may “pull down” the entire bus. Therefore, isolation should be added between the two wires VA and VB and the bus. Typically, a 4.7Ω PTC resistor is connected in series between VA and VB and the bus, along with a 5V TVS diode to ground to eliminate surge interference. If there are no PTC resistors and TVS diodes, ordinary resistors and voltage regulators can be used as substitutes.
5. Reasonable Chip Selection
For external devices, to prevent strong electromagnetic (lightning) impacts, it is recommended to select lightning protection chips such as TI’s 75LBC184. For applications requiring a large number of nodes, the SP485R from S工PEX can be selected.
2. RS-485 Network Configuration
1. Number of Network Nodes
The number of network nodes is related to the driving capability of the selected RS-485 chip and the input impedance of the receiver. For example, the nominal maximum for 75LBC184 is 64 points, and for SP485R, it is 400 points. In practical use, due to cable length, wire diameter, network distribution, and transmission rates, the actual number of nodes rarely reaches the theoretical value. For instance, if the 75LBC184 is used in a 500m RS-485 network, if the number of nodes exceeds 50 or the rate exceeds 9.6kb/s, the working reliability significantly decreases. It is generally recommended to select the number of nodes at 70% of the maximum value of the RS-485 chip, and the transmission rate should be chosen between 1200-9600b/s. For communication distances within 1km, considering communication efficiency, node count, and distance, 4800b/s is optimal. For distances over 1km, methods such as adding relay modules or reducing rates should be considered to improve data transmission reliability.
2. Distance Between Nodes and Backbone
Theoretically, the shorter the distance between RS-485 nodes and the backbone (T-head, also known as lead wire), the better. Nodes with T-heads less than 10m can use T-type connections without significant impact on network matching, but for very short node spacing (less than 1m, such as LED module combination screens), star-type connections should be used. If T-type or bead-type connections are used, normal operation cannot be guaranteed. RS-485 is a half-duplex structured communication bus, mostly used in one-to-many communication systems, so the host (PC) should be placed at one end, not in the middle, forming a T-type distribution of the backbone.
3. Improving RS-485 Communication Efficiency
RS-485 is typically used in one-to-many master-slave response communication systems, and its efficiency is much lower than that of full-duplex buses like RS-232. Therefore, selecting appropriate communication protocols and control methods is very important.
1. Bus Steady State Control (Handshake Signal) Most users choose to set the transceiver control end TC to high level for 1ms before sending data, allowing the bus to enter a stable sending state before transmitting data; after the data is sent, TC is set to low level after a delay of 1ms to ensure reliable transmission before switching to receiving state. According to the author’s experience, a delay of 4 machine cycles at the TC end has met the requirements;
2. To ensure data transmission quality, while verifying each byte, the characteristic word and check word should be minimized. The commonly used data packet format consists of a header code, length code, address code, command code, data, checksum, and tail code, with each data packet length reaching 20-30 bytes. In RS-485 systems, such protocols are not very concise. It is recommended that users utilize the MODBUS protocol, which has been widely applied in the international standards of water resources, hydrology, power, and other industry equipment and systems.
4. Power Supply and Grounding of RS-485 Interface Circuit
For measurement and control networks formed by MCU and RS-485 micro-systems, independent power supply schemes for each micro-system should be prioritized. It is best not to use one large power supply to parallel power the micro-systems, and the power lines (AC and DC) should not share the same multi-core cable with the RS-485 signal lines. RS-485 signal lines should use twisted pairs with a cross-sectional area of 0.75mm² or more rather than flat wires. For each small-capacity DC power supply, using a linear power supply LM7805 is more suitable than using a switching power supply. Of course, attention should be paid to the protection of LM7805:
1. A 220μF electrolytic capacitor should be connected between the input end and ground of LM7805;
2. A 1N4007 diode should be connected in reverse between the input and output ends of LM7805;
3. A 470μF electrolytic capacitor and a 104pF ceramic capacitor should be connected between the output end and ground of LM7805, and a 1N4007 diode should be connected in reverse;
4. The optimal input voltage is 8-10V, with a maximum allowable range of 6.5-24V. TI’s P丁5100 can be used as a substitute for LM7805 to achieve an ultra-wide voltage input of 9-38V.
5. Optical Isolation
In certain industrial control fields, due to the complexity of the site conditions, there exists a high common-mode voltage between various nodes. Although the RS-485 interface uses differential transmission mode, which has a certain ability to resist common-mode interference, when the common-mode voltage exceeds the limit reception voltage of the RS-485 receiver, specifically greater than +12V or less than -7V, the receiver can no longer operate normally, and in severe cases, it may even burn out the chip and equipment.
The solution to such problems is to isolate the system power supply and the power supply of the RS-485 transceiver through DC-DC; isolate the signal through optical isolation to completely eliminate the impact of common-mode voltage. The methods to achieve this solution can be divided into:
1. Build the circuit using optical couplers and isolated DC-DC RS-485 chips;
2. Use integrated chips such as PS1480 and MAX1480.
6. Common Faults and Handling Methods in RS-485 Systems
RS-485 is a low-cost, easy-to-operate communication system, but it has weak stability and strong interdependence. Usually, a fault in one node can lead to overall or partial paralysis of the system, and it is difficult to diagnose. Therefore, the author introduces some common methods for maintaining RS-485.
1. If the system is completely paralyzed, it is mostly due to the breakdown of the VA and VB of a certain node chip to the power supply. Using a multimeter, the differential voltage between VA and VB is zero, while the common-mode voltage to ground is greater than 3V. At this point, the common-mode voltage can be measured to troubleshoot; the larger the common-mode voltage, the closer it is to the fault point, and vice versa;
2. If several nodes on the bus cannot work normally, it is generally caused by a fault in one of the nodes. A fault in one node will cause 2-3 adjacent nodes (usually subsequent ones) to be unable to communicate. Therefore, disconnect each node from the bus one by one; if the bus can return to normal after disconnecting a certain node, it indicates that the node has a fault;
3. In centrally powered RS-485 systems, some nodes often do not operate normally during power-up, but it is not always the same each time. This is due to unreasonable design of the RS-485 transceiver control end TC, causing the node’s receiving and transmitting states to be chaotic upon power-up, thus leading to bus congestion. The improvement method is to add power switches to each micro-system and power them separately;
4. The system is generally normal but occasionally experiences communication failures. This is generally caused by unreasonable network construction, leading to the system’s reliability being in a critical state. It is best to change the wiring or add relay modules. One emergency method is to replace the failing node with a higher-performing chip;
5. If the TC end is in a long transmission state due to MCU failure, it may pull down the entire bus. Readers are reminded not to forget to check the TC end. Although RS-485 specifies that a differential voltage greater than 200mV can operate normally, actual measurements show that a well-functioning system typically has a differential voltage around 1.2V (due to network distribution and rate differences, the differential voltage may range from 0.8-1.5V).
Clickto read the original article for free and learn about electrical engineering, PLC, frequency servo, CNC robots, and more.