EtherCAT real-time performance improving method and system, storage medium and program product

By optimizing the control flow of the EtherCAT system, prioritizing data transmission before computation, and combining instruction buffer queues and hash table optimizations, the problems of jitter and high computational complexity in low-latency tasks of the EtherCAT system were solved, resulting in improved real-time performance and stability, and meeting the precision and safety requirements of industrial control.

CN120848442AActive Publication Date: 2025-10-28临海市新睿电子科技股份有限公司

Patent Information

Application Number
CN202511377697.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-25
Publication Date
2025-10-28
Estimated Expiration
2045-09-25

AI Technical Summary

Technical Problem

In low-latency tasks, the uncertainty of the update() operation in the EtherCAT system causes jitter in the message transmission cycle, which affects the probability of communication timeout and system stability. This makes it impossible to meet the requirements of deterministic timing in industrial control, and the update calculation has high time complexity, which affects the accuracy and safety of motion control.

Method used

The master station first performs a read operation and immediately sends the command. Then, it performs update calculations during the remaining time of the control cycle. It optimizes the calculation efficiency by using the command buffer queue and the joint index hash table. By reconstructing task management resources online and implementing strict log level filtering, it ensures the timeliness and integrity of control commands.

Benefits of technology

It reduces the probability of message jitter, improves the real-time performance and stability of the system, meets the deterministic requirements of low-latency tasks, enhances computational efficiency and system fault tolerance, and ensures the accuracy and security of control commands.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120848442A_ABST
    Figure CN120848442A_ABST
Patent Text Reader

Abstract

The invention provides an EtherCAT real-time performance improving method and system, a storage medium and a program product, and relates to the technical field of industrial data high-speed transmission. The master station firstly executes the reading operation and then executes the instruction sending operation, and the operation is immediately carried out after the reading operation, so that the additional delay introduced by the updating calculation operation can be effectively avoided, the control instruction calculated in the last period is directly and quickly sent to the slave station, the slave station is ensured to execute the latest command in time, the data can be quickly sent out in the current period, and the real-time performance is improved. The updating calculation operation is arranged after the instruction is sent, and the remaining time of the control period is fully utilized to prepare the instruction for the next period in advance, so that the calculation efficiency is improved, the delay influence on the previous link is reduced, and the disorder of the subsequent message sending time caused by the uncertain updating calculation execution time is avoided; therefore, under a low-delay task (such as a 1ms period task), the occurrence probability of a jitter phenomenon is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of high-speed industrial data transmission technology, and in particular to a method, system, storage medium and program product for improving the real-time performance of EtherCAT. Background Technology

[0002] In the field of industrial automation, especially in applications with stringent real-time requirements (such as high-speed precision machining, robot collaborative control, and servo drive systems), EtherCAT (Ethernet Control Automation Technology) has become the mainstream real-time industrial Ethernet solution due to its nanosecond-level communication jitter and sub-millisecond-level cycle time.

[0003] The existing EtherCAT system follows a pattern of repeatedly executing a series of tasks: read() (reading relevant data), update() (performing update calculations), and write() (outputting relevant instructions).

[0004] However, in actual operation, the time required for the update() operation is highly uncertain. This uncertainty directly leads to the difficulty in determining the subsequent message sending time, resulting in jitter in the message sending cycle.

[0005] Industrial control has stringent requirements, demanding strict deterministic timing within each cycle. However, the `update()` phase involves complex calculations such as logical operations and path planning, making its computation time prone to fluctuations. This inevitably leads to non-deterministic offsets in message transmission (commonly known as jitter). Furthermore, this can cause a series of more serious adverse consequences. Firstly, the probability of communication timeouts increases significantly. If a sudden delay occurs in the `update()` phase, causing the `write()` operation to exceed the predetermined 1ms window, the EtherCAT master's watchdog timeout (WD_TIMEOUT) mechanism will be triggered. In this situation, a minor impact might be that the slave device enters a safe-operational state; more seriously, it could directly cause an emergency shutdown of the entire production line, undoubtedly resulting in significant losses and severe disruptions to industrial production.

[0006] On the other hand, Quality of Service (QoS) policies will also fail as a result. It's important to understand that critical data flows like secure I / O signals rely on priority queues for low-latency transmission. However, jitter in the message transmission cycle disrupts the original timing predictions of the message scheduler, ultimately causing high-priority frames to be discarded due to buffer overflows, resulting in priority inversion. This is undoubtedly a major obstacle for data transmissions that require priority protection, severely impacting the normal operation of the system and the execution of critical operations.

[0007] Further investigation revealed that when the control logic was updated, the original execution time of `update()` reached 1.4ms, exceeding the set 1ms execution period. This exacerbated the jitter and even caused disconnections, making the system unable to support normal operation within a 1ms period. Therefore, a 4ms period was used for testing, but even then, many serious problems remained.

[0008] First, the jitter becomes difficult to suppress. When the update() time reaches 1.4ms, exceeding the original cycle, the system is forced to activate the cycle extension compensation mechanism (such as skipping the cycle for execution). This causes the actual cycle to fluctuate drastically between 1.4ms and 4ms, resulting in a cycle jitter rate as high as 300%, far exceeding the industrial standard requirement of less than 10%, which undermines the stability and predictability of the system operation.

[0009] Secondly, motion control performance also showed significant degradation. After the period was extended to 4ms, the phase margin of the servo control loop decreased sharply. Calculating with a typical servo bandwidth of 500Hz, a 4ms period can only support a maximum control frequency of 125Hz, which is far from meeting the precision requirements of motion control in actual industrial control scenarios. This leads to problems such as mechanical vibration or trajectory tracking instability, affecting the accuracy of production and processing and product quality.

[0010] Finally, data integrity is also compromised. When the update() operation is forcibly entered into the next cycle before it is completed, the process data image (PDO) may contain outdated data that has not yet been updated. This can cause conflicts between control commands, such as sudden motor jumps or valve malfunctions, posing a great safety hazard and operational failure to the entire industrial production process.

[0011] In summary, in applications requiring a 1ms cycle time, the strong uncertainty of update() leads to jitter, which directly or indirectly causes the aforementioned problems. Reducing the cycle time to 4ms can solve this problem, but it degrades the entire system into a soft real-time system, completely losing the determinism necessary for industrial control scenarios. Summary of the Invention

[0012] This application provides a method, system, storage medium, and program product for improving the real-time performance of EtherCAT, which reduces the probability of jitter in low-latency tasks (e.g., 1ms periodic tasks).

[0013] In a first aspect, this application provides a method for improving the real-time performance of EtherCAT, comprising: applied to an EtherCAT communication system consisting of a master station and at least one slave station, the method sequentially executing the following steps within a preset control cycle: the master station performs a read operation, which obtains the current real-time status data of the slave station from at least one slave station and stores the real-time status data of the slave station in the memory of the master station; after performing the read operation, the master station performs a send command operation, which writes the control command of the previous cycle to at least one slave station via EtherCAT; after the send command operation, the master station uses the remaining time of the current control cycle to perform an update calculation operation, which uses the real-time status data of the slave station to perform control logic operations and trajectory interpolation to generate the next cycle control command for use in the next control cycle, and stores the next cycle control command.

[0014] By adopting the above technical solution, the master station first performs a read operation, followed by a send command operation. This immediate execution of the read operation effectively avoids the additional delay introduced by the update calculation operation, directly and quickly sending the control commands calculated in the previous cycle to the slave station. This ensures that the slave station executes the latest commands promptly, allowing data to be transmitted quickly within the current cycle, thus improving real-time performance. The update calculation operation is scheduled after the send command, making full use of the remaining time in the control cycle to prepare commands for the next cycle. This improves calculation efficiency and reduces the impact of delays on preceding steps, avoiding subsequent message transmission time irregularities caused by the uncertain execution time of the update calculation. This suppresses message transmission cycle jitter, thus reducing the probability of jitter in low-latency tasks (e.g., 1ms cycle tasks).

[0015] In conjunction with some embodiments of the first aspect, in some embodiments, during the step of the master station performing the update calculation operation using the remaining time of the current control cycle, the method further includes: the master station synchronously performing an online reconstruction task, wherein the agreed duration of the online reconstruction task is less than the remaining time; the task nodes of the online reconstruction task are selected from the nodes released by the update calculation operation; after a preset time, the master station determines the completion status of the online reconstruction task and the number of selected task nodes; when the completion status is less than a preset completion threshold and the number of selected task nodes is less than a preset number threshold, the master station cancels the online reconstruction task and releases all selected task nodes within the control cycle; and changes the correspondence of the online reconstruction task; when the completion status is less than the preset completion threshold and the number of selected task nodes is greater than or equal to the preset number threshold, the master station increases the agreed duration of the online reconstruction task, and the increased agreed duration is not greater than the remaining time.

