A distributed system and operation method based on RS485 ring network
By adopting the design of ring networking and two-channel RS485 circuits in the RS485 bus system, the node communication abnormalities caused by communication instability and cable looseness in multi-node and long-distance RS485 bus systems are solved, and the system is high reliability and stability are achieved.
Patent Information
- Application Number
- CN202111227518.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-21
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2041-10-21
AI Technical Summary
The existing RS485 bus system has problems such as instability in communication, loose cables, complicated impedance matching and debugging, and insufficient equipment power supply in multiple nodes and long-distance occasions, which affects the system stability and reliability.
Using a distributed system based on the RS485 ring network, the structural design of converting 1 serial port unit into 2 RS485 circuits, the two RS485 circuits work simultaneously at any time to form a ring network. When the cable of any node is loose, other nodes realize normal communication through another RS485 circuit, and monitor and adjust communication quality in real time through the monitoring unit and the baud rate automatic configuration unit.
It realizes that all nodes can communicate normally when the cables of any node are loose, improves bus signal quality and system reliability, reduces engineering complexity and cable losses, and ensures the normal operation of the equipment.
Smart Images

Figure CN114070670B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of RS485 network communication, and in particular to a distributed system and an operation method based on RS485 ring network. Background Art
[0002] RS485 bus adopts differential signal transmission, has strong anti-common mode capability, supports multiple nodes, and has excellent communication distance of up to 1200 meters. It is more and more widely used in distributed control systems. In actual engineering use, the hand-in-hand bus topology is generally adopted. However, due to the insufficient driving ability of the RS485 converter itself and the poor wiring of the RS485 bus wiring construction, the communication phenomenon of good and bad often occurs, which brings great hidden dangers to the stability of the system.
[0003] The system using traditional RS485 bus has the following disadvantages:
[0004] (1) When the cable is loose or falls off, it may cause communication abnormalities in all nodes behind the node, expanding the accident area;
[0005] (2) In multi-node and long-distance scenarios, the network needs to be debugged for impedance matching, which increases engineering complexity;
[0006] (3) In situations where there are multiple nodes and long distances, and the equipment needs to be powered by RS485 communication cables, the equipment far away from the RS485 host may be prone to unstable operation due to cable loss and insufficient power supply voltage.
[0007] On May 8, 2018, the China Patent Office disclosed an invention named a method and device for simulating RS485 bus faults, and its publication number is CN108009060A. The invention includes: receiving the fault injection strategies sent by the host computer in the order specified by the fault injection sequence; injecting the fault items included in all the fault injection strategies in the fault injection sequence into the bus signal received from the receiving device, and after each fault injection, sending the bus signal after the fault items are injected to the receiving device. The scheme of the invention can achieve comprehensive detection of the device under test. However, the invention can only detect faults, and cannot solve the faults in time, and cannot ensure the stability of the communication system. The RS485 redundant system currently proposed has a complex network structure, and the starting box and the plug-in box need to support dual 485 ports, which is costly. Summary of the invention
[0008] The purpose of the present invention is to overcome the problems existing in the prior art and provide a distributed system and operation method based on RS485 ring network. When the bus cable of any node is loose, all nodes still communicate normally; the quality of the bus signal is improved, which is conducive to improving the reliability of the system.
[0009] In order to achieve the above object, the present invention adopts the following technical solutions:
[0010] A distributed system based on RS485 ring network, comprising:
[0011] RS485 master unit: determines the network status of RS485 slave units and makes adjustments;
[0012] RS485 slave unit: includes several nodes, which are connected to the RS485 master unit in a ring networking mode;
[0013] The RS485 host unit includes:
[0014] Control unit: analyzes bus signals, automatically adjusts bus communication baud rate, and sends alarm signals;
[0015] Serial port unit: USART unit or UART unit, used to send and receive data of RS485 circuit unit;
[0016] RS485 circuit unit: including two RS485 circuits that work simultaneously at any time
[0017] USART is a synchronous / asynchronous transceiver, and UART is an asynchronous transceiver. Two RS485s work simultaneously at any time. When the cable of one of the nodes is loose, all nodes can still communicate normally. The present invention adopts a structural design in which a 1-way serial port unit is converted into a 2-way RS485 circuit, and the two-way RS485 circuit and several nodes of the RS485 slave unit are ring-networked. When the bus cable between any two nodes is loose or falls off, the nodes at both ends of the faulty cable complete normal communication through one RS485 circuit respectively, thereby achieving that when a certain fault occurs, all nodes can communicate as usual, improving the quality of the bus signal and being conducive to improving system reliability.
[0018] Preferably, each RS485 circuit in the RS485 circuit unit is provided with a matching resistor R. In this way, when the system is networked, the engineering personnel do not need to add impedance matching, which reduces the complexity of the project.
[0019] Preferably, the control unit comprises:
[0020] Monitoring unit: monitors the data sent and received by the serial port unit and the communication quality between nodes, determines the quality of the bus waveform and whether there is any fault in the cable between nodes;
[0021] Baud rate automatic configuration unit: automatically adjusts the communication baud rate according to the monitoring results to improve the communication quality.
[0022] The monitoring unit can monitor the width, delay and other parameters of the waveform of the serial port unit's data receiving and sending pins in real time to determine the bus waveform quality. The baud rate automatic configuration unit can automatically adjust the communication baud rate to make the system RS485 bus work in an optimal state, thereby achieving the purpose of improving communication quality.
[0023] Preferably, the 2-way RS485 circuit includes RS485_1 and RS485_2, RS485_1 and RS485_2 are respectively the starting point and the end point of the RS485 slave unit, the RS485_1 is connected to the first node, several nodes are sequentially connected in series, and the last node is connected to RS485_2 to form a ring network. RS485_1 and RS485_2 are respectively the starting point and the end point of the RS485 slave unit, but there is no distinction between the two, and the starting point and the end point are just a way of saying it.
[0024] Preferably, the control unit further comprises a storage unit for storing software faults in RS485 communication, so as to facilitate checking fault information.
[0025] As a preference, it also includes:
[0026] Alarm unit: to remind the staff of cable failure;
[0027] Display unit: displays the location of the faulty cable;
[0028] The alarm unit and the display unit are both connected to the control unit
[0029] When a single-point failure of RS485 occurs, the alarm unit will sound an alarm, prompting the staff to inspect and maintain the cable. The display unit is used to show which two nodes have a cable failure, so that the staff can accurately locate the fault.
[0030] A distributed system operation method based on RS485 ring network comprises the following steps:
[0031] S1: Connect the distributed system based on RS485 ring network in a ring networking mode;
[0032] S2: The monitoring unit monitors the serial port unit in real time to determine the waveform quality and whether there is a fault between nodes. If the waveform quality is not good, step S3 is executed. If there is a fault between nodes, the fault position is located;
[0033] S3: The baud rate automatic configuration unit automatically adjusts the communication baud rate to enable normal communication.
[0034] When connecting, the control unit is connected to the serial port unit, the serial port unit is connected to RS485-1 and RS485_2, RS485-1 is connected to node 1, node 1 is connected to node 2, ..., node n-1 is connected to node n, ..., node m is connected to node m+1, node m+1 is connected to RS485_2, forming a ring network.
[0035] Preferably, the step S2 further comprises:
[0036] S2.1: The baud rate range is preset for normal operation. The monitoring unit monitors the waveform parameters of the serial port unit receiving and sending data in real time, including the width and delay of the pin waveform, and monitors the data of the RS485 circuit read by the serial port unit;
[0037] S2.2: Calculate the baud rate based on the monitored waveform parameters, compare it with the preset value, and judge the bus waveform quality;
[0038] S2.3: Based on the data read by the serial port unit from the RS485 circuit unit, if it is detected that the serial port unit can only read node n and its previous nodes through RS485_1, and can only read node (n+1) and its subsequent nodes in reverse through RS485_2, it means that a fault occurs between node n and node (n+1).
[0039] When a fault occurs between nodes, the serial port unit can only read the current node and the previous node through RS485_1, and can only read the next node and the nodes after it through RS485_2, thereby completing normal communication. Therefore, by judging the node read by the serial port unit, it is possible to determine whether a fault occurs between nodes and the location of the fault.
[0040] Preferably, in step S3, the communication baud rate is automatically adjusted in the following manner: the baud rate is adjusted according to a preset value so that the adjusted baud rate is between the preset values, and the data of the serial port unit is received at the adjusted baud rate, and then the monitoring unit continues to monitor the serial port unit.
[0041] Therefore, the present invention has the following beneficial effects: 1. The bus carrying capacity is increased to 2 times of the original one, which is conducive to the RS485 receiver to correctly identify the signal; 2. In the ring networking mode, when the cable of one of the nodes is loose, all the nodes can still communicate normally; 3. The 2-way RS485 has its own matching resistor, which reduces the complexity of the project; 4. In the case of multiple nodes and long distances, where the equipment needs to be powered by RS485 communication cables, the ring networking reduces the cable loss and effectively protects the normal operation of the equipment; 5. The baud rate automatic configuration unit automatically adjusts the bus communication baud rate by analyzing the bus signal, so that the system RS485 bus works in an optimal state. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a schematic diagram of the structure of the present invention;
[0043] Figure 2 It is a schematic diagram of a single node failure of the present invention;
[0044] Figure 3 is a flow chart of the steps of the method of the present invention;
[0045] In the figure: 1. Control unit; 2. Serial port unit; 3. RS485 master unit; 4. RS485 slave unit. DETAILED DESCRIPTION
[0046] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments:
[0047] This embodiment is a distributed system based on RS485 ring network. Figure 1 As shown, it includes RS485 host unit 3 and RS485 slave unit 4. The RS485 host unit on the left includes control unit 1 and serial port unit 2. The control unit and serial port unit exchange information. The serial port unit is converted into 2 RS485 circuits: RS485-1 and RS485_2. The bus load capacity is increased to 2 times the original, which is conducive to the RS485 receiver to correctly identify the signal. A matching resistor R is added to the RS485 circuit, so that when the system is networked, the engineer does not need to add impedance matching. The RS485 slave unit on the right includes several nodes. Node 1 to node m+1 form a ring network by holding hands, which reduces the loss of the cable and effectively protects the normal operation of the equipment.
[0048] The serial port unit can be a USART unit or a UART unit, USART is a synchronous / asynchronous transceiver, and UART is an asynchronous transceiver. The control unit includes a monitoring unit, a baud rate automatic configuration unit and an alarm unit. The monitoring unit can monitor the width, delay and other parameters of the waveform of the serial port unit receiving and sending data pins in real time to judge the quality of the bus waveform. The baud rate automatic configuration unit can automatically adjust the communication baud rate so that the system RS485 bus works in an optimal state to achieve the purpose of improving the communication quality. When a single-point failure of RS485 occurs, the alarm unit will alarm to prompt the staff to detect and maintain the cable. The display unit is used to display which two nodes have a cable failure, which is convenient for the staff to accurately locate. The control unit also includes a storage unit for storing software failures in RS485 communication, which is convenient for viewing fault information. During operation, the two RS485s work simultaneously at any time, so that when the cable of one of the nodes is loose, all nodes can still communicate normally.
[0049] For the sake of convenience, it is assumed that RS485_1 is the "starting point" and RS485_2 is the "end point" (in fact, there is no distinction). The system forms a ring network from "starting point" -> "node 1" -> "node 2" -> "node 3" -> ... -> "node m+1" -> "end point".
[0050] Figure 2 This is a schematic diagram of a single node failure in a distributed system based on an RS485 ring network. Assume that the cable between "node 1" and "node 2" is loose or falls off. At this time, the system can communicate normally with the "starting point" and "node 1" through RS485_1. It can communicate normally with the "end point", "node m+1", "node m"... and "node 2" through RS485_2. At this time, all nodes in the entire system can communicate normally.
[0051] This embodiment is a distributed system operation method based on RS485 ring network. Figure 3 As shown, the following steps are included:
[0052] S1: Connect the distributed system based on RS485 ring network in a ring networking mode
[0053] The control unit is connected to the serial port unit, the serial port unit is connected to RS485-1 and RS485_2, RS485-1 is connected to node 1, node 1 is connected to node 2, ..., node n-1 is connected to node n, ..., node m is connected to node m+1, node m+1 is connected to RS485_2, forming a ring network.
[0054] S2: The monitoring unit monitors the serial port unit in real time to determine the waveform quality and whether there is a fault between nodes. If the waveform quality is not good, step S3 is executed. If there is a fault between nodes, the fault position is located.
[0055] The step S2 further comprises:
[0056] The baud rate range is preset for normal operation. The monitoring unit monitors the waveform parameters of the serial port unit receiving and sending data in real time, including the width and delay of the pin waveform, and monitors the data of the RS485 circuit read by the serial port unit at the same time; the baud rate is calculated based on the monitored waveform parameters, and compared with the preset value to judge the bus waveform quality; according to the data read by the serial port unit to the RS485 circuit unit, if it is monitored that the serial port unit can only read the n node and the node before it through RS485_1, and can only read the (n+1) node and the node after it through RS485_2, it means that there is a fault between the n node and the (n+1) node. When a fault occurs between nodes, the serial port unit can only read the current node and the node before it through RS485_1, and can only read the next node and the node after it through RS485_2, thereby completing normal communication. Therefore, by judging the nodes read by the serial port unit, it is possible to judge whether there is a fault between nodes and the location of the fault.
[0057] S3: The baud rate automatic configuration unit automatically adjusts the communication baud rate to ensure normal communication
[0058] The baud rate is adjusted according to the preset value so that the adjusted baud rate is between the preset values, and the data of the serial port unit is received at the adjusted baud rate, and then the monitoring unit continues to monitor the serial port unit.
[0059] The above-described embodiment is only a preferred solution of the present invention and does not limit the present invention in any form. There are other variations and modifications without exceeding the technical solution described in the claims.
Claims
1. A distributed system based on RS485 ring network, characterized in that: include: RS485 master unit: determines the network status of RS485 slave units and makes adjustments; RS485 slave unit: includes several RS485 nodes, which are connected to the RS485 master unit in a ring networking mode; The RS485 host unit includes a control unit, a serial port unit and an RS485 circuit unit. The control unit analyzes the bus signal, automatically adjusts the bus communication baud rate and sends an alarm signal according to the width and delay of the waveform of the receiving and sending data pins of the serial port unit; Serial port unit: USART unit or UART unit, used to send and receive data of RS485 circuit unit, judge whether there is a fault between nodes and determine the location of the fault according to the nodes read by the serial port unit; RS485 circuit unit: including two RS485 circuits that work simultaneously at any time; The two-way RS485 circuit includes RS485_1 and RS485_2. RS485_1 and RS485_2 are the starting point and the end point of the RS485 slave unit respectively. RS485_1 is connected to the first RS485 node. Several RS485 nodes are connected in series in sequence. The last RS485 node is connected to RS485_2 to form a ring network.
2. A distributed system based on RS485 ring network according to claim 1, characterized in that, Each RS485 circuit in the RS485 circuit unit is provided with a matching resistor R.
3. A distributed system based on RS485 ring network according to claim 1 or 2, characterized in that, The control unit comprises: Monitoring unit: monitors the waveform of the serial port unit's received and sent data and the communication quality between nodes, and determines the quality of the bus waveform and whether the cable between nodes is faulty; Baud rate automatic configuration unit: automatically adjusts the communication baud rate according to the monitoring results to improve the communication quality.
4. A distributed system based on RS485 ring network according to claim 1, characterized in that: The control unit also includes a storage unit for storing software faults in RS485 communication.
5. A distributed system based on RS485 ring network according to claim 1 or 4, characterized in that, Also includes: Alarm unit: to remind the staff of cable failure; Display unit: displays the location of the faulty cable; The alarm unit and the display unit are both connected to the control unit.
6. A distributed system operation method based on RS485 ring network, using the system described in any one of claims 1 to 5, characterized in that: The following steps are involved: S1: Connect the distributed system based on RS485 ring network in a ring networking mode; S2: The monitoring unit monitors the serial port unit in real time to determine the waveform quality and whether there is a fault between nodes. If the waveform quality is not good, step S3 is executed. If there is a fault between nodes, the fault position is located; S3: The baud rate automatic configuration unit automatically adjusts the communication baud rate to enable normal communication.
7. A distributed system operation method based on RS485 ring network according to claim 6, characterized in that: The step S2 further comprises: S2.1: The baud rate range is preset for normal operation. The monitoring unit monitors the waveform parameters of the serial port unit receiving and sending data in real time, including the width and delay of the pin waveform, and monitors the data of the RS485 circuit read by the serial port unit; S2.2: Calculate the baud rate based on the monitored waveform parameters, compare it with the preset value, and judge the bus waveform quality; S2.3: Based on the data read by the serial port unit from the RS485 circuit unit, if it is detected that the serial port unit can only read node n and its previous nodes through RS485_1, and can only read node (n+1) and its subsequent nodes in reverse through RS485_2, it means that a fault occurs between node n and node (n+1).
8. A distributed system operation method based on RS485 ring network according to claim 6, characterized in that: In step S3, the communication baud rate is automatically adjusted in the following manner: the baud rate is adjusted according to a preset value so that the adjusted baud rate is between the preset values, and the data of the serial port unit is received at the adjusted baud rate, and then the monitoring unit continues to monitor the serial port unit.
Citation Information
Patent Citations
RS485 bus fault simulation method and device
CN108009060A
Baud rate adaptive method based on sequencing pulse width differential
CN102201960A
Ring network based on RS485 bus
CN110034991A