A Ring-shaped CAN Bus Communication Method Based on Network Timing Arbitration
By designing session messages in the ring CAN bus network, the bus timing arbitration and resource allocation unbalanced problems when the number of nodes exceeds three is solved, the node communication frequency is consistent and the integrity and timeliness of network communication is achieved, the development difficulty and cost are reduced, and the single point failure risk of network center nodes is avoided.
Patent Information
- Application Number
- CN202310550464.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-16
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2043-05-16
AI Technical Summary
When the number of nodes in the ring CAN bus network exceeds three, there are problems of bus timing arbitration and unbalanced resource allocation, resulting in inconsistent communication frequency, untimely information exchange and waste of resources. The existing solutions have high development difficulties, high cost and network reliability.
Design a session message. All ring CAN bus network nodes can receive and send the message to differentiate the session state, ensure that the communication frequency of each node is consistent, and adopt a unified communication program design to avoid central nodes and reduce network complexity and equipment costs.
The communication frequency of each node is consistent, ensuring the integrity and timeliness of network communication, reducing development difficulty and cost, avoiding the risk of network paralysis, and improving resource utilization.
Smart Images

Figure CN116527441B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technologies, and more particularly, to a ring-shaped CAN bus communication method based on network timing arbitration. Background Art
[0002] A ring-shaped CAN bus network specifically refers to a CAN bus networking form in which the number of communication nodes on the network is more than three and the status of each node is the same, and interactive communication can occur between each node. The simplest three-node ring-shaped CAN bus network structure is as Figure 1-2 shown. The bus timing allocation and resource control for the CAN bus network to ensure normal communication between each node and balanced resource occupancy are called the timing arbitration of the CAN bus.
[0003] When the number of nodes on the CAN bus network exceeds three, there are problems of bus timing arbitration and allocation. Due to the half-duplex working characteristic of the CAN bus, it is determined that only a single message can be transmitted on the bus at a certain moment. This is like a group of people having a remote meeting and sharing a set of speaking systems. Only one person can speak at a certain moment, otherwise there will be chaos. The special nature of the ring-shaped CAN bus network that each node needs to communicate with each other determines that the requirements for bus timing arbitration are higher. This is like every two participants in a remote meeting seeking to initiate a conversation. When A and B are talking, C cannot interrupt to speak, otherwise it will cause chaos, and reasonable time, order, and reasonable pairing are needed to avoid communication obstacles and speech conflicts. The actual communication situation is as Figure 1 shown. During the communication between nodes A and B, node C should avoid initiating communication, otherwise a bus conflict will occur, forming a bus blockage, just like a highway congestion, which will further affect subsequent communication, causing the communication failure counters of each node to overflow and triggering a fault program. When there are more nodes on the ring-shaped CAN bus network, this problem is more difficult and serious, and the timing arbitration of the CAN bus is more urgent and important.
[0004] The above problems are often encountered in the practice of the ring-shaped CAN bus network. Because each node on the bus is an independent system unit, they each work at their own clock frequencies, and the program timing and content they execute are also different. Each node will not be unified about when to initiate a conversation with which node on the bus. Therefore, the ring-shaped CAN bus network timing arbitration technology is essential and is an important technical topic in the field of communication technologies.
[0005] There is a relatively simple timing arbitration scheme for the ring-shaped CAN bus network, which is the time-division multiplexing polling scheme. That is, the timing of the CAN bus network is segmented. Only one pair of nodes starts a communication conversation at each moment, and all nodes are polled according to time periods. This is equivalent to the timed conversation mechanism in a remote meeting, where a fixed conversation time is allocated between every two participants, and it is executed according to a fixed order and schedule. After any two participants have completed their conversations, it loops from the beginning and so on. The advantage of this scheme is its simple structure and low cost. However, this scheme also has obvious deficiencies:
[0006] 1) Each node on the CAN bus is an independent system unit. They each work at their own clock frequencies, and the program timing and content they execute are also different. Therefore, the polling timing cannot be strictly unified. This is like the participants in a remote meeting calculating the polling timing according to their own schedules, and the timing standards and task situations of each participant are different, so it is difficult to achieve strict consistency. The result of this situation is that as the number of loops increases, this timing difference gradually accumulates and becomes larger and larger, and eventually time-sharing errors or polling conflicts are inevitable.
[0007] 2) Also for the above reasons, it will lead to another adverse effect: A node on a certain CAN bus network may fail to initiate a communication conversation in a timely manner because it is dealing with a higher-priority interrupt task. When this node completes the task and can initiate a communication conversation, it has already missed the specified segmented timing. As a result, this node misses one or several rounds of polling communication, leading to inconsistent communication frequencies among the nodes on the CAN bus network, and untimely and unequal information exchange, which will affect the stability and reliability of the entire system. This is like the situation in a remote meeting where some people can always talk and speak, while some people miss the opportunity to speak very little, resulting in others lacking information about those who speak very little.
[0008] 3) The time-division multiplexing polling scheme cannot achieve the highest utilization rate of the CAN bus timing resources. Some segmented timings may not have effective communication conversations, and there is a waste of CAN bus timing resources.
[0009] The existing relatively complex timing arbitration scheme for the ring-shaped CAN bus network is the master station control scheme, also known as the master-slave scheme. As the name implies, it is to set up a special node with CAN bus control function in the ring-shaped CAN bus network, generally called the master station node, and other nodes except the master station node are called slave station nodes. The master station node is equivalent to the host in a remote meeting. Each session of the remote meeting is initiated by the host. He can directly call a certain participant to have a conversation, or specify two participants to have a conversation. The host determines the communication frequency of all participants and the meeting time arrangement. In actual CAN bus network communication, the master station node controls the timing allocation on the CAN bus. It is the master station node that decides when to directly access which slave station node on the CAN bus for communication conversation or allows which two slave station nodes to communicate with each other. The master station node is responsible for the state control and timing allocation of the CAN bus. Each CAN communication can only be initiated and ended by the master station node, and the slave station nodes are not allowed to actively access the CAN bus. The advantage of this scheme is reliable communication and high efficiency. However, this scheme still has obvious deficiencies:
[0010] 1) It is necessary to separately design the communication program of the CAN bus master station node, which is different from the communication programs of other network nodes. Therefore, the communication programs between each network node cannot be unified, increasing the development difficulty and cost.
[0011] 2) The master station node needs to overall control and coordinate the entire ring-shaped CAN bus network. The reliability and efficiency of network communication both depend on the master station node. The master station node needs to control the CAN bus timing in real time, monitor all messages, send various instruction messages and session messages, monitor network anomalies and make handling, etc. These will occupy a large amount of resources of the master station node, resulting in a significant decline in the ability and efficiency of the master station node to execute other tasks except CAN bus communication. Therefore, in most cases, the master station node is separately added and set up, and no longer executes other tasks except CAN bus communication, which undoubtedly increases the complexity and equipment cost of the ring-shaped CAN bus network.
[0012] 3) The master station node is equivalent to the center of the entire ring-shaped CAN bus network. If the master station node fails or has an anomaly, it will cause the entire communication network to collapse, which is undoubtedly a huge hidden danger to the security and reliability of the entire ring-shaped CAN bus network. Summary of the Invention
[0013] In view of the deficiencies of the prior art, the present invention provides a ring-shaped CAN bus communication method based on network timing arbitration. The present invention specially designs a "session occurrence" message. All nodes of the ring-shaped CAN bus network distinguish the session state by receiving and sending this message, ensuring that the communication frequencies of each node of the ring-shaped CAN bus network are consistent, and ensuring the integrity and timeliness of network communication.
[0014] The technical means adopted by the present invention are as follows:
[0015] A ring CAN bus communication method based on network timing arbitration enables all ring CAN bus network nodes to receive and send session occurrence messages, each bit of the session occurrence message corresponds to the session occurrence state of a node, when the node corresponding logic value is 0, it means that the node fails to complete a communication dialogue, when the node corresponding logic value is 1, it means that the node completes a communication dialogue;
[0016] The method comprises the following steps:
[0017] S1, each node initializes the session occurrence message;
[0018] S2: The current node enters the listening state and starts receiving interrupts, receiving updated session occurrence messages pushed by other nodes and corresponding communication dialogue requests from other nodes at any time;
[0019] S3, determine whether a communication dialogue request for the node is received, if a communication dialogue request for the node is detected, respond to the communication dialogue request first, otherwise determine the content of the session occurrence message: if the corresponding bit logic value of the node is "1", execute S2, if the corresponding bit logic value of the node is "0", execute S4;
[0020] S4, the current node determines whether the current ring CAN bus network is in an idle state according to the monitoring feedback, and if it is in an idle state, it actively initiates a communication dialogue request to the CAN bus and sends addressing information;
[0021] S5. The current node determines whether the communication dialogue request is correctly responded to. If it is correctly responded to, the current node and the target node conduct a normal communication dialogue;
[0022] S6, determine whether the communication dialogue is completed, if not completed, execute S5, if completed, execute S7;
[0023] S7. Update the content of the session occurrence message and change the logic state of the corresponding bit of this node from "0" to "1".
[0024] Furthermore, the method further comprises:
[0025] S8. Determine whether the corresponding bit logic values of each node in the updated session occurrence message content are all "1". If they are all "1", rewrite the logic values of the corresponding bits of all nodes to "0". Otherwise, push the updated "session occurrence" message to the ring CAN bus network and execute S2.
[0026] Further, if a communication dialogue request for this node is detected, the communication dialogue request shall be preferentially responded to, including: this node executes communication response, exchanges data in real time, and executes S2 after a group of communication responses ends.
[0027] Further, the current node determines whether the current ring-shaped CAN bus network is in an idle state according to the listening feedback, and further includes: if it is not in an idle state, then execute S2.
[0028] Further, the current node determines whether the communication dialogue request is correctly responded to, and further includes that if it is not correctly responded to, the CAN bus shall be immediately relinquished and S2 shall be executed.
[0029] Further, each node initializes the session occurrence message, including: setting the logical values of the corresponding bits of all nodes to "0".
[0030] Compared with the prior art, the present invention has the following advantages:
[0031] 1. The present invention avoids the asynchronous network timing calculation and cumulative chaos caused by different working reference frequencies of each node in the ring-shaped CAN bus network.
[0032] 2. The present invention can ensure that the communication frequencies of each node in the ring-shaped CAN bus network are consistent, realizing the integrity and timeliness of network communication;
[0033] 3. The communication programs of all nodes in the ring-shaped CAN bus network of the present invention adopt the same set of design schemes, and there is no difference in the communication programs, reducing the development difficulty and cost.
[0034] 4. The present invention no longer separately sets up special nodes responsible for managing the ring-shaped CAN bus network, reducing the network complexity and equipment cost.
[0035] 5. The entire ring-shaped CAN bus network of the present invention has no central node, and the status of each node is the same. The functional loss of any node will not cause the paralysis of the entire network. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained according to these drawings without creative efforts.
[0037] Figure 1 It is a schematic diagram of the communication requirements of a three-node ring-shaped CAN bus network.
[0038] Figure 2 It is the topological structure of a three-node ring-shaped CAN bus network.
[0039] Figure 3 This is a flowchart of a ring CAN bus communication method based on network timing arbitration according to the present invention.
[0040] Figure 4 This is a schematic diagram of the message data structure in the session in the embodiment.
[0041] Figure 5 This is a flowchart of the communication program execution in the embodiment. Detailed implementation manners
[0042] In order to enable those skilled in the art of the present technology to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present invention.
[0043] As Figure 3 shown, the present invention provides a ring CAN bus communication method based on network timing arbitration, enabling all ring CAN bus network nodes to receive and send session occurrence messages. Each bit of the session occurrence message corresponds to the session occurrence status of a node. When the logical value corresponding to the node is 0, it means that the node fails to complete a communication conversation. When the logical value corresponding to the node is 1, it means that the node completes a communication conversation. The method includes the following steps:
[0044] S1. Each node initializes the session occurrence message, including setting the logical values of all bits corresponding to the nodes to "0".
[0045] S2. The current node enters the listening state and enables the reception interrupt to receive the updated session occurrence messages pushed by other nodes and the communication conversation requests of the corresponding other nodes at any time.
[0046] S3. Determine whether a communication conversation request for the current node is received. If a communication conversation request for the current node is detected, the communication conversation request is preferentially responded to, including the current node performing communication responses and exchanging data in real time. After a group of communication responses ends, S2 is executed. Otherwise, the content of the session occurrence message is judged: if the logical value of the corresponding bit of the current node is "1", S2 is executed; if the logical value of the corresponding bit of the current node is "0", S4 is executed.
[0047] S4. The current node judges whether the current ring CAN bus network is in an idle state according to the listening feedback. If it is in an idle state, a communication conversation request is actively sent to the CAN bus and addressing information is sent. If it is not in an idle state, S2 is executed.
[0048] S5. The current node determines whether the communication dialogue request is correctly responded. If it is correctly responded, the current node conducts a normal communication dialogue with the target node. If it is not correctly responded, the CAN bus is immediately relinquished and S2 is executed.
[0049] S6. Determine whether the communication dialogue is completed. If not, execute S5. If so, execute S7.
[0050] S7. Update the content of the session occurrence message, and rewrite the logical state of the corresponding bit of the current node from "0" to "1".
[0051] Furthermore, the method further includes:
[0052] S8. Determine whether the logical values of the corresponding bits of each node in the updated session occurrence message content are all "1". If they are all "1", rewrite the logical values of the corresponding bits of all nodes to "0". Otherwise, push the updated "session occurrence" message to the ring-shaped CAN bus network and execute S2.
[0053] The solutions and effects of the present invention are further described below through specific application examples.
[0054] In this embodiment, a "session occurrence" message is specifically designed, and all nodes in the ring-shaped CAN bus network receive and send this message. The design content is referred to Figure 4 , and each bit of this message is designated as the session occurrence status of a certain node in the ring-shaped CAN bus network: the logical value of the corresponding bit of the node that fails to complete a communication dialogue is "0", and the logical value of the corresponding bit of the node that completes a communication dialogue is "1". In normal operation, all nodes in the ring-shaped CAN bus network work in the listening mode after startup. If the logical value of the corresponding bit of the current node in the "session occurrence" message is "1", the current node is not allowed to send a communication dialogue request and can only respond to other nodes as an answer. If the logical value of the corresponding bit of the current node in the "session occurrence" message is "0", when the CAN bus is actively monitored to be in the idle state, a communication session request is sent. After the session ends, the logical value of the corresponding bit of the current node in the "session occurrence" message is rewritten to "1" and sent to the entire network. When the logical values of the corresponding bits of all nodes in the ring-shaped CAN bus network in the "session occurrence" message are all "1", it indicates that this round of communication is completed. The last node that rewrites the "session occurrence" message is responsible for clearing the logical values of all nodes in the "session occurrence" message to "0" again, and then sending it to the CAN bus to start the next round of communication. The execution flow of the communication program is as Figure 5 shown. Specifically, it includes:
[0055] At box 1, the program starts the communication task phase and executes the initialization content. The most important part is that the program presets the initial content of the "session occurrence" message corresponding to this ring CAN bus network.
[0056] At block 2, the program controls the node to enter a listening state and starts a receiving interruption so as to receive updated "session occurrence" messages pushed by other nodes and corresponding communication dialogue requests from other nodes at any time.
[0057] In block 3, it is determined whether a communication session request for the node is received. If a communication session request for the node is detected, the process goes to block 4; otherwise, the process goes to block 5.
[0058] At block 4, a corresponding response is made according to the communication dialogue request received from other nodes. At this time, the working state of this node is equivalent to the slave node state in the master-slave scheme, executing communication response and exchanging data in real time. When a group of communication responses is completed, return to block 2.
[0059] At block 5, the content of the "session occurred" message is determined. If the corresponding bit logic value of this node is "1", it means that a round of communication dialogue requirements have been completed, and the process returns to block 2; if the corresponding bit logic value of this node is "0", it means that the communication dialogue requirements have not been completed, and the process enters block 6.
[0060] At block 6, the program determines whether the current ring CAN bus network is in an idle state according to the monitoring feedback. If the result is no, it means that other communication dialogues are taking place on the CAN bus, and then returns to block 2; if the result is yes, then enters block 7.
[0061] At block 7, the program actively initiates a communication session request to the CAN bus and sends addressing information.
[0062] At block 8, the program determines whether the communication dialogue request is correctly responded to. If the conclusion is no, it means that there is no correct response: the reason may be that the CAN bus is preempted by other nodes faster and other communication dialogue requests have been issued, or the target node of the communication dialogue is temporarily busy and cannot respond immediately. In either case, the CAN bus should be given up immediately and enter block 2; if the result is yes, enter block 9.
[0063] At frame 9, the program controls this node to conduct normal communication dialogue with the object node. At this time, the working state of this node is equivalent to the master node state in the master-slave scheme, initiating a response, controlling the communication dialogue timing, and ending the response.
[0064] At block 10, it is determined whether the communication session is completed. If not, return to block 9; if yes, proceed to block 11.
[0065] At frame 11, update the content of the "Session Occurred" message, and rewrite the logical state of the corresponding bit of this node from "0" to "1".
[0066] At frame 12, judge the content of the updated "Session Occurred" message: whether the corresponding bit logical values of all the nodes in the ring-shaped CAN bus network are all "1". If the result is yes, it means that all the nodes in the ring-shaped CAN bus network have completed a communication dialogue, and this node is the last node to complete the communication dialogue in this round of polling, and enter frame 13; if the result is no, enter frame 14.
[0067] At frame 13, the program updates the "Session Occurred" message again, and rewrites the logical values of the corresponding bits of all nodes to "0", and enter frame 14.
[0068] At frame 14, push the updated "Session Occurred" message to the ring-shaped CAN bus network, and return to frame 2.
[0069] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A ring-shaped CAN bus communication method based on network timing arbitration, characterized in that, All the ring CAN bus network nodes receive and send session occurrence messages, each bit of the session occurrence message corresponds to the session occurrence state of a node, when the corresponding logic value of the node is 0, it means that the node fails to complete a communication dialogue, when the corresponding logic value of the node is 1, it means that the node completes a communication dialogue; The method comprises the following steps: S1, each node initializes the session occurrence message; S2: The current node enters the listening state and starts receiving interrupts, receiving updated session occurrence messages pushed by other nodes and corresponding communication dialogue requests from other nodes at any time; S3, determine whether a communication dialogue request for the node is received, if a communication dialogue request for the node is detected, respond to the communication dialogue request first, otherwise determine the content of the session occurrence message: if the corresponding bit logic value of the node is "1", execute S2, if the corresponding bit logic value of the node is "0", execute S4; S4, the current node determines whether the current ring CAN bus network is in an idle state according to the monitoring feedback, and if it is in an idle state, it actively initiates a communication dialogue request to the CAN bus and sends addressing information; S5. The current node determines whether the communication dialogue request is correctly responded to. If it is correctly responded to, the current node and the target node conduct a normal communication dialogue; S6, determine whether the communication dialogue is completed, if not completed, execute S5, if completed, execute S7; S7. Update the content of the session occurrence message and change the logic state of the corresponding bit of this node from "0" to "1".
2. A ring-shaped CAN bus communication method based on network timing arbitration according to claim 1, characterized in that, The method further includes: S8. Determine whether the corresponding bit logic values of each node in the updated session occurrence message content are all "1". If they are all "1", rewrite the logic values of the corresponding bits of all nodes to "0". Otherwise, push the updated "session occurrence" message to the ring CAN bus network and execute S2.
3. A ring-shaped CAN bus communication method based on network timing arbitration according to claim 1, characterized in that If a communication dialogue request for the node is detected, the communication dialogue request is responded to first, including: the node executes a communication response, exchanges data in real time, and executes S2 after a group of communication responses are completed.
4. A ring-shaped CAN bus communication method based on network timing arbitration according to claim 1, characterized in that, The current node determines whether the current ring CAN bus network is in an idle state according to the monitoring feedback, and further includes: if it is not in an idle state, executing S2.
5. A ring-shaped CAN bus communication method based on network timing arbitration according to claim 1, characterized in that, The current node determines whether the communication dialogue request is correctly responded to, and if not correctly responded to, immediately gives up the CAN bus and executes S2.
6. A method for ring-shaped CAN bus communication based on network timing arbitration according to claim 1, characterized in that, Each node initializes the session generation message, including: setting the logical values of the corresponding bits of all nodes to "0".
Citation Information
Patent Citations
D-BUS high-speed bus technology based on ring type Ethernet and auxiliary network
CN102347879A
Dual-redundant CAN bus communication system
CN105743755A