[0016] By adopting the above technical solution, when the main station performs update calculations using the remaining time of the current control cycle, given the uncertainty of `update()`, it chooses to have the online reconstruction task run in parallel. Nodes released by the update calculations are selected for the reconstruction task, utilizing idle resources while avoiding conflicts caused by excessive resource contention, ensuring that both can start collaboratively in the initial stage. After a period of time, the overall situation is controlled by judging the completion status of the online reconstruction task and the number of nodes. When the completion status is poor and the number is also unsatisfactory, it means that `update()` is under great pressure and the trend has not improved. At this time, the online reconstruction task is directly canceled without affecting the completion of `update()`. When the completion status is poor but the number is ideal, it indicates that the trend of `update()` is gradually improving. To avoid affecting `update()`, the agreed duration of the online reconstruction task is increased, thus improving the completion status of the online reconstruction task from another dimension.

[0017] In conjunction with some embodiments of the first aspect, in some embodiments, the step of writing the previous cycle control instruction to at least one slave station via EtherCAT specifically includes: the master station retrieving the previous cycle control instruction from the head of the instruction buffer queue and writing it to at least one slave station via EtherCAT; and the step of storing the next cycle control instruction specifically includes: the master station pushing the next cycle control instruction to the end of the instruction buffer queue.

[0018] By adopting the above technical solution and introducing an instruction buffer queue, a decoupled buffer layer is established between instruction production (update calculation) and consumption (instruction sending). This enhances the system's fault tolerance, ensuring the continuity and integrity of control instructions even in the face of sudden computational delays, thus improving the system's stability and reliability.

[0019] In conjunction with some embodiments of the first aspect, in some embodiments, after the step of the master station determining the completion status of the online reconstruction task and the number of selected task nodes after a preset time, the method further includes: the master station determining whether there is a control instruction in the instruction buffer queue; if there is a control instruction, the master station determining whether the control instruction was generated in the current control cycle; if it was generated in the current control cycle, then when the completion status is less than a preset completion threshold and the number of selected task nodes is less than a preset number threshold, the master station cancels the online reconstruction task and releases all selected task nodes within the control cycle; and changes the correspondence of the online reconstruction task; when the completion status is less than the preset completion threshold and the number of selected task nodes is greater than the preset number threshold, the master station increases the agreed duration of the online reconstruction task, and the increased agreed duration is not greater than the remaining time; if it was not generated in the current control cycle, then when the completion status is less than the preset completion threshold, the master station cancels the online reconstruction task and releases all selected task nodes within the control cycle; and changes the correspondence of the online reconstruction task.

[0020] By adopting the above technical solution, the current length of the instruction buffer queue is taken into consideration, thus affecting the rigor of the judgment on online reconstruction tasks. When the completion rate is less than the preset threshold and the number of selected task nodes is less than the preset threshold, it means that even under the most lenient conditions, the online reconstruction task is difficult to complete. In this case, the task is directly canceled and resources are released according to the established strategy. When the completion rate is less than the preset threshold and the number of selected task nodes is greater than the preset threshold, considering that even with a large amount of resources invested, the task may still not be completed, the system further checks whether there are instructions in the instruction buffer queue. If there are instructions, it is further determined whether they were generated in the current control cycle. If they were generated in the current control cycle, it means that update() has been completed, and the online reconstruction task can be completed normally. If they were not generated in the current control cycle, it means that there is a backlog of old instructions, etc. In this case, the online reconstruction task is canceled, resources are released, and the corresponding relationships are changed to improve the completion rate of update().

[0021] In conjunction with some embodiments of the first aspect, in some embodiments, the control logic operation includes a joint sequence adjustment algorithm; the joint sequence adjustment algorithm specifically includes: the master station traverses the n preset internal joints of the robot control system, and creates a joint index hash table with the name of each internal joint as the key and its corresponding internal index as the value; the master station receives a trajectory message containing m target joint names and their corresponding target values; for each target joint name in the trajectory message, the master station uses the joint index hash table to look up the corresponding internal index and obtain the mapping relationship between the target joint and the internal index; the master station fills the target value in the trajectory message into the control instruction data structure corresponding to the internal index according to the mapping relationship.

[0022] By adopting the above technical solution, a key operation of creating a joint index hash table is introduced into the joint sequence adjustment algorithm. First, a hash table is constructed using the names of each internal joint preset by the robot control system as keys and their corresponding internal indices as values. Subsequently, when receiving trajectory messages containing target joint names and their corresponding target values, the hash table is used to look up the internal index for each target joint name, thereby obtaining the mapping relationship and filling the control command data structure. In this way, the originally computationally intensive traversal search operation is cleverly transformed into a near-constant-time lookup operation, reducing the overall adjustment time complexity from O(m・n) to O(m+n). This fundamentally shortens the total time of the update calculation steps, better meeting the needs of industrial control scenarios for precise and rapid command generation.

[0023] In conjunction with some embodiments of the first aspect, in some embodiments, the update calculation operation further includes managing log records; wherein, the master station receives a log record request containing an event severity level; the master station compares the event severity level with a preset log record threshold; if the event severity level is equal to or higher than the log record threshold, the master station performs an I / O operation to write the data corresponding to the log record request; if the event severity level is lower than the log record threshold, the master station directly discards the log record request.

[0024] By adopting the above technical solution and implementing strict log level filtering, unnecessary I / O interference was eliminated at the system level. This creates a cleaner and more deterministic operating environment for EtherCAT communication tasks, eliminating a significant source of random jitter.

[0025] In conjunction with some embodiments of the first aspect, in some embodiments, trajectory interpolation specifically includes: the master station acquiring the current state data of the controlled object and determining the current running state according to preset state machine logic; when the running state is running, the following sub-steps are executed in sequence: the master station generates a target motion command containing the target position; the master station generates a feedback control command based on the error between the target position and the actual position; the master station performs a safety check on the feedback control command to determine whether it exceeds a preset safety threshold; if the master station determines the result is yes, it updates the running state to a fault state and designates a preset braking command as the final control command; if the master station determines the result is no, it combines the feedback control command and the feedforward command to generate the final control command; the master station stores the final control command.

[0026] By adopting the above technical solution, the master station first obtains the current state data of the controlled object and accurately determines the current operating state based on the preset state machine logic. This lays the foundation for subsequent operations such as instruction generation, ensuring that each step is carried out in accordance with the actual situation. When the operating state is running, a series of sub-steps are executed sequentially. First, a target motion instruction containing the target position is generated. Then, a feedback control instruction is generated based on the error between the target position and the actual position. Next, the feedback control instruction is verified for safety. Through this process, abnormal instructions that may exceed the preset safety threshold can be detected in a timely manner. If they exceed the threshold, the operating state is quickly updated to a fault state and the braking instruction is designated as the final control instruction, ensuring system safety. If the threshold is not exceeded, the feedback control instruction and the feedforward instruction are combined to generate the final control instruction. Finally, the final control instruction is stored. Each step works closely together and is interconnected, so that the generation of control instructions takes into account both the actual operating state and safety factors. This not only improves the accuracy and timeliness of instruction generation but also effectively avoids faults caused by abnormal instructions, ensuring the accuracy, stability, and safety of the entire system's control over the controlled object, and better serving the control needs in complex industrial scenarios.

[0027] In a second aspect, this application provides an EtherCAT real-time performance enhancement system, which includes: one or more processors and a memory; the memory is coupled to one or more processors, and the memory is used to store computer program code, which includes computer instructions, and the one or more processors invoke the computer instructions to cause the EtherCAT real-time performance enhancement system to perform the method described in the first aspect and any possible implementation thereof.

[0028] Thirdly, this application provides a computer program product containing instructions that, when run on an EtherCAT real-time performance enhancement system, cause the EtherCAT real-time performance enhancement system to perform the method described in the first aspect and any possible implementation thereof.

[0029] Fourthly, this application provides a computer-readable storage medium including instructions that, when executed on an EtherCAT real-time enhancement system, cause the EtherCAT real-time enhancement system to perform the method described in the first aspect and any possible implementation thereof.

[0030] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. The master station performs a read operation first, followed by a send command operation. This immediate execution of the read operation effectively avoids the additional delays introduced by the update calculation operation, directly and quickly sending the control commands calculated in the previous cycle to the slave station. This ensures the slave station executes the latest commands promptly, allowing data to be transmitted quickly within the current cycle, thus improving real-time performance. The update calculation operation is scheduled after the send command operation, making full use of the remaining time in the control cycle to prepare commands for the next cycle. This improves calculation efficiency and reduces the impact of delays on preceding steps, avoiding subsequent message transmission time irregularities caused by the uncertain execution time of the update calculation. This suppresses message transmission cycle jitter, thus reducing the probability of jitter in low-latency tasks (e.g., 1ms cycle tasks).

