Communication method and device for multiple nodes on RS485 bus

By configuring the linked list code and the transfer packet mechanism on the RS485 bus, the problem of real-time data and low response speed in multi-node RS485 communication is solved, and the temporary host function of the slave node is realized, which improves communication efficiency.

CN119449519AActive Publication Date: 2025-02-14ZHONGKE KUYUAN TECH (WUHAN) CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In multi-node RS485 communication, the prior art leads to poor real-time data and slow response time, mainly because in half-duplex communication mode, nodes can only send and receive information after the host polls, resulting in wasted time.

Method used

By configuring the linked list code on each node, the host node writes its own linked list code into the transfer packet and sends it to all slave nodes. The slave node whose address code is consistent with the linked list code in the transfer packet is obtained by using the bus. As a communication node, after completing the communication requirements, write the linked list code to a new transfer packet, and gradually transfer the bus usage rights to the next node.

Benefits of technology

This method greatly improves the real-time and response speed of data, avoids polling, querying and forwarding by host nodes, and allows slave nodes to directly transmit and receive information as temporary hosts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119449519A_ABST
    Figure CN119449519A_ABST
Patent Text Reader

Abstract

The invention provides a communication method and device for multiple nodes on an RS485 bus. The method comprises the following steps: configuring a linked list code on each node according to a preset sequence; the host node writes a linked list code of the host node into a weight shifting message and sends all the weight shifting messages to all the slave nodes, the slave nodes of which the address codes are consistent with the linked list codes in the weight shifting messages obtain the bus use right and serve as communication nodes, and after the communication nodes complete the communication requirements of the communication nodes, the communication nodes send the bus use right to the host node. The link table code of the communication node is written into a new shift right message, the new shift right message is sent to all other nodes to obtain a new communication node, and the above steps are repeated until the communication requirements of all slave nodes are completely completed; the bus use right is transferred to each slave node, so that the slave nodes serve as temporary hosts to directly transmit and receive information, query and forwarding do not need to be performed by relying on host nodes, and the real-time performance and the response speed of data are greatly improved.
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 communication method and device for multiple nodes on an RS485 bus. Background Art

[0002] RS485 bus is the internal communication standard between programmable logic controllers commonly used in industrial environments. It adopts half-duplex working mode and supports multi-point data communication. The protocol based on RS485 bus is mainly question-and-answer polling protocol.

[0003] The half-duplex communication mode requires that there can only be one data transmitter at the same time, and other nodes can only serve as receivers. This results in that in the RS485 communication including multiple nodes, if the slave node wants to send information to the host node or other slave nodes, it can only wait for the host 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 host node. When the query finds that the slave node has information transmission and reception requirements, the host receives or forwards the relevant message, resulting in a lot of time waste, 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 the field of this technology. 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 solution:

