A bidirectional heartbeat detection method based on CANOPEN

By configuring the heartbeat cycle and SDO read/write operations on the CANOPEN master station, the problem of communication disconnection of the servo motor was solved, and the reliability of servo motor operation and fault handling capabilities were improved.

CN119341957BActive Publication Date: 2025-10-31TIANJIN JINHANG COMP TECH RES INST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411470784.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-10-31
Estimated Expiration
2044-10-21

AI Technical Summary

Technical Problem

In servo motor follow-up control, communication may be interrupted due to bus interference and bus failure. The servo motor will continue to run according to the last issued speed command and will be unable to handle the host computer failure in time, resulting in safety issues.

Method used

A bidirectional heartbeat determination method based on CANOPEN is adopted. By configuring the heartbeat cycle on the CANOPEN master station, SDO read and write operations are implemented, the heartbeat configuration of the servo driver is performed, and the heartbeat is periodically corrected to ensure the reliability of bidirectional communication.

Benefits of technology

It achieves reliable operation of servo motors and ensures communication reliability and fault handling capabilities in the event of bus interference or failure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119341957B_ABST
    Figure CN119341957B_ABST
Patent Text Reader

Abstract

This invention discloses a bidirectional heartbeat determination method based on CANOPEN, comprising the following steps: In the CANOPEN master station object dictionary, the 0x1017 index is configured with the value ProducerTim; a timer is created in the master station, and timing operations are performed in the timer callback function; a variable TimCnt is defined, and incremented by one each time in the timer callback function; when the value of TimCnt equals the value of ProducerTim, the CAN driver is called to send heartbeat data; for different slave nodes, the 0x1016 index is configured according to the CANOPEN CIA403 standard protocol; after successful slave configuration, the timer set in step S2 is started to periodically send heartbeat data. This invention, by configuring the heartbeat cycle in the CANOPEN master station and implementing SDO read / write operations, configures the heartbeat for different models of servo drivers and performs periodic heartbeat correction, thus achieving bidirectional heartbeat functionality and ensuring the reliability of servo motor operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer control technology and relates to a bidirectional heartbeat determination method based on CANOPEN. Background Technology

[0002] CANopen communication is a communication method built on top of the CAN data link layer, and this communication method specifies relevant requirements for the application layer. The CANopen device model includes a communication section, an object dictionary, and an application section. The communication section includes PDO objects, SDO objects, and NMT objects. The object dictionary includes data types, communication objects, and application objects.

[0003] The advantages of the CANOPEN protocol include high efficiency, precise positioning, anti-interference, multi-functionality, ease of configuration, high efficiency in data transmission, flexible configuration and status query functions, open standards, high data security, and secure communication constraints. Summary of the Invention

[0004] (a) Technical problems to be solved

[0005] In servo motor servo control, the host computer typically performs position planning calculations, converts them into running speed, and sends them to the servo controller via PDO messages. It also receives real-time speed information and other operating parameters from the servo driver. However, in actual use, communication interruptions such as bus interference or bus failures can cause the servo motor to maintain the speed command issued last. Conversely, the host computer may not receive the interrupted information and fail to handle the fault, leading to various safety issues.

[0006] (II) Technical Solution

[0007] To address the aforementioned technical problems, this invention provides a bidirectional heartbeat determination method based on CANOPEN, comprising the following steps:

[0008] S1: Configure the data for index 0x1017 in the canopen master site object dictionary, and set the value to ProducerTim;

[0009] S2: Create a Timer in the main station, perform timing operations in the timer callback function, define a variable TimCnt, and increment it by one each time in the timer callback function. When the value of TimCnt is equal to the value of ProducerTim, call the CAN driver to send heartbeat data.

[0010] S3: For different slave nodes, configure the slave 0x1016 index according to the CANopen IA403 standard protocol;

[0011] S4: After the slave station is successfully configured, start the timer set in step S2 to periodically send heartbeat data.

[0012] In step S1, the configuration unit is ms.

[0013] In step S2, the timing interval is 1ms.

[0014] In step S3, the configured value represents the heartbeat consumption cycle.

[0015] Step S3, configuring the slave station's 0x1016 index, includes:

[0016] S3_1 reads data from the space with index 0x1016 and sub-index 1 for different slave stations;