[0031] 2. When the main station performs update calculations using the remaining time of the current control cycle, given the uncertainty of `update()`, it chooses to have the online reconstruction task run in parallel. Nodes released by the update calculations are selected for the reconstruction task, utilizing idle resources while avoiding excessive resource contention and conflicts, ensuring that both can start collaboratively in the initial stage. After a period of time, the overall situation is monitored by judging the completion status of the online reconstruction task and the number of nodes. When the completion status is poor and the number of nodes is also unsatisfactory, it means that `update()` is under heavy pressure and the trend has not improved. In this case, the online reconstruction task is directly canceled without affecting the completion of `update()`. When the completion status is poor but the number of nodes is ideal, it indicates that the trend of `update()` is gradually improving. To avoid affecting `update()`, the agreed duration of the online reconstruction task is increased, thus improving the completion status of the online reconstruction task from another dimension.

[0032] 3. The current length of the instruction buffer queue is taken into consideration, affecting the stringency of the judgment on online refactoring tasks. When the completion rate is less than the preset threshold and the number of selected task nodes is less than the preset threshold, it means that even under the most lenient conditions, the online refactoring task is difficult to complete. In this case, the task is canceled and resources are released directly according to the established strategy. When the completion rate is less than the preset threshold and the number of selected task nodes is greater than the preset threshold, considering that even with a large amount of resources invested, the task may still not be completed, the system further checks whether there are instructions in the instruction buffer queue. If there are instructions, it is further determined whether they were generated in the current control cycle. If they were generated in the current control cycle, it means that update() has been completed, and the online refactoring task can be completed normally. If they were not generated in the current control cycle, it means that there is a backlog of old instructions, etc. In this case, the online refactoring task is canceled, resources are released, and the corresponding relationships are changed to improve the completion rate of update(). Attached Figure Description

[0033] Figure 1 This refers to the EtherCAT cycle loop process in related technologies; Figure 2 This is the EtherCAT cycle loop process in the embodiments of this application; Figure 3 This is a flowchart illustrating a method for improving the real-time performance of EtherCAT in an embodiment of this application. Figure 4 This is another flowchart illustrating the EtherCAT real-time performance improvement method in this application embodiment; Figure 5 This is a schematic diagram of an exemplary hardware structure of the EtherCAT real-time performance improvement system in this application embodiment. Detailed Implementation

[0034] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to and includes any or all possible combinations of one or more of the listed items.

[0035] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0036] To clearly demonstrate the differences between this application and related technologies, the following provides a comparison between the EtherCAT cycle loop process in related technologies and the EtherCAT cycle loop process of this application. It should be noted that the above two processes are only to highlight key differences and do not cover all differences.

[0037] See also Figure 1 , Figure 1 This refers to the EtherCAT cycle loop process in related technologies; S101, Begin; S102, waiting period before departure; S103, Read EtherCAT slave data - read(); S104. Perform distributed clock synchronization; S105, Perform control logic update - update(); S106, Write control command - write(); S107. Send EtherCAT data frame; S108, Listening to the CtrlC semaphore; S109. The cycle ends; prepare for the next cycle. See also Figure 1 , Figure 2 This is the EtherCAT cycle loop process in the embodiments of this application; S201, Begin; S202, waiting period before departure; S203, Read EtherCAT slave data - read(); S204, Write control command - write(); S205, Perform control logic update - update(); S206, joint trajectory adjustment algorithm; S207, Perform distributed clock synchronization; S208, Send EtherCAT data frame; S209, Listening to the CtrlC semaphore; S210, Cycle ends, prepare for the next cycle; By comparing the two processes described above, it can be seen that the main difference in this application lies in steps S104-S106 and S204-S207. The following embodiments will illustrate these differences in detail.

[0038] See also Figure 3 , Figure 3 This is a flowchart illustrating a method for improving the real-time performance of EtherCAT in an embodiment of this application. An EtherCAT real-time performance improvement method is applied to an EtherCAT communication system consisting of a master station and at least one slave station. The method executes the following steps sequentially within a preset control cycle: S301. The master station performs a read operation, which retrieves the current real-time status data of at least one slave station and stores the real-time status data of the slave station into the memory of the master station. In the EtherCAT communication system, the master station is the device that plays a leading and controlling role. It is responsible for managing and coordinating communication with slave stations, processing system data, and generating commands. Slave stations are devices controlled by the master station in the EtherCAT communication system. They are responsible for executing commands sent by the master station and feeding back their real-time status data. Slave station real-time status data refers to information such as the slave station's current operating parameters and working status, including position, speed, temperature, and pressure. This data reflects the real-time operating status of the slave station.

[0039] S302. After performing the read operation, the master station performs the send command operation, writing the control command of the previous cycle to at least one slave station via EtherCAT. Among them, the previous cycle control instruction refers to the set of instructions generated by the master station after calculation and processing in the previous control cycle, which is used to control the slave station to perform a specific task, similar to the next cycle control instruction in step S303.

[0040] Immediately after the read operation, the control command from the previous cycle is sent to ensure that the slave station can obtain and execute the latest control command in a timely manner, reducing the command sending delay caused by waiting for the update calculation operation to complete, and improving the real-time performance and response speed of the system.

[0041] In existing technologies, the uncertainty of the update() operation time may cause delays in the write() operation, exceeding the 1ms period window and leading to communication timeouts. This step decouples the command sending operation from the update calculation operation by executing the command sending operation immediately after the read operation. This avoids the impact of update() operation time fluctuations on command sending, ensuring that the slave station can receive and execute control commands in a timely manner, and reducing the risk of communication timeouts.

[0042] S303. After sending the command operation, the master station uses the remaining time of the current control cycle to perform an update calculation operation. The update calculation operation uses the real-time status data of the slave station to perform control logic operations and trajectory interpolation to generate the next cycle control command for use in the next control cycle, and stores the next cycle control command.

[0043] Among these, update calculation operations refer to a series of computational processes performed by the master station to generate control commands for the next cycle. Control logic operations refer to logical judgments and calculations based on the system's control rules and real-time status data from the slave stations to determine the next control strategy. Trajectory interpolation, in motion control scenarios, calculates the midpoints on the motion trajectory using algorithms based on given start and end points and motion parameters to achieve precise motion control.

[0044] Specifically, after the master station sends the control command of the previous cycle to the slave station, it checks the remaining time of the current control cycle. Within the remaining time, it initiates an update calculation operation. The master station reads the previously acquired real-time status data of the slave station from memory, using it as input data for control logic operations and trajectory interpolation. During the control logic operations, the master station analyzes and judges the real-time status data of the slave station according to pre-set control rules and algorithms to determine the next control strategy. For the motion control part, the trajectory interpolation algorithm calculates the position and velocity of the midpoint on the motion trajectory based on the given starting point, ending point, and related parameters. The results of the control logic operations and trajectory interpolation are integrated to generate the control command for the next cycle. Finally, the generated control command for the next cycle is stored in the storage area designated by the master station so that it can be sent to the slave station at the beginning of the next control cycle.

[0045] In related technologies, the uncertainty of the update() operation time can lead to message transmission cycle jitter, causing problems such as communication timeouts and degraded service quality. This step decouples the update calculation operation from the message transmission time by scheduling it within the remaining time of the control cycle after the command transmission operation. This avoids the interference of update calculation operation time fluctuations on the message transmission cycle, suppresses message transmission cycle jitter, improves system stability and reliability, and meets the stringent requirements of industrial control for deterministic timing.

[0046] As can be seen, the master station performs the read operation first, followed by the command sending operation. This immediate execution of the read operation effectively avoids the additional delay introduced by the update calculation operation, directly and quickly sending the control commands calculated in the previous cycle to the slave station. This ensures that the slave station executes the latest commands promptly, allowing data to be transmitted quickly within the current cycle, thus improving real-time performance. Furthermore, the update calculation operation is scheduled after the command sending operation, making full use of the remaining time in the control cycle to prepare commands for the next cycle. This improves computational efficiency and reduces the impact of delays on preceding steps, avoiding subsequent message transmission time irregularities caused by the uncertain execution time of the update calculation. This, in turn, suppresses message transmission cycle jitter, thus reducing the probability of jitter in low-latency tasks (e.g., 1ms cycle tasks).

