Method for assigning a can bus node id and can bus system
By using the CAN bus node ID allocation method, the control component automatically generates a new ID when an ID conflict is detected, which solves the problem of message conflict in multi-node systems, realizes address configuration without manual intervention, and improves the maintainability and scalability of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN SYSLAB ELECTRONICS CO LTD
- Filing Date
- 2026-06-15
- Publication Date
- 2026-07-31
AI Technical Summary
In existing industrial settings, when multiple control motherboards use the same communication identifier to access the same bus due to identical factory default values, maintenance or replacement errors, or parameter restoration to the initial state, problems such as message conflicts, abnormal master station identification, and control motherboard failure occur. Manual configuration methods are cumbersome and difficult to deploy on a large scale.
The CAN bus node ID allocation method is adopted. When the control component detects an ID conflict, it enters the ID registration state, broadcasts a preset registration message, generates a new ID using the processor UID, and initializes CAN communication to achieve automatic ID reallocation.
It reduces the operational costs of manual address configuration and equipment replacement, improves the maintainability and scalability of the system, and enables address configuration of multi-node systems without manual intervention.
Smart Images

Figure CN122496348A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of CAN bus technology, and in particular to a CAN bus node ID allocation method and a CAN bus system. Background Technology
[0002] In existing industrial settings, multiple control boards are often connected to the same monitoring system via a controller area network (Controller Area Network) bus to achieve centralized monitoring, operational status acquisition, and remote control. For multi-node access scenarios, each control board is typically required to have a unique communication identifier to avoid bus message conflicts and device identification errors.
[0003] In existing multi-node Controller Area Network (CLAN) bus systems, control motherboards typically require pre-configured communication identifiers. When multiple control motherboards use the same communication identifier to connect to the same bus due to identical factory defaults, maintenance errors, or parameter restoration to initial states, issues such as message conflicts, master station identification anomalies, and control motherboard failures can arise. Especially in scenarios where multiple identical control motherboards operate in parallel, relying solely on manual configuration makes it difficult to guarantee address uniqueness and field consistency.
[0004] Existing technologies typically handle conflicts by manually scanning codes for binding, registering each device individually on a host computer, or temporarily disconnecting the device to configure it one by one. However, these methods are cumbersome, rely on the experience of the installers, and are not conducive to large-scale deployment. Summary of the Invention
[0005] The main objective of this invention is to provide a CAN bus node ID allocation method and a CAN bus system, aiming to reduce the operational costs of manual address configuration, maintenance, and device replacement in CAN bus communication, and improve system maintainability and scalability.
[0006] To achieve the above objectives, this invention proposes a CAN bus node ID allocation method, applied to a CAN bus system. The CAN bus system includes a communication bus and multiple control components electrically connected to the communication bus. Each of the multiple control components includes multiple corresponding processor UIDs. The CAN bus node ID allocation method includes: If the control component at any node of the communication bus confirms that there is an ID conflict on the communication bus, it enters the ID registration state. When the control component is in ID registration state, a preset registration message is broadcast; If a control component that is not in the ID registration state receives a preset registration message, each control component generates a new ID based on its own processor UID and initializes CAN communication.
[0007] In one embodiment, the step of the control component on any node of the communication bus confirming the existence of an ID conflict on the communication bus specifically includes: If the control component at any node of the communication bus confirms that there is a message ID on the communication bus that matches its own ID, and the number of confirmations is greater than the preset number, and the time interval between any two confirmations is less than the first preset time interval, then the communication bus is confirmed to have an ID conflict.
[0008] In one embodiment, the step of the control component on any node of the communication bus confirming the existence of an ID conflict on the communication bus specifically includes: If the control component on any node of the communication bus receives a message with the same ID, and the receiving frequency of the message with the same ID is greater than the preset frequency, and the data fingerprints are different, it is confirmed that there is an ID conflict on the communication bus.
[0009] In one embodiment, the step of broadcasting a preset registration message when the control component is in the ID registration state specifically includes: When the control component is in the ID registration state, it broadcasts a target number of preset registration messages to the communication bus at a second preset time interval.
[0010] In one embodiment, the step of generating a new ID based on its own processor UID when a control component not in the ID registration state receives a preset registration message specifically involves: If a control component that is not in the ID registration state receives a preset registration message, each control component uploads a message containing its own processor UID to the control component that is in the ID registration state. The control component in the ID registration state generates a processor UID order list based on the order in which each control component uploads messages containing its own processor UID and its own processor UID, and broadcasts a message including the processor UID order list. Upon receiving a message containing a list of processor UIDs in sequence, each control component determines its new ID based on the correspondence between its own processor UID and the list of processor UIDs in sequence.
[0011] In one embodiment, the step of each control component uploading a message containing its own processor UID to the control component in the ID registration state when the control component not in the ID registration state receives a preset registration message specifically involves: If a control component that is not in the ID registration state receives a preset registration message, each control component stops uploading the current message and uploads a message containing its own processor UID to the control component that is in the ID registration state.
[0012] In one embodiment, the step of determining its own new ID based on the correspondence between its own processor UID and the processor UID in the processor UID sequence list upon receiving a message includes the following steps: Upon receiving a message containing a list of processor UIDs in sequence, each control component determines the order of its new ID in CAN bus communication based on the correspondence between its own processor UID and the list of processor UIDs in sequence. Among them, the IDs of control components in the ID registration state are in the first order.
[0013] In one embodiment, after the step of determining its own new ID based on the correspondence between its own processor UID and the processor UID in the processor UID sequence list upon receiving a message including such a list, the method further includes: Once each control component determines its own new ID, it stores its new ID.
[0014] The present invention also proposes a CAN bus system, the CAN bus system including a communication bus and a plurality of control components electrically connected to the communication bus; The control component includes a memory, a processor, and a CAN bus node ID allocation program stored in the memory and executable on the processor. The CAN bus node ID allocation program is configured to implement the steps of the CAN bus node ID allocation method as described in any of the preceding claims.
[0015] In one embodiment, the memory is an electrically erasable programmable read-only memory.
[0016] This invention employs a CAN bus node ID allocation method, which reduces the operational costs of manual address configuration, maintenance, and device replacement in CAN bus communication, thereby improving system maintainability and scalability. The CAN bus system includes a communication bus and multiple control components electrically connected to the communication bus, each control component comprising multiple corresponding processor UIDs. The CAN bus node ID allocation method includes: when a control component on any node of the communication bus confirms an ID conflict, it enters an ID registration state; while in the ID registration state, the control component broadcasts a preset registration message; when a control component not in the ID registration state receives the preset registration message, each control component generates a new ID based on its own processor UID and initializes CAN communication. This method enables automated ID reassignment in the event of ID conflicts in CAN bus communication, achieved solely through control components electrically connected to the communication bus, thus enabling address configuration of a multi-node system without manual intervention. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0018] Figure 1 This is a flowchart illustrating the CAN bus node ID allocation method of the present invention. Figure 2 This is a flowchart illustrating an embodiment of the CAN bus node ID allocation method of the present invention.
[0019] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not 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 creative effort are within the scope of protection of the present invention.
[0021] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indication will also change accordingly.
[0022] Furthermore, the use of terms such as "first" and "second" in this invention is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature. Additionally, the technical solutions of the various embodiments can be combined with each other, but only on the basis of being achievable by those skilled in the art. When the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed by this invention.
[0023] In existing industrial settings, multiple control boards are often connected to the same monitoring system via a controller area network (Controller Area Network) bus to achieve centralized monitoring, operational status acquisition, and remote control. For multi-node access scenarios, each control board is typically required to have a unique communication identifier to avoid bus message conflicts and device identification errors.
[0024] In existing multi-node Controller Area Network (CLAN) bus systems, control motherboards typically require pre-configured communication identifiers. When multiple control motherboards use the same communication identifier to connect to the same bus due to identical factory defaults, maintenance errors, or parameter restoration to initial states, issues such as message conflicts, master station identification anomalies, and control motherboard failures can arise. Especially in scenarios where multiple identical control motherboards operate in parallel, relying solely on manual configuration makes it difficult to guarantee address uniqueness and field consistency.
[0025] Existing technologies typically handle conflicts by manually scanning codes for binding, registering each device individually on a host computer, or temporarily disconnecting the device to configure it one by one. However, these methods are cumbersome, rely on the experience of the installers, and are not conducive to large-scale deployment.
[0026] To solve the above problems, refer to Figure 1 This application proposes a CAN bus node ID allocation method for a CAN bus system. The CAN bus system includes a communication bus and multiple control components electrically connected to the communication bus. Each of the multiple control components includes multiple corresponding processor UIDs. The CAN bus node ID allocation method includes: Step S100: If the control component on any node of the communication bus confirms that there is an ID conflict on the communication bus, it enters the ID registration state; Step S200: When the control component is in the ID registration state, broadcast a preset registration message; Step S300: If a control component that is not in the ID registration state receives a preset registration message, each control component generates a new ID based on its own processor UID and initializes CAN communication.
[0027] Understandably, in CAN bus communication, every node on the bus has equal communication status, and any node can initiate communication when the bus is idle. Therefore, the CAN bus communication system employs a "non-destructive bit-by-bit arbitration" mechanism. If two nodes simultaneously require communication, they are prioritized based on their ID priority. Specifically, each device's message has a unique identifier (ID). This ID represents not only the device's identity but also its priority—the smaller the ID value, the higher the priority.
[0028] Furthermore, all communication devices on the CAN bus have control components. Specifically, these control components typically include a microcontroller, a CAN controller, and a CAN transceiver. The CAN controller is responsible for handling the protocol logic of the data link layer. Its main tasks include message formatting (packaging data from the MCU into data frames conforming to the CAN protocol standard); error detection (automatically detecting bit errors, stuffing errors, CRC errors, etc., during communication to ensure reliable data transmission); message filtering (determining whether to receive a specific message on the bus based on a preset ID, avoiding the MCU processing a large amount of irrelevant information); and bus arbitration (executing an arbitration procedure when multiple devices attempt to send data simultaneously, ensuring that messages with higher priority are sent first). It is important to note that the microcontroller contains a processor, and each processor has a unique identifier (UID), meaning that each processor's identification information is different and can serve as a unique correspondence.
[0029] In this implementation, when the control components on the CAN bus are powered on, each control component will attempt to communicate using a default temporary ID to confirm whether the CAN bus communication is normal. If any control component on any node of the communication bus detects an ID conflict, that control component will enter ID registration mode, i.e., reassign IDs to all control components and itself. It can be understood that the control component in ID registration mode is the master, while the other control components not in ID registration mode are slaves.
[0030] Optionally, the step of the control component on any node of the communication bus confirming the existence of an ID conflict on the communication bus specifically includes: Step S110: If the control component on any node of the communication bus confirms that there is a message ID on the communication bus that matches its own ID, and the number of confirmations is greater than the preset number, and the time interval between any two confirmations is less than the first preset time interval, then the communication bus is confirmed to have an ID conflict.
[0031] In this embodiment, the control component can confirm whether there is an ID conflict on the communication bus by verifying whether there is a message ID on the communication bus that matches its own ID information, and that the number of verifications is greater than a preset number, and the time interval between any two verifications is less than a first preset time interval. The preset number of verifications and the first preset time interval can be determined by researchers through experiments. For example, the preset number of verifications could be 10, and the first preset time interval could be 1 second. This method can prevent the control component from mistakenly triggering the ID registration state.
[0032] Optionally, the step of the control component on any node of the communication bus confirming the existence of an ID conflict on the communication bus specifically includes: Step S120: If the control component on any node of the communication bus receives a message with the same ID, and the receiving frequency of the message with the same ID is greater than the preset frequency, and the data fingerprints are different, it is confirmed that there is an ID conflict on the communication bus.
[0033] Understandably, in normal CAN bus communication, data changes under the same ID usually follow a predictable pattern. However, in ID conflict situations, the data content under the same ID will experience drastic and unpredictable jumps within a very short period. Because two different control components (e.g., device A transmitting speed and device B transmitting water temperature) are vying to transmit the same ID, the data received by the receiving control component will sometimes be from device A and sometimes from device B, resulting in a complete logical mismatch. Therefore, the control component can confirm an ID conflict on the communication bus by receiving messages with the same ID, where the frequency of receiving these messages exceeds a preset frequency, and the data fingerprints are different.
[0034] In this embodiment, when one control component is initially in the ID registration state, that control component will first broadcast a preset registration message. This will cause the other control components to remain silent upon receiving the preset registration message, i.e., suspend uploading device status messages, to avoid interfering with the ID re-registration and allocation. It can be understood that the control component in the ID registration state is the master, and the control components not in the ID registration state are slaves.
[0035] Optionally, the step of broadcasting a preset registration message when the control component is in ID registration state specifically includes: Step S210: When the control component is in the ID registration state, broadcast a target number of preset registration messages to the communication bus at a second preset time interval.
[0036] In this embodiment, the control component in the ID registration state broadcasts a preset registration message to the communication bus at a second preset time interval, targeting a specific number of times, thereby preventing the omission of control components not in the ID registration state. The target number of times in the second preset time interval can be set according to the researchers' experiments, and the preset registration message can also be set according to actual needs, so that control components not in the ID registration state can enter a silent state upon receiving the preset registration message.
[0037] In this embodiment, when a control component not in ID registration receives a preset registration message, each control component generates a new ID based on its own processor UID and initializes CAN communication. As mentioned above, the processor UID is a unique identifier, thus eliminating the problem of duplicate or conflicting IDs. Therefore, each control component can use its own processor UID as its new ID. It is important to note that the new IDs of each control component must correspond to the ID address format of the CAN bus communication. Furthermore, each control component's new ID must have a priority so that during subsequent CAN bus communication, each control component can communicate normally in the corresponding order according to the priority of its new ID.
[0038] By employing a CAN bus node ID allocation method, the operational costs of manual address configuration, maintenance, and device replacement in CAN bus communication can be reduced, improving system maintainability and scalability. The CAN bus system includes a communication bus and multiple control components electrically connected to the communication bus, each control component including multiple corresponding processor UIDs. The CAN bus node ID allocation method includes: when a control component on any node of the communication bus confirms an ID conflict, it enters an ID registration state; while in the ID registration state, the control component broadcasts a preset registration message; when a control component not in the ID registration state receives the preset registration message, each control component generates a new ID based on its own processor UID and initializes CAN communication. This method allows for automated ID reassignment in the event of ID conflicts in CAN bus communication, solely through control components electrically connected to the communication bus, thus enabling address configuration of a multi-node system without manual intervention.
[0039] refer to Figure 2In one embodiment of the present invention, the step of generating a new ID based on its own processor UID when a control component not in the ID registration state receives a preset registration message specifically includes: Step S310: If a control component that is not in the ID registration state receives a preset registration message, each control component uploads a message containing its own processor UID to the control component that is in the ID registration state. Step S320: The control component in the ID registration state generates a processor UID order list based on the order in which each control component uploads messages containing its own processor UID and its own processor UID, and broadcasts a message containing the processor UID order list. Step S330: Upon receiving a message including a list of processor UIDs in sequence, each control component determines its new ID based on the correspondence between its own processor UID and the list of processor UIDs in sequence.
[0040] In this embodiment, when a control component not in the ID registration state receives a preset registration message, the control component not in the ID registration state will upload a message containing its own processor UID to the control component in the ID registration state. This allows the control component in the ID registration state to generate a corresponding processor UID order list based on the order of the processor UIDs uploaded by each control component. It is important to note that the processor UID order list generated by the control component in the ID registration state will be sorted according to the ID priority of each control component based on the received processor UIDs, thereby generating the processor UID order list. The control component will then broadcast a message containing the processor UID order list. Upon receiving the message containing the processor UID order list, each control component can determine its new ID by confirming the correspondence between its own processor UID and the processor UID in the order list.
[0041] Optionally, the step of each control component uploading a message containing its own processor UID to the control component in the ID registration state when the control component not in the ID registration state receives the preset registration message specifically involves: Step S311: If a control component that is not in the ID registration state receives a preset registration message, each control component stops uploading the current message and uploads a message containing its own processor UID to the control component that is in the ID registration state.
[0042] In this embodiment, when a control component that is not in the ID registration state receives a preset registration message, each control component stops uploading the current message to avoid interfering with the broadcast messages of the control component in the ID registration state, while also avoiding receiving the broadcast messages of the control component in the ID registration state itself.
[0043] Optionally, the step of determining its own new ID based on the correspondence between its own processor UID and the processor UID in the processor UID sequence list when a message including the processor UID sequence list is received specifically includes: Step S331: Upon receiving a message including a processor UID order list, each control component determines the order of its new ID in CAN bus communication based on the correspondence between its own processor UID and the processor UID in the processor UID order list. Among them, the IDs of control components in the ID registration state are in the first order.
[0044] In this embodiment, the control component in the ID registration state sets its own ID order to first order, while the IDs of the other control components not in the ID registration state are registered according to their order in the processor UID order list. For example, the number of control components electrically connected to the communication bus is 10, namely control component A, control component B, control component C, control component D, control component E, control component F, control component G, control component H, control component I, and control component J. Among them, control component A is in the ID registration state, while the other control components are in the unregistered state. Control component A in the ID registration state receives the processor UID messages from control components B, C, D, E, F, G, H, I, and J in sequence. At this time, control component A, which is in the ID registration state, will generate a processor UID sequence list in the order of control component A, control component B, control component C, control component D, control component E, control component F, control component G, control component H, control component I, and control component J, and the processor UID sequence list contains the processor UIDs of all control components.
[0045] Furthermore, after the step of determining its own new ID based on the correspondence between its own processor UID and the processor UID in the processor UID sequence list upon receiving a message, the method further includes: Once each control component determines its own new ID, it stores its new ID.
[0046] In this embodiment, after each control component determines its own new ID, each control component will store its own new ID so that after the CAN bus communication is initialized, each control component can directly use the ID to communicate.
[0047] The present invention also proposes a CAN bus system, the CAN bus system including a communication bus and a plurality of control components electrically connected to the communication bus; The control component includes a memory, a processor, and a CAN bus node ID allocation program stored in the memory and executable on the processor. The CAN bus node ID allocation program is configured to implement the steps of the CAN bus node ID allocation method as described in any of the preceding claims.
[0048] It is worth noting that since the CAN bus system of the present invention is based on the above-described CAN bus node ID allocation method, the embodiments of the CAN bus system of the present invention include all the technical solutions of all embodiments of the above-described CAN bus node ID allocation method, and the technical effects achieved are exactly the same, so they will not be repeated here.
[0049] In one embodiment, the memory is an electrically erasable programmable read-only memory to enable fine-grained storage and erasure.
[0050] The above description is merely a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural transformations made using the contents of the present invention's specification and drawings under the inventive concept of the present invention, or direct / indirect applications in other related technical fields, are included within the patent protection scope of the present invention.
Claims
1. A CAN bus node ID allocation method applied to a CAN bus system, the CAN bus system comprising a communication bus and a plurality of control components electrically connected to the communication bus, and each of the plurality of control components comprising a plurality of corresponding processor UIDs, characterized in that, The CAN bus node ID allocation method includes: If the control component at any node of the communication bus confirms that there is an ID conflict on the communication bus, it enters the ID registration state. When the control component is in ID registration state, a preset registration message is broadcast; If a control component that is not in the ID registration state receives a preset registration message, each control component generates a new ID based on its own processor UID and initializes CAN communication.
2. The CAN bus node ID assignment method of claim 1, wherein, The specific steps for the control component on any node of the communication bus to confirm the existence of an ID conflict on the communication bus are as follows: If the control component at any node of the communication bus confirms that there is a message ID on the communication bus that matches its own ID, and the number of confirmations is greater than the preset number, and the time interval between any two confirmations is less than the first preset time interval, then the communication bus is confirmed to have an ID conflict.
3. The CAN bus node ID assignment method of claim 1, wherein, The specific steps for the control component on any node of the communication bus to confirm the existence of an ID conflict on the communication bus are as follows: If the control component on any node of the communication bus receives a message with the same ID, and the receiving frequency of the message with the same ID is greater than the preset frequency, and the data fingerprints are different, it is confirmed that there is an ID conflict on the communication bus.
4. The CAN bus node ID allocation method as described in claim 1, characterized in that, The step of broadcasting a preset registration message when the control component is in ID registration state is specifically as follows: When the control component is in the ID registration state, it broadcasts a target number of preset registration messages to the communication bus at a second preset time interval.
5. The CAN bus node ID allocation method as described in claim 1, characterized in that, The specific steps for each control component to generate a new ID based on its own processor UID when it receives a preset registration message if it is not in an ID registration state are as follows: If a control component that is not in the ID registration state receives a preset registration message, each control component uploads a message containing its own processor UID to the control component that is in the ID registration state. The control component in the ID registration state generates a processor UID order list based on the order in which each control component uploads messages containing its own processor UID and its own processor UID, and broadcasts a message including the processor UID order list. Upon receiving a message containing a list of processor UIDs in sequence, each control component determines its new ID based on the correspondence between its own processor UID and the list of processor UIDs in sequence.
6. The CAN bus node ID allocation method as described in claim 5, characterized in that, The specific steps for each control component to upload a message containing its own processor UID to the control component in the ID registration state when the control component not in the ID registration state receives the preset registration message are as follows: If a control component that is not in the ID registration state receives a preset registration message, each control component stops uploading the current message and uploads a message containing its own processor UID to the control component that is in the ID registration state.
7. The CAN bus node ID allocation method as described in claim 5, characterized in that, The step of each control component determining its new ID based on the correspondence between its own processor UID and the processor UID in the processor UID sequence list upon receiving a message is as follows: Upon receiving a message containing a list of processor UIDs in sequence, each control component determines the order of its new ID in CAN bus communication based on the correspondence between its own processor UID and the list of processor UIDs in sequence. Among them, the IDs of control components in the ID registration state are in the first order.
8. The CAN bus node ID allocation method as described in claim 5, characterized in that, After the step of determining its own new ID based on the correspondence between its own processor UID and the processor UID in the processor UID sequence list upon receiving a message including such a list, the method further includes: Once each control component determines its own new ID, it stores its new ID.
9. A CAN bus system, characterized in that, The CAN bus system includes a communication bus and multiple control components electrically connected to the communication bus. The control component includes a memory, a processor, and a CAN bus node ID allocation program stored in the memory and executable on the processor. The CAN bus node ID allocation program is configured to implement the steps of the CAN bus node ID allocation method as described in any one of claims 1 to 8.
10. The CAN bus system as described in claim 9, characterized in that, The memory is an electrically erasable programmable read-only memory.