[0017] S3_2 writes data to the space with index 0x1016 and sub-index 1 for different slave stations.

[0018] In S3_1, the `readNetworkDict` function is used to read the slave object dictionary data from the master. It retrieves the data value at index 0x1016 and sub-index 1. The function parameters are the master object dictionary `master402_Data` and the slave node number `nodeID`. The master controls two nodes, node 1 and node 2, with an index value of 0x1016 and a sub-index value of 1. The type parameter is `uint32`.

[0019] Check the return value of the readNetworkDict function call; if it is 0xFF, return an error directly.

[0020] The `getReadResultNetworkDict` function, which retrieves the result of the slave object dictionary from the master station, is called to obtain the current read status. The function parameters are the master station object dictionary `master402_Data` and the slave node number `nodeID`. The return value is checked; if it is 0x03, it indicates that data is being transmitted. After a 1ms delay, the `getReadResultNetworkDict` function is used again to retrieve the current read status until the return value is not 0x03, at which point the loop exits. The retrieved data is then passed to the variables `get1016_node1` and `get1016_node2` via pointers.

[0021] The data transfer process is closed using the closeSDOtransfer function, with parameters master402_Data (master site object dictionary), nodeID (slave site node number), and index value 0x1016.

[0022] Check the return value. If the return value is 0x01, it means that the data transmission is complete. Then, report the data transmission success and pass out get1016_node1 and get1016_node2; otherwise, discard this value.

[0023] In S3_2, the writeNetworkDict function, which reads the slave object dictionary data from the host using canopen, writes the consumed time ProducerTim to index 0x1016 and sub-index 1. The function parameters are the master object dictionary master402_Data, the slave node number nodeID, the index value 0x1016, the sub-index value 1, and the type parameter uint32.

[0024] Check the return value of the writeNetworkDict function call; if it is 0xFF, return an error directly.

[0025] The `getWriteResultNetworkDict` function, which retrieves the result of the slave object dictionary from the master station, is called to obtain the current read status. The function parameters are the master station object dictionary `master402_Data` and the slave node ID. The return value is checked; if it is 0x03, it indicates that data is being transmitted. After a 1ms delay, `getWriteResultNetworkDict` is used again to retrieve the current read status until the return value is not 0x03, at which point the loop exits.

[0026] The `closeSDOtransfer` function is used to close the data transfer process. The parameters are the master object dictionary `master402_Data`, the slave node number `nodeID`, and the index value `index` of 0x1016. The return value is then checked. If the return value is 0x01, the data transfer is reported as successful; otherwise, failure is returned directly.

[0027] In step S4, the time variable TIMEVALUE is timed and incremented within the timer. In the timer callback function, the value of TIMEVALUE is checked. If the value is equal to UPDATEVALUE, the value of slave object dictionary index 1016 is first written to 0, the slave heartbeat consumption function is paused, and after a delay of TIME_DELAY, the value of slave object dictionary index 1016 is written to the consumed time ProducerTim, and the value of TIMEVALUE is written to 0 to start counting again.

[0028] (III) Beneficial Effects

[0029] The bidirectional heartbeat determination method based on CANOPEN provided by the above technical solution configures the heartbeat cycle on the CANOPEN master station and implements SDO read / write operations to configure the heartbeat for different models of servo drives and periodically correct the heartbeat, thereby realizing the bidirectional heartbeat function and ensuring the reliability of servo motor operation. Attached Figure Description

[0030] Figure 1 This is a flowchart of the bidirectional heartbeat determination method based on CANOPEN according to the present invention. Detailed Implementation

[0031] To make the objectives, contents, and advantages of the present invention clearer, the specific embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples.

[0032] Reference Figure 1 As shown, the bidirectional heartbeat determination method based on CANOPEN in this embodiment includes the following steps:

[0033] S1: In the canopen master site object dictionary, configure the data for index 0x1017 with the configuration value ProducerTim and the configuration unit is ms.

[0034] S2: Create a timer in the main station with a timing interval of 1ms. Perform timing operations in the timer callback function, define a variable TimCnt, and increment it by one each time in the timer callback function. When the value of TimCnt is equal to the value of ProducerTim, call the CAN driver to send heartbeat data.

