CANOPEN-based bidirectional heartbeat judgment method

By configuring the heartbeat cycle and sending heartbeat data in the CANOPEN main station object dictionary, the two -way heartbeat function of the servo motor is realized, the security problem caused by the communication disconnection is solved, and the reliability and security of the servo motor run.

CN119341957AActive Publication Date: 2025-01-21TIANJIN JINHANG COMP TECH RES INST
View PDF 3 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In the servo motor follow-up control, due to communication disconnection problems such as bus interference and bus failure, the servo motor maintains the last speed command issued by the servo motor. The upper computer cannot receive the interruption and fault processing, resulting in safety problems.

Method used

The bidirectional heartbeat judgment method based on CANOPEN is adopted. By configuring the heartbeat cycle in the CANOPEN master station object dictionary and sending heartbeat data in the timer callback function, the bidirectional heartbeat function is implemented to ensure the reliability of the servo motor operation.

Benefits of technology

Through the bidirectional heartbeat judgment method, the safety problem of the servo motor when communication is disconnected is solved, ensuring the reliability and safety of the servo motor operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119341957A_ABST
    Figure CN119341957A_ABST
Patent Text Reader

Abstract

The invention discloses a bidirectional heartbeat judgment method based on CANOPEN, and the method comprises the following steps: carrying out the data configuration of a 0 * 1017 index in a canopen master station object dictionary, and enabling a configuration value to be ProducerTims; the method comprises the following steps: creating a timer in a master station, carrying out timing operation in a timer callback function, defining a variable TimCnt, carrying out one addition operation in the timer callback function each time, and calling a CAN drive to send heartbeat data when the value of the TimCnt is equal to the value of ProducerTims; for different slave station nodes, a slave station 0 * 1016 index is configured according to a canopen cia403 standard protocol; and after the slave station is successfully configured, starting the timer set in the step S2, and periodically sending heartbeat data. According to the method, the heartbeat cycle is configured in the CANOPEN master station, SDO read-write operation is achieved, heartbeat configuration is conducted on servo drivers of different models, heartbeat correction is conducted periodically, the two-way heartbeat function is achieved, and the running reliability of the servo motor is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of computer control and relates to a bidirectional heartbeat judgment method based on CANOPEN. Background Art

[0002] CANopen communication is a form of communication based on the CAN data link layer. This communication method has relevant provisions for the application layer. The CANopen device model includes the communication part, object dictionary and application part. The communication part 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, versatility, easy configuration, high efficiency of data transmission, flexible configuration and status query functions, open standards, high data security, and secure communication constraints. Summary of the invention

[0004] 1. Technical issues to be resolved

[0005] In the servo motor follow-up control, the host computer usually performs position planning calculations, converts it into operating speed and sends it to the servo controller through PDO messages, and receives the real-time speed information and other operating parameters of the servo drive. In actual use, due to communication disconnection problems such as bus interference and bus failure, the servo motor keeps running at the last issued speed command. On the contrary, the host computer cannot receive the disconnection interruption and generate fault processing, thus causing various safety problems.

[0006] (II) Technical solution

[0007] In order to solve the above technical problems, the present invention provides a bidirectional heartbeat judgment method based on CANOPEN, which comprises the following steps:

[0008] S1: In the canopen master object dictionary, configure the data for the 0x1017 index, and the configuration value is ProducerTim;

[0009] S2: Create a timer Timer in the master station, perform timing operations in the timer callback function, define the variable TimCnt, and add 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 CIA403 standard protocol;

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

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

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

[0014] In step S3, a configuration value represents a heartbeat consumption period.

[0015] In step S3, configuring the slave station 0x1016 index includes:

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

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

[0018] In S3_1, the canopen host is used to read the slave object dictionary data function readNetworkDict to obtain the data value of 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, namely node 1 and node 2. The index value index is 0x1016, the sub-index value is 1, and the type parameter is uint32.

[0019] Determine the return value of the readNetworkDict function call. If it is 0xFF, an error is returned directly.

[0020] Call the master station to read the slave station object dictionary result function getReadResultNetworkDict to obtain the current reading status. The function parameters are the master station object dictionary master402_Data and the slave station node number nodeID. Judge the return value. If the value is 0x03, it means that the data is being transmitted. Delay 1ms and continue to get the current reading status from the slave station object dictionary result function getReadResultNetworkDict until the return value is not 0x03, then exit the loop judgment. Pass the obtained data to variables get1016_node1 and get1016_node2 through pointers.

[0021] Use the closeSDOtransfer function to close the data transfer process. The parameters are the master object dictionary master402_Data, the slave node ID nodeID, and the index value index is 0x1016.

