A multi-node communication method and device on RS485 bus

By configuring linked list codes and right transfer messages on the RS485 bus, efficient communication between nodes is achieved, the problems of data real-time and slow response speed are solved, and communication efficiency is improved.

CN119449519BActive Publication Date: 2025-09-23ZHONGKE KUYUAN TECH (WUHAN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411580277.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-07
Publication Date
2025-09-23
Estimated Expiration
2044-11-07

AI Technical Summary

Technical Problem

In multi-node communication over the RS485 bus, existing technologies suffer from poor data real-time performance and slow response time. This is mainly because in half-duplex communication mode, slave nodes can only exchange information after being polled by the host, resulting in time waste.

Method used

By configuring a linked list code on each node, the host node sends a transfer message to determine the communication node and transfers the bus usage right between nodes in a preset order, so that the slave node can directly send and receive information as a temporary host, reducing dependence on the host.

Benefits of technology

It improves the real-time performance and response speed of data, reduces communication delay, and improves the communication efficiency and bandwidth utilization of the RS485 bus.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119449519B_ABST
    Figure CN119449519B_ABST
Patent Text Reader

Abstract

The present invention provides a communication method and device for multiple nodes on an RS485 bus. A linked list code is configured on each node according to a preset sequence. A host node writes its own linked list code into a transfer message, and sends all the transfer messages to all slave nodes. A slave node whose address code is consistent with the linked list code in the transfer message obtains the right to use the bus and serves as a communication node. After the communication node completes its own communication needs, it writes the linked list code of the communication node into a new transfer message, and sends the new transfer message to all other nodes to obtain a new communication node. The above steps are repeated until the communication needs of all slave nodes are met. By transferring the bus use right to each slave node, the slave node acts as a temporary host to directly send and receive information without relying on the host node for query and forwarding, thereby greatly improving the real-time performance and response speed of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a multi-node communication method and device on an RS485 bus. Background Art

[0002] The RS485 bus is a common internal communication standard between programmable logic controllers (PLCs) in industrial environments. It uses a half-duplex mode and supports multi-point data communication. The protocol used for the RS485 bus is primarily a question-and-answer polling protocol.

[0003] The half-duplex communication mode requires that only one data transmitter can be used at a time, and the other nodes can only serve as receivers. This means that in multi-node RS485 communications, if a slave node wants to send information to the master node or other slave nodes, it can only wait for the master to send query information to each slave node one by one through polling. Each query requires sending query information back and forth between the slave node and the master node. When the query detects that the slave node has information to send or receive, the host node receives or forwards the relevant message, resulting in a large amount of time wasted, poor data real-time performance, and slow response time.

[0004] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in this technical field. Summary of the Invention

[0005] The technical problem to be solved by the present invention is how to improve data real-time performance and response speed in multi-node RS485 communication.

[0006] The present invention adopts the following technical solutions:

[0007] In a first aspect, a communication method for multiple nodes on an RS485 bus is provided, comprising:

[0008] Configure a linked list code on each node according to a preset order, wherein the linked list code is the address code of the next node to obtain the right to use the bus;

[0009] The master node writes its own linked list code into the transfer message and sends all transfer messages to all slave nodes;

[0010] Among all the slave nodes that have received the transfer message, the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus usage right and serves as a communication node. After the communication node completes its own communication needs, it writes the linked list code of the communication node into a new transfer message, and sends the new transfer message to all other nodes. The slave node whose address code is consistent with the linked list code in the new transfer message is used as the new communication node to transfer the bus usage right to the corresponding node in turn.

[0011] Preferably, among all the slave nodes that have obtained the transfer message, the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus use right and serves as a communication node. After the communication node completes its own communication needs, it writes the linked list code of the communication node into a new transfer message, which specifically includes:

[0012] When the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus use right and becomes a communication node, after a preset delay time, the communication node determines whether it needs to send or receive communication data according to its own communication needs;

[0013] If the communication node needs to send or receive communication data, the communication node obtains information of all peer nodes according to its own communication needs;

[0014] The communication node sends communication data to the opposite node according to the acquired information of the opposite node;

[0015] After receiving the communication data, the opposite node sends reply data to the communication node.

[0016] Preferably, among all the slave nodes that have obtained the transfer message, the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus use right and serves as a communication node. After the communication node completes its own communication needs, it writes the linked list code of the communication node into a new transfer message, further comprising:

[0017] When a slave node whose address code is consistent with the linked list code in the transfer message obtains the right to use the bus and becomes a communication node, if the communication node determines that it does not need to send or receive communication data based on its own communication needs, then after a preset delay time, the linked list code of the communication node is written into a new transfer message, and the new transfer message is sent to all other nodes.

[0018] Preferably, when a new slave node needs to be added, the information of the new slave node to be added is updated to the preset order, and the chain list code of the upper-level slave node and the chain list code of the lower-level slave node corresponding to the new slave node are synchronously changed according to the information of the new slave node;

[0019] When a designated slave node needs to be removed, the information of the designated slave node to be removed is removed from the preset order, and the linked list codes of the upper-level slave node and the lower-level slave node corresponding to the designated slave node are synchronously changed.

[0020] Preferably, the transfer message includes: an address code of the node that sends the transfer message and a linked list code of the node that sends the transfer message.

[0021] Preferably, the step of writing the linked list code of the communication node into a new transfer message and sending the new transfer message to all other nodes further includes:

[0022] Each time the master node receives the new transfer message, it obtains the address code of the current communication node according to the address code in the new transfer message, and obtains the transfer progress of the bus usage right between each slave node according to the address code of the current communication node and the preset order.

[0023] Preferably, the step of writing the linked list code of the communication node into a new transfer message and sending the new transfer message to all other nodes further includes:

[0024] The timing starts every time the host node obtains the new transfer message;

[0025] If the host node obtains the next transfer message within the preset timeout period, it is determined that the communication node corresponding to the next transfer message is normal, and the host node restarts the timing;

[0026] If the host node fails to obtain the next transfer message within a preset timeout period, it is determined that the communication node corresponding to the linked list code in the new transfer message is faulty;

[0027] The master node acquires the next slave node after the communication node according to the preset order, and transfers the bus use right to the next slave node.

[0028] Preferably, the master node acquires the next slave node after the communication node according to the preset order and transfers the bus use right to the next slave node, specifically including:

[0029] When the host node determines that the communication node corresponding to the linked list code in the new transfer message fails, the host node obtains the bus use right;

[0030] The master node obtains the next slave node after the communication node according to the preset sequence, uses the address code of the next slave node as the linked list code, and generates a temporary transfer report;

[0031] The master node sends the temporary right transfer message to all slave nodes to transfer the bus use right to the next slave node.

[0032] In a second aspect, a multi-node communication device on an RS485 bus is provided, comprising at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to execute the multi-node communication method on the RS485 bus.

[0033] In a third aspect, the present invention further provides a non-volatile computer storage medium, wherein the computer storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors to complete the method described in the first aspect.

[0034] In a fourth aspect, a chip is provided, comprising: a processor and an interface, for calling and running a computer program stored in a memory to execute the method of the first aspect.

[0035] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer or a processor, causes the computer or the processor to execute the method of the first aspect.

[0036] In a sixth aspect, a multi-node communication system on an RS485 bus is provided, comprising a multi-node communication device on an RS485 bus as in the second aspect, and using a multi-node communication method on an RS485 bus as in the first aspect.

[0037] The present invention provides a communication method and device for multiple nodes on an RS485 bus. A linked list code is configured on each node according to a preset order. A host node writes its own linked list code into a transfer message, and sends all the transfer messages to all slave nodes. A slave node whose address code is consistent with the linked list code in the transfer message obtains the right to use the bus and serves as a communication node. After the communication node completes its own communication needs, it writes the linked list code of the communication node into a new transfer message, and sends the new transfer message to all other nodes to obtain a new communication node. The above steps are repeated until the communication needs of all slave nodes are met. By transferring the bus use right to each slave node, the slave node acts as a temporary host to directly send and receive information without relying on the host node for query and forwarding, thereby greatly improving the real-time performance and response speed of data. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive effort.

[0039] Figure 1 1 is a method flow chart of a multi-node communication method on an RS485 bus provided by an embodiment of the present invention;

[0040] Figure 2 1. It is a flow chart of a method for transmitting and receiving communication data of a communication node in a multi-node communication method on an RS485 bus provided by an embodiment of the present invention;

[0041] Figure 3 A flow chart of a method for determining whether a slave node has an abnormality in a multi-node communication method on an RS485 bus provided by an embodiment of the present invention;

[0042] Figure 4 This is a flow chart of a method for a host node to maintain an abnormal situation in a multi-node communication method on an RS485 bus provided by an embodiment of the present invention;

[0043] Figure 5 It is a method block diagram of a multi-node communication method on an RS485 bus provided by an embodiment of the present invention;

[0044] Figure 6 1 is a method flow chart of a multi-node communication method on an RS485 bus provided by an embodiment of the present invention;

[0045] Figure 7 The present invention is a schematic diagram of a multi-node communication device on an RS485 bus provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0047] In the description of the present invention, it should be understood that the terms "center", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the present disclosure and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present disclosure.

