Method for quickly reconstructing CANopen communication
By proactively predicting and optimizing the CANopen communication process, and utilizing historical configuration cache and priority grading, the problems of long recovery time and insufficient resource scheduling when a slave goes offline are resolved, enabling fast and stable communication recovery.
Patent Information
- Application Number
- CN202511141575.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-15
- Publication Date
- 2025-10-21
AI Technical Summary
The existing CANopen communication system takes too long to recover when a slave goes offline, has a relatively passive detection mechanism, and lacks resource scheduling in multi-slave scenarios, resulting in low recovery efficiency and an inability to meet the real-time performance requirements of critical scenarios.
By proactively predicting the communication quality of slave stations and utilizing historical configuration cache and priority grading mechanisms, parallel operations and resource scheduling are achieved, optimizing the communication recovery process, including pre-recovery, cache reuse, and multi-slave scheduling.
It shortens the slave recovery time, reduces the bus conflict rate and CPU occupancy, improves system stability and resource utilization, and meets the real-time performance requirements of key scenarios.
Smart Images

Figure CN120825366A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network communications, and in particular to a method for quickly reestablishing CANopen communication. Background Art
[0002] In the CANopen protocol, the slave communication reestablishment process relies primarily on the Node Management Protocol (NMT) and Service Data Object (SDO) specifications. However, existing technical processes have significant flaws, resulting in inefficient recovery. The traditional recovery process can be divided into the following steps: 1. Detecting a disconnection; 2. Confirming the status; 3. Resetting the slave; 4. Reconfiguring; and 5. Starting the slave.
[0003] During the initial disconnection detection process, the master typically triggers a heartbeat timeout or node protection mechanism. This traditional approach takes 50 to 100 milliseconds, but because the detection is passive and lacks advance preparation, it creates a long window of opportunity, increasing system risk. The master then enters the confirmation phase, sending an NMT status request to verify the slave's status. Waiting for a response takes 20 to 50 milliseconds. While this ensures status confirmation, it does not address the fundamental issue with the overall process. The master then resets the slave, sending an NMT reset command to force the slave to perform hardware initialization. This step typically takes 100 to 200 milliseconds, but the drawback is that even if the slave was previously connected, the reset action is repeated, resulting in unnecessary delays. During the reconfiguration phase, the master writes all the slave's object dictionary parameters via the SDO protocol, taking 150 to 300 milliseconds. However, this process duplicates a large number of unchanged parameters, increasing redundancy in bus data exchange and wasting communication resources. Finally, the master sends an NMT start command to activate the slave, which takes 10 to 20 milliseconds to complete the entire communication reconstruction.
[0004] In addition, these defects are further exacerbated in multi-slave scenarios. When two or more slaves go offline at the same time, the master lacks an effective resource scheduling mechanism and is unable to manage the recovery process in an orderly manner, resulting in a sharp increase in CPU usage and a bus message conflict rate exceeding 30%. This extends the actual recovery time to 2 to 3 times that of the original single-slave scenario, seriously affecting system stability and real-time performance.
[0005] In general, in existing CANopen communication systems, when a slave goes offline, the traditional communication reestablishment process has three core issues: First, the recovery time is too long. The entire process requires redundant steps such as "detecting offline - resetting the slave - reconfiguring - starting the slave." The recovery time often exceeds 400ms, which cannot meet the requirements of critical scenarios such as wind turbine pitch converters (which require a response time of ≤100ms). Second, the detection mechanism is relatively passive. It mainly relies on the "post-detection" method of heartbeat timeout. There is a "window" between detecting the disconnection and initiating recovery, which further increases the overall time consumption. Third, it lacks adaptability in multi-slave scenarios. When multiple slaves go offline simultaneously, the master experiences resource contention (e.g., CPU, cache) and bus congestion, significantly reducing recovery efficiency. High-priority slaves may also experience security risks due to delays. Summary of the Invention
[0006] Based on this, it is necessary to provide a method for quickly reconstructing CANopen communication to address the above technical issues.
[0007] The present invention provides a method for quickly reestablishing CANopen communication, the method comprising: Based on the prediction indicators, the master station monitors the communication quality of the slave station in real time, determines the offline status of the slave station, and schedules the master station to perform pre-recovery parallel operations when the slave station is determined to be offline. The master station sends verification parameters to the slave station that is determined to be offline to determine whether it is the first connection of the slave station and, based on the determination result, performs the corresponding slave station offline recovery operation; Based on the priority classification mechanism, the slave stations are prioritized and when multiple slave stations are offline at the same time, the master station resource load is dynamically scheduled to avoid bus conflicts. When the slave's communication is restored, recheck is performed with the master to maintain normal communication.
[0008] Furthermore, the prediction indicators include heartbeat delay fluctuation rate, bus error frame count and process data object data mutation rate; When any of the prediction indicators reaches the trigger condition, it is determined that the slave station is offline.
[0009] Furthermore, when it is determined that the slave station is offline, the parallel operation of scheduling the master station to perform pre-recovery includes: Extracting historical configuration parameters of the slave station from the local flash memory of the master station and loading the historical configuration parameters of the slave station into the random access memory of the master station; Allocate a dedicated process data object buffer for the slave station in the offline state and suspend the non-critical data transmission of the third priority slave; The master station sends a silent node management protocol status request to the slave station and caches the current status code of the slave station.
[0010] Furthermore, the master station sends verification parameters to the slave station determined to be offline, and determines whether the slave station is connected for the first time, including: When the slave connects to the master for the first time, the configuration and cache of the first connection are established on the master. When the master detects that the slave is offline, it queries the cache of the local flash memory for confirmation. If the slave's configuration record package is found, it marks the slave as not connecting for the first time.
[0011] Furthermore, when the slave connects to the master for the first time, the configuration and cache for establishing the first connection on the master include: The master station sends the verification parameters of the CAN open protocol through the service data object, including the device type and communication cycle; The slave station stores the check parameters in an electrically erasable programmable read-only memory and calculates a cyclic redundancy check value using a cyclic redundancy check algorithm; The master station caches the configuration record package of the slave station in the local flash memory and marks the corresponding slave station as not being connected for the first time.
[0012] Furthermore, based on the determination result, executing the corresponding slave offline recovery operation includes: The master station sends a node management protocol startup command, and the slave station loads the verification parameters from the electrically erasable programmable read-only memory; The slave activates the process data object channel within the preset activation cycle and enters the operating state; The master station waits for one message cycle. If no response is received from the slave station, it retries, and the retry time is less than or equal to two preset activation cycles. If no response is received after the retry, an alarm is triggered.
[0013] Furthermore, based on the priority classification mechanism, the slave stations are prioritized, and when multiple slave stations are offline at the same time, the resource load of the master station is dynamically scheduled, including: The master station prioritizes the slave stations according to their functional importance and allocates corresponding CPU resources to the slave stations of different priorities, wherein the priorities include first priority, second priority and third priority; The time slice is divided according to the priority of the slave station, and slave stations with different priorities occupy different time slice lengths; Slaves with the same priority send commands to the master station at different times to achieve time-sharing transmission of response frames. When the bus load rate exceeds a preset threshold, the master station dynamically adjusts the load response of slave stations with different priorities.
[0014] Furthermore, dynamically adjusting the load response of the master station to slave stations of different priorities includes: Extending the time slice length of the third priority slave station to a preset upper limit value; The check frame of the first priority slave station is compressed in a compressed format.
[0015] Furthermore, slave stations with the same priority send commands to the master station at different times to achieve time-sharing transmission of response frames, including: Slaves with the same priority level send commands to the master in ascending order of node ID, set the time interval between adjacent commands, and include a response delay value in the command.
[0016] Furthermore, when the communication of the slave station is restored, rechecking is performed using the master station, and after the rechecking passes, maintaining normal communication between the master station and the slave station includes: After communication is restored, the master station sends a check frame including the cyclic redundancy check value to the slave station, and the slave station recalculates the cyclic redundancy check value of the check parameter and returns the result; The master station compares the cyclic redundancy check values before and after communication is restored. If they are consistent, communication proceeds normally; if they are inconsistent, the preset configuration process is triggered to maintain the correctness of the cyclic redundancy check value.
[0017] The beneficial effects of the present invention are: 1. By combining active prediction with pre-recovery, passive detection is upgraded to "real-time communication quality monitoring + pre-recovery parallel processing", shortening the detection window to less than 10ms. Cache reuse simplifies the process, with the master station caching the historical configuration of the slave station. When it is not the first connection, the reset and SDO configuration steps are skipped and the slave station is started directly. A scheduling strategy is designed for multi-slave scenarios. Through priority classification, time slice rotation and bus peak shifting mechanisms, resource competition and congestion problems are resolved, ensuring that high-priority slaves are recovered first.
[0018] 2. The recovery time of a single slave is shortened from over 400ms to ≤50ms. The pre-recovery mechanism reduces the window period by 10ms. When multiple slaves go offline at the same time, the recovery time of the high-priority slave can still be maintained at ≤50ms, significantly improving the slave recovery speed.
[0019] 3. Cache reuse reduces SDO interactions by 80%, reduces the bus conflict rate from 30% to below 5%, and reduces the peak CPU occupancy of the master station from 90% to 60%, effectively optimizing resource utilization.
[0020] 4. CRC check can avoid parameter errors, and priority scheduling ensures that key equipment is restored first. In addition, this solution can be directly adapted to existing CANopen hardware without additional costs, effectively enhancing reliability and adaptability. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings: Figure 1 is a flow chart of a method for quickly reestablishing CANopen communication according to an embodiment of the present invention; Figure 2 This is a fast reconstruction flow chart including three modules according to an embodiment of the present invention; Figure 3 is a flowchart of historical configuration caching and pre-recovery processing according to an embodiment of the present invention; Figure 4 4 is a flow chart of a multi-slave scheduling and bus conflict avoidance strategy according to an embodiment of the present invention. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0023] See also Figure 1 , provides a method for quickly reestablishing CANopen communication, the method comprising: S1. Based on the prediction indicators, the master station monitors the communication quality of the slave station in real time, determines the offline status of the slave station, and schedules the master station to perform pre-recovery parallel operations when the slave station is determined to be offline.
[0024] In the description of the present invention, the prediction indicators include heartbeat delay fluctuation rate, bus error frame count and process data object data mutation rate (PDO data mutation rate).
[0025] When any of the prediction indicators reaches the trigger condition, the slave station is determined to be offline; the master station will enter the "pre-recovery state".
[0026] Specifically, the master station adds three new indicators for prediction based on the conventional heartbeat detection: Heartbeat delay fluctuation rate: When the ratio of the delay standard deviation to the average value for five consecutive cycles exceeds 30%, it is judged as "communication stability deterioration"; Bus error frame count: If more than five error frames (such as arbitration loss and CRC error) occur within 100ms, it is considered "bus interference is increasing"; PDO data mutation rate: When the mutation rate of key status variables (such as pitch current) transmitted by the slave exceeds ±10% within two consecutive cycles, it is judged as "abnormal slave response".
[0027] In the description of the present invention, when it is determined that the slave station is in an offline state, scheduling the master station to perform a parallel operation of pre-recovery includes: S11, cache parameter preloading: extract the historical configuration parameters of the slave station from the local flash memory (local Flash) of the master station, and load the historical configuration parameters of the slave station into the random access memory (RAM) of the master station.
[0028] S12, bus resource reservation: allocate a dedicated process data object buffer (PDO buffer) for the slave station in the offline state, and suspend the non-critical data transmission of the third priority (low priority) slave station.
[0029] S13, status snapshot pre-storage: The master sends a silent node management protocol (NMT) status request to the slave (sends only 0x700 + node ID, does not wait for a response), and caches the slave's current status code to reduce the time spent on subsequent confirmation operations.
[0030] S2. The master station sends verification parameters to the slave station that is determined to be offline, determines whether the slave station is connected for the first time, and executes the corresponding slave station offline recovery operation based on the determination result.
[0031] In the description of the present invention, Figure 3 As shown, the master station sends verification parameters to the slave station determined to be offline, determines whether the slave station is connected for the first time, and based on the determination result, performs the corresponding slave station offline recovery operation including: S21. When the slave station connects to the master station for the first time, the configuration and cache of the first connection are established on the master station.
[0032] In the description of the present invention, when a slave station connects to a master station for the first time, the configuration and cache for establishing the first connection at the master station include: S211. The master station sends the verification parameters of the Controller Area Network Open Protocol (CANopen) through the Service Data Object (SDO), including the device type and communication cycle, that is, the object dictionary index 0x1000: device type; 0x1005: communication cycle.
[0033] S212. The slave station stores the check parameters in an electrically erasable programmable read-only memory (EEPROM, address 0x0000-0x0003), and calculates a cyclic redundancy check value (CRC check value) using a cyclic redundancy check algorithm (CRC-16-IBM algorithm).
[0034] S213 , the master station caches the configuration record package of the slave station into the local flash memory, and marks the corresponding slave station as not being connected for the first time.
[0035] The configuration record package consists of node ID + parameter value + CRC + configuration timestamp.
[0036] S22. When it is detected that the slave station is offline, the master station queries the cache of the local flash memory for confirmation. If the configuration record package of the slave station is found, the master station is marked as not being connected for the first time.
[0037] Among them, when the slave station is offline, the master station queries the cache to confirm that it is "not the first connection", and then executes the following simplified process from S23 to S25.
[0038] S23, skip the reset step: the master station sends the NMT (Node Management Protocol) start command (0x01+node ID), and the slave station loads the verification parameters from the Electrically Erasable Programmable Read-Only Memory (EEPROM). No hardware reset is required (only the CAN controller is initialized).
[0039] S24, fast activation: The slave activates the process data object (PDO) channel within a preset activation period (e.g. 15ms) and enters the operating state.
[0040] S25, retry mechanism: The master station waits for one message cycle. If no response is received from the slave station, it retries, and the retry time is less than or equal to two preset activation cycles (total time ≤ 30ms). If no response is received after the retry, an alarm is triggered.
[0041] S3. Based on the priority classification mechanism, the slave stations are prioritized, and when multiple slave stations are offline at the same time, the master station resource load is dynamically scheduled to avoid bus conflicts.
[0042] In the description of the present invention, Figure 4 As shown in the figure, based on the priority classification mechanism, the slave stations are prioritized and the master station resource load is dynamically scheduled when multiple slave stations are offline at the same time to avoid bus conflicts. The following are included: S31. The master station prioritizes the slave stations according to their functional importance and allocates corresponding central processing unit resources to the slave stations of different priorities, wherein the priorities include a first priority, a second priority, and a third priority.
[0043] Specifically, the priority classification mechanism allows the master station to divide the slave stations according to the importance of their functions: 1. High priority (first priority): pitch drive, emergency brake unit (directly affecting system safety); 2. Medium priority (second priority): converters and power controllers (affecting operating efficiency); 3. Low priority (third priority): status sensors, auxiliary equipment (only for data collection).
[0044] The master allocates 60% of the CPU resources to high-priority slaves, 30% to medium-priority slaves, and 10% to low-priority slaves to avoid resource competition.
[0045] S32. Divide the time slices according to the priorities of the slave stations, and slave stations of different priorities occupy different time slice lengths.
[0046] Specifically, the time slice is divided as follows: high-priority slaves occupy a 5ms / 10ms cycle, medium-priority slaves occupy a 10ms / 20ms cycle, and low-priority slaves occupy a 20ms / 50ms cycle.
[0047] S33. Slaves with the same priority level send commands to the master station in staggered order to achieve time-sharing transmission of response frames.
[0048] In the description of the present invention, slave stations with the same priority send commands to the master station in staggered time intervals to implement time-sharing transmission of response frames, including: Slaves with the same priority send commands to the master in ascending order of node ID, set the time interval between adjacent commands, and include a response delay value in the command (e.g., a delay of 4ms for a slave with ID = 0x04) to ensure that response frames can be transmitted in time-sharing fashion.
[0049] S34. When the bus load rate exceeds a preset threshold, dynamically adjust the load response of the master station to slave stations of different priorities.
[0050] In the description of the present invention, dynamically adjusting the load response of the master station to slave stations of different priorities includes: The time slice length of the third priority slave station is extended to a preset upper limit value.
[0051] The check frame of the first priority slave is compressed in a compressed format (3 bytes instead of 8 bytes).
[0052] S4. When the communication of the slave station is restored, recheck is performed using the master station to maintain normal communication.
[0053] In the description of the present invention, when the communication of the slave station is restored, performing rechecking with the master station, and maintaining normal communication between the master station and the slave station after the rechecking passes includes: S41. After communication is restored, the master station sends a check frame including a cyclic redundancy check value (CRC value) to the slave station. The slave station recalculates the cyclic redundancy check value of the check parameter and returns the result.
[0054] S42: The master station compares the cyclic redundancy check values before and after communication is restored. If they are consistent, communication proceeds normally. If they are inconsistent, a preset configuration process is triggered to maintain the correctness of the cyclic redundancy check value.
[0055] The following describes in detail a method for quickly reestablishing CANopen communication designed by the present invention in conjunction with specific embodiments.
[0056] The core idea of this invention is to focus on "active prediction - cache reuse - intelligent scheduling". In the process of building a system architecture with this method, the rapid reconstruction of communication is achieved through the collaborative work of three innovative modules, such as Figure 2 As shown, the three modules are: The first module: pre-recovery and parallel processing module, used to solve the problem of passive detection; The second module: cache reuse module (historical configuration caching and process simplification), is used to solve the problem of redundant steps; The third module: multi-slave scheduling module (multi-slave scheduling strategy), is used to resolve conflict problems.
[0057] Example 1: Fast recovery of a non-first connection of a single slave (corresponding to the "cache reuse module").
[0058] System configuration: The master station uses the Beckhoff CX5140PLC (master control), and the slave stations include three pitch drives (node ID = 0x03, 0x04, 0x05, corresponding to blades 1-3 respectively). The communication cycle is 10ms, and the command response delay is required to be ≤100ms.
[0059] CANopen core parameters (issued via SDO): Object dictionary index 0x1000 (device type) = 0x0120 (stored as bytes 0x20 and 0x01, stored with the least significant byte first); index 0x1005 (communication period) = 0x000A (stored as bytes 0x0A and 0x00, corresponding to 10 ms).
[0060] Implementation steps include: 1. System initialization and first configuration: After the unit is powered on, the master station detects that the slave station is connected for the first time (no cache record), and the specific operations are as follows: 1.1. Send the NMT reset command (0x01+0x04) to reset the driver with ID = 0x04 and wait 200ms to complete hardware initialization.
[0061] 1.2. Write parameters via SDO: Object dictionary index 0x1000 (Device type, value = 0x0120, 16-bit data, stored as 2 bytes with the low byte first: 0x20, 0x01); Index 0x1005 (Communication cycle, value = 0x000A, 16-bit data, stored as 2 bytes with the low byte first: 0x0A, 0x00, corresponding to 10ms).
[0062] 1.3. The slave calculates the CRC value of the 0x1000 / 0x1005 parameter (the process is as follows): Byte stream: 0x20 → 0x01 → 0x0A → 0x00; After input inversion: 0x04→0x80→0x50→0x00; Performing CRC calculation byte by byte (polynomial 0x8005, initial value 0x0000), the final result is 0xA05C.
[0063] 1.4. The master station stores "ID = 0x04 + 0x1000 / 0x1005 parameters + CRC = 0xA05C + timestamp" in the Flash and marks it as "not the first connection".
[0064] 2. Normal operation and offline detection: The master sends the target angle (for example, 30°) through TPDO1. The slave transmits the current angle (29.8°) and current (5.2A) through RPDO1. It receives a heartbeat message (0x700 + 0x04) every 50ms. Due to transient interference on the bus, the heartbeat of the slave with ID = 0x04 times out (50ms × 1.5 = 75ms), triggering the master to trigger the recovery process.
[0065] 3. Fast recovery (not the first connection): After querying the cache and confirming that it is not the first connection, the master station skips the reset and SDO configuration steps and directly sends the NMT start command (0x01+0x04). The slave station loads the 0x1000 / 0x1005 parameters from the EEPROM, initializes the CAN controller only, activates the PDO channel within 15ms, and sends back a heartbeat response. The master station receives the response within 30ms, with a total recovery time of 45ms (75ms detection + 45ms recovery). It then immediately sends a 30° target command via the PDO, and the slave station responds and makes adjustments.
[0066] 4. Verification after recovery: The master station sends a PDO verification frame (ID = 0x200 + 0x04, data field: 0x02 + 0x5C + 0xA0); the slave station recalculates the CRC = 0xA05C and returns the result through RPDO1. After the master station compares and finds a consistency, it continues monitoring.
[0067] Effect of Example 1: The recovery time of a single slave station is 45ms, which is 90% shorter than the traditional process (over 400ms), meeting the real-time requirement of ≤100ms.
[0068] Example 2: Pre-recovery and parallel processing (corresponding to the "pre-recovery module").
[0069] Scenario: The communication quality of the pitch drive with ID = 0x03 degrades due to gusty wind conditions, and the master station triggers pre-recovery in advance.
[0070] like Figure 3 As shown, the implementation steps include: 1. Communication quality prediction: When the master station detects abnormalities in the indicator ID = 0x03 in real time, including the heartbeat delay fluctuation rate = 35% (exceeding the 30% threshold) and the bus error frame rate = 6 frames within 100ms (exceeding the 5-frame threshold), the pre-recovery state is triggered and the following operations are performed at the same time: 1.1. Load cache parameters into RAM (saving 10ms of Flash read time); 1.2. Reserve PDO buffer and suspend data transmission of low-priority sensors; 1.3. Send a silent NMT status request and cache the current status code of the slave.
[0071] , offline and fast recovery: After 10ms, the slave station with ID = 0x03 confirms the offline. Since the master station has completed preloading, it directly sends the NMT start command; the slave station activates PDO within 15ms, and the master station receives the response within 20ms. The total recovery time is 35ms (including 10ms pre-recovery preparation time).
[0072] Effect of Example 2: The pre-recovery mechanism reduces the window period by 10ms. Compared with Example 1, the recovery time is further shortened by 22%.
[0073] Example 3: Scheduling multiple slaves when they are offline simultaneously (corresponding to the "Multi-slave Scheduling Module"). Scenario: Sudden electromagnetic interference causes ID = 0x03 (high priority, blade 1), ID = 0x04 (high priority, blade 2), and ID = 0x06 (medium priority, converter) to go offline simultaneously.
[0074] like Figure 4 As shown, the implementation steps include: 1. Priority classification and resource allocation: The master station schedules according to the priority queue: 60% of the CPU resources are allocated to high priority (0x03, 0x04) and 30% of the CPU resources are allocated to medium priority (0x06).
[0075] 2. Time-slice staggered transmission: 2.1, 0ms: Send NMT start command 0x03 (response delay 3ms); 2.2, 1ms: Send the NMT start command 0x04 (response delay 4ms); 2.3, 2ms: Send the NMT start command 0x06 (response delay 6ms); At this time, the bus load rate = 55% (does not exceed the threshold), and the normal time slice configuration (high priority 5ms / 10ms cycle) is maintained.
[0076] 3. Parallel recovery results: 3.1, 0x03 slave: response within 3ms, total recovery time 40ms; 3.2, 0x04 slave: response within 4ms, total recovery time 41ms; 3.3, 0x06 slave: response within 6ms, total recovery time 62ms; No bus conflicts occurred during the entire process (conflict rate = 0), and the recovery time of high-priority slaves all met the requirement of ≤50ms.
[0077] Effect of Example 3: When multiple slave stations are offline at the same time, high-priority devices can be restored first, the bus conflict rate is reduced from the traditional 30% to 0, and the system stability is significantly improved.
[0078] Summary of the embodiments: The above three embodiments correspond to the three core innovations of "cache reuse", "pre-recovery" and "multi-slave station scheduling", covering scenarios such as single slave station, pre-judgment recovery, and multi-slave station conflict.
[0079] All examples are based on the real parameters of a wind turbine pitch control system (communication cycle 10ms, response threshold 100ms), verifying the feasibility of the solution in key industrial scenarios.
[0080] From the quantitative effect point of view, the recovery time is shortened by 80%-90%, and the bus conflict rate is close to 0, which can meet the requirements of high real-time performance and high reliability.
[0081] In summary, with the help of the above technical solutions of the present invention, by combining active prediction with pre-recovery, passive detection is upgraded to "real-time communication quality monitoring + pre-recovery parallel processing", shortening the detection window period to less than 10ms; with the help of cache reuse to simplify the process, the master station caches the historical configuration of the slave station, skips the reset and SDO configuration steps when it is not the first connection, and directly starts the slave station; a scheduling strategy is designed for multi-slave scenarios, and through priority classification, time slice rotation and bus peak shifting mechanism, resource competition and congestion problems are solved to ensure that high-priority slaves are restored first. The recovery time of a single slave station is shortened from more than 400ms to ≤50ms, and the pre-recovery mechanism reduces the window period by 10ms; when multiple slave stations are disconnected at the same time, the recovery time of the high-priority slave station can still be maintained at ≤50ms, significantly improving the recovery speed of the slave station. Cache reuse reduces 80% of SDO interactions, the bus conflict rate is reduced from 30% to less than 5%, and the peak occupancy rate of the master station CPU is reduced from 90% to 60%, effectively optimizing resource utilization. CRC checking can avoid parameter errors, and priority scheduling ensures that critical equipment is restored first. In addition, this solution can be directly adapted to existing CANopen hardware without additional costs, effectively enhancing reliability and adaptability.
[0082] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
Claims
1. A method for quickly reestablishing CANopen communication, characterized in that: The method includes: Based on the prediction indicators, the master station monitors the communication quality of the slave station in real time, determines the offline status of the slave station, and schedules the master station to perform pre-recovery parallel operations when the slave station is determined to be offline. The master station sends verification parameters to the slave station that is determined to be offline to determine whether it is the first connection of the slave station and, based on the determination result, performs the corresponding slave station offline recovery operation; Based on the priority classification mechanism, the slave stations are prioritized and when multiple slave stations are offline at the same time, the master station resource load is dynamically scheduled to avoid bus conflicts. When the slave's communication is restored, recheck is performed with the master to maintain normal communication.
2. A method for quickly reestablishing CANopen communication according to claim 1, characterized in that: The prediction indicators include heartbeat delay fluctuation rate, bus error frame count and process data object data mutation rate; When any of the prediction indicators reaches the trigger condition, it is determined that the slave station is offline.
3. The method for quickly reestablishing CANopen communication according to claim 1, characterized in that: When determining that the slave station is in an offline state, scheduling the master station to perform a parallel operation of pre-recovery includes: Extracting historical configuration parameters of the slave station from the local flash memory of the master station and loading the historical configuration parameters of the slave station into the random access memory of the master station; Allocate a dedicated process data object buffer for the slave station in the offline state and suspend the non-critical data transmission of the third priority slave; The master station sends a silent node management protocol status request to the slave station and caches the current status code of the slave station.
4. The method for quickly reestablishing CANopen communication according to claim 1, characterized in that: The master station sends a verification parameter to the slave station determined to be in an offline state, and determines whether the slave station is connected for the first time, including: When the slave connects to the master for the first time, the configuration and cache of the first connection are established on the master. When the master detects that the slave is offline, it queries the cache of the local flash memory for confirmation. If the slave's configuration record package is found, it marks the slave as not connecting for the first time.
5. A method for quickly reestablishing CANopen communication according to claim 4, characterized in that: When the slave station connects to the master station for the first time, the configuration and cache of the first connection established at the master station include: The master station sends the verification parameters of the CAN open protocol through the service data object, including the device type and communication cycle; The slave station stores the check parameters in an electrically erasable programmable read-only memory and calculates a cyclic redundancy check value using a cyclic redundancy check algorithm; The master station caches the configuration record package of the slave station in the local flash memory and marks the corresponding slave station as not being connected for the first time.
6. A method for quickly reestablishing CANopen communication according to claim 4, characterized in that: The executing of the corresponding slave offline recovery operation based on the determination result includes: The master station sends a node management protocol startup command, and the slave station loads the verification parameters from the electrically erasable programmable read-only memory; The slave activates the process data object channel within the preset activation cycle and enters the operating state; The master station waits for one message cycle. If no response is received from the slave station, it retries, and the retry time is less than or equal to two preset activation cycles. If no response is received after the retry, an alarm is triggered.
7. The method for quickly reestablishing CANopen communication according to claim 1, characterized in that: The priority classification mechanism is based on which the slave stations are prioritized, and when multiple slave stations are offline at the same time, the resource load of the master station is dynamically scheduled, including: The master station prioritizes the slave stations according to their functional importance and allocates corresponding central processing unit resources to the slave stations of different priorities, wherein the priorities include first priority, second priority and third priority; The time slice is divided according to the priority of the slave station, and slave stations with different priorities occupy different time slice lengths; Slaves with the same priority send commands to the master station at different times to achieve time-sharing transmission of response frames. When the bus load rate exceeds a preset threshold, the master station dynamically adjusts the load response of slave stations with different priorities.
8. The method for quickly reestablishing CANopen communication according to claim 7, characterized in that: The dynamic adjustment of the master station's load response to slave stations of different priorities includes: Extending the time slice length of the third priority slave station to a preset upper limit value; The check frame of the first priority slave station is compressed in a compressed format.
9. A method for quickly reestablishing CANopen communication according to claim 8, characterized in that: The slave stations of the same priority send commands to the master station at different peak times to realize time-sharing transmission of response frames, including: Slaves with the same priority level send commands to the master in ascending order of node ID, set the time interval between adjacent commands, and include a response delay value in the command.
10. The method for quickly reestablishing CANopen communication according to claim 1, characterized in that: When the communication of the slave station is restored, rechecking is performed by the master station, and after the rechecking passes, maintaining normal communication between the master station and the slave station includes: After communication is restored, the master station sends a check frame including the cyclic redundancy check value to the slave station, and the slave station recalculates the cyclic redundancy check value of the check parameter and returns the result; The master station compares the cyclic redundancy check values before and after communication is restored. If they are consistent, communication proceeds normally; if they are inconsistent, the preset configuration process is triggered to maintain the correctness of the cyclic redundancy check value.