[0047] In practical applications, the common algorithm for adjusting the joint sequence in the update calculation steps of a robot control system is based on traversal search. However, as the number of joints inside the robot (n) increases, as does the number of target joints in the received trajectory messages (m), and the complexity of the instructions continues to rise, the computation time of this traversal search method increases dramatically, reaching a time complexity of O(m・n). This leads to the overall update calculation step becoming extremely unstable and often excessively long, becoming a key bottleneck restricting the real-time performance and efficient operation of the entire system, making it difficult to meet the requirements of rapid and accurate generation of control instructions in industrial scenarios.

[0048] Therefore, in some other embodiments, the control logic operation in step S303 includes a joint order adjustment algorithm; wherein the joint order adjustment algorithm specifically includes: S3031, the main station traverses the n internal joints preset by the robot control system, and creates a joint index hash table with the name of each internal joint as the key and its corresponding internal index as the value. In this context, the n pre-defined internal joints of the robot control system refer to pre-set joint units within the robot's mechanical structure, each with different functions and involved in motion control. These joints, such as the movable joints of the robot's arms and legs, are numbered n. Each joint has a unique name for identification and a corresponding internal index. The internal index can be understood as a unique identifier or code for that joint within the entire control system, facilitating its location and operation. A joint index hash table is a data structure that uses a hash function to associate and store the joint name (key) with its corresponding internal index (value). This allows for rapid retrieval of the corresponding internal index based on the joint name, offering high search efficiency compared to traditional traversal search methods, enabling the retrieval of required information in a shorter time.

[0049] The main application scenarios are in industrial automation fields such as robot collaborative control. When a robot needs to adjust the movement sequence of each joint according to the received trajectory message in order to achieve precise motion control, it is necessary to first create such a joint index hash table to prepare for quick lookup of joint indexes later. For example, in scenarios such as the execution of complex actions by robotic arms on industrial production lines, or high-precision assembly tasks by multi-joint robots.

[0050] Specifically, the main station initiates a traversal of the n pre-defined internal joints of the robot's control system. It visits these internal joints one by one in a pre-set order (e.g., according to the physical order of the joints on the robot's body structure or their logical order within the control system). For each visited internal joint, the main station extracts its name information and obtains its corresponding internal index. Then, using the joint name as the key and the corresponding internal index as the value, it stores this information in a newly created data structure—the joint index hash table—using a specific hash function algorithm. During this process, the hash function calculates a unique hash address based on the joint name, storing the joint name and its corresponding internal index at the address for easy retrieval later. By processing all n internal joints in this way, a complete joint index hash table is ultimately constructed. This hash table covers the correspondence between the names and indices of all the robot's internal joints, providing an efficient data foundation for receiving trajectory messages and quickly finding joint indexes.

[0051] S3032. The master station receives a trajectory message containing m target joint names and their corresponding target values; The trajectory message containing m target joint names and their corresponding target values ​​refers to a set of data information sent from an external system (such as a host computer planning system) to indicate the robot's motion trajectory. It clearly indicates the names of m target joints that need to be focused on and controlled and adjusted, as well as the target value corresponding to each target joint. The target value can be a specific value such as the angle, position, or speed that the joint needs to move to. This information together constitutes the motion trajectory requirements that the robot must follow. The master station needs to generate corresponding control commands based on this information so that the robot can accurately complete the motion action as required.

[0052] S3033. For each target joint name in the trajectory message, the main station uses the joint index hash table to look up the corresponding internal index and obtain the mapping relationship between the target joint and the internal index. The mapping relationship between target joints and internal indexes refers to the one-to-one correspondence between the target joint name and its corresponding internal index established through the lookup operation. This clarifies the specific identifier of each target joint in the control system, making it easier to accurately fill the target value into the corresponding control command data structure later.

[0053] In the process of the robot performing motion control based on the received trajectory message, in order to accurately map the target value in the trajectory message to the specific joint control command, it is necessary to first look up the internal index of the target joint through the joint index hash table and establish a mapping relationship.

