Automatic CAN address acquisition method for parallel operation of multiple devices

Through the power -on device and automatically allocated the unique address feature sequence SN based on the power -on order, the problem of low Canal address distribution efficiency when multiple devices and machines are combined with the power of multiple devices, and the automatic address acquisition and dynamic status monitoring. Reduce manual intervention.

CN119363713APending Publication Date: 2025-01-24JIANGSU QUNLING ENERGY TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411480937.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

In the prior art, when multiple devices are paralleled, CAN address allocation efficiency is low, and manual intervention is required for secondary address allocation, resulting in low address allocation efficiency and frequent manual intervention.

Method used

Each device is activated by powering one by one, and automatically allocates the unique address feature sequence SN according to the power sequence of the device to avoid address conflict and repeated allocation. The dynamic monitoring of the equipment is online, online, and offline.

Benefits of technology

It realizes automatic acquisition of CAN addresses when multiple devices are paralleled, improves address allocation efficiency, reduces manual intervention, and avoids address conflicts and repeated allocation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119363713A_ABST
    Figure CN119363713A_ABST
Patent Text Reader

Abstract

The invention relates to an automatic CAN address acquisition method for parallel operation of multiple devices, which relates to the technical field of address allocation and comprises the following steps: S1, initialization; s2, electrifying the equipment one by one; s3, judging whether equipment starting exists or not; s4, the equipment sends a message to the bus; the equipment receives the message from the bus; s5, acquiring the total online number of the equipment; s6, setting a unique address feature sequence SN of the equipment; s7, the equipment broadcasts a message containing the address feature sequence SN to the bus every 500 ms; the equipment receives a message containing an address feature sequence SN from the bus; and S8, obtaining the online total number of the equipment. The method has the effect of improving the address allocation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of address allocation, and in particular to a method for automatically acquiring CAN addresses for parallel operation of multiple devices. Background Art

[0002] CAN is an ISO internationally standardized serial communication protocol. Each node device on the CAN bus is connected to the physical bus through the two output terminals CANH and CANL of the CAN transceiver interface chip. The device on each node of the CAN bus can send data to any other node device on the bus. In order to distinguish each device on the bus, a CAN communication address needs to be assigned to each node device.

[0003] At present, the CAN addresses of multiple devices are manually assigned by means of DIP switches or software parameter settings. When two devices with the same address are moved and connected to the same bus at a later stage, manual intervention is required for secondary address assignment, resulting in low address assignment efficiency when multiple devices are set up in parallel. Summary of the invention

[0004] In order to improve the efficiency of address allocation, the present application provides a method for automatically obtaining CAN addresses for parallel operation of multiple devices.

[0005] The present application provides a method for automatically obtaining CAN addresses for parallel operation of multiple devices using the following technical solution: A method for automatically acquiring CAN addresses for parallel operation of multiple devices comprises the following steps: S1, initialization; S2, powering on devices one by one; S3, judging whether there is a device startup; S4, the device sending a message to a bus; the device receiving a message from the bus; S5, acquiring the total number of online devices; S6, setting a unique address feature sequence SN of the device; S7, the device broadcasting a message containing the address feature sequence SN to the bus at intervals of 500ms; the device receiving a message containing the address feature sequence SN from the bus; S8, acquiring the total number of online devices.

[0006] Preferably, the step S3 includes the following steps: if a device is powered on and started, proceed to step S4; if no device is powered on and started, proceed to step S3.

[0007] Preferably, the step S1 includes the following steps: setting the number of online devices m to 0; and setting the address feature code D.

[0008] Preferably, the step S5 includes the following steps: S51, if the number of online devices m is 0, proceed to step S52; if the number of online devices m is not 0, proceed to step S53; S52, if the message received by the device contains the address feature code D, report an error and proceed to step S1; if the message received by the device does not contain the address feature code D, the total number of online devices M=1, and proceed to step S54; S53, if the message sent by the device does not contain the address feature code D, the total number of online devices M=m+1, and proceed to step S54; if the message sent by the device contains the address feature code D, the total number of online devices M=m; proceed to step S54; S54, output the total number of online devices M, the number of online devices m=M.