[0048] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "multiple" means two or more. In addition, for example, the description may also use the method of adding "A" and "B" at the end to describe the same type of nouns as two independent individuals. In this case, the corresponding features defined as "A" and "B" are only used to distinguish the description purposes of the same type of individuals, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.

[0049] As used herein, "about," "substantially," or "approximately" includes the stated value and an average value that is within an acceptable range of deviation from the particular value as determined by one of ordinary skill in the art taking into account the measurements in question and the errors associated with the measurement of the particular quantity (i.e., the limitations of the measurement system).

[0050] Unless the context requires otherwise, throughout the specification and claims, the term "including" is to be interpreted as meaning open inclusion, that is, "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "example", "specific example" or "some examples" and the like are intended to indicate that the specific features, structures, materials or characteristics associated with the embodiment or example are included in at least one embodiment or example of the present disclosure. The schematic representation of the above terms does not necessarily refer to the same embodiment or example. In addition, the specific features, structures, materials or characteristics may be included in any one or more embodiments or examples in any appropriate manner, that is, although they may be carried in the embodiments or examples of the above terms due to reasons such as the order and position of appearance, it is not limited to that they can be carried in combination by one embodiment or example.

[0051] In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0052] Embodiment 1:

[0053] Embodiment 1 of the present invention provides a communication method for multiple nodes on an RS485 bus, such as Figure 1 As shown, the method flow includes:

