
How to Design a Modular Host Computer?
Why is there such a big difference in the situation of engineers at home and abroad?
Easy Learning of TIA Portal SCL Programming Structured Variables
Understand S7-1500 PLC Reading and Writing SQL Microsoft Database in Seconds
1. Device Functionality
Among various schemes for medium to long distance communication between MCUs, RS-485 is widely used in fields such as factory automation, industrial control, community monitoring, and hydraulic automatic reporting due to its simple hardware design, ease of control, and low cost.
However, the RS-485 bus still has deficiencies in anti-interference, adaptability, and communication efficiency. Improper handling of certain details can often lead to communication failures or even system crashes, thus improving the operational reliability of the RS-485 bus is crucial.
1. Hardware Design of RS-485 Interface Circuit
There are two methods for bus matching: one is to add matching resistors. The differential ports 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 a significant amount of current, making them unsuitable for systems with strict power consumption limits.
Another more power-efficient matching scheme is RC matching, which uses a capacitor C to block the DC component, saving most of the power. However, selecting the value for capacitor C is challenging, requiring a compromise between power consumption and matching quality. In addition to these two methods, there is also a diode 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 transmits data in bytes, and before each byte is sent, a low-level start bit is used for handshaking. To prevent interference signals from mistakenly triggering RO (Receiver Output) to produce negative transitions and cause the receiving MCU to enter receiving mode, it is recommended to connect a 10kΩ pull-up resistor to RO.
3. Ensure RS-485 Chip is in Receive Mode at Power On
For the transceiver control pin TC, it is recommended to use an MCU pin controlled through an inverter, rather than directly controlling it with an MCU pin to prevent interference on the bus when the MCU powers on.
The RS-485 bus is a parallel two-wire interface. If one chip fails, it may cause the bus to be ‘pulled dead’. Therefore, isolation should be applied 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 ground to eliminate line 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) impacts, it is recommended to use TI’s 75LBC184 or similar lightning protection chips. For systems requiring a large number of nodes, SIPEX’s SP485R can be chosen.
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, 75LBC184 has a nominal maximum of 64 points, while SP485R has a nominal maximum of 400 points. In practical use, due to cable length, wire diameter, network distribution, and transmission rate differences, the actual number of nodes often does not reach theoretical values. For instance, when 75LBC184 is used in a 500m distributed RS-485 network, if the number of nodes exceeds 50 or the rate exceeds 9.6kb/s, the reliability of operation significantly decreases. It is generally recommended to select the number of nodes at 70% of the RS-485 chip’s maximum value, and choose a transmission rate between 1200-9600b/s. For communication distances within 1km, considering communication efficiency, number of nodes, and distance, 4800b/s is optimal. For distances over 1km, consider increasing relay modules or reducing the rate 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. For nodes with T-heads less than 10m, T-type connections can be used without significant impact on network matching. However, for very small node spacing (less than 1m, such as LED module combination screens), star connections should be used; T-type or bead-type connections may not work properly. RS-485 is a half-duplex structured communication bus, mostly used for one-to-many communication systems, so the master (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, which is much less efficient compared to full-duplex buses like RS-232, making the selection of appropriate communication protocols and control methods 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 transmitting data; after data transmission is completed, TC is set low after a delay of 1ms to ensure reliable sending is completed before entering the receiving state. The delay on the TC pin should satisfy the requirement within 4 machine cycles.
2. To ensure data transmission quality, while checking each byte, it is advisable to minimize the characteristic and checksum data. The common data packet format consists of a header code, length code, address code, command code, data, checksum, 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 as an international standard in water conservancy, hydrology, power, and other industry equipment and systems.
4. Power Supply and Grounding of RS-485 Interface Circuit
For measurement and control networks built by MCU combined with RS-485 microsystems, independent power supply solutions for each microsystem should be preferred. It is best not to use one large power supply for parallel powering of microsystems, 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 ideally use twisted pairs with a cross-sectional area of 0.75 square millimeters or more, rather than flat lines. For each small-capacity DC power supply, using a linear power supply like LM7805 is more suitable than using a switching power supply.
Of course, attention should be paid to the protection of LM7805:
1. Connect a 220-1000μF electrolytic capacitor between the input terminal of LM7805 and ground;
2. Connect a 1N4007 diode in reverse between the input and output terminals of LM7805;
3. Connect a 470-1000μF electrolytic capacitor and a 104pF ceramic capacitor in parallel at the output terminal of LM7805 and reverse connect a 1N4007 diode;
4. The input voltage is best at 8-10V, with a maximum allowable range of 6.5-24V. TI’s PT5100 can be used as a substitute for LM7805 to achieve an ultra-wide voltage input of 9-38V.
In certain industrial control fields, due to the complexity of on-site conditions, there is a high common-mode voltage between nodes. Although the RS-485 interface uses differential transmission and has some ability to resist common-mode interference, when the common-mode voltage exceeds the limit receiving voltage of the RS-485 receiver (greater than +12V or less than -7V), the receiver can no longer function normally, and in severe cases, it may even burn out the chip and equipment.
The solution to this problem is to isolate the system power supply and the RS-485 transceiver power supply through DC-DC; isolate the signal using opto-isolators to completely eliminate the effects of common-mode voltage. The approaches to implement this solution can be divided into:
1. Constructing a circuit using opto-isolators, isolated DC-DC, and RS-485 chips;
2. Using secondary integrated chips such as PS1480, MAX1480, etc.
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 interdependencies. Usually, a fault in one node can cause the overall or partial paralysis of the system, and it is often difficult to diagnose. Therefore, common maintenance methods for RS-485 are introduced to the readers.
1. If the system is completely paralyzed, it is mostly due to the breakdown of the VA and VB of a certain node chip against the power supply, using a multimeter to measure the differential voltage between VA and VB as zero, while the common-mode voltage to ground is greater than 3V. At this time, 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 can cause 2-3 adjacent nodes (usually subsequent) to be unable to communicate. Therefore, disconnect them from the bus one by one; if disconnecting a certain node restores normal operation on the bus, it indicates that the node is faulty;
3. In RS-485 systems with centralized power supply, some nodes often do not function normally at power-on, but each time it is not the same. This is due to unreasonable design of the RS-485 transceiver control pin TC, causing the receiving state of the nodes to be chaotic when the microsystem powers on, leading to bus congestion. The improvement method is to install power switches on each microsystem and power them on separately;
4. The system is generally normal but occasionally communication fails. This is usually due to unreasonable network construction, causing the system reliability to be 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 chip of superior performance.
5. The TC pin is in a prolonged high state due to MCU failure, causing the bus to be pulled dead. Readers are reminded not to forget to check the TC pin. Although RS-485 specifies that a differential voltage greater than 200mV can work normally, actual measurements show that a well-functioning system usually has a differential voltage around 1.2V (due to network distribution and rate differences, the differential voltage may range from 0.8-1.5V).
What Everyone is Watching
[Video] How German Engineers Make PLC Cabinets?
[Video] How are German Witte Electric Cabinets Produced?
[Video] What is the Working Environment of German Engineers Like?
[Video] Why is PROFINET Better than PROFIBUS?