CANOPEN bus node state switching method
By setting 7 service statuses and StartorStop functions in the CANOPEN bus node, the management problems of service operations in different modes are solved, the bus communication efficiency is improved, and the efficiency of state switching is achieved.
Patent Information
- Application Number
- CN202411470741.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-01-03
AI Technical Summary
CANopen bus nodes require different service operations in different modes, but the prior art is difficult to efficiently manage and switch bus states, resulting in inefficient communication.
A CANOPEN bus node state switching method is provided. By setting 7 service states and StartorStop functions, the opening or closing of different states is handled according to the new node state, including switching of initialization, pre-operation, operation and stop states.
The service is turned on or off through the status management table, which improves the communication efficiency of the bus and ensures the correct operation and status switching of the service in different modes.
Smart Images

Figure CN119254567A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of computer control and relates to a CANOPEN bus node state switching method. 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] The CANopen bus includes multiple bus node states, including initialization state, pre-operation state, operation state, and stop state. Different service operations are required in different bus states under different modes. The present invention proposes a CANOPEN bus node state switching method, which marks the opening or closing of different services in different modes through a state management table and completes the switching of the bus state.
[0006] (II) Technical solution
[0007] In order to solve the above technical problems, the present invention provides a CANOPEN bus node state switching method, which comprises the following steps:
[0008] S1: Set 7 service states for use in the bus node state switching process;
[0009] S2: Set the StartorStop function. The first parameter is the 7 service states in S1, and the second parameter is the start or stop state. 1 means starting the state, and 0 means stopping the state.
[0010] S3: If it is determined that the new node state newState to be switched is not equal to the node state nodeState stored in the current object dictionary, different states are processed according to the value of newState; if the new state newState to be switched is equal to the operation state nodeState in the object dictionary, no operation is performed.
[0011] In step S1, the seven service states include: online state sBoot_up, service data object state sSDO, emergency message state sEmergency, synchronization state sSYNC, online guard state sLifeGuard, process data object state sPDO, and layer setting service state sLSS.
[0012] In step S2, for the sBoot_up state, no function is called when starting, and the slave restart function SlavesendBootup is called when stopping.
[0013] For the sSDO state, no function is called when starting, and the reset SDO function resetSDO is called when stopping. The restSDOline function is used in the resetSDO function to close all opened SDOs.
[0014] For the sEmergency state, the emergencyInit function is called when starting, and the RegisterSetODentryCallBack function is called to start emergency management, and the emergencyStop function is called when stopping.
[0015] For the sSYNC state, the startSYNC function is called when starting, the synchronization frame timer is started, and the synchronization frame is sent according to the synchronization frame timing; the stopSYNC function is called when stopping, the synchronization frame timer is turned off, and the synchronization frame sending is stopped.
[0016] For the sLifeGuard state, the lifeGuardInit function is called at startup, in which the heartbeatInit function is called to initialize the heartbeat, and the nodeguardInit function is called; when stopping, the lifeGuardStop function is called, and the heartbeatStop function is called.
[0017] For the sPDO state, the PDOInit initialization function is called when starting to map the data in the master object dictionary, and the PDOStop stop function is called when stopping.
[0018] In step S3, the process of processing different states according to the value of newState includes:
[0019] S3_1 If newState is the initialization state, the sBoot_up state is set to 1, the sSDO state is set to 0, the sEmergency state is set to 0, the sSYNC state is set to 0, the sLifeGuard state is set to 0, and the sPDO state is set to 0. The different states are processed through the StartorStop function;
[0020] S3_2 If newState is the pre-operational state Pre_operational, set the sBoot_up state to 0, the sSDO state to 1, the sEmergency state to 1, the sSYNC state to 1, the sLifeGuard state to 1, and the sPDO state to 0, and process different states through the StartorStop function; set the current state nodeState to the pre-operational state Pre_operational, and call the masterSendNMTstateChange function to reset the child node;
[0021] S3_3 If newState is the operational state Operational, set the sBoot_up state to 0, the sSDO state to 1, the sEmergency state to 1, the sSYNC state to 1, the sLifeGuard state to 1, and the sPDO state to 1, and process different states through the StartorStop function; set the current state nodeState to the pre-operational state Operational;
[0022] S3_4 If newState is the pre-operation state Stopped, set the sBoot_up state to 0, the sSDO state to 0, the sEmergency state to 0, the sSYNC state to 0, the sLifeGuard state to 1, and the sPDO state to 0, and process different states through the StartorStop function; set the current state nodeState to the pre-operation state Stopped.
[0023] (III) Beneficial effects
[0024] The CANOPEN bus node state switching method provided by the above technical solution opens or closes the service and switches the state through the state management table, which greatly improves the communication efficiency of the bus. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is a flow chart of the CANOPEN bus node state switching method of the present invention. DETAILED DESCRIPTION
[0026] 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.
[0027] Reference Figure 1 As shown, the CANOPEN bus node state switching method of this embodiment includes the following steps:
[0028] S1: Set 7 service states for use during bus node state switching.
[0029] The 7 service states include: online state sBoot_up, service data object state sSDO, emergency message state sEmergency, synchronization state sSYNC, online guard state sLifeGuard, process data object state sPDO, and layer setting service state sLSS.
[0030] S2: Set the StartorStop function. The first parameter is the 7 service states in S1, and the second parameter is the start or stop state. 1 means starting the state, and 0 means stopping the state.
[0031] For the sBoot_up state, S2_1 does not call any function when starting, and calls the slave restart function SlavesendBootup when stopping.
[0032] For the sSDO state, S2_2 does not call any function when starting, and calls the reset SDO function resetSDO when stopping. In the resetSDO function, the restSDOline function is used to close all opened SDOs.
[0033] S2_3 For the sEmergency state, the emergencyInit function is called when starting, and the RegisterSetODentryCallBack function is called to start emergency management, and the emergencyStop function is called when stopping.
[0034] S2_4 For the sSYNC state, the startSYNC function is called when starting, the synchronization frame timer is started, and the synchronization frame is sent according to the synchronization frame timing. The stopSYNC function is called when stopping, the synchronization frame timer is turned off, and the synchronization frame sending is stopped.
[0035] S2_5 For the sLifeGuard state, the lifeGuardInit function is called when starting, and the heartbeatInit function is called in this function to initialize the heartbeat, and the nodeguardInit function is called. When stopping, the lifeGuardStop function is called, and the heartbeatStop function is called.
[0036] S2_6 For the sPDO state, the PDOInit initialization function is called when starting to map the data in the master object dictionary, and the PDOStop stop function is called when stopping.
[0037] S3: If the new node state newState to be switched is not equal to the node state nodeState stored in the current object dictionary, go to S3_1 to S3_4 according to the value of newState to process different states; if the new state newState to be switched is equal to the operation state nodeState in the object dictionary, no operation is performed.
[0038] S3_1 If newState is the initialization state, the sBoot_up state is set to 1, the sSDO state is set to 0, the sEmergency state is set to 0, the sSYNC state is set to 0, the sLifeGuard state is set to 0, and the sPDO state is set to 0. The different states are processed through the StartorStop function.
[0039] S3_2 If newState is the pre-operational state Pre_operational, set the sBoot_up state to 0, the sSDO state to 1, the sEmergency state to 1, the sSYNC state to 1, the sLifeGuard state to 1, and the sPDO state to 0, and process different states through the StartorStop function. Set the current state nodeState to the pre-operational state Pre_operational, and call the masterSendNMTstateChange function to reset the child node.
[0040] S3_3 If newState is the operational state Operational, set the sBoot_up state to 0, the sSDO state to 1, the sEmergency state to 1, the sSYNC state to 1, the sLifeGuard state to 1, and the sPDO state to 1, and process different states through the StartorStop function. Set the current state nodeState to the pre-operational state Operational.
[0041] S3_4 If newState is the pre-operation state Stopped, set the sBoot_up state to 0, the sSDO state to 0, the sEmergency state to 0, the sSYNC state to 0, the sLifeGuard state to 1, and the sPDO state to 0, and process different states through the StartorStop function. Set the current state nodeState to the pre-operation state Stopped.
[0042] 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 CANOPEN bus node state switching method, characterized in that: The following steps are involved: S1: Set 7 service states for use in the bus node state switching process; S2: Set the StartorStop function. The first parameter is the 7 service states in S1, and the second parameter is the start or stop state. 1 means starting the state, and 0 means stopping the state. S3: If it is determined that the new node state newState to be switched is not equal to the node state nodeState stored in the current object dictionary, different states are processed according to the value of newState; If the new state newState to be switched is equal to the operation state nodeState in the object dictionary, no operation is performed.
2. The CANOPEN bus node state switching method as claimed in claim 1, characterized in that: In step S1, the seven service states include: online state sBoot_up, service data object state sSDO, emergency message state sEmergency, synchronization state sSYNC, online guard state sLifeGuard, process data object state sPDO, and layer setting service state sLSS.
3. The CANOPEN bus node state switching method as claimed in claim 2, characterized in that: In step S2, for the sBoot_up state, no function is called when starting, and the slave restart function SlavesendBootup is called when stopping.
4. The CANOPEN bus node state switching method as claimed in claim 3, characterized in that: In step S2, for the sSDO state, no function is called when starting, and the reset SDO function resetSDO is called when stopping. The restSDOline function is used in the resetSDO function to close all opened SDOs.
5. The CANOPEN bus node state switching method as claimed in claim 4, characterized in that: In step S2, for the sEmergency state, the emergencyInit function is called when starting, and the RegisterSetODentryCallBack function is called to start emergency management, and the emergencyStop function is called when stopping.
6. The CANOPEN bus node state switching method as claimed in claim 5, characterized in that: In step S2, for the sSYNC state, the startSYNC function is called when starting, the synchronization frame timer is started, and the synchronization frame is sent according to the synchronization frame timing; the stopSYNC function is called when stopping, the synchronization frame timer is turned off, and the synchronization frame sending is stopped.
7. The CANOPEN bus node state switching method as claimed in claim 6, characterized in that: In step S2, for the sLifeGuard state, the lifeGuardInit function is called at startup, in which the heartbeatInit function is called to initialize the heartbeat, and the nodeguardInit function is called; when stopping, the lifeGuardStop function is called, and the heartbeatStop function is called.
8. The CANOPEN bus node state switching method as claimed in claim 7, characterized in that: In step S2, for the sPDO state, the PDOInit initialization function is called when starting to map the data in the master object dictionary, and the PDOStop stop function is called when stopping.
9. The CANOPEN bus node state switching method as claimed in claim 8, characterized in that: In step S3, the process of processing different states according to the value of newState includes: S3_1 If newState is the initialization state, the sBoot_up state is set to 1, the sSDO state is set to 0, the sEmergency state is set to 0, the sSYNC state is set to 0, the sLifeGuard state is set to 0, and the sPDO state is set to 0. The different states are processed through the StartorStop function; S3_2 If newState is the pre-operational state Pre_operational, set the sBoot_up state to 0, the sSDO state to 1, the sEmergency state to 1, the sSYNC state to 1, the sLifeGuard state to 1, and the sPDO state to 0, and process different states through the StartorStop function; set the current state nodeState to the pre-operational state Pre_operational, and call the masterSendNMTstateChange function to reset the child node; S3_3 If newState is the operational state Operational, set the sBoot_up state to 0, the sSDO state to 1, the sEmergency state to 1, the sSYNC state to 1, the sLifeGuard state to 1, and the sPDO state to 1, and process different states through the StartorStop function; set the current state nodeState to the pre-operational state Operational; S3_4 If newState is the pre-operation state Stopped, set the sBoot_up state to 0, the sSDO state to 0, the sEmergency state to 0, the sSYNC state to 0, the sLifeGuard state to 1, and the sPDO state to 0, and process different states through the StartorStop function; set the current state nodeState to the pre-operation state Stopped.
10. Application of the CANOPEN bus node state switching method according to any one of claims 1 to 9 in the field of computer control technology.