[0022] Determine the return value. If the return value is 0x01, indicating that the data transmission is completed, the data transmission success will be reported, and get1016_node1 and get1016_node2 will be passed out; otherwise, the value will be abandoned.

[0023] In S3_2, the canopen host is used to read the slave object dictionary data function writeNetworkDict, and the consumed time ProducerTim is written to the index 0x1016, sub-index 1. The function parameters are the master object dictionary master402_Data, the slave node number nodeID, the index value index value is 0x1016, the sub-index value is 1, and the type parameter is uint32;

[0024] Determine the return value of the writeNetworkDict function call. If it is 0xFF, an error is returned directly.

[0025] Call the master station to read the slave station object dictionary result function getWriteResultNetworkDict to obtain the current reading status. The function parameters are the master station object dictionary master402_Data and the slave station node number nodeID. Determine the return value. If the value is 0x03, it means that the data is being transmitted. Delay 1ms, continue to getWriteResultNetworkDict to obtain the current reading status until the return value is not 0x03, then exit the loop judgment;

[0026] Use the closeSDOtransfer function to close the data transfer process. The parameters are the master object dictionary master402_Data, the slave node number nodeID, the index value index value 0x1016, and further judge the return value. If the return value is 0x01, the data transmission will be reported successful, otherwise it will directly return failure.

[0027] In step S4, the time variable TIMEVALUE is set, and TIMEVALUE is incremented in the timer. The value of TIMEVALUE is judged in the timer callback function. If this value is equal to UPDATEVALUE, the slave object dictionary index 1016 is first called and written as 0, the slave consumption heartbeat function is suspended, and after a delay of TIME_DELAY, the slave object dictionary index 1016 is called and written as the consumed time ProducerTim, and the TIMEVALUE value is written as 0, and the counting is restarted.

[0028] (III) Beneficial effects

[0029] The CANOPEN-based bidirectional heartbeat judgment method provided by the above technical solution configures the heartbeat cycle in the CANOPEN master station and implements SDO read and write operations, configures the heartbeat of servo drives of different models, and periodically performs heartbeat correction, thereby realizing a bidirectional heartbeat function and ensuring the reliability of the servo motor operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 The figure is a flow chart of the bidirectional heartbeat determination method based on CANOPEN of the present invention. DETAILED DESCRIPTION

[0031] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.

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

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

[0034] S2: Create a timer Timer in the master station with a timing time of 1ms. Perform timing operations in the timer callback function, define the variable TimCnt, and add 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 0x1016 index includes:

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

[0038] Use the canopen host to read the slave object dictionary data function readNetworkDict to obtain the data value of 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 is 0x1016, the sub-index value is 1, and the type parameter is uint32.

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

[0040] Call the master station to read the slave station object dictionary result function getReadResultNetworkDict to obtain the current reading status. The function parameters are the master station object dictionary master402_Data and the slave station node number nodeID. Judge the return value. If the value is 0x03, it means that the data is being transmitted. Delay 1ms, and continue to obtain the current reading status from the slave station object dictionary result function getReadResultNetworkDict until the return value is not 0x03 (data is being transmitted), then exit the loop judgment. Pass the obtained data to variables get1016_node1 and get1016_node2 through pointers.

[0041] Use the closeSDOtransfer function 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 is 0x1016.

[0042] Further judge the return value, if the return value is 0x01 (data transmission completed), the data transmission success will be reported, and get1016_node1 and get1016_node2 will be passed out. Otherwise, the value is abandoned.

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

[0044] Use the canopen host to read the slave object dictionary data function writeNetworkDict, write 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 value is 0x1016, the sub-index value is 1, and the type parameter is uint32.

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

[0046] Call the master station to read the slave station object dictionary result function getWriteResultNetworkDict to obtain the current reading status. The function parameters are the master station object dictionary master402_Data and the slave station node number nodeID. Determine the return value. If the value is 0x03, it means that the data is being transmitted. Delay 1ms, continue to getWriteResultNetworkDict to obtain the current reading status until the return value is not 0x03 (data is being transmitted), then exit the loop judgment.

[0047] Use the closeSDOtransfer function to close the data transfer process. The parameters are the master object dictionary master402_Data, the slave node ID nodeID, and the index value index value 0x1016. Then further judge the return value in ③. If the return value is 0x01 (data transmission completed), the data transmission will be reported as successful, otherwise it will directly return failure.

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

[0049] The time variable TIMEVALUE is set, and TIMEVALUE is incremented in the timer. The value of TIMEVALUE is determined in the timer callback function. If this value is equal to UPDATEVALUE (this value is set to 1000000 in the present invention), the slave object dictionary index 1016 is first called and written as 0, the slave consumption heartbeat function is suspended, and after a delay of TIME_DELAY (10ms in this example), the slave object dictionary index 1016 is called and written as the consumption time ProducerTim. The TIMEVALUE value is written as 0, and the counting is restarted.