[0035] S3: For different slave nodes, configure the slave 0x1016 index according to the CANopen CIA403 standard protocol. The configured value represents the heartbeat consumption cycle.

[0036] Configuring the slave station's 0x1016 index includes:

[0037] S3_1 reads data from the space with index 0x1016 and sub-index 1 for different slave stations.

[0038] The `readNetworkDict` function, used by the `canopen` host, reads data from the slave object dictionary. It retrieves the data value at index 0x1016 and sub-index 1. The function parameters are the master object dictionary `master402_Data`, the slave node number `nodeID` (in this example, the master controls two nodes, node 1 and node 2), the index value `index` (0x1016), the sub-index value `1`, and the type parameter `uint32`.

[0039] Check the return value of the readNetworkDict function call. If it is 0xFF, return an error directly.

[0040] The `getReadResultNetworkDict` function, which retrieves the result of the slave object dictionary from the master station, is called to obtain the current read status. The function parameters are the master station object dictionary `master402_Data` and the slave node ID `nodeID`. The return value is checked; if it is 0x03, it indicates data is being transmitted. After a 1ms delay, the `getReadResultNetworkDict` function is used again to retrieve the current read status until the return value is not 0x03 (data is being transmitted). Then the loop exits. The retrieved data is passed to the variables `get1016_node1` and `get1016_node2` via pointers.

[0041] The data transfer process is closed using the closeSDOtransfer function, with parameters master402_Data (master site object dictionary), nodeID (slave site node number), and index value 0x1016.

[0042] Further check the return value. If the return value is 0x01 (data transmission completed), then report successful data transmission and pass get1016_node1 and get1016_node2 out. Otherwise, discard the data.

[0043] S3_2 writes data to the space with index 0x1016 and sub-index 1 for different slave stations.

[0044] The `writeNetworkDict` function, which reads data from the slave object dictionary using `canopen`, writes the consumed time `ProducerTim` to index 0x1016, sub-index 1. The function parameters are the master object dictionary `master402_Data`, the slave node number `nodeID` (in this example, the master controls two nodes, node 1 and node 2), the index value `index` of 0x1016, the sub-index value of 1, and the type parameter `uint32`.

[0045] Check the return value of the writeNetworkDict function call. If it is 0xFF, return an error directly.

[0046] The `getWriteResultNetworkDict` function, which retrieves the result of the slave object dictionary from the master station, is called to obtain the current read status. The function parameters are the master station object dictionary `master402_Data` and the slave node ID `nodeID`. The return value is checked; if it is 0x03, it indicates that data is being transmitted. After a 1ms delay, `getWriteResultNetworkDict` is used again to retrieve the current read status until the return value is not 0x03 (data is being transmitted), at which point the loop exits.

[0047] The `closeSDOtransfer` function is used to close the data transfer process. The parameters are the master site object dictionary `master402_Data`, the slave site node number `nodeID`, and the index value `index` (0x1016). The return value from step ③ is then checked. If the return value is 0x01 (data transfer complete), a successful data transfer report is sent; otherwise, a failure report is sent.

[0048] S4: After the slave station is successfully configured, start the timer set in S2 to periodically send heartbeat data.

[0049] A timer variable TIMEVALUE is used, and it is incremented within the timer. In the timer callback function, the value of TIMEVALUE is checked. If it equals UPDATEVALUE (set to 1000000 in this invention), the value at index 1016 of the slave object dictionary is first written to 0, pausing the slave's heartbeat consumption function. After a delay of TIME_DELAY (10ms in this example), the value at index 1016 of the slave object dictionary is written to the consumed time ProducerTim. Then, TIMEVALUE is written to 0, and the count restarts.