[0009] Preferably, the address feature sequence SN of step S6 consists of an address feature code D and an address feature parameter A, and the address feature parameter A=M.

[0010] Preferably, the step S1 further comprises the following steps: setting the number of online devices n to 0.

[0011] Preferably, the step S8 includes the following steps: S81, determine whether there is a dynamic time stamp; S82, if there is no dynamic time stamp, the total number of online devices N=1, and proceed to step S88; if there is a dynamic time stamp, proceed to step S83; S83, determine whether the device unique address feature sequence SN has established a corresponding dynamic time stamp; S84, if the device unique address feature sequence SN has not established a corresponding dynamic time stamp, proceed to step S85; if the device unique address feature sequence SN has established a corresponding dynamic time stamp, proceed to step S86; S85, establish a device unique address feature sequence SN corresponds to the dynamic time stamp, the total number of online devices N=n+1, and proceed to step S88; S86, determine whether the dynamic time stamp corresponding to the device unique address feature sequence SN is being updated; S87, if the dynamic time stamp corresponding to the device unique address feature sequence SN is being updated, the total number of online devices N=n, and proceed to step S88; if the dynamic time stamp corresponding to the device unique address feature sequence SN is not being updated, clear the dynamic time stamp corresponding to the device address, the total number of online devices N=n-1, and proceed to step S88; S88, output the total number of online devices N, the number of online devices n=N, and proceed to step S4.

[0012] Preferably, step S86 includes the following steps: if the time interval between two consecutive receptions of device address messages exceeds 5s, the device of the address feature sequence SN is offline, and the dynamic time stamp corresponding to the device's unique address feature sequence SN stops updating; if the time interval between two consecutive receptions of device address messages does not exceed 5s, the device of the address is online, and the dynamic time stamp corresponding to the device's unique address feature sequence SN is updated normally.

[0013] In summary, the present application includes at least one of the following beneficial technical effects: When multiple devices are connected to the CAN bus, each device is powered on in turn. According to the order in which each device is powered on, a unique address characteristic sequence SN is automatically assigned to each device. Since each device is powered on one by one, the power-on order of each device is different, so the address assigned to each device is unique, avoiding address conflicts and repeated allocation problems, reducing the need for manual secondary address allocation, not only improving the efficiency of address allocation, but also reducing the need for manual intervention; By dynamically monitoring the online status, online status and offline status of devices on the CAN bus, the total number of devices actually running on the CAN bus is reflected in real time. When other devices on the CAN bus are shut down and powered off, the running devices can obtain the total number of devices online without affecting functions related to the total number of devices online. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 It is a flow chart of a method for automatically acquiring CAN addresses for parallel operation of multiple devices in an embodiment of the present application.

[0015] Figure 2 This is a flowchart of obtaining the total number of online devices in an embodiment of the present application.

[0016] Figure 3 This is a flow chart of obtaining the total number of online devices in an embodiment of the present application. DETAILED DESCRIPTION

[0017] The following is combined with Figure 1-3 This application is described in further detail.

[0018] The embodiment of the present application discloses a method for automatically acquiring CAN addresses for parallel operation of multiple devices, comprising the following steps.

[0019] S1. Initialization. Set the number of online devices m to 0; set the number of online devices n to 0, and set the address feature code D S2. Power on the devices connected to the CAN bus one by one.

[0020] S3, determine whether there is a device powered on. If there is a device powered on, proceed to step S4; if there is no device powered on, proceed to step S3.

[0021] S4. The device sends a message to the bus; the device receives a message from the bus.

[0022] S5. Obtain the total number of online devices. Step S5 includes the following steps.

[0023] S51. If the number of online devices m is 0, proceed to step S52; if the number of online devices m is not 0, proceed to step S53; S52, if the message received by the device contains the address feature code D, an error is reported and step S1 is performed; if the message received by the device does not contain the address feature code D, the total number of online devices M=1, and step S54 is performed; S53. If the message sent by the device does not contain the address feature code D, the total number of online devices M=m+1, and the process goes to step S54; if the message sent by the device contains the address feature code D, the total number of online devices M=m; and the process goes to step S54; S54. Output the total number of online devices M, where the number of online devices m=M.