[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 that obtains 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 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. The slave node whose address code is consistent with the linked list code in the new transfer message is used as a new communication node to transfer the bus use right to the corresponding nodes in turn.

[0011] Preferably, among all the slave nodes that obtain the transfer message, the 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, the linked list code of the communication node is written 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 right transfer message obtains the right to use the bus and becomes a communication node, after a preset delay time, the communication node determines whether it needs to send and receive communication data according to its own communication needs;

[0013] If the communication node needs to send and 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 counterpart node sends reply data to the communication node.

[0016] Preferably, among all the slave nodes that obtain the transfer message, the 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, the linked list code of the communication node is written 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 acts as 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 next-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 code of the upper-level slave node and the linked list code of the next-level slave node corresponding to the designated slave node are synchronously changed.

[0020] Preferably, 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.

[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 host 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 rights 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 each 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 the 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 host node acquires the next slave node after the communication node according to the preset sequence, and transfers the bus use right to the next slave node.

[0028] Preferably, the host 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 right transfer message fails, the host node acquires the right to use the bus;

[0030] The host node acquires 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 host 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 communication device for multiple nodes 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 communication method for multiple nodes 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 the memory from a memory to execute the method of the first aspect.

[0035] According to a fifth aspect, a computer program product comprising instructions is provided. When the instructions are executed on a computer or a processor, the computer or the processor executes the method according to 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 bus use right and serves as a communication node. After the communication node completes its own communication needs, 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 to obtain a new communication node. The above steps are repeated until the communication needs of all slave nodes are completed. By transferring the bus use right to each slave node, the slave node is used as a temporary host to directly send and receive information without relying on the host node for query and forwarding, which greatly improves the real-time performance and response speed of data. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order 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, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0039] Figure 1 It is a method flow chart of a communication method for multiple nodes on an RS485 bus provided by an embodiment of the present invention;

[0040] Figure 2 It is a method flow chart of sending and receiving communication data of a communication node in a communication method of multiple nodes on an RS485 bus provided by an embodiment of the present invention;

[0041] Figure 3 It is a flow chart of a method for a host node to determine 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 It 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 communication method for multiple nodes on an RS485 bus provided by an embodiment of the present invention;

[0044] Figure 6 It is a method flow chart of a communication method for multiple nodes 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 solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with 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 is necessary to understand that the terms "center", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present disclosure and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present disclosure.

[0048] In the description of the present invention, the terms "first" and "second" are used only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. 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, the meaning of "multiple" is two or more. In addition, for example, the same type of nouns may be described as two independent individuals by adding "A" and "B" at the end. In this case, the corresponding features defined as "A" and "B" are only used to distinguish the same type of individuals for description purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features.

[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 open inclusion, that is, "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "examples", "specific examples" or "some examples" and the like are intended to indicate that 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 an address code of a node that is to obtain the right to use the bus next time.

[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. No matter 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 right transfer message, and sends all the right 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, and 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 use right is transferred from the host node. The linked list code of the host node corresponds to the address code of the next slave node of the host node in the preset order. The transfer message is used to transmit the transfer information of the bus use right to each node, and 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) Small data volume, 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 sends 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 sends the transfer message, and 0x0B is the linked list code of the node that sends the transfer message.

[0063] In step 103, 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 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. The slave node whose address code is consistent with the linked list code in the new transfer message is used as a new communication node to transfer the bus use right to the corresponding nodes in turn.

[0064] The above step 103 is repeated until the communication requirements of all slave nodes are completely 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 it is necessary to send and receive communication data, if necessary, it also includes the specific content of the communication data, and the node object that needs to transmit data. The processing includes: when the node needs to send and receive communication data, the corresponding communication data is transmitted, and when the node does not need to send and receive communication data, there is no need to transmit communication data. When the communication demand of the node is processed, the bus use right can be transferred to the next node in a preset order, so it is necessary to generate a new transfer message and send it to all other nodes, and this cycle is repeated until all nodes have been transferred the bus use right to ensure that the communication data required by all nodes are processed and received.

[0067] If the existing slave nodes want to send information to the host node or other slave nodes, they can only wait for the host 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 host node. When the slave node is found to have information transmission and reception requirements, the host receives or forwards related messages, resulting in a large amount of time waste, resulting in poor real-time data and slow response time. In the method provided in this embodiment, the bus use right is transferred between each slave node. When a slave node with information transmission and reception requirements obtains the bus use right, the slave node can directly transmit and receive information as a temporary host without relying on the host node for query and forwarding, which greatly improves the real-time data and response speed.

[0068] In actual application scenarios, when the transfer message is sent to all other nodes, the transfer messages are received by each node at different times. In the process of sending a round of transfer messages, it may happen that a slave node has received the transfer message first and obtained the right to use the bus and become a communication node, but other slave nodes have not received the transfer message. At this time, if the communication node directly sends and receives communication data with the slave node that has not 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, resulting in problems with data transmission. In order to more clearly demonstrate 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, and 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 problems in data transmission.

[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 right transfer message obtains the right to use the bus and becomes a communication node, after a preset delay time, the communication node determines whether it needs to send and receive communication data according to its own communication needs.

[0072] In this embodiment, the preset delay time is set by technical personnel in this field. 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 right transfer message and then send and receive communication data, so as to avoid interference and conflict between the right 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 or receive communication data, the communication node obtains information of all peer 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 send and receive communication data, and some slave nodes do not need to send and receive communication data, these slave nodes that do not need to send and receive communication data may also receive the transfer message first and become communication nodes. If the communication node directly sends the next round of transfer messages, it will cause interference conflicts with the slave nodes that have not received the transfer message in the previous round. In order to more clearly demonstrate the above problem, the following example is used for explanation:

[0079] This example includes 1 host node and 10 slave nodes, where 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 acts as the communication node next. 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 the 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 conflicts 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 right to use the bus and serves as a communication node. After the communication node completes its own communication needs, the linked list code of the communication node is written 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 acts as 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 technical personnel in this field. 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 right transfer message and then send the next round of right transfer messages, so as to avoid interference and conflict between the reception of the previous round of right transfer messages and the reception of the next round of right transfer messages.

[0084] Furthermore, considering that there are a large number of slave nodes, in the actual application process, the 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 the bus use right is obtained, it is also impossible to send the transfer message and send and receive communication data as a temporary host. Therefore, when an abnormal slave node obtains the bus use right, it is necessary to discover it in time and skip the node to avoid the node being unable to send the transfer message, resulting in the stagnation of the transfer of the bus use right 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 bus use right in real time through the host node. This embodiment also involves the following designs:

[0085] Each time the host 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 rights 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 that currently has the abnormality 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 timing starts each 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 a fault; the host node obtains the next slave node after the communication node according to the preset order, and transfers the bus usage rights to the next slave node.

[0091] In this embodiment, the preset timeout limit is set by a technician in this field. 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 host node detects that the slave node (i.e., the communication node) that obtains the bus usage right is abnormal, the host 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 host node determines that the slave node corresponding to the linked list code in the new right transfer message fails, the host node acquires the right to use the bus.

[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 through the bus usage right.

[0096] In step 404, the failed slave node 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 demonstrate the above method, the following examples are listed here 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 abnormality, and the transfer message is abnormally lost;

[0101] When the host node fails to receive the transfer message within the preset timeout period, the host node 0xAA automatically obtains the right to use the bus, and the host node 0xAA generates a temporary transfer message, wherein the temporary transfer message is: 0xEB 0xAA 0xAD, wherein the abnormal slave node 0xAC is skipped and switched to the next slave node 0xAD after the slave node 0xAC in the preset order, so that data communication continues to be executed in the preset order.

[0102] like Figure 5 and Figure 6 , which are respectively a schematic block diagram and a method 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 is updated to the preset order, 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 next-level slave node; when a specified slave node needs to be removed, the information of the specified slave node to be removed is removed from the preset order, and the linked list code of the upper-level slave node corresponding to the new slave node is 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 host node and the slave node, will automatically obtain the right to use the bus in a preset order, complete the sending and receiving of communication data in real time and point-to-point, and realize efficient and fast communication of RS485 bus data.

[0106] The master node will intervene in the communication control only when the slave node is abnormal. As a result, the RS485 communication bandwidth will be freed from the original "master-slave-question-answer" mode, reducing the communication burden of the bus and improving the communication bandwidth utilization of the RS485 bus.

[0107] Embodiment 2:

[0108] like Figure 7 FIG. 2 is a schematic diagram of a communication device for multiple nodes on an RS485 bus according to an embodiment of the present invention. The communication device for multiple nodes 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 example of connecting through bus is taken in the following.

[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 communication method for multiple nodes on the RS485 bus in the above embodiment. The processor 41 executes the communication method for multiple nodes on the RS485 bus by running the non-volatile software programs and instructions stored in the memory 42.

[0111] The memory 42 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 42 may optionally include a memory remotely arranged relative to the processor 41, and these remote memories may be connected to the processor 41 via a network. Examples of the above-mentioned network 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, the communication method of multiple nodes on the RS485 bus in the above embodiment is executed, for example, the above described Figure 1-Figure 6 The steps shown.

[0113] The embodiment of the present invention further provides a computer storage medium, on which computer program instructions are stored; 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 protection scope of the present invention.

Claims

1. A communication method for multiple nodes on 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 that obtains 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 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. The slave node whose address code is consistent with the linked list code in the new transfer message is used as a new communication node to transfer the bus use right to the corresponding nodes in turn.

2. The communication method of multiple nodes on the RS485 bus according to claim 1, wherein 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 right to use the bus and serves as a communication node. After the communication node completes its own communication needs, the linked list code of the communication node is written into a new transfer message, specifically including: When the slave node whose address code is consistent with the linked list code in the right transfer message obtains the right to use the bus and becomes a communication node, after a preset delay time, the communication node determines whether it needs to send and receive communication data according to its own communication needs; If the communication node needs to send and 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 counterpart node sends reply data to the communication node.

3. The communication method of multiple nodes on the RS485 bus according to claim 2, 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 right to use the bus and serves as a communication node. After the communication node completes its own communication needs, the linked list code of the communication node is written 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 acts as 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 multiple nodes on the RS485 bus according to claim 1, wherein 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 also 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 multiple nodes on RS485 bus according to claim 1, wherein 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 multiple nodes on the RS485 bus according to claim 5, 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 host 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 rights between each slave node according to the address code of the current communication node and the preset order.

7. The communication method of multiple nodes on the RS485 bus according to claim 6, 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 each 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 the preset timeout period, it is determined that the communication node corresponding to the linked list code in the new transfer message is faulty; The host node acquires the next slave node after the communication node according to the preset sequence, and transfers the bus use right to the next slave node.

8. The communication method of multiple nodes on the RS485 bus according to claim 7, characterized in that, The host node acquires the next slave node after the communication node according to the preset sequence, 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 right transfer message fails, the host node acquires the right to use the bus; The host node acquires 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 host 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: It includes 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 communication method for multiple nodes on the RS485 bus as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Real-time multi-path multiplexing synchronous high-speed transmission serial bus protocol

    CN101459675A

  • Intelligent illumination bus system and control method thereof

    CN101742774A

  • Method for using special frame to control sending by nodes on RS485 bus

    CN104168168A

  • Switching method and system for main controller in multi-controller storage device

    CN112100007A

  • Point-to-multipoint underwater acoustic instant messaging system

    CN115103003A