
Automation Software:Download Link
Data Express:Member Access
Siemens TIA Portal Usage and Application Tutorial!
Complete Tutorial for Siemens S7-1500 Project Design and Practice!
Free Download of Siemens Communication Principles and Methods Mastery Tutorial!
Download of Over 600 Common Electrical Circuit Diagrams!
Free Download of Popular PLC Programming Series!
Among the various solutions for medium to long-distance communication between MCUs, RS-485 is widely used in factory automation, industrial control, community monitoring, and hydraulic automatic reporting due to its simple hardware design, convenient control, and low cost.
However, the RS-485 bus still has shortcomings in anti-interference, adaptability, and communication efficiency. Improper handling of certain details can often lead to communication failures or even system crashes, making it crucial to improve the operational reliability of the RS-485 bus.
1. Hardware Design of RS-485 Interface Circuit
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 absorb noise caused by mismatches, effectively suppressing noise interference.However, matching resistors consume significant current and are not suitable for systems with strict power consumption limits.
The other more power-saving matching scheme is RC matching, which uses a capacitor C to block the DC component, saving most power, but selecting the value of capacitor C is challenging and requires a trade-off between power consumption and matching quality. Besides these two methods, there is also a diode-based matching scheme, which, while not achieving true matching, uses the clamping effect of diodes to quickly weaken reflected signals to improve signal quality, achieving significant energy savings.
2. Pull-up Resistor Configuration for RO and DI Pins
Asynchronous communication data is transmitted in bytes, and before transmitting each byte, a low-level start bit is used to achieve handshake. To prevent interference signals from erroneously triggering a negative transition on RO (Receiver Output), causing the receiving MCU to enter receive mode, it is recommended to connect a 10kΩ pull-up resistor externally to RO.
3. Ensure RS-485 Chip is in Receive Mode on Power-Up
For the transceiver control pin TC, it is recommended to use an MCU pin controlled through an inverter rather than directly controlling the MCU pin to avoid interference on the bus during MCU power-up.
The RS-485 bus is a two-wire interface in parallel; if one chip fails, it may cause the bus to be “pulled down.” Therefore, isolation should be added between the two wires VA and VB and the bus. Typically, a 4-10Ω PTC resistor is connected in series between VA, VB, and the bus, along with a 5V TVS diode to eliminate surge interference. If PTC resistors and TVS diodes are not available, ordinary resistors and voltage regulators can be used as substitutes.
5. Reasonable Chip Selection
For external devices, to prevent strong electromagnetic (lightning) shocks, it is recommended to choose TI’s 75LBC184 and other lightning protection chips, while for a larger number of nodes, SIPEX’s SP485R 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 the 75LBC184 is 64 points, while the SP485R’s nominal maximum is 400 points. In actual use, due to varying cable lengths, wire diameters, network distribution, and transmission rates, the actual number of nodes may not reach theoretical values. For example, if the 75LBC184 is used in an RS-485 network distributed over 500m, 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, with transmission rates 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 Trunk
Theoretically, the shorter the distance between RS-485 nodes and the trunk (T-head, also known as branch 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 connections should be used. If T-type or string connections are used, they will not work properly. RS-485 is a half-duplex structured communication bus, mostly used for one-to-many communication systems, so the host (PC) should be placed at one end, not in the middle, forming a T-type distribution for the trunk.
3. Improving RS-485 Communication Efficiency
RS-485 is typically used in a master-slave response communication system with one-to-many points, and its efficiency is significantly 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 pin TC to high for 1ms before sending data, allowing the bus to enter a stable sending state before data transmission; after data transmission is complete, TC is set to low after a 1ms delay to ensure reliable sending before switching to receive mode. Using TC’s delay of 4 machine cycles meets the requirements.
2. To ensure data transmission quality, while checking each byte, it is advisable to minimize the characteristic words and checksum words. The commonly used data packet format consists of a header code, length code, address code, command code, data, checksum code, and tail code, with each packet length reaching 20-30 bytes. Such protocols are not very concise in RS-485 systems. It is recommended that users adopt the MODBUS protocol, which has been widely applied in international standards for equipment and systems in industries such as hydraulics, hydrology, and electricity.
4. Power Supply and Grounding of RS-485 Interface Circuit
For a measurement and control network formed by MCU combined with RS-485 microsystems, independent power supply schemes for each microsystem should be prioritized. It is best not to use a single large power supply to power multiple microsystems in parallel, and the power lines (AC and DC) should not share the same multi-core cable with RS-485 signal lines. RS-485 signal lines should use twisted pairs with a cross-sectional area of 0.75 square millimeters or more, rather than flat lines. A linear power supply LM7805 is more suitable for each small capacity DC power supply than a switching power supply.
Of course, attention should be paid to the protection of LM7805:
1. A 220-1000 uF electrolytic capacitor should be connected between the input of LM7805 and ground;
2. A 1N4007 diode should be connected in reverse between the input and output of LM7805;
3. A 470-1000 uF electrolytic capacitor and a 104pF ceramic capacitor should be connected between the output of LM7805 and ground, along with a 1N4007 diode in reverse;
4. The input voltage is best at 8-10V, with a maximum allowable range of 6.5-24V. TI’s PT5100 can be used to replace LM7805 to achieve ultra-wide voltage input of 9-38V.
In some industrial control fields, due to the complexity of the site, there is a high common-mode voltage between nodes. Although the RS-485 interface uses differential transmission, which has certain resistance to common-mode interference, when the common-mode voltage exceeds the limit receiving voltage of the RS-485 receiver, i.e., greater than +12V or less than -7V, the receiver can no longer function properly, 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 RS-485 transceiver power supply through DC-DC; use optical isolators to completely eliminate the influence of common-mode voltage. The ways to implement this solution can be divided into:
1. Constructing a circuit with optocouplers, isolated DC-DC, and RS-485 chips;
2. Using secondary integrated chips, such as PS1480, MAX1480, etc.
6. Common Faults and Handling Methods of RS-485 Systems
RS-485 is a low-cost, easy-to-operate communication system, but its stability is weak, and mutual constraints are strong. Usually, a fault in one node can cause the entire system or part of it to crash, making it difficult to diagnose. Therefore, we introduce some common methods for maintaining RS-485.
1. If the system is completely down, it is often due to breakdown of the VA and VB of a certain node chip against the power supply, using a multimeter to measure the differential mode voltage between VA and VB as zero, while the common-mode voltage to ground is greater than 3V. At this point, the common-mode voltage can be measured to troubleshoot, with larger common-mode voltages indicating proximity to the fault point, and vice versa;
2. If several nodes on the bus cannot function properly, it is generally caused by a fault in one of the nodes. A fault in one node can cause 2-3 neighboring nodes (usually subsequent ones) to lose communication. Therefore, disconnect each node from the bus one by one; if the bus returns to normal after disconnecting a certain node, it indicates that node has failed;
3. In a centrally powered RS-485 system, some nodes often do not function properly at power-up, but the issues are not consistent each time. This is due to unreasonable design of the transceiver control pin TC for RS-485, causing the node’s send/receive state to be chaotic upon power-up, leading to bus blockage. The improvement method is to install power switches for each microsystem and power them up separately;
4. If the system is generally normal but occasionally experiences communication failures, it is usually caused by unreasonable network construction leading to the system’s reliability being at 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 better-performing chip.
5. If MCU failure causes the TC pin to remain in a long send state, pulling the bus down, readers are reminded not to forget to check the TC pin. Although RS-485 specifies that a differential mode voltage greater than 200mV can operate normally, actual measurements show that a well-functioning system generally has a differential mode voltage around 1.2V (due to network distribution and rate differences, the differential mode voltage may range from 0.8-1.5V).