[0054] In step 101, a linked list code is configured on each node according to a preset order, wherein the linked list code is the address code of the next node that obtains the right to use the bus.

[0055] In this embodiment, the node represents a host node and a slave node, and the bus usage right refers to the right to use the RS485 bus. Regardless of whether the host node or the slave node obtains the bus usage right, the node can be regarded as a temporary host and has the function of actively sending and receiving data with other nodes.

[0056] In this embodiment, in order to realize the function of sending and receiving communication data between each node, the bus usage rights are transferred between each node, thereby realizing the sending and receiving of communication data of each node. The preset order is the order of transferring the bus usage rights between each node. The preset order is set by technical personnel in this field according to actual conditions.

[0057] In this embodiment, in order to facilitate the acquisition of information of each node and the transfer of bus usage rights, each node is configured with an address code, which is the unique identifier of each node. Each node is also configured with a linked list code, which is the address code of the next node of the node in the preset order.

[0058] In step 102, the master node writes its own linked list code into the transfer message, and sends all transfer messages to all slave nodes.

[0059] In this embodiment, in the initial stage, each node needs to be initialized first, so that each node enters the preparation state. The preparation state includes: establishing and initializing various functional parameters of each node, allowing each slave node to enter the message receiving state, and the initial bus usage rights are transferred from the master node. The linked list code of the master node corresponds to the address code of the slave node next to the master node in the preset sequence. The transfer message is used to transmit the transfer information of bus usage rights to each node. The transfer message has the following properties:

[0060] (1) Group call nature, that is, when a node sends a transfer message, all nodes except this node (including the host node) will receive the transfer message.

[0061] (2) The data volume is small, that is, the transfer message occupies a small amount of bus communication bandwidth. Compared with the existing communication data transmission and reception between nodes through polling, the data volume of the message required for polling is much larger than the transfer message in this embodiment. At the same time, the data volume of the transfer message is relatively smaller, so that there is more space for the transmission and reception of communication data between each node.

[0062] In this embodiment, the transfer message includes the address code of the current communication node and the linked list code of the node that issued the transfer message. Take the following specific transfer message as an example: 0xEB 0x0A 0x0B; where 0xEB is the message data header, 0x0A is the address code of the node that issued the transfer message, and 0x0B is the linked list code of the node that issued the transfer message.

[0063] In step 103, among all the slave nodes that have received the transfer message, the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus usage right and serves as a communication node. After the communication node completes its own communication needs, it writes the linked list code of the communication node into a new transfer message, and sends the new transfer message to all other nodes. The slave node whose address code is consistent with the linked list code in the new transfer message is used as the new communication node to transfer the bus usage right to the corresponding node in sequence.