[0050] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A bidirectional heartbeat judgment method based on CANOPEN, characterized in that: The following steps are involved: S1: In the canopen master object dictionary, configure the data for the 0x1017 index, and the configuration value is ProducerTim; S2: Create a timer Timer in the master station, perform timing operations in the timer callback function, define the variable TimCnt, and add 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 CIA403 standard protocol; S4: After the slave station is successfully configured, the timer set in step S2 is started to periodically send heartbeat data.

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

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

4. The bidirectional heartbeat determination method based on CANOPEN as claimed in claim 3, characterized in that: In step S3, a configuration value represents a heartbeat consumption period.

5. The bidirectional heartbeat determination method based on CANOPEN as claimed in claim 4, characterized in that: In step S3, configuring the slave station 0x1016 index includes: S3_1 reads data from the space with sub-index 1 and index 0x1016 of different slave stations; S3_2 writes data to the space with index 0x1016 and sub-index 1 of different slave stations.

6. The bidirectional heartbeat determination method based on CANOPEN as claimed in claim 5, characterized in that: In S3_1, the canopen host is used to read the slave object dictionary data function readNetworkDict to obtain the data value of 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, namely node 1 and node 2. The index value index is 0x1016, the sub-index value is 1, and the type parameter is uint32. Determine the return value of the readNetworkDict function call. If it is 0xFF, an error is returned directly. Call the master station to read the slave station object dictionary result function getReadResultNetworkDict to obtain the current reading status. The function parameters are the master station object dictionary master402_Data and the slave station node number nodeID. Judge the return value. If the value is 0x03, it means that the data is being transmitted. Delay 1ms and continue to get the current reading status from the slave station object dictionary result function getReadResultNetworkDict until the return value is not 0x03, then exit the loop judgment. Pass the obtained data to variables get1016_node1 and get1016_node2 through pointers. Use the closeSDOtransfer function to close the data transfer process. The parameters are the master object dictionary master402_Data, the slave node ID nodeID, and the index value index is 0x1016. Determine the return value. If the return value is 0x01, it means that the data transmission is completed. Then the data transmission success will be reported and get1016_node1 and get1016_node2 will be passed out. Otherwise, the value will be abandoned.

7. The CANOPEN-based bidirectional heartbeat determination method according to claim 6, characterized in that: In S3_2, the canopen host is used to read the slave object dictionary data function writeNetworkDict, and the consumed time ProducerTim is written to the index 0x1016, sub-index 1. The function parameters are the master object dictionary master402_Data, the slave node number nodeID, the index value index value is 0x1016, the sub-index value is 1, and the type parameter is uint32; Determine the return value of the writeNetworkDict function call. If it is 0xFF, an error is returned directly. Call the master station to read the slave station object dictionary result function getWriteResultNetworkDict to obtain the current reading status. The function parameters are the master station object dictionary master402_Data and the slave station node number nodeID. Determine the return value. If the value is 0x03, it means that the data is being transmitted. Delay 1ms, continue to getWriteResultNetworkDict to obtain the current reading status until the return value is not 0x03, then exit the loop judgment; Use the closeSDOtransfer function to close the data transfer process. The parameters are the master object dictionary master402_Data, the slave node number nodeID, the index value index value 0x1016, and further judge the return value. If the return value is 0x01, the data transmission will be reported successful, otherwise it will directly return failure.

8. The bidirectional heartbeat determination method based on CANOPEN as claimed in claim 7, characterized in that: In step S4, the time variable TIMEVALUE is set, and TIMEVALUE is incremented in the timer. The value of TIMEVALUE is judged in the timer callback function. If this value is equal to UPDATEVALUE, the slave object dictionary index 1016 is first called and written as 0, the slave consumption heartbeat function is suspended, and after a delay of TIME_DELAY, the slave object dictionary index 1016 is called and written as the consumed time ProducerTim, and the TIMEVALUE value is written as 0, and the counting is restarted.

9. The bidirectional heartbeat determination method based on CANOPEN as claimed in claim 8, characterized in that: In step S4, UPDATEVALUE is set to 1000000.

10. The bidirectional heartbeat determination method based on CANOPEN as claimed in claim 9, characterized in that: In step S4, TIME_DELAY is 10 ms.

Citation Information

Patent Citations

  • Method for realizing CANopen slave station

    CN101854300A

  • Method for realizing master station in dual-motor system

    CN117459342A

  • Method for transmitting data via a canopen bus

    US20130080585A1