[0024] S6. Set the unique address feature sequence SN of the device. The address feature sequence SN consists of the address feature code D and the address feature parameter A, and the address feature parameter A=M.

[0025] S7. The device broadcasts a message containing the address characteristic sequence SN to the bus every 500ms; the device receives a message containing the address characteristic sequence SN from the bus.

[0026] S8. Obtain the total number of online devices. Step S8 includes the following steps.

[0027] S81, determining whether there is a dynamic time scale; S82, if there is no dynamic time stamp, the total number of online devices N=1, and proceed to step S88; if there is a dynamic time stamp, proceed to step S83; S83, determining whether the device unique address characteristic sequence SN establishes a corresponding dynamic time stamp; S84, if the device unique address feature sequence SN has not established a corresponding dynamic time stamp, proceed to step S85; if the device unique address feature sequence SN has established a corresponding dynamic time stamp, proceed to step S86; S85, establish a dynamic time stamp corresponding to the unique address feature sequence SN of the device, the total number of online devices N=n+1, and proceed to step S88; S86, determine whether the dynamic time stamp corresponding to the unique address feature sequence SN of the device is being updated; if the time interval between two consecutive receptions of the device address message exceeds 5s, the device with the address feature sequence SN is offline, and the dynamic time stamp corresponding to the unique address feature sequence SN of the device stops being updated; if the time interval between two consecutive receptions of the device address message does not exceed 5s, the device with the address is online, and the dynamic time stamp corresponding to the unique address feature sequence SN of the device is updated normally; S87, if the dynamic time stamp corresponding to the device unique address feature sequence SN is being updated, the total number of online devices N=n, and step S88 is performed; if the dynamic time stamp corresponding to the device unique address feature sequence SN is not being updated, the dynamic time stamp corresponding to the device address is cleared, the total number of online devices N=n-1, and step S88 is performed; S88. Output the total number of online devices N, the number of online devices n=N, and proceed to step S4.

[0028] When a device receives a message containing a specific address feature sequence SN sent by other devices, if the address feature sequence SN does not have a corresponding dynamic timestamp, a corresponding dynamic timestamp will be automatically created. This dynamic timestamp is used to reflect the online status of the device, indicating that the device corresponding to the address feature sequence SN is online, and the count of the total number of online devices is increased accordingly, thereby dynamically monitoring the online status of the device.

[0029] When a device receives a message containing a specific address feature sequence SN sent by other devices, if the address feature sequence SN has a corresponding dynamic time stamp, this dynamic time stamp is used to reflect the online status of the device corresponding to the address feature sequence SN. If the device can receive two messages with the same address feature sequence SN within 5s, then the dynamic time stamp will be continuously updated. This continuous update status indicates that the device sending the message is still online, and the total number of online CAN bus devices remains unchanged, thereby dynamically monitoring the online status of the device.

[0030] When a device receives a message containing a specific address feature sequence SN sent by another device, if the address feature sequence SN has a corresponding dynamic time stamp, this dynamic time stamp is used to reflect the online status of the device corresponding to the address feature sequence SN. If the device only receives a message with the same address feature sequence SN once within 5 seconds, then this dynamic time stamp will stop updating and be cleared, indicating that the device sending the message has gone offline. Once the device is detected to be offline, the total number of online devices is reduced accordingly, thereby dynamically monitoring the offline status of the device.

[0031] By dynamically monitoring the online status, online status and offline status of devices on the CAN bus, the total number of devices actually running on the CAN bus is reflected in real time. When other devices on the CAN bus are shut down and powered off, the running devices can obtain the total number of devices online without affecting functions related to the total number of devices online.

[0032] The implementation principle of the method for automatically acquiring CAN addresses for parallel connection of multiple devices in the embodiment of the present application is as follows: after multiple devices are connected in parallel to the CAN bus, each device is powered on in sequence, and a unique address feature sequence SN is automatically assigned to each device according to the order in which each device is powered on. Since each device is powered on one by one, the power-on times of each device are different, so the address assigned to each device is unique, avoiding the problem of address conflict and repeated allocation. Reducing the need for manual secondary address allocation not only improves the efficiency of address allocation, but also reduces the situation of manual intervention.