[0064] Repeat step 103 until all communication requirements of the slave nodes are processed.

[0065] In this embodiment, after each node receives the transfer message, it compares the linked list code in the transfer message with its own address code. Since the address code is unique, there is only one node among all the nodes whose address code is consistent with the linked list code in the current transfer message. When the address code of the node is consistent with the linked list code in the transfer message, the node automatically obtains the right to use the bus, that is, the communication node.

[0066] In this embodiment, since some nodes have communication needs and need to send and receive communication data to other nodes, while some nodes do not have communication needs and do not need to send and receive communication data to other nodes, the communication configuration is used to record the above information, namely: whether communication data needs to be sent and received, and if so, the specific content of the communication data, as well as the node object that needs to transmit the data. The processing includes: when a node needs to send and receive communication data, the corresponding communication data is transmitted; when a node does not need to send and receive communication data, the communication data does not need to be transmitted. When the node's communication needs are processed, the bus usage rights can be transferred to the next node in a preset order. Therefore, a new transfer message needs to be generated and sent to all other nodes. This cycle repeats until all nodes have transferred the bus usage rights to ensure that the transmission and reception of communication data required by all nodes are processed.

[0067] If an existing slave node wants to send information to a master node or other slave nodes, it can only wait for the master to send query information to each slave node one by one through polling. Each query requires sending query information back and forth between the slave node and the master node. When the slave node is found to have information transmission and reception requirements, the host node receives or forwards the relevant message, resulting in a large amount of time wasted, resulting in poor real-time data performance and slow response time. In the method provided in this embodiment, the bus usage rights are transferred between the various slave nodes. When a slave node with information transmission and reception requirements obtains the bus usage rights, the slave node can directly transmit and receive information as a temporary master without relying on the master node for querying and forwarding, greatly improving the real-time performance and response speed of the data.

[0068] In actual application scenarios, when the transfer message is sent to all other nodes, the time at which each node receives the transfer message varies. During a round of transfer message transmission, a slave node may have received the transfer message first and obtained the right to use the bus and become a communication node, but other slave nodes have not yet received the transfer message. At this time, if the communication node directly sends and receives communication data with the slave node that has not yet received the transfer message, the transfer message and communication data will exist on the bus at the same time. If multiple data are transmitted on the bus at the same time, conflicts and interference will occur, leading to problems in data transmission. In order to more clearly illustrate the above problem, the following example is used to illustrate:

[0069] This example includes 1 host node and 10 slave nodes. When the 5th slave node acts as a communication node and completes its own communication needs, it sends a transfer message to 1 host node and the other 9 slave nodes. According to the preset order, the 6th slave node is the next communication node. However, since each slave node obtains the transfer message at different times, the 6th slave node obtains the transfer message relatively faster, while the 8th slave node has not yet obtained the transfer message. If the 6th slave node acts as a communication node and has communication needs with the 8th slave node at this time, it needs to send data to the 8th slave node. Then, the behavior of the 6th slave node sending data to the 8th slave node will conflict and interfere with the transfer message that the 8th slave node has not yet received, resulting in data transmission problems.

[0070] Therefore, in order to avoid the above problems, the following designs are also involved:

[0071] In step 201, when the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus use right and becomes a communication node, after a preset delay time, the communication node determines whether it needs to send and receive communication data based on its own communication needs.

[0072] In this embodiment, the preset delay time is set by a person skilled in the art. The preset delay time is used to ensure that even if a slave node has obtained the right to use the bus, all remaining slave nodes have enough time to receive the transfer message and then send and receive communication data, so as to avoid interference and conflict between the transfer message reception of other slave nodes and the data transmission and reception of communication nodes.

[0073] Furthermore, in the existing communication mode, the slave node can only act as a receiving end and reply, and cannot actively send information to other nodes. It can only rely on the host to actively send information to the slave node first, and the slave node will then reply. In this embodiment, when the slave node obtains the right to use the bus, the slave node can act as a temporary host and can directly interact with other nodes for data without forwarding through the host node, thereby realizing direct point-to-point data transmission between slave nodes, greatly improving the data transmission efficiency between nodes, such as Figure 2 As shown, this embodiment also involves the following designs:

[0074] In step 202, if the communication node needs to send and receive communication data, the communication node obtains information of all opposite nodes according to its own communication needs.

