Multi-device high real-time control method based on RS485 bus
By using two channels on the RS485 bus for synchronizing pulses and data transmission, and using a phase-locked loop to achieve the synchronization of slave scanning and host timing, the problems of low data synchronization and bus utilization in multiple slave systems are solved, and efficient data transmission is achieved.
Patent Information
- Application Number
- CN202510368694.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-26
- Publication Date
- 2025-07-08
AI Technical Summary
The existing RS485 bus is difficult to achieve high-speed synchronous communication in multi-slave systems, the bus utilization rate is low, and the existing solutions are complex in operation, and the redundancy is difficult to guarantee or the real-time data is impossible.
Two RS485 communication channels are used, one for periodic synchronization pulse generation and the other for data transmission. Through periodic synchronization pulses and the slave's phase-locked loop, the slave realizes timing synchronization between the slave scanning and the master. Each slave sends data after a fixed delay to ensure data synchronization and bus utilization.
During a communication cycle, the data transmission of the master and slave machines does not conflict, which improves the utilization rate of the bus and can transmit more data per unit time, which is suitable for the control of intelligent robot joints and motors.
Smart Images

Figure CN120277020A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field related to high-speed synchronous data communication, and in particular to a multi-device high-real-time control method based on RS485 bus. Background Art
[0002] With the rapid development of artificial intelligence, embodied intelligence has made rapid progress, especially intelligent robots, such as quadruped robot dogs and humanoid robots, which have received widespread attention. In order to achieve various flexible postures, intelligent robots generally require multiple joints to achieve posture control. In order to ensure the accuracy of the robot's posture change process, each joint driver needs to communicate with the controller in real time and at high speed, which poses a challenge to the communication bus between the joint driver and the controller. Conventional communication methods use EtherCAT communication protocol or CAN-FD bus. EtherCAT bus can achieve high-speed real-time transmission, but it requires additional ASIC chips, which are expensive, complex protocols, high development costs, and large space. Intelligent robot joints are generally small in size, with large quantity requirements, and are sensitive to cost and size. The CAN-FD bus has relatively low cost and simple protocol, but its communication data flexibility is low and the baud rate is low. In addition, CAN-FD has a short development time and fewer supporting controllers, which also increases development costs and hardware costs in disguise. The RS485 bus has been developed to a very mature level with flexible communication speed and protocol. Some solutions also use the RS485 bus, but RS485 is a half-duplex bus. When facing a multi-slave system, it mainly uses a question-and-answer communication method, that is, the slave can only send data to the host when the host asks the corresponding slave. The bus utilization rate is low, and it is difficult to achieve high-speed synchronous communication.
[0003] There are many solutions for high-speed synchronous communication based on RS485 bus, such as:
[0004] (1) CN116418625A: A high-speed synchronous data acquisition method for leg impact based on RS485 bus. In this patent, the working mode of RS485 bus is continuously switched between pulse mode and bus mode, the pulse mode is used to achieve phase lock between the host and the slave, and the bus mode is used to achieve the switching of communication slaves and data transmission. This solution is complex to operate, has high requirements for the operation of the slaves, is difficult to ensure redundancy, and has low bus utilization.
[0005] (2) CN221842556U: A RS485 bus multi-master communication circuit. By designing an additional circuit, it is possible to identify whether the bus is transmitting data. If not, it starts transmitting data. If yes, it continues to wait for the data transmission to be completed. This solution requires additional circuit design, and the data cannot meet strict real-time requirements.
[0006] (3)CN119071102A: A control system for concurrent processing of 485 bus data. In this patent, before a slave station sends data, it needs to query whether there is data being sent on the bus. If not, it starts sending data after a random time; if there is, it waits for the bus to be idle. This solution cannot guarantee the real-time performance of data and is prone to occupying the processor resources of the slave station. Summary of the Invention
[0007] The present invention is to overcome the above-mentioned deficiencies in the prior art and provides a high-real-time control method for multiple devices based on the RS485 bus to solve the problem of data synchronization under multiple slave machines.
[0008] To achieve the above object, the present invention adopts the following technical solutions:
[0009] A high-real-time control method for multiple devices based on the RS485 bus includes two RS485 communication channels. One RS485 communication channel is used for generating periodic synchronization pulses, and the other RS485 communication channel is used for data transmission. Through the periodic synchronization pulses and the phase-locked loops of each slave machine, the slave machine scanning and the timing synchronization between each slave machine and the master machine are realized. After a fixed delay duration of the periodic synchronization pulse signal, each slave machine starts to send data not exceeding a preset amount; specifically includes the following steps:
[0010] (1) Configure the addresses of the master machine and the slave machines. The master machine sends a slave device scanning instruction and a periodic synchronization pulse. After receiving the periodic synchronization pulse, a slave machine delays for a random time. If the data bus is idle, one of the slave machines sends device information to the master machine. After all devices are scanned, the master machine broadcasts the address of each device and the corresponding data sending time to the data bus;
[0011] (2) The master machine sends a slave phase-locked instruction, and then sends a periodic synchronization pulse signal. The slave machine captures the arrival moment of the periodic synchronization pulse and adjusts the time interval between its own task start point and the periodic synchronization pulse through the phase-locked loop. This time interval is determined by the data sending time sent by the master machine during device scanning;
[0012] (3) After a period of time, when the phase-locked loops of the slave machines work stably, the master machine broadcasts a synchronous data instruction, and then the master machine starts to send a data frame not exceeding the predetermined length of the master machine at the moment when the periodic synchronization pulse occurs. The slave machine starts to send a data frame not exceeding the predetermined length of the slave machine after the predetermined time of the periodic synchronization pulse signal.
[0013] The present invention ensures that the master machine and all slave machines send data using their respective time slices within a communication cycle without generating conflicts through the above control method, guarantees the data synchronization, improves the utilization rate of the bus, and can transmit more data per unit time.
[0014] Preferably, in step (1), the specific operation method is as follows:
[0015] (11) After the host receives the slave device scan instruction, the host pauses sending the periodic synchronization pulse and data. After waiting for a period of time and confirming that there is no more data transmission on the data bus, the host broadcasts the slave scan device instruction through the data bus;
[0016] (12) After the slave device scan instruction is sent, the host sends a periodic synchronization pulse signal to the periodic synchronization pulse bus;
[0017] (13) After the slave receives the device scan instruction and the periodic synchronization pulse signal sent by the host, the slave waits for a random time, and then checks whether there is a second periodic synchronization pulse signal on the periodic synchronization pulse bus and whether there is data transmission on the data bus; if there is, wait for the data on the data bus to be sent; if not, the slave also sends a pulse signal to the periodic synchronization pulse bus, and starts to broadcast the device information to the data bus, and then the slave no longer detects the periodic synchronization pulse bus and responds to the device scan instruction;
[0018] (14) When the host finishes receiving the device information sent by the slave, it sends a periodic synchronization pulse signal to the periodic synchronization pulse bus again. The slave that has not sent the device information receives the periodic synchronization pulse signal after a random time and broadcasts the pulse signal and device information of the slave; until all slaves have sent the device information, if there is no device response to the periodic synchronization pulse signal sent by the host within the preset time period, it means that the device scan is completed;
[0019] (15) The host calculates the time for each slave to broadcast the synchronization data according to the address information of each slave, and then broadcasts the data and address to the data bus, thus completing the device scan and data segment allocation.
[0020] Preferably, in step (2), specifically: the host broadcasts the slave phase-locked instruction to the data bus. After the data is sent, it starts to send the periodic synchronization pulse signal through the periodic synchronization pulse bus. After the slave captures the periodic synchronization pulse signal, it adjusts the time interval between the starting point of its own data sending time and the periodic synchronization pulse moment through the phase-locked loop to a preset time.
[0021] Preferably, in step (3), specifically: the host sends a data frame not exceeding the host's predetermined length at the moment when the periodic synchronization pulse occurs. The data frame contains the data required by each slave according to the message protocol; the slave starts to send a data frame not exceeding the slave's predetermined length after the predetermined time of the periodic synchronization pulse signal. The data frame may contain data content and device address information.
[0022] The beneficial effects of the present invention are as follows: It ensures that the host and all slave devices send data using their respective time slices within a communication cycle without conflicts, guarantees the synchronization of data, improves the utilization rate of the bus, and enables more data to be transmitted per unit time. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 is a schematic diagram of the bus topology of the present invention;
[0024] Figure 2 is a schematic diagram of the communication timing of the present invention;
[0025] Figure 3 is a flowchart of the slave device scanning of the present invention;
[0026] Figure 4 is a flowchart of the method operation of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0027] The present invention will be further described below in conjunction with the drawings and specific embodiments.
[0028] As Figure 1 described in the embodiment, a multi-device high-real-time control method based on the RS485 bus. Since RS485 belongs to the differential mode, each channel bus includes two differential signal lines, positive and negative. The topology structure includes a total of two RS485 communication channels (i.e., two bus channels, 4 signal lines). One RS485 communication channel is a periodic synchronization pulse generator for generating periodic synchronization pulses (i.e., the pulse bus), and the other RS485 communication channel is a data transmission channel for data transmission (i.e., the data bus). Through the periodic synchronization pulse and the phase-locked loops of each slave, the slave scanning and the timing synchronization between each slave and the host are realized. After a fixed delay duration of the periodic synchronization pulse signal, each slave starts to send data not exceeding a preset amount. The fixed delay duration of each slave station is different according to its own device address to solve the problem of data synchronization under multiple slaves.
[0029] Suppose there are the following parameters: the synchronization period is Ts, within each synchronization period, the length of the host data does not exceed Tm, and the length of the slave data does not exceed Tf. Then it can be configured as follows: starting from the periodic synchronization pulse, the host data is sent first, and the data sending is completed after Tm; the slave 1 starts to send data at time t1; the slave 2 starts to send data at time t2... until all the data is sent. For the convenience of calculation, the time interval between the data transmissions of two adjacent slaves is Td, and it is required that Tm is less than t1 and Tf is less than Td. The data sending schematic diagram is as Figure 2 shown.
[0030] As Figure 4 shown, it specifically includes the following steps:
[0031] (1) Configure the host and slave addresses. The host sends a slave device scan instruction and a periodic synchronization pulse. When a slave receives this periodic synchronization pulse and delays for a random time, if the data bus is idle, one of the slaves sends device information to the host. After all devices have been scanned, the host broadcasts the address of each device and the corresponding data transmission time to the data bus; as Figure 3 shown, the specific operation method is as follows:
[0032] (11) When the host receives the slave device scan instruction, the host pauses sending the periodic synchronization pulse and data. After waiting for a period of time and confirming that there is no more data transmission on the data bus, the host broadcasts the slave scan device instruction through the data bus;
[0033] (12) After the slave device scan instruction is sent, the host sends a periodic synchronization pulse signal to the periodic synchronization pulse bus;
[0034] (13) After the slave receives the device scan instruction and the periodic synchronization pulse signal sent by the host, the slave waits for a random time, then checks whether there is a second periodic synchronization pulse signal on the periodic synchronization pulse bus and whether there is data transmission on the data bus; if there is, wait for the data transmission on the data bus to complete, if not, the slave also sends a pulse signal to the periodic synchronization pulse bus, and starts to broadcast information such as the device address to the data bus, and then this slave no longer detects the periodic synchronization pulse bus and responds to the device scan instruction;
[0035] (14) When the host has received the device address and other information sent by the slave, it sends a periodic synchronization pulse signal to the periodic synchronization pulse bus again. The slave that has not sent device information receives the periodic synchronization pulse signal after a random time and broadcasts the pulse signal and device information of this slave; until all slaves have sent device address and other information, if there is no device response to the periodic synchronization pulse signal sent by the host within the preset time period, it means that the device scan is completed;
[0036] (15) The host calculates the moments of the broadcast synchronization data of each slave according to the address information of each slave, that is, parameters such as t1, t2, t3... etc., and then broadcasts this data and the address to the data bus, thus completing the device scan and data segment allocation.
[0037] (2) The host sends a slave phase-locked instruction, and then sends a periodic synchronization pulse signal. The slave captures the arrival moment of the periodic synchronization pulse and adjusts the time interval between its own task start point and the periodic synchronization pulse through a phase-locked loop. This time interval is determined by the data transmission time sent by the host during device scanning;
[0038] Specifically: The host broadcasts the slave phase-locked instruction to the data bus. After the data transmission is completed, it starts to send the cycle synchronization pulse signal with a period of Ts through the cycle synchronization pulse bus. After the slave captures the cycle synchronization pulse signal, it adjusts the time interval between the starting point of its own data transmission time and the cycle synchronization pulse moment through the phase-locked loop, and adjusts it to a preset time, such as Figure 2 As shown, the preset time of slave 1 is t1, the preset time of slave 2 is t2, the preset time of slave 3 is t3... and so on. Among them, the phase-locked loop is not the focus of the present invention, so it will not be described in detail. After synchronization is completed, the host broadcasts the synchronous data instruction to the data bus.
[0039] (3) After a period of time, when the slave phase-locked loop works stably, the host broadcasts the synchronous data instruction, and then the host starts to send a data frame not exceeding the host's predetermined length at the moment of the cycle synchronization pulse occurrence. The data frame contains the data required by each device according to the message protocol; the slave starts to send a data frame not exceeding the slave's predetermined length after the predetermined time of the cycle synchronization pulse signal. The data frame may contain data content and device address information.
[0040] Through the above control method, the present invention ensures that the host and all slaves send data within their respective time slices within a communication cycle without generating conflicts, ensuring data synchronization, improving the utilization rate of the bus, being able to transmit more data per unit time, and can be used for the control of devices such as robot joints and motors.
Claims
1. A multi-device high-real-time control method based on the RS485 bus, characterized in that, It includes two RS485 communication channels. One RS485 communication channel is used for the generation of periodic synchronization pulses, and the other RS485 communication channel is used for data transmission. Through the periodic synchronization pulses and the phase-locked loops of each slave, the slave scanning and the timing synchronization between each slave and the master are realized. After a fixed delay duration of the periodic synchronization pulse signal, each slave starts to send data not exceeding a preset amount; specifically, it includes the following steps: (1) Configure the addresses of the master and slaves. The master sends a slave device scanning instruction and a periodic synchronization pulse. After receiving the periodic synchronization pulse, a slave delays for a random time. If the data bus is idle, one of the slaves sends device information to the master. After all devices are scanned, the master broadcasts the address of each device and the corresponding data sending time to the data bus; (2) The master sends a slave phase-locked instruction, and then sends a periodic synchronization pulse signal. The slave captures the arrival moment of the periodic synchronization pulse and adjusts the time interval between its own task start point and the periodic synchronization pulse through the phase-locked loop. This time interval is determined by the data sending time sent by the master during device scanning; (3) After a period of time, when the slave phase-locked loop works stably, the master broadcasts a synchronous data instruction, and then the master starts to send a data frame not exceeding the preset length of the master at the moment when the periodic synchronization pulse occurs. The slave starts to send a data frame not exceeding the preset length of the slave after a preset time of the periodic synchronization pulse signal; 2. The multi-device high-real-time control method based on the RS485 bus according to claim 1, wherein In step (1), the specific operation method is as follows: (11) After the master receives the slave device scanning instruction, the master pauses sending the periodic synchronization pulse and data. After waiting for a period of time and confirming that there is no data transmission on the data bus, the master broadcasts a slave scanning device instruction through the data bus; (12) After the slave device scanning instruction is sent, the master sends a periodic synchronization pulse signal to the periodic synchronization pulse bus; (13) After the slave receives the device scanning instruction and the periodic synchronization pulse signal sent by the master, the slave waits for a random time, and then checks whether there is a second periodic synchronization pulse signal on the periodic synchronization pulse bus and whether there is data transmission on the data bus; If there is, wait for the data on the data bus to be sent out. If not, this slave also sends a pulse signal to the periodic synchronization pulse bus and starts to broadcast the device information to the data bus. Then this slave no longer detects the periodic synchronization pulse bus and replies to the device scanning instruction; (14) After the master receives the device information sent by the slave, the master sends a periodic synchronization pulse signal to the periodic synchronization pulse bus again. The slave that has not sent device information receives the periodic synchronization pulse signal after a random time and broadcasts the pulse signal and device information of this slave; until all slaves have sent device information, if there is no device response to the periodic synchronization pulse signal sent by the master within a preset time period, it means that the device scanning is completed; (15) The master calculates the moment of broadcasting synchronous data for each slave according to the address information of each slave, and then broadcasts this data and the address to the data bus. Thus, the device scanning and data segment allocation are completed.
3. A multi-device high-real-time control method based on the RS485 bus according to claim 1, characterized in that, In step (2), specifically: the host broadcasts a slave phase-locked instruction to the data bus. After the data transmission is completed, it starts to send a periodic synchronization pulse signal through the periodic synchronization pulse bus. After the slave captures the periodic synchronization pulse signal, it adjusts the time interval between the starting point of its own data transmission time and the periodic synchronization pulse moment through a phase-locked loop, and adjusts it to a preset time.
4. A multi-device high-real-time control method based on the RS485 bus according to claim 1, characterized in that, In step (3), specifically: the host sends a data frame not exceeding the predetermined length of the host at the moment when the periodic synchronization pulse occurs. The data frame contains the data required by each slave according to the message protocol; the slave starts to send a data frame not exceeding the predetermined length of the slave after a predetermined time of the periodic synchronization pulse signal. The data frame may contain data content and device address information.
Citation Information
Patent Citations
Data concurrent processing control system based on 485 bus
CN119071102A
RS-485 bus multi-master communication circuit
CN221842556U
Cited By
Multi-device parallel communication method and device based on UART (Universal Asynchronous Receiver / Transmitter) and bus communication system
CN121524119A
UART-based multi-device parallel communication method and device, and bus-type communication system
CN121524119B