[0050] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A bidirectional heartbeat determination method based on CANOPEN, characterized in that, Includes the following steps: S1: Configure the data for index 0x1017 in the canopen master site object dictionary, and set the value to ProducerTim; S2: Create a Timer in the main station, perform timing operations in the timer callback function, define a variable TimCnt, and increment it by one each time in the timer callback function. When the value of TimCnt is equal to the value of ProducerTim, call the CAN driver to send heartbeat data. S3: For different slave nodes, configure the slave 0x1016 index according to the CANopen IA403 standard protocol; S4: After the slave station is successfully configured, start the timer set in step S2 to periodically send heartbeat data; Step S3, configuring the slave station's 0x1016 index, includes: S3_1 reads data from the space with index 0x1016 and sub-index 1 for different slave stations; S3_2 writes data to the space with index 0x1016 and sub-index 1 for different slave stations; In S3_1, the `readNetworkDict` function is used to read the slave object dictionary data from the master. It retrieves the data value at index 0x1016 and sub-index 1. The function parameters are the master object dictionary `master402_Data` and the slave node number `nodeID`. The master controls two nodes, node 1 and node 2, with an index value of 0x1016 and a sub-index value of 1. The type parameter is `uint32`. Check the return value of the readNetworkDict function call; if it is 0xFF, return an error directly. The `getReadResultNetworkDict` function, which retrieves the result of the slave object dictionary from the master station, is called to obtain the current read status. The function parameters are the master station object dictionary `master402_Data` and the slave node number `nodeID`. The return value is checked; if it is 0x03, it indicates that data is being transmitted. After a 1ms delay, the `getReadResultNetworkDict` function is used again to retrieve the current read status until the return value is not 0x03, at which point the loop exits. The retrieved data is then passed to the variables `get1016_node1` and `get1016_node2` via pointers. The data transfer process is closed using the closeSDOtransfer function, with parameters master402_Data (master site object dictionary), nodeID (slave site node number), and index value 0x1016. Check the return value. If the return value is 0x01, it means that the data transmission is complete. Then, report the data transmission success and pass out get1016_node1 and get1016_node2; otherwise, discard this value.

2. The bidirectional heartbeat determination method based on CANOPEN as described in claim 1, characterized in that, In step S1, the configuration unit is ms.

3. The bidirectional heartbeat determination method based on CANOPEN as described in claim 2, characterized in that, In step S2, the timing interval is 1ms.

4. The bidirectional heartbeat determination method based on CANOPEN as described in claim 3, characterized in that, In step S3, the configured value represents the heartbeat consumption cycle.

5. The bidirectional heartbeat determination method based on CANOPEN as described in claim 4, characterized in that, In S3_2, the writeNetworkDict function, which reads the slave object dictionary data from the host using canopen, writes the consumed time ProducerTim to index 0x1016 and sub-index 1. The function parameters are the master object dictionary master402_Data, the slave node number nodeID, the index value 0x1016, the sub-index value 1, and the type parameter uint32. Check the return value of the writeNetworkDict function call; if it is 0xFF, return an error directly. The `getWriteResultNetworkDict` function, which retrieves the results of the slave object dictionary from the master station, is called to obtain the current read status. The function parameters are the master station object dictionary `master402_Data` and the slave node number `nodeID`. The return value is checked. If the value is 0x03, it means that the data is being transmitted. After a 1ms delay, `getWriteResultNetworkDict` is used to retrieve the current read status again until the return value is not 0x03, at which point the loop is exited. The `closeSDOtransfer` function is used to close the data transfer process. The parameters are the master object dictionary `master402_Data`, the slave node number `nodeID`, and the index value `index` of 0x1016. The return value is then checked. If the return value is 0x01, the data transfer is reported as successful; otherwise, failure is returned directly.

6. The bidirectional heartbeat determination method based on CANOPEN as described in claim 5, characterized in that, In step S4, the time variable TIMEVALUE is timed and incremented within the timer. In the timer callback function, the value of TIMEVALUE is checked. If the value is equal to UPDATEVALUE, the value of slave object dictionary index 1016 is first written to 0, the slave heartbeat consumption function is paused, and after a delay of TIME_DELAY, the value of slave object dictionary index 1016 is written to the consumed time ProducerTim, and the value of TIMEVALUE is written to 0 to start counting again.

7. The bidirectional heartbeat determination method based on CANOPEN as described in claim 6, characterized in that, In step S4, UPDATEVALUE is set to 1000000.

8. The bidirectional heartbeat determination method based on CANOPEN as described in claim 7, characterized in that, In step S4, TIME_DELAY is 10ms.

Citation Information

Patent Citations

  • Method for realizing CANopen slave station

    CN101854300A

  • Method for realizing master station in dual-motor system

    CN117459342A