[0075] In this embodiment, the opposite node is the object node to which the communication node needs to send and receive data.

[0076] In step 203, the communication node sends communication data to the opposite node according to the acquired information of the opposite node.

[0077] In step 204, after receiving the communication data, the counterpart node sends reply data to the communication node.

[0078] Furthermore, in this embodiment, since some slave nodes need to transmit and receive communication data, while some slave nodes do not, these slave nodes that do not need to transmit and receive communication data may also receive the transfer message first and become communication nodes. If these communication nodes directly send the transfer message for the next round, they will cause interference conflicts with slave nodes that have not received the transfer message in the previous round. To more clearly illustrate the above problem, the following example is used for illustration:

[0079] This example includes 1 host node and 10 slave nodes. When the 7th slave node acts as a communication node and completes its own communication needs, it sends a transfer message to 1 host node and the other 9 slave nodes. According to the preset order, the 8th slave node is the next communication node. The 8th slave node obtains the transfer message relatively faster, while the 10th slave node has not yet obtained the transfer message. The communication needs of the 8th slave node do not require data transmission with other slave nodes. If the 8th slave node directly sends a transfer message to all other nodes at this time, the bus will simultaneously transmit the transfer message of this round (i.e., the transfer message from the 8th slave node) and the transfer message of the previous round (i.e., the transfer message from the 7th slave node), resulting in the existence of two transfer messages on the bus, which will cause conflict and interference, resulting in problems in data transmission.

[0080] Therefore, this embodiment also involves the following designs:

[0081] Among all the slave nodes that have obtained the transfer message, the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus use right and serves as a communication node. After the communication node completes its own communication needs, it writes the linked list code of the communication node into a new transfer message, further comprising:

[0082] When a slave node whose address code is consistent with the linked list code in the transfer message obtains the right to use the bus and becomes a communication node, if the communication node determines that it does not need to send or receive communication data based on its own communication needs, then after a preset delay time, the linked list code of the communication node is written into a new transfer message, and the new transfer message is sent to all other nodes.

[0083] In this embodiment, the preset delay time is set by those skilled in the art. The preset delay time is used to ensure that even if a slave node has obtained the right to use the bus, all remaining slave nodes have enough time to receive the transfer message and then send the next round of transfer messages, so as to avoid interference and conflict between the reception of the previous round of transfer messages and the reception of the next round of transfer messages.

[0084] Furthermore, considering that there are a large number of slave nodes, in actual application, slave nodes may be abnormal. When an abnormality occurs, the slave node may not be able to perform normal reception and reply as a receiving end. When obtaining the right to use the bus, it is also impossible to send transfer messages and receive and send communication data as a temporary master. Therefore, when an abnormal slave node obtains the right to use the bus, it is necessary to promptly discover and skip the node to avoid the node being unable to send transfer messages, resulting in stagnation of the transfer of bus use rights, and affecting the progress of the entire data transmission. In order to avoid the above situation, it is first necessary to monitor all slave nodes that have obtained the right to use the bus in real time through the master node. This embodiment also involves the following designs:

[0085] Each time the master node receives the new transfer message, it obtains the address code of the current communication node according to the address code in the new transfer message, and obtains the transfer progress of the bus usage right between each slave node according to the address code of the current communication node and the preset order.

[0086] In this embodiment, the preset order is pre-stored in the host node. By comparing the address code of the current communication node in each received transfer message with the preset order, the information of the slave node that currently obtains the right to use the bus and the progress of the transfer of the bus use rights are obtained. This is used to timely know the information of the slave node where the abnormality is currently occurring when an abnormality is subsequently discovered in the slave node.

[0087] Furthermore, it is necessary to set corresponding judgment criteria for the abnormality of the slave node so as to perform corresponding processing. Therefore, this embodiment also involves the following designs, such as Figure 3 As shown:

[0088] In step 301, the time starts every time the host node obtains the new transfer message.

[0089] In step 302, if the host node obtains the next transfer message within the preset timeout period, it is determined that the communication node corresponding to the next transfer message is normal, and the host node restarts the timing.

[0090] In step 303, if the host node fails to obtain the next transfer message within the preset timeout period, it is determined that the communication node corresponding to the linked list code in the new transfer message has failed; the host node obtains the next slave node after the communication node according to the preset order, and transfers the bus usage right to the next slave node.