[0033] The above are all preferred embodiments of the present application, and the protection scope of the present application is not limited thereto. Therefore, any equivalent changes made according to the structure, shape, and principle of the present application should be included in the protection scope of the present application.

Claims

1. A method for automatically acquiring CAN addresses for parallel operation of multiple devices, characterized in that: The following steps are involved: S1, initialization; S2. Power on the devices one by one; S3, determining whether there is a device startup; S4, the device sends a message to the bus; the device receives a message from the bus; S5. Obtain the total number of online devices; S6, setting the device unique address characteristic sequence SN; S7, the device broadcasts a message containing the address characteristic sequence SN to the bus every 500ms; the device receives the message containing the address characteristic sequence SN from the bus; S8. Obtain the total number of online devices.

2. The method for automatically acquiring CAN addresses for parallel operation of multiple devices according to claim 1, characterized in that: The step S3 includes the following steps: if a device is powered on and started, proceed to step S4; if no device is powered on and started, proceed to step S3.

3. The method for automatically acquiring CAN addresses for parallel operation of multiple devices according to claim 1, characterized in that: The step S1 includes the following steps: setting the number of online devices m to 0; and setting the address feature code D.

4. The method for automatically acquiring CAN addresses for parallel operation of multiple devices according to claim 3 is characterized in that: The step S5 includes the following steps: S51. If the number of online devices m is 0, proceed to step S52; if the number of online devices m is not 0, proceed to step S53; S52, if the message received by the device contains the address feature code D, an error is reported and step S1 is performed; if the message received by the device does not contain the address feature code D, the total number of online devices M=1, and step S54 is performed; S53. If the message sent by the device does not contain the address feature code D, the total number of online devices M=m+1, and the process goes to step S54; if the message sent by the device contains the address feature code D, the total number of online devices M=m; and the process goes to step S54; S54. Output the total number of online devices M, where the number of online devices m=M.

5. The method for automatically acquiring CAN addresses for parallel operation of multiple devices according to claim 4 is characterized in that: The address feature sequence SN of step S6 is composed of an address feature code D and an address feature parameter A, and the address feature parameter A=M.

6. The method for automatically acquiring CAN addresses for parallel operation of multiple devices according to claim 3 is characterized in that: The step S1 also includes the following steps: setting the number of online devices n to 0.

7. The method for automatically acquiring CAN addresses for parallel operation of multiple devices according to claim 6, characterized in that: The step S8 includes the following steps: S81, determining whether there is a dynamic time scale; S82, if there is no dynamic time stamp, the total number of online devices N=1, and proceed to step S88; if there is a dynamic time stamp, proceed to step S83; S83, determining whether the device unique address characteristic sequence SN establishes a corresponding dynamic time stamp; S84, if the device unique address feature sequence SN has not established a corresponding dynamic time stamp, proceed to step S85; if the device unique address feature sequence SN has established a corresponding dynamic time stamp, proceed to step S86; S85, establish a dynamic time stamp corresponding to the unique address feature sequence SN of the device, the total number of online devices N=n+1, and proceed to step S88; S86, determining whether the dynamic time stamp corresponding to the device unique address characteristic sequence SN is being updated; S87, if the dynamic time stamp corresponding to the device unique address feature sequence SN is being updated, the total number of online devices N=n, and step S88 is performed; if the dynamic time stamp corresponding to the device unique address feature sequence SN is not being updated, the dynamic time stamp corresponding to the device address is cleared, the total number of online devices N=n-1, and step S88 is performed; S88. Output the total number of online devices N, the number of online devices n=N, and proceed to step S4.

8. The method for automatically acquiring CAN addresses for parallel operation of multiple devices according to claim 7, characterized in that: The step S86 includes the following steps: if the time interval between two consecutive receptions of device address messages exceeds 5s, the device with the address feature sequence SN is offline, and the dynamic time stamp corresponding to the device's unique address feature sequence SN stops updating; if the time interval between two consecutive receptions of device address messages does not exceed 5s, the device with the address is online, and the dynamic time stamp corresponding to the device's unique address feature sequence SN is updated normally.