[0054] Specifically, after receiving the trajectory message and extracting the m target joint names, the master station performs a lookup operation for each target joint name. The master station takes the target joint name as input and passes it to the lookup function of the joint index hash table (this lookup function is based on the hash function used when the hash table was created). The lookup function calculates the corresponding hash address based on the target joint name and then retrieves the corresponding internal index information stored at that address. For example, if the target joint name is the shoulder joint, a lookup in the hash table can quickly obtain its corresponding internal index value (let's say 10), thus establishing a mapping relationship between the shoulder joint and the internal index 10. The master station performs this lookup operation sequentially for each target joint name in the trajectory message, thereby obtaining the mapping relationship between all target joints and their respective internal indices. These mapping relationships are stored in an internal temporary data structure (such as a mapping relationship list) for subsequent filling operations of the control command data structure.

[0055] S3034. The master station fills the target value in the trajectory message into the control instruction data structure corresponding to the internal index according to the mapping relationship.

[0056] The control instruction data structure is a pre-designed data format used to store information related to control instructions. It contains various parameter information required to control each joint of the robot, such as the index of the target joint, the target value, and the control method. By filling the target value into the corresponding position in this data structure, complete control instructions that can be used to command the movement of each joint of the robot can be generated.

[0057] This step is executed after obtaining the mapping relationship between the target joint and the internal index in step S3033. The main application scenario is in robot motion control. When it is necessary to generate specific control commands based on the received trajectory messages to drive the robot to move along the required trajectory, the master station must accurately fill the target value into the control command data structure according to the previously established mapping relationship. For example, when various industrial robots perform different production tasks, such as handling and processing, this step is required to generate appropriate control commands to ensure the accuracy and precision of the robot's movement.

[0058] Specifically, after obtaining the mapping relationship between the target joints and their internal indices, as well as the target values ​​from the trajectory messages, the master station begins filling the control command data structure. First, the master station locates the position in the control command data structure corresponding to the internal index of the target joint. This position is determined according to the pre-defined format specifications of the control command data structure. For example, in a data structure that stores control command information in a table format, the column corresponding to the internal index might be the position used to store the target value. Then, according to the mapping relationship, the master station sequentially fills the target value corresponding to each target joint in the trajectory messages into the corresponding internal index position in the control command data structure. For example, if the internal index of the elbow joint is 15, and its corresponding target value is a bending angle of 90 degrees, the master station will fill the target value of 90 degrees into the corresponding angle parameter field at index 15 in the control command data structure. By sequentially filling the target values ​​of all target joints in this way, a complete control command data structure is finally generated. This data structure contains the control information of all target joints, which can then be directly converted into specific control commands and sent to the corresponding slave stations of each joint of the robot, thereby enabling the robot to perform accurate motion control according to the received trajectory messages.

[0059] As can be seen, the key operation of creating a joint index hash table is introduced into the joint sequence adjustment algorithm. First, a hash table is constructed using the names of each internal joint preset by the robot control system as keys and their corresponding internal indices as values. Subsequently, when receiving trajectory messages containing target joint names and their corresponding target values, the hash table is used to look up the internal index for each target joint name, thus obtaining the mapping relationship and filling the control command data structure. In this way, the originally computationally intensive traversal search operation is cleverly transformed into a near-constant-time lookup operation, reducing the overall adjustment time complexity from O(m・n) to O(m+n). This fundamentally shortens the total time of the update calculation steps, better meeting the needs of industrial control scenarios for precise and rapid command generation.

[0060] In actual use, the INFO and DEBUG level log outputs used for status monitoring are not turned off in the production environment. Their frequent I / O operations become a hidden source of interference, constantly causing unpredictable minor interruptions to high-priority real-time tasks, thus accumulating into significant periodic jitter.

[0061] Therefore, in some embodiments, the update calculation operation in step S303 further includes: S3034, managing log records; wherein, the master station receives a log record request containing the severity level of the event; Log recording refers to the recording of various events, states, errors, and other information generated during system operation. It is used for system debugging, monitoring, and troubleshooting, such as recording task execution status and data transmission status. Management here refers to controlling and standardizing the generation and storage of log records to ensure that log recording meets requirements without impacting system performance. Event severity level refers to the classification and labeling of the severity of events involved in log recordings, typically including different levels such as DEBUG, INFO, WARN, ERROR, and FATAL, with higher levels indicating more severe events. A log recording request is a request issued by a module or component in the system to record information related to a specific event. This request includes the event's severity level and the data content to be recorded.

[0062] Specifically, during the update calculation operation, various functional modules within the system (such as the communication module and the calculation module) generate various events during runtime. When a module deems it necessary to record event information, it generates a log recording request. This request not only includes a detailed description of the event and the time of occurrence, but also clearly indicates the severity level of the event. The main station receives these log recording requests from various modules through its internal log management interface or related communication mechanisms. During the receiving process, the main station performs preliminary format validation on the requests to ensure that they contain necessary information (such as the event severity level) for further processing and judgment, thereby achieving effective management of log recording and preventing uncontrolled logging from impacting system performance.

[0063] By receiving log requests that include the severity level of the event, the main station can determine whether to perform log recording I / O operations based on the severity of the event. This allows the main station to process log requests of different levels in a targeted manner, avoiding indiscriminate recording of all logs and thus reducing unnecessary I / O operations from interfering with real-time tasks.

[0064] S3035. The main station compares the severity level of the event with a preset log recording threshold; S3036. If the severity level of an event is equal to or higher than the log recording threshold, the main station will perform an I / O operation to write the data corresponding to the log recording request. S3037. If the severity level of an event is lower than the logging threshold, the main site will directly discard the logging request.

[0065] As can be seen, by implementing strict log level filtering, unnecessary I / O interference was eliminated at the system level. This creates a cleaner and more deterministic operating environment for EtherCAT communication tasks, eliminating a significant source of random jitter.

[0066] In practical applications, during the motion control of robots and other controlled objects, the relevant trajectory interpolation methods, when generating control commands, struggle to accurately and systematically execute each relevant sub-step based on the real-time operating status of the controlled object. This can lead to situations where commands are generated or processed blindly without considering the current actual operating conditions. Furthermore, the lack of effective safety verification for feedback control commands makes it difficult to detect whether they exceed safety thresholds in a timely manner. This can easily result in abnormal control commands causing malfunctions that cannot be addressed promptly, thus affecting the stable operation of the entire system. Additionally, the insufficient coordination between steps makes it difficult to guarantee the accuracy and timeliness of command generation, failing to adequately meet the demands for precise and safe control of controlled objects in complex industrial scenarios.

[0067] Therefore, in some embodiments, the trajectory interpolation in step S303 specifically includes: S3038, the master station obtains the current state data of the controlled object, and determines the current running state according to the preset state machine logic; The controlled object, or the executing entity of this application, such as a robot, is defined in the system design phase as a set of pre-defined logical rules based on the different working modes and possible state changes of the controlled object. These rules are used to determine the current operating state of the controlled object based on relevant input data (such as current state data). For example, setting a robot joint within a certain speed and angle range as normal operation, and exceeding this range as abnormal, is crucial for accurate state determination. The current operating state refers to the specific working state of the controlled object as determined by the aforementioned state machine logic. Common state classifications include running, stopped, and faulty states, with subsequent control operations differing depending on the state.

[0068] Specifically, the master station first sends a request to the controlled object (e.g., through its corresponding slave device) to obtain current state data according to a predetermined communication protocol via a communication link established with the controlled object. Upon receiving the request, the controlled object organizes and encapsulates the parameter information reflecting its current state collected by its various sensors (e.g., position information from position sensors, joint angle information from angle sensors), and then sends it back to the master station. After receiving this data, the master station verifies its integrity and accuracy, checking for correct data format and data loss. After successful verification, the master station uses this current state data of the controlled object as input and passes it to a preset state machine logic module. This state machine logic module contains a series of judgment rules and logical branches. Based on the specific values ​​of each parameter in the current state data, it compares them with pre-set different state judgment conditions (e.g., speed range, position interval, etc., corresponding to different state standards) to determine the current operating state of the controlled object. For example, it determines that the robot is currently in normal operating state and can continue to execute subsequent motion trajectory planning operations, thus providing an accurate state basis for the entire trajectory interpolation and subsequent control command generation operations.

[0069] When the running status is "Running", the following sub-steps are executed in sequence: S3039. The main station generates a target motion command containing the target location; Specifically, the main station first obtains the target position information corresponding to the current motion task. This target position information may come from the task planning of the host computer (such as setting the robot's various working positions according to the production process on an automated production line), or it may be calculated based on a preset motion trajectory (such as calculating the target position for each stage when the robot is performing welding operations according to a fixed trajectory). Then, the main station combines the current actual state of the controlled object (such as the current movement speed, acceleration, etc.) and the motion control strategy set by the system (such as speed limits and acceleration curves for different stages), integrates the target position information and other necessary motion parameters (such as the desired movement speed, acceleration, etc.), and encapsulates them into a target motion instruction containing the target position according to a predetermined instruction format. For example, for a certain joint of the robot, the target motion instruction will clearly indicate the angle position (target position) that the joint should move to and the speed and acceleration to achieve this movement, so that the controlled object can move accurately toward the target position according to this instruction.

[0070] S30310. The master station generates feedback control commands based on the error between the target position and the actual position. Specifically, after generating the target motion command, the master station continuously acquires the actual position information of the controlled object. This information is collected in real time by position sensors (such as encoders) on the controlled object and fed back to the master station via a communication link. Upon receiving the actual position information, the master station compares it with the previously set target position (extracted from the target motion command) to calculate the error values ​​between the target position and the actual position in various dimensions (such as the X, Y, and Z axes of spatial coordinates, or joint angles). Then, based on a pre-set control algorithm (such as a PID control algorithm), the master station uses these error values ​​as input parameters and determines, through the algorithm's calculation logic, how to adjust the motion parameters (such as speed and acceleration) of the controlled object, thereby generating feedback control commands. For example, if the error between the target position and the actual position is large in a certain direction, and the control algorithm calculates that the speed in that direction needs to be increased, the feedback control command will include corresponding speed adjustment information, instructing the controlled object to accelerate its movement to reduce the position error, allowing the controlled object to move more accurately towards the target position, thus achieving precise motion control.

[0071] S30311. The master station performs a safety check on the feedback control command to determine whether it exceeds the preset safety threshold. Among them, the preset safety threshold refers to the upper limit or range of safety values ​​of various parameters that are pre-set during the system design phase based on factors such as the mechanical performance, working environment, and safety requirements of the controlled object. For example, the maximum speed threshold and maximum torque threshold of robot joint movement are set. Once the parameters in the feedback control command exceed these thresholds, there may be safety risks.

[0072] Specifically, after generating the feedback control command, the master station extracts the key motion parameters (such as speed, acceleration, and torque) contained in the command and then compares these parameters with pre-set corresponding safety thresholds. For example, for the controlled object's speed set in the feedback control command, the master station searches for the maximum safe speed threshold for that controlled object in the current operating mode, comparing the speed parameter in the command with this threshold. If the speed parameter is less than or equal to the safe speed threshold, it indicates that the speed is safe; conversely, if the speed parameter is greater than the safe speed threshold, there may be a safety risk. Similarly, the master station performs similar comparisons and checks on other key parameters such as acceleration and torque. Through this comprehensive comparison and judgment of each parameter in the feedback control command with the pre-set safety thresholds, the master station can determine whether the feedback control command exceeds the safe range, thus providing a basis for taking corresponding measures based on the judgment results and ensuring that the controlled object's motion control is performed under safe conditions.

[0073] S30312. If the master station determines the result as yes, it will update the running status to fault status and specify the preset braking command as the final control command. Specifically, when the master station determines in step S3034 that the safety verification result of the feedback control command is yes (i.e., a parameter exceeds the safety threshold), it first changes the current running status of the controlled object from running to fault state in the system's running status management module. This change in status triggers the system's fault handling mechanism, notifying relevant monitoring modules, alarm modules, etc. (e.g., issuing fault alarm information to operators), informing the entire system that an abnormal situation has occurred in the controlled object. Simultaneously, the master station extracts a preset braking command from the pre-stored command set. This braking command is carefully designed and tested to ensure that the controlled object stops moving or enters a safety protection state as quickly as possible under various possible fault scenarios. The master station determines this braking command as the final control command and subsequently sends it to the corresponding slave station of the controlled object according to communication protocol requirements. Upon receiving the braking command, the slave station executes corresponding operations, such as controlling the robot's joint motors to quickly stop rotating or locking the mechanical structure, to prevent the controlled object from continuing to move according to feedback control commands that pose a safety risk, thereby avoiding potentially more serious faults or safety accidents.

[0074] When a safety risk is detected when the feedback control command exceeds the safety threshold, the controlled object can be quickly stopped from dangerous actions by updating the operating status to a fault state and designating the braking command as the final control command in a timely manner. This prevents the fault from escalating further and solves the problem of the inability to respond to faults caused by abnormal commands in a timely manner in the existing technology. It ensures the safety and stability of the entire system in the event of abnormal situations.

[0075] S30313. If the master station determines the result as negative, it will combine the feedback control command and the feedforward command to generate the final control command. Specifically, the master station first extracts the key motion parameters contained in the feedback control command and the feedforward command, such as the current speed adjustment and acceleration adjustment in the feedback control command, and the preset desired speed and desired acceleration in the feedforward command. Then, according to a pre-set synthesis algorithm (such as a weighted average algorithm, with the weights of each parameter set according to different control requirements and system characteristics), these extracted motion parameters are synthesized. Taking speed as an example, if the speed adjustment required by the feedback control command is an increase of a certain value, and the desired speed in the feedforward command is a specific value, the final synthesized speed value is calculated according to the set synthesis algorithm (assuming a weight allocation of 0.4 for the feedback control command and 0.6 for the feedforward command). The master station also performs synthesis calculations on other key motion parameters (such as acceleration and position) in the same way, encapsulates these synthesized motion parameters according to a predetermined command format, and generates the final control command. Through this synthetic operation, the final control command takes into account both the error between the current actual position of the controlled object and the target position (reflected in the feedback control command) and the pre-planned motion requirements (reflected in the feedforward command), enabling the controlled object to move under more precise and efficient control, and better meeting the requirements for motion control accuracy and efficiency in complex industrial scenarios.

[0076] Under the premise of safe and reasonable feedback control commands, the final control command is generated by combining the feedback control command with the feedforward command. This combines the advantages of both and can further improve the accuracy and efficiency of motion control. It solves the problems of difficulty in ensuring the accuracy and timeliness of command generation and insufficient connection between steps in the existing technology, and realizes more realistic and optimized motion control.

[0077] S30314. The master station stores the final control command.

[0078] It should be noted that the various data in this application are intended for use in the next control cycle.

[0079] As can be seen, the main station first acquires the current state data of the controlled object and accurately determines its current operating state based on the preset state machine logic. This lays the foundation for subsequent operations such as instruction generation, ensuring that each step is carried out in accordance with the actual situation. When the operating state is running, a series of sub-steps are executed sequentially. First, a target motion instruction containing the target position is generated. Then, a feedback control instruction is generated based on the error between the target position and the actual position. Next, the feedback control instruction is verified for safety. Through this process, abnormal instructions that may exceed the preset safety threshold can be detected in a timely manner. If they exceed the threshold, the operating state is quickly updated to a fault state and the braking instruction is designated as the final control instruction, ensuring system safety. If the threshold is not exceeded, the feedback control instruction and the feedforward instruction are combined to generate the final control instruction, which is then stored. Each step works closely together and is interconnected, so that the generation of control instructions takes into account both the actual operating state and safety factors. This not only improves the accuracy and timeliness of instruction generation but also effectively avoids faults caused by abnormal instructions, ensuring the accuracy, stability, and safety of the entire system's control over the controlled object, and better serving the control needs in complex industrial scenarios.

[0080] In practical use, online refactoring tasks are encountered. Within the operational system built by related technologies, the idle time between `write()` and `read()` operations is utilized to perform these tasks. This is possible because the time required for each of the `write()` and `read()` operations is relatively stable under normal operating conditions. Therefore, the idle time that naturally occurs between these two operations can be effectively utilized for executing online refactoring tasks.

[0081] However, under the unique technical framework of this application, the situation changes significantly. This application makes an adjustment by moving the `update()` operation to the end of the workflow. Therefore, when attempting to utilize idle time to execute online refactoring tasks as in related technologies, resource conflicts easily arise between the `update()` operation and the online refactoring task. After all, the online refactoring task itself also requires critical system resources such as computing resources and memory space to complete its important tasks, such as configuration updates. However, due to its inherent uncertainty, the `update()` operation is difficult to coordinate and schedule with the online refactoring task in terms of time, unlike the `write()` and `read()` operations.

[0082] The direct consequence of this resource conflict is that the update() operation may be unreasonably interrupted or terminated abnormally, preventing it from completing the data update task smoothly according to the pre-set plan. From a macro perspective, due to the conflict between the update() operation and the online reconstruction task, the expansion of the instruction buffer queue gradually deviates from its original, effectively controllable state. Furthermore, the length of the instruction buffer queue increases, leading to increasingly severe latency. When it becomes severe enough, it deviates from the original intention of the application scenario requiring a 1ms cycle timer.

[0083] See also Figure 4 , Figure 4 This is another flowchart illustrating the EtherCAT real-time performance improvement method in this application embodiment; Therefore, in some embodiments, during the step S303 in which the master station performs the update calculation operation using the remaining time of the current control cycle, the method further includes S401 in which the master station synchronously performs an online reconstruction task, the agreed duration of the online reconstruction task is less than the remaining time; the task node of the online reconstruction task is selected from the node released by the update calculation operation. In this context, an online refactoring task refers to a task that dynamically adjusts and updates certain configurations and parameters of the system during system operation. The agreed-upon duration refers to the pre-defined allowed time for the online refactoring task to execute, limiting the time the task can reasonably occupy system resources without affecting other critical operations. Remaining time refers to the available time within the current control cycle after completing previous related operations (such as sending instructions), determined based on the entire control cycle duration and the time already used. Task nodes refer to the specific processing units, operational steps, or basic units of resource allocation involved in the execution of an online refactoring task, such as a specific computing module or data storage area; these nodes constitute the key elements for completing the online refactoring task. Nodes released during update computing operations refer to resource nodes that are no longer needed after certain stages or partial data processing are completed during update computing operations performed on the main station. These nodes can be reasonably allocated to online refactoring tasks to achieve efficient resource utilization.

[0084] It's important to note that, conventionally, both online refactoring tasks and the `update()` operation consume system resources during execution. The usual solutions are either to schedule them in time-sharing sessions, avoiding resource conflicts, or to simply discard one to ensure the other's successful execution. However, this embodiment employs a different approach, breaking with conventional thinking and presenting a completely different method.

[0085] S402. After a preset time, the main station determines the completion status of the online reconstruction task and the number of selected task nodes; S403. When the completion status is less than the preset completion threshold and the number of selected task nodes is less than the preset number threshold, the master station cancels the online reconstruction task and releases all selected task nodes within the control cycle; and changes the correspondence of the online reconstruction task. During the online refactoring process, the system monitors and judges the completion status of the online refactoring task and the number of selected task nodes. When it is found that the completion status is less than the preset completion threshold and the number of selected task nodes is less than the preset number threshold, this step will be executed.

[0086] It's important to understand that, in general terms, the main site will monitor the progress and resource usage of the online refactoring task in real time. If it finds that despite investing resources (i.e., selecting some task nodes) to execute the online refactoring task, the task completion progress is far behind expectations (completion is less than the preset completion threshold), and the invested resources are significantly insufficient (the number of selected task nodes is less than the preset number threshold), this means that the update() operation itself is facing heavy task pressure, and there are no signs of improvement. If the online refactoring task continues to run concurrently with the update() operation, it may cause both tasks to fail to complete smoothly, thus affecting the normal operation of the entire system. Therefore, the main site needs to take the measures described in this step to adjust the online refactoring task in a timely manner.

[0087] Specifically, when the main station detects through corresponding monitoring mechanisms (such as a timed task progress check module and a resource usage statistics module) that the completion status of the online reconstruction task is less than a preset completion threshold, and the number of selected task nodes is less than a preset number threshold, the main station will first initiate the termination process for the online reconstruction task. It will send task cancellation command signals to each functional module responsible for executing the online reconstruction task. Upon receiving the signal, these functional modules will immediately stop all ongoing operations related to the online reconstruction task. Whether it's ongoing configuration parameter updates, network topology adjustments, or other subtasks, all will be forcibly interrupted, and subsequent unfinished parts will not continue to be executed. This prevents the online reconstruction task from continuing to consume critical system resources such as computing resources, memory resources, and network bandwidth.

[0088] Next, the main station will perform resource reclamation operations on all task nodes previously allocated to the online refactoring task. The main station will traverse the task node information related to the online refactoring task recorded in the resource management system. For each allocated task node, by modifying its corresponding resource occupancy flag (e.g., marking the corresponding memory block as free in the memory management table, releasing the corresponding computing core from the computing resource allocation table), the main station will release the various resources occupied by these task nodes and reintegrate them into the system's available resource pool. This allows these resources to be utilized by other running or subsequently started tasks (especially tasks critical to system operation like update()), achieving reasonable resource allocation and efficient reuse.

[0089] It is important to note that when online refactoring tasks are performing poorly and resources are insufficient, continuing to run them concurrently with the `update()` operation could lead to both tasks failing to complete due to resource shortages, thus impacting the overall system's normal operation. By promptly canceling online refactoring tasks, releasing the resource nodes they occupy, and modifying their corresponding relationships, we can prioritize ensuring that critical tasks such as the `update()` operation have sufficient resources to execute smoothly. This also prepares for a reasonable restart of online refactoring tasks later, preventing the system from falling into more serious operational problems due to the current difficulties with online refactoring tasks, thereby maintaining the overall stability and real-time performance of the system.

[0090] S404. When the completion status is less than the preset completion threshold and the number of selected task nodes is greater than or equal to the preset number threshold, the main station increases the agreed duration of the online reconstruction task, and the increased agreed duration is not greater than the remaining time.

[0091] Specifically, when the main station detects through relevant monitoring and statistical mechanisms that the completion status of the online reconstruction task is less than the preset completion threshold, while the number of selected task nodes is greater than or equal to the preset number threshold, the main station will initiate a process to adjust the agreed duration of the online reconstruction task. The original agreed duration will be appropriately increased by a certain number of time units (such as adding a few milliseconds or seconds, the specific increase determined according to the threshold). During the process of increasing the agreed duration, the main station will monitor the changes in the remaining time in real time to ensure that the increased agreed duration never exceeds the remaining time, thus preventing the start of the next cycle.

[0092] It should be noted that when an online refactoring task is progressing poorly despite sufficient resource investment, it indicates that it still has the potential to be completed. Directly canceling the task would waste resources and hinder system optimization. By appropriately increasing its agreed-upon duration, without affecting other critical operations within the current cycle (limited by the remaining time), more time can be provided for the online refactoring task to continue execution. This allows for full utilization of invested resources, increases the chance of completing the remaining tasks, and avoids impacting system stability and subsequent operation due to prolonged task stagnation or inability to complete. This achieves dynamic system optimization and stable operation, while also balancing resource utilization and task progress between the online refactoring task and the update() operation to some extent.

[0093] It should be noted that, in this embodiment, there are also cases where the completion status is not less than a preset completion threshold. This situation typically occurs when the update() operation experiences relatively low task pressure and system resources are relatively abundant—because the update() operation can proceed relatively easily and does not create intense resource competition with the online refactoring task, the online refactoring task can often proceed normally as planned and reach the expected completion progress, and is generally completed smoothly. Given that this situation represents a normal, ideal state of system operation, its processing logic is relatively simple and clear, and will not be elaborated upon here.

[0094] As can be seen, when the main station performs update calculations using the remaining time of the current control cycle, given the uncertainty of `update()`, it chooses to have the online reconstruction task run in parallel. Nodes released by the update calculations are selected for the reconstruction task, utilizing idle resources while avoiding excessive resource contention and conflicts, ensuring that both can start collaboratively in the initial stage. After a period of time, the overall situation is monitored by judging the completion status of the online reconstruction task and the number of nodes. When the completion status is poor and the number of nodes is also unsatisfactory, it means that `update()` is under heavy pressure and the trend has not improved. In this case, the online reconstruction task is directly canceled without affecting the completion of `update()`. When the completion status is poor but the number of nodes is ideal, it indicates that the trend of `update()` is gradually improving. To avoid affecting `update()`, the agreed duration of the online reconstruction task is increased, thus improving the completion status of the online reconstruction task from another dimension.

[0095] In actual use, if update() experiences an extreme delay (e.g., exceeding one cycle), EtherCAT will force the robot to enter the next cycle. In this case, the instructions may be overwritten, causing the robot's actions to jump abruptly.

[0096] Step S301, writing the previous cycle control command to at least one slave station via EtherCAT, is replaced by: S501, retrieving the previous cycle control command from the head of the slave command buffer queue and writing it to at least one slave station via EtherCAT. The instruction buffer queue is a data structure used to temporarily store control instructions. It arranges instructions according to the First-In-First-Out (FIFO) principle, like a queue of instructions waiting to be processed. Newly generated instructions are added to the end of the queue, while instructions to be sent are retrieved from the head, thus serving as a buffer and scheduling mechanism for instructions. The head of the instruction buffer queue stores the earliest instructions that entered the queue; following the FIFO principle, these instructions are retrieved first for subsequent operations.

[0097] The step S303, which involves storing the control instruction for the next cycle, is replaced with: S502, where the master station pushes the control instruction for the next cycle to the end of the instruction buffer queue.

[0098] Specifically, after the master station generates the control instructions for the next cycle through update calculations and other related processes, it begins storing these instructions. First, the master station organizes and encapsulates the generated control instructions to ensure standardized formatting and data integrity, facilitating subsequent storage and retrieval. Then, following the first-in, first-out (FIFO) rule of the instruction buffer queue, the master station locates the end of the queue and adds the encapsulated control instructions for the next cycle to that end position via the appropriate queue operation interface or data storage mechanism. In this way, these newly generated instructions queue sequentially in the queue. When the next control cycle arrives, they are retrieved from the head of the queue according to the FIFO principle and sent to the corresponding slave station, enabling continuous control of the slave station. This ensures the smooth and orderly operation of the entire system's control flow, maintaining stable system operation and precise control of the industrial production process.

[0099] As can be seen, by introducing an instruction buffer queue, a decoupled buffer layer is established between instruction production (update calculation) and consumption (send instruction). This enhances the system's fault tolerance, ensuring the continuity and integrity of control instructions even in the face of sudden computational delays, thus improving the system's stability and reliability.

[0100] It should be noted that in some embodiments, if update() experiences an extreme delay (e.g., exceeding one cycle), EtherCAT will forcibly enter the next cycle. In this case, the instructions may be overwritten, resulting in sudden jumps in robot actions.

[0101] The above describes the problem of conflicting instructions. Beyond this technical issue, a new challenge arises: the absence of any instructions. In some embodiments, the relevant technologies involved in this cycle can be cleverly integrated with other existing related technologies to create a comprehensive technical solution.

[0102] An EtherCAT cyclic process includes: S101, Begin; S102, waiting period before departure; S301. The master station performs a read operation, which retrieves the current real-time status data of at least one slave station and stores the real-time status data of the slave station into the memory of the master station. SA, determine whether there is a control instruction from the previous cycle; If so, proceed with steps S104 to S109; S104. Perform distributed clock synchronization; S105, Perform control logic update - update(); S106, Write control command - write(); S107. Send EtherCAT data frame; S108, Listening to the CtrlC semaphore; S109. The cycle ends; prepare for the next cycle. If not, proceed with steps S302, S303, S207, S208, S209, and S210. S302. After performing the read operation, the master station performs the send command operation, writing the control command of the previous cycle to at least one slave station via EtherCAT. S303. After sending the command operation, the master station uses the remaining time of the current control cycle to perform an update calculation operation. The update calculation operation uses the real-time status data of the slave station to perform control logic operations and trajectory interpolation to generate the next cycle control command for use in the next control cycle, and stores the next cycle control command.

[0103] S207, Perform distributed clock synchronization; S208, Send EtherCAT data frame; S209, Listening to the CtrlC semaphore; S210, Cycle ends, prepare for the next cycle; In this way, the advantages of both approaches can be retained, allowing them to complement each other and enhance each other's strengths. This makes the integrated technical solution more advantageous in dealing with various complex situations, better meeting the diverse needs of practical applications, and further improving the overall performance and effectiveness.

[0104] In practical applications, if the embodiments corresponding to steps S401 to S405 and the embodiments corresponding to steps S501 to S502 occur simultaneously, a new problem arises. Specifically, because the embodiments represented by steps S401 to S405 increase the probability of the update() operation failing to complete, the instruction buffer queue in the embodiments represented by steps S501 to S502 will continuously lengthen. As the length of the instruction buffer queue continues to increase, the latency rate gradually rises, eventually making it difficult to meet the low latency requirements in practical applications.

[0105] Therefore, in some embodiments, after the master station determines the completion status of the online reconstruction task and the number of selected task nodes after a preset time in step S401, the method further includes: S601. The master station checks whether there are control commands in the instruction buffer queue; S602. If a control command exists, the master station determines whether the control command was generated in the current control cycle. Specifically, after the master station determines in step S601 that control commands exist in the command buffer queue, it will perform further source tracing judgment on these control commands. The master station will check the relevant timestamps, generation markers, or corresponding information recorded by the command generation module for each control command to determine whether the control command was generated within the current control cycle or left over from previous cycles. For example, a command is tagged with a corresponding timestamp when it is generated. The master station extracts this timestamp and compares it with the time range of the current control cycle. If the timestamp is between the start time and the current time of the current control cycle, then the control command is determined to have been generated in the current control cycle; otherwise, if the timetamp corresponds to a time before the current control cycle, it is determined not to have been generated in the current control cycle. Through such detailed judgment, the master station can more accurately grasp the source of the commands, providing a more detailed basis for making reasonable decisions based on the online reconstruction task.

[0106] S603. If the problem is generated during the control cycle, then when the completion status is less than the preset completion threshold and the number of selected task nodes is less than the preset number threshold, the master station cancels the online reconstruction task and releases all selected task nodes within the control cycle; and changes the correspondence of the online reconstruction task. It should be noted that when the situation is determined to occur within the current control cycle, formally speaking, it is simply equivalent to the occurrence of the embodiments corresponding to steps S401 to S405, and does not have an overlapping effect with the embodiments represented by steps S501 to S502. Based on this premise, the processing logic of steps S401 to S405 can still be followed, and will not be elaborated here.

[0107] S604. When the completion status is less than the preset completion threshold and the number of selected task nodes is greater than the preset number threshold, the main station increases the agreed duration of the online reconstruction task, and the increased agreed duration is not greater than the remaining time. S605. If the task was not generated within the current control cycle, then when the completion status is less than the preset completion threshold, the master station cancels the online reconstruction task and releases all selected task nodes within the control cycle, and changes the correspondence of the online reconstruction task.

[0108] It should be noted that when it is determined that the situation is not caused by the current control cycle, the embodiments represented by steps S401 to S405 will increase the probability that the update() operation will not be completed, which will cause the instruction buffer queue in the embodiments represented by steps S501 to S502 to continuously lengthen. Therefore, when control instructions are not generated in the current cycle (there is a backlog of old instructions) and the online refactoring task is not performing well, by canceling the task, releasing resources and adjusting the corresponding relationships, the resource requirements of critical operations such as update() can be prioritized, the system delay risk caused by the backlog of old instructions can be reduced, and the online refactoring task and critical operations can be prevented from further competing for resources, thereby improving the system's fault tolerance and stability in handling emergencies.

[0109] As can be seen, the current length of the instruction buffer queue is taken into consideration, affecting the stringency of the judgment on online refactoring tasks. When the completion rate is less than the preset threshold and the number of selected task nodes is less than the preset threshold, it means that even under the most lenient conditions, the online refactoring task is difficult to complete. In this case, the task is directly canceled and resources are released according to the established strategy. When the completion rate is less than the preset threshold and the number of selected task nodes is greater than the preset threshold, considering that even with a large amount of resources invested, the task may still not be completed, the system further checks whether there are instructions in the instruction buffer queue. If there are instructions, it is further determined whether they were generated in the current control cycle. If they were generated in the current control cycle, it means that update() has been completed, and the online refactoring task can be completed normally. If they were not generated in the current control cycle, it means that there is a backlog of old instructions, etc. In this case, the online refactoring task is canceled, resources are released, and the corresponding relationships are changed to improve the completion rate of update().

[0110] The following describes an exemplary EtherCAT real-time performance enhancement system 500 provided in the embodiments of this application. Figure 5 This is an exemplary hardware structure diagram of the EtherCAT real-time performance improvement system 500 provided in the embodiments of this application.

[0111] In some embodiments, the EtherCAT real-time performance enhancement system 500 is a computer device or includes a computer device in the EtherCAT real-time performance enhancement system 500. The computer device includes a processor, memory, and a network interface connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The database of the computer device is used to store data. The network interface of the computer device is used to communicate with other external terminals or servers via a network connection. In some embodiments, the network interface can be a wired network interface; in some embodiments, the network interface can also be a wireless network interface. When the computer program is executed by the processor, it implements the methods in the embodiments of this application.

[0112] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0113] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

[0114] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".

[0115] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.

[0116] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A method for improving the real-time performance of EtherCAT, characterized in that, include: Applied to an EtherCAT communication system consisting of a master station and at least one slave station, the method sequentially executes the following steps within a preset control cycle: The master station performs a read operation, which retrieves the current real-time status data of at least one slave station and stores the real-time status data of the slave station into the memory of the master station. After performing the read operation, the master station performs a send command operation, writing the control command of the previous cycle to the at least one slave station via EtherCAT; After sending the command operation, the master station uses the remaining time of the current control cycle to perform an update calculation operation. The update calculation operation uses the real-time status data of the slave station to perform control logic operations and trajectory interpolation to generate the next cycle control command for use in the next control cycle, and stores the next cycle control command.

2. The method according to claim 1, characterized in that, During the step of the master station performing update calculations using the remaining time of the current control cycle, the method further includes: The main station synchronously performs online reconstruction tasks, wherein the agreed duration of the online reconstruction task is less than the remaining time; the task node of the online reconstruction task is selected from the node released by the update calculation operation; After a preset time, the main station determines the completion status of the online reconstruction task and the number of selected task nodes; When the completion status is less than a preset completion threshold and the number of selected task nodes is less than a preset number threshold, the master station cancels the online reconstruction task and releases all selected task nodes within the control cycle; and changes the correspondence of the online reconstruction task. When the completion status is less than a preset completion threshold and the number of selected task nodes is greater than or equal to a preset number threshold, the main station increases the agreed duration of the online reconstruction task, and the increased agreed duration is not greater than the remaining time.

3. The method according to claim 2, characterized in that, The step of writing the previous cycle control command to the at least one slave station via EtherCAT specifically includes: retrieving the previous cycle control command from the head of the master station's slave command buffer queue and writing it to the at least one slave station via EtherCAT; The step of storing the next cycle control instruction specifically includes: the master station pushing the next cycle control instruction to the end of the instruction buffer queue.

4. The method according to claim 3, characterized in that, After the step of the main station determining the completion status of the online reconstruction task and the number of selected task nodes after a preset time, the method further includes: The master station determines whether there are control instructions in the instruction buffer queue; If a control command exists, the master station determines whether the control command was generated in the current control cycle; If the online reconstruction task is generated within the control cycle, then when the completion status is less than the preset completion threshold and the number of selected task nodes is less than the preset number threshold, the master station cancels the online reconstruction task and releases all selected task nodes within the control cycle; and changes the correspondence of the online reconstruction task. When the completion status is less than a preset completion threshold and the number of selected task nodes is greater than a preset number threshold, the main station increases the agreed duration of the online reconstruction task, and the increased agreed duration is not greater than the remaining time. If the task was not generated within the control cycle, then when the completion status is less than the preset completion threshold, the master station cancels the online reconstruction task and releases all selected task nodes within the control cycle, and changes the correspondence of the online reconstruction task.

5. The method according to claim 1, characterized in that, The control logic operation includes a joint sequence adjustment algorithm; The joint order adjustment algorithm specifically includes: the main station traverses the n preset internal joints of the robot control system, and creates a joint index hash table with the name of each internal joint as the key and its corresponding internal index as the value; The master station receives a trajectory message containing m target joint names and their corresponding target values; For each target joint name in the trajectory message, the main station uses the joint index hash table to look up the corresponding internal index and obtain the mapping relationship between the target joint and the internal index. The master station, based on the mapping relationship, fills the target value in the trajectory message into the control instruction data structure corresponding to the internal index.

6. The method according to claim 1, characterized in that, The update calculation operation also includes log recording management; wherein, the master station receives a log recording request containing the severity level of the event; The main station compares the severity level of the event with a preset log recording threshold; If the severity level of the event is equal to or higher than the log recording threshold, the main station will perform an I / O operation to write the data corresponding to the log recording request. If the severity level of the event is lower than the log recording threshold, the main station will directly discard the log recording request.

7. The method according to claim 1, characterized in that, The trajectory interpolation specifically includes: The master station obtains the current state data of the controlled object and determines the current running state according to the preset state machine logic; When the running state is "running", the following sub-steps are executed in sequence: The master station generates a target motion command containing the target location; The master station generates feedback control commands based on the error between the target position and the actual position; The master station performs a security check on the feedback control command to determine whether it exceeds a preset security threshold. If the master station determines that the result is yes, it updates the operating status to a fault status and designates the preset braking command as the final control command. If the master station determines the result to be negative, it combines the feedback control command and the feedforward command to generate the final control command. The master station stores the final control command.

8. A system for improving the real-time performance of EtherCAT, characterized in that, The EtherCAT real-time performance enhancement system includes: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the EtherCAT real-time performance enhancement system to perform the method as described in any one of claims 1-7.

9. A computer program product containing instructions, characterized in that, When the computer program product is run on the EtherCAT real-time enhancement system, the EtherCAT real-time enhancement system performs the method as described in any one of claims 1-7.

10. A computer-readable storage medium comprising instructions, characterized in that, When the instruction is executed on the EtherCAT real-time enhancement system, the EtherCAT real-time enhancement system performs the method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Data transmission method and device

    CN105207971A

  • Design method of master / slave station card for implementing Powerlink industrial real-time Ethernet communication

    CN108650136A

  • Mechanical arm real-time control system

    CN112091978A

  • Bus communication method, slave station and bus communication system

    CN116016010A

  • Periodic data communication method based on communication protocol

    CN117729064A

Cited By

  • Work step instruction issuing method and device, electronic equipment and readable storage medium

    CN121411334A