[0091] In this embodiment, the preset timeout limit is set by those skilled in the art. The preset timeout limit is used for the host node to wait for the slave node that obtains the right to use the bus to send a transfer message. If the transfer message is received within the preset timeout limit, it means that there is no abnormality in the slave node (i.e., the communication node) that currently obtains the right to use the bus. If the transfer message is not received within the preset timeout limit, it means that there is an abnormality in the slave node (i.e., the communication node) that currently obtains the right to use the bus.

[0092] Furthermore, in this embodiment, when the master node detects that the slave node (ie, the communication node) that has obtained the bus usage right has an abnormality, the master node will transfer the bus usage right to the next slave node in the preset order by the following method, such as Figure 4 As shown, the method flow includes:

[0093] In step 401, when the master node determines that the slave node corresponding to the linked list code in the new transfer message fails, the master node obtains the bus use right.

[0094] In step 402, the master node generates a temporary transfer report according to the address code of the next slave node of the failed slave node in the preset sequence.

[0095] In step 403, the master node sends the temporary right transfer message to all slave nodes via the bus usage right.

[0096] In step 404, the slave node having the fault obtains the right to use the bus from the next slave node in the preset order.

[0097] In this embodiment, in order to more clearly illustrate the above method, the following examples are given for explanation:

[0098] The default order is [……,0xAA,0xAB,0xAC,0xAD,……];

[0099] The corresponding transfer message generated by the previous slave node 0xAB is: 0xEB 0xAB 0xAC;

[0100] The current slave node 0xAC has an exception, and the transfer message is lost abnormally;

[0101] When the master node does not receive the transfer message within the preset timeout period, the master node 0xAA automatically obtains the bus usage right and generates a temporary transfer message, which is: 0xEB 0xAA 0xAD. The slave node 0xAC with the abnormality is skipped and the slave node 0xAD next to the slave node 0xAC in the preset order is transferred to the slave node 0xAD, so that data communication continues to be executed in the preset order.

[0102] like Figure 5 and Figure 6 1 and 2 are a schematic block diagram and a flow chart of a multi-node communication method on an RS485 bus provided in this embodiment.

[0103] It is worth mentioning that when a new slave node needs to be added, the information of the new slave node to be added will be updated to the preset order, the linked list code of the upper-level slave node corresponding to the new slave node will be changed to the address code of the new slave node, and the linked list code of the new slave node will be configured as the address code of the next-level slave node; when a specified slave node needs to be removed, the information of the specified slave node to be removed will be removed from the preset order, and the linked list code of the upper-level slave node corresponding to the new slave node will be changed to the address code of the next-level slave node.

[0104] In summary, this embodiment achieves the following technical effects through the above method:

[0105] The communication nodes on the RS485 bus, including the master node and the slave node, will automatically obtain the right to use the bus in a preset order, and complete the sending and receiving of communication data in real time and point-to-point, realizing efficient and fast communication of RS485 bus data.

[0106] The master node only intervenes to control communication when a slave node experiences an abnormality. This frees up the RS485 communication bandwidth from the original "master-slave - question-and-answer" model, reducing the communication burden on the bus and improving the communication bandwidth utilization of the RS485 bus.

[0107] Example 2:

[0108] like Figure 7 FIG. 2 is a schematic diagram of a multi-node communication device on an RS485 bus according to an embodiment of the present invention. The multi-node communication device on an RS485 bus according to this embodiment includes one or more processors 41 and a memory 42 .

[0109] The processor 41 and the memory 42 may be connected via a bus or other means. Figure 7 The bus connection is taken as an example.

[0110] The memory 42 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs and non-volatile computer executable programs, such as the multi-node communication method on the RS485 bus in the above embodiment. The processor 41 executes the multi-node communication method on the RS485 bus by running the non-volatile software programs and instructions stored in the memory 42.

[0111] The memory 42 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some embodiments, the memory 42 may optionally include a memory remotely located relative to the processor 41, and such remote memory may be connected to the processor 41 via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0112] The program instructions / modules are stored in the memory 42 and, when executed by the one or more processors 41, execute the multi-node communication method on the RS485 bus in the above embodiment, for example, execute the above described Figures 1-6 The steps shown.

[0113] An embodiment of the present invention further provides a computer storage medium having computer program instructions stored thereon; when the computer program instructions are executed by a processor, the multi-node communication method on the RS485 bus provided by the embodiment of the present invention is implemented.

[0114] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A communication method for multiple nodes on an RS485 bus, characterized in that: include: Configure a linked list code on each node according to a preset order, wherein the linked list code is the address code of the next node to obtain the right to use the bus; The master node writes its own linked list code into the transfer message and sends all transfer messages to all slave nodes; Among all the slave nodes that have received the transfer message, the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus usage right and serves as a communication node. After the communication node completes its own communication needs, it writes the linked list code of the communication node into a new transfer message, and sends the new transfer message to all other nodes. The slave node whose address code is consistent with the linked list code in the new transfer message is used as the new communication node to transfer the bus usage right to the corresponding node in turn.

2. the communication method of multi-node on RS485 bus according to claim 1, is characterized in that, Among all the slave nodes that have received the transfer message, the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus use right and serves as a communication node. After the communication node completes its own communication needs, it writes the linked list code of the communication node into a new transfer message, specifically including: When the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus use right and becomes a communication node, after a preset delay time, the communication node determines whether it needs to send or receive communication data according to its own communication needs; If the communication node needs to send or receive communication data, the communication node obtains information of all peer nodes according to its own communication needs; The communication node sends communication data to the opposite node according to the acquired information of the opposite node; After receiving the communication data, the opposite node sends reply data to the communication node.

3. the communication method of multi-node on RS485 bus according to claim 2, is characterized in that, Among all the slave nodes that have obtained the transfer message, the slave node whose address code is consistent with the linked list code in the transfer message obtains the bus use right and serves as a communication node. After the communication node completes its own communication needs, it writes the linked list code of the communication node into a new transfer message, further comprising: When a slave node whose address code is consistent with the linked list code in the transfer message obtains the right to use the bus and becomes a communication node, if the communication node determines that it does not need to send or receive communication data based on its own communication needs, then after a preset delay time, the linked list code of the communication node is written into a new transfer message, and the new transfer message is sent to all other nodes.

4. the communication method of multi-node on RS485 bus according to claim 1, is characterized in that, When a new slave node needs to be added, the information of the new slave node to be added is updated to the preset order; The step of configuring the linked list code on each node in a preset order further includes: The linked list code of the upper-level slave node corresponding to the new slave node is changed to the address code of the new slave node, and the linked list code of the new slave node is configured as the address code of the slave node of the next level.

5. the communication method of multi-node on RS485 bus according to claim 1, is characterized in that, The transfer message includes: an address code of a node that sends the transfer message and a linked list code of the node that sends the transfer message.

6. the communication method of multi-node on RS485 bus according to claim 5, is characterized in that, The step of writing the linked list code of the communication node into a new transfer message and sending the new transfer message to all other nodes further includes: Each time the master node receives the new transfer message, it obtains the address code of the current communication node according to the address code in the new transfer message, and obtains the transfer progress of the bus usage right between each slave node according to the address code of the current communication node and the preset order.

7. the communication method of multi-node on RS485 bus according to claim 6 is characterized in that, The step of writing the linked list code of the communication node into a new transfer message and sending the new transfer message to all other nodes further includes: The timing starts every time the host node obtains the new transfer message; If the host node obtains the next transfer message within the preset timeout period, it is determined that the communication node corresponding to the next transfer message is normal, and the host node restarts the timing; If the host node fails to obtain the next transfer message within a preset timeout period, it is determined that the communication node corresponding to the linked list code in the new transfer message is faulty; The master node acquires the next slave node after the communication node according to the preset order, and transfers the bus use right to the next slave node.

8. the communication method of multi-node on RS485 bus according to claim 7 is characterized in that, The master node acquires the next slave node after the communication node according to the preset order, and transfers the bus use right to the next slave node, specifically including: When the host node determines that the communication node corresponding to the linked list code in the new transfer message fails, the host node obtains the bus use right; The master node obtains the next slave node after the communication node according to the preset sequence, uses the address code of the next slave node as the linked list code, and generates a temporary transfer report; The master node sends the temporary right transfer message to all slave nodes to transfer the bus use right to the next slave node.

9. A multi-node communication device on an RS485 bus, characterized in that: The invention comprises at least one processor and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to execute the communication method for multiple nodes on the RS485 bus according to any one of claims 1 to 8.

10. A non-volatile computer storage medium, characterized in that The computer storage medium stores computer program instructions, which, when executed by one or more processors, implement the multi-node communication method on the RS485 bus according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Monitoring system for disaster prevention lighting

    JP2005032115A

  • Host / slave device control method and control system, and blood cabinet

    WO2023279910A1