An EtherCAT real-time improvement method, system, storage medium and program product

By optimizing the read and update operation sequence of the EtherCAT system, and combining buffer queues and resource management, the jitter problem caused by the uncertainty of update() in low-latency tasks of the EtherCAT system was solved, thereby improving real-time performance and stability and meeting the accuracy and safety requirements of industrial control.

CN120848442BActive Publication Date: 2025-11-28临海市新睿电子科技股份有限公司
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

In low-latency tasks, the EtherCAT system suffers from message transmission cycle jitter due to the uncertainty of the update() operation, which affects the probability of communication timeout and system stability, and fails to meet the requirements of industrial control for deterministic timing and motion control accuracy.

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 allocation of computing resources by using the command buffer queue and online reconstruction tasks. Combined with the joint index hash table and strict log management, it ensures the timeliness and integrity of control commands.

Benefits of technology

It effectively reduces message transmission jitter, improves the real-time performance and stability of the system, meets the requirements of industrial control for low-latency tasks, and ensures the accuracy and security of control commands.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120848442B_ABST
    Figure CN120848442B_ABST
Patent Text Reader

Abstract

The application provides an EtherCAT real-time improvement method, system, storage medium and program product, and relates to the technical field of high-speed industrial data transmission. The master station first performs a read operation, then performs a send instruction operation, which is carried out immediately after the read operation, can effectively avoid the additional delay introduced by the update calculation operation, directly sends the control instruction calculated in the previous cycle to the slave station quickly, ensures that the slave station executes the latest command in time, makes the data quickly transmitted in the current cycle, and improves the real-time performance. The update calculation operation is arranged after the send instruction, fully utilizes the remaining time of the control cycle to prepare the instruction for the next cycle in advance, improves the calculation efficiency, reduces the delay influence on the previous link, avoids the disorder of the subsequent message sending time caused by the uncertain execution time of the update calculation, and further suppresses the message sending cycle jitter, so that the occurrence probability of the jitter phenomenon is reduced under the low delay task (for example, 1ms cycle task).
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of industrial data high-speed transmission, and particularly relates to an EtherCAT real-time improvement method and system, a storage medium and a program product. BACKGROUND

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

[0003] The existing EtherCAT system follows a series of cyclic tasks such as read (i.e., reading related data), update (i.e., performing update calculation operations), and write (responsible for outputting related instructions and the like) during operation.

[0004] However, in actual operation and use, the time actually required by the update operation has strong uncertainty. This uncertainty will first directly lead to the difficulty in determining the subsequent message sending time, and further cause the message sending period to appear jitter phenomenon.

[0005] The industrial control field has strict requirements, that is, strict deterministic timing must be guaranteed within each cycle. Since the update stage involves complex calculations such as logical operations, path planning, and the like, the calculation time is prone to fluctuation, which inevitably leads to the non-deterministic offset (also known as jitter) of the message sending time. Moreover, it will also cause a series of more serious adverse consequences. On the one hand, the probability of communication timeout will significantly increase. Once the update stage has a sudden delay, causing the write operation to exceed the established 1ms cycle window, the watchdog timeout (WD_TIMEOUT) mechanism of the EtherCAT master station will be triggered. In this case, the lighter impact is that the slave device will enter the safe state (Safe-Operational), but more seriously, it may directly cause the entire production line to stop suddenly, which will undoubtedly bring great loss and serious interference to industrial production.

[0006] On the other hand, the quality of service (QoS) policy will also be invalidated. As a matter of fact, critical data streams such as safety IO signals rely on priority queues to achieve low-latency transmission. The jitter in the message sending period will disturb the original timing prediction of the message dispatcher, eventually leading to the phenomenon of priority inversion, in which high-priority frames are discarded due to buffer overflow. This is a great obstacle to data transmission that needs to be prioritized, seriously affecting the normal operation of the system and the execution of critical operations.

[0007] Further, when the control logic is updated, the original execution time of update() reaches 1.4 ms, which has already exceeded the set 1 ms execution period, thus intensifying the jitter condition and even causing disconnection, making the system unable to support the normal operation of the 1 ms period. Therefore, a 4 ms period is used for testing, but even so, there are still many serious problems.

[0008] First, the jitter phenomenon becomes difficult to suppress. When the update() time reaches 1.4 ms, which exceeds the original period, the system is forced to enable the period extension compensation mechanism (such as the jump period execution method), which causes the actual period to fluctuate dramatically between 1.4 ms and 4 ms, resulting in a period jitter rate of up to 300%, far exceeding the industrial standard requirement of less than 10%, thus destroying the stability and predictability of system operation.

[0009] Second, the motion control performance also shows obvious degradation. After the period is extended to 4 ms, the phase margin of the servo control loop will decrease sharply. Taking a typical servo bandwidth of 500 Hz as an example, a 4 ms period can only support a control frequency of up to 125 Hz, which is far from meeting the precision requirements of motion control in actual industrial control scenarios, thus causing problems such as mechanical vibration or trajectory tracking instability, affecting the precision of production and product quality.

[0010] Finally, data integrity is also destroyed. When the update() operation has not been completed, the process data image (PDO) may contain outdated data that has not been updated, which will cause conflicts between control commands, such as sudden jump of the motor, misoperation of the valve, etc., bringing great safety hazards and operation failures to the entire industrial production process.

[0011] In summary, in the application scenario of 1ms periodic task requirement, the update() has strong uncertainty, leading to jitter phenomenon, and directly or indirectly causing the above problems. If the period is reduced to 4ms, the problem can be solved, but the entire system has degenerated into a soft real-time system, completely losing the determinism required in industrial control scenarios. SUMMARY

[0012] The application provides an EtherCAT real-time improvement method, system, storage medium and program product, which is used to reduce the occurrence probability of jitter phenomenon under low delay task (such as 1ms periodic task).

[0013] In a first aspect, the application provides an EtherCAT real-time improvement method, which is applied to an EtherCAT communication system composed of a master station and at least one slave station. The method sequentially performs the following steps within a preset control period: the master station performs a read operation to obtain current slave station real-time state data from the at least one slave station and stores the slave station real-time state data in the memory of the master station; after the read operation, the master station performs a send instruction operation to write the last period control instruction to the at least one slave station through EtherCAT; after the send instruction operation, the master station performs an update calculation operation using the remaining time of the current control period. The update calculation operation performs control logic operation and trajectory interpolation using the slave station real-time state data to generate a next period control instruction for the next control period, and stores the next period control instruction.

[0014] By adopting the above technical solution, the master station first performs the read operation, and then performs the send instruction operation. The read operation is carried out immediately after the read operation, which can effectively avoid the additional delay introduced by the update calculation operation, directly sends the control instruction calculated in the last period to the slave station, ensures that the slave station executes the latest command in time, and makes the data quickly transmitted in the current period, thereby improving the real-time performance. The update calculation operation is arranged after the send instruction operation, which fully utilizes the remaining time of the control period to prepare the instruction for the next period, improves the calculation efficiency, reduces the delay influence on the previous link, avoids the disorder of subsequent message sending time caused by the uncertain execution time of the update calculation, and further suppresses the period jitter of message sending, thereby reducing the occurrence probability of jitter phenomenon under low delay task (such as 1ms periodic task).

[0015] In some embodiments in combination with the first aspect, in the step of performing the update calculation operation by the master station using the remaining time of the current control period, the method further comprises: the master station synchronously performing an online reconstruction task, wherein a scheduled time length 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 judges a completion condition of the online reconstruction task and a number of the selected task nodes; when the completion condition is less than a preset completion threshold and the number of the selected task nodes is less than a preset number threshold, the master station cancels the online reconstruction task and releases all the selected task nodes in the control period; and changes a corresponding relationship of the online reconstruction task; when the completion condition is less than the preset completion threshold and the number of the selected task nodes is greater than or equal to the preset number threshold, the master station increases the scheduled time length of the online reconstruction task, and the increased scheduled time length is not greater than the remaining time.

[0016] By adopting the above technical solution, when the master station performs the update calculation operation using the remaining time of the current control period, in view of the uncertainty of the update(), the online reconstruction task is selected to be carried out in parallel, and the nodes released by the update calculation operation are selected for the reconstruction task, so that idle resources are utilized, and conflicts caused by excessive resource occupation are avoided, thereby ensuring that the two can start together in the initial stage. After a period of time, the overall situation is controlled by judging the completion condition and the number of nodes of the online reconstruction task. When the completion condition is poor and the number is not ideal, it means that the update() is under great pressure and the trend has not improved. At this time, the online reconstruction task is directly cancelled, which does not affect the completion of the update(). When the completion condition is poor and the number is ideal, it means that the trend of the update() is gradually improved. In order to avoid affecting the update(), the scheduled time length of the online reconstruction task is increased to improve the completion condition of the online reconstruction task in another dimension.

[0017] In some embodiments in combination with the first aspect, the step of writing the control instruction of the last period to at least one slave station through EtherCAT specifically comprises: the master station taking the control instruction of the last period from the head of the instruction buffer queue and writing it to at least one slave station through EtherCAT; and the step of storing the control instruction of the next period specifically comprises: the master station pushing the control instruction of the next period to the end of the instruction buffer queue.

[0018] By adopting the above technical solution, by introducing the instruction buffer queue, a decoupling buffer layer is established between the production (update calculation) and consumption (sending instructions) of instructions. This enhances the fault tolerance of the system, ensures the continuity and integrity of the control instruction even in the face of sudden calculation delay, and improves the stability and reliability of the system.

[0019] In some embodiments of the first aspect, after the step of determining the completion of the online reconstruction task and the number of selected task nodes by the master station after a preset time, the method further comprises: determining by the master station whether the instruction buffer queue has control instructions; if the instruction buffer queue has control instructions, determining by the master station whether the control instructions are generated in the current control period; if the control instructions are generated in the current control period, canceling the online reconstruction task and releasing all selected task nodes in the current control period by the master station when the completion is less than a preset completion threshold and the number of selected task nodes is less than a preset number threshold, and changing the correspondence of the online reconstruction task; increasing the scheduled time of the online reconstruction task by the master station when the completion is less than the preset completion threshold and the number of selected task nodes is greater than the preset number threshold, and the increased scheduled time is not greater than the remaining time; if the control instructions are not generated in the current control period, canceling the online reconstruction task and releasing all selected task nodes in the current control period by the master station when the completion is less than the preset completion threshold, and changing 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 account, and the strictness of the judgment on the online reconstruction task is affected. When the completion is less than the preset threshold and the number of selected task nodes is less than the preset threshold, it means that the online reconstruction task is difficult to complete even under the most lenient conditions, and the task is canceled and the resources are released directly according to the established strategy at this time. When the completion is less than the preset threshold and the number of selected task nodes is greater than the preset threshold, considering that although more resources are invested, the task may still not be completed, it is further determined whether the instruction buffer queue has instructions. If the instruction buffer queue has instructions, it is further determined whether the instructions are generated in the current control period. If the instructions are generated in the current control period, it means that the update() has been completed, and the online reconstruction task can be normally completed at this time. If the instructions are not generated in the current control period, it means that there is an old instruction backlog, and the online reconstruction task is canceled and the resources are released, and the correspondence is changed to improve the completion rate of the update().

[0021] In some embodiments of the first aspect, the control logic operation comprises a joint sequence adjustment algorithm. The joint sequence adjustment algorithm specifically comprises: the master station traverses n internal joints preset by the robot control system, 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 comprising 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 find the corresponding internal index to obtain the mapping relationship between the target joint and the internal index; and the master station fills the target values in the trajectory message into the control instruction data structure corresponding to the internal index according to the mapping relationship.

[0022] By adopting the technical scheme, the key operation of creating a joint index hash table is introduced in the joint sequence adjustment algorithm. First, a hash table is constructed with the names of each internal joint preset by the robot control system as the key and the corresponding internal index as the value. Then, when receiving a trajectory message containing the target joint name and its corresponding target value, the hash table is used to find the internal index for each target joint name, and the mapping relationship is obtained and the control instruction data structure is filled. In this way, the originally computationally intensive traversal search operation is ingeniously changed to a nearly constant time search operation, reducing the total adjustment time complexity from O(m・n) to O(m+n). The total length of the update calculation step is fundamentally shortened, better meeting the needs of industrial control scenarios for accurate and fast instruction generation.

[0023] In combination 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 of writing 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 technical scheme, unnecessary I / O interference is eliminated from the system level by implementing strict log level filtering. This creates a cleaner and more deterministic operating environment for EtherCAT communication tasks, eliminating an important source of random jitter.

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

[0026] By adopting the technical scheme, the master station first acquires the current state data of the controlled object, and accurately judges the current running state according to the preset state machine logic, which lays a foundation for subsequent instruction generation and other operations, and ensures that each step is carried out in accordance with the actual situation. When the running state is running, a series of sub-steps are executed in sequence. First, a target motion instruction containing a 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 safety checked. Through such a process, abnormal instructions that may exceed the preset safety threshold can be found in time. If the abnormal instructions exceed the preset safety threshold, the running state is updated to the fault state and the braking instruction is specified as the final control instruction, thereby ensuring the safety of the system. If the abnormal instructions do not exceed the preset safety threshold, 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 is closely coordinated and interlocked, so that the generation of the control instruction not only considers the actual running state but also takes into account the safety factor. This not only improves the accuracy and timeliness of instruction generation, but also effectively avoids faults caused by abnormal instructions, thereby ensuring the accuracy, stability and safety of the entire system in controlling the controlled object, and better serving the control requirements in complex industrial scenarios.

[0027] In a second aspect, the present application provides an EtherCAT real-time improvement system, comprising: one or more processors and a memory; the memory is coupled with the one or more processors, and the memory is configured to store computer program codes, the computer program codes comprising computer instructions, the one or more processors invoking the computer instructions to enable the EtherCAT real-time improvement system to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0028] In a third aspect, the present application provides a computer program product comprising instructions, which, when executed on an EtherCAT real-time improvement system, enable the EtherCAT real-time improvement system to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0029] In a fourth aspect, the present application provides a computer-readable storage medium comprising instructions, which, when executed on an EtherCAT real-time improvement system, enable the EtherCAT real-time improvement system to perform the method described in the first aspect and any possible implementation manner of the first aspect.

[0030] The one or more technical solutions provided in the embodiments of the present application have at least the following technical effects or advantages:

[0031] 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).

[0032] 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.

[0033] 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

[0034] Figure 1 This refers to the EtherCAT cycle loop process in related technologies;

[0035] Figure 2 is an EtherCAT cycle loop process in the embodiment of the present application;

[0036] Figure 3 is a flowchart of an EtherCAT real-time improvement method in the embodiment of the present application;

[0037] Figure 4 is another flowchart of an EtherCAT real-time improvement method in the embodiment of the present application;

[0038] Figure 5 is an exemplary hardware structure diagram of an EtherCAT real-time improvement system in the embodiment of the present application. DETAILED DESCRIPTION

[0039] The terms used in the following embodiments of the present application are only for the purpose of describing the specific embodiments and are not intended to be limiting of the present application. As used in the specification and the appended claims of the present application, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.

[0040] Hereinafter, the terms "first" and "second" are only for the purpose of description and cannot be understood as implying or suggesting relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first" and "second" can explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, the meaning of "a plurality of" is two or more, unless otherwise specified.

[0041] To clearly present the difference between the present application and the related art, the EtherCAT cycle loop process in the related art and the EtherCAT cycle loop process of the present application are compared and described below. It should be noted that the above two processes are only for highlighting the key differences and do not cover all the differences.

[0042] Please refer to Figure 1 , Figure 1 is an EtherCAT cycle loop process in the related art;

[0043] S101, start;

[0044] S102, wait for cycle start;

[0045] S103, read EtherCAT slave data - read();

[0046] S104, distributed clock synchronization is performed;

[0047] S105, control logic update-update() is performed;

[0048] S106, control instruction write-write() is written;

[0049] S107, EtherCAT data frame is sent;

[0050] S108, ctrlc semaphore is monitored;

[0051] S109, the cycle ends, and the next cycle is prepared;

[0052] Please refer to Figure 1 , Figure 2 is an EtherCAT cycle loop process in the embodiment of the application;

[0053] S201, start;

[0054] S202, wait for cycle start;

[0055] S203, read EtherCAT slave data-read();

[0056] S204, write control instruction-write();

[0057] S205, control logic update-update() is performed;

[0058] S206, joint trajectory adjustment algorithm;

[0059] S207, distributed clock synchronization is performed;

[0060] S208, EtherCAT data frame is sent;

[0061] S209, ctrlc semaphore is monitored;

[0062] S210, the cycle ends, and the next cycle is prepared;

[0063] By comparing the above two processes, the main difference of the application is reflected in the steps of S104-S106 and S204-S207. The following embodiments will elaborate on these differences.

[0064] Please refer to Figure 3 , Figure 3 is a process diagram of the method for improving EtherCAT real-time performance in the embodiment of the application;

[0065] The application relates to an EtherCAT real-time improvement method applied to an EtherCAT communication system composed of a master station and at least one slave station, and the method sequentially performs the following steps in a preset control cycle:

[0066] S301, the master station performs a reading operation, the reading operation obtains current slave station real-time state data from the at least one slave station, and the slave station real-time state data is stored in the memory of the master station;

[0067] The master station represents a device that plays a leading control role in the EtherCAT communication system, is responsible for managing and coordinating communication with the slave stations, and processes system data and generates instructions. The slave station refers to a device controlled by the master station in the EtherCAT communication system, which is responsible for executing instructions sent by the master station and feeding back real-time state data of the slave station. The slave station real-time state data refers to running parameters and working states of the slave station at the current moment, such as position, speed, temperature and pressure, which reflect the real-time running state of the slave station.

[0068] S302, after the reading operation is performed, the master station performs a sending instruction operation, and writes the last cycle control instruction into the at least one slave station through EtherCAT;

[0069] The last cycle control instruction refers to a set of instructions generated by the master station after calculation and processing in the last control cycle, which is used for controlling the slave station to execute a specific task, similar to the next cycle control instruction in step S303.

[0070] The last cycle control instruction is sent immediately after the reading operation, so that the slave station can obtain the latest control instruction and execute it in time, reduces the delay of sending instructions caused by waiting for the completion of the update calculation operation, and improves the real-time performance and response speed of the system.

[0071] The uncertainty of the update() operation time in the prior art may cause the delay of the write() operation, exceed the 1ms cycle window and cause communication timeout and other problems. The sending instruction operation is performed immediately after the reading operation in the step, the sending instruction operation and the update calculation operation are decoupled, the influence of the update() operation time fluctuation on the sending instruction is avoided, the slave station can receive and execute the control instruction in time, and the risk of communication timeout is reduced.

[0072] S303, after the sending instruction operation, the master station performs an update calculation operation using the remaining time of the current control cycle, the update calculation operation uses the slave station real-time state data to perform control logic operation and trajectory interpolation, generates a next cycle control instruction for the next control cycle, and stores the next cycle control instruction.

[0073] The update calculation operation refers to a series of calculation and processing work performed by the master station for generating the next period control instruction. The control logic operation refers to logical judgment and calculation based on the control rules of the system and the real-time state data of the slave station to determine the next control strategy. The trajectory interpolation is to calculate the intermediate points on the motion trajectory according to the given starting point, ending point and motion parameters, etc. in the motion control scenario, to achieve precise motion control.

[0074] Specifically, after the master station completes sending the last period control instruction to the slave station, the remaining time of the current control period is checked. The update calculation operation is started in the remaining time. The master station reads the previously obtained real-time state data of the slave station from the memory as input data, and performs control logic operation and trajectory interpolation operation respectively. In the control logic operation process, the real-time state data of the slave station is analyzed and judged according to the pre-set control rules and algorithms to determine the next control strategy. For the part involving motion control, the intermediate point position and speed parameters on the motion trajectory are calculated according to the given motion starting point, ending point and related parameters through the trajectory interpolation algorithm. The results of the control logic operation and the trajectory interpolation are integrated to generate the next period control instruction. Finally, the generated next period control instruction is stored in the storage area designated by the master station, so as to be sent to the slave station at the beginning of the next control period.

[0075] The uncertainty of the update() operation time in the related art can cause message sending period jitter, causing communication timeout, service quality degradation and other problems. This step arranges the update calculation operation in the remaining time of the control period after the instruction sending operation, decouples the update calculation operation from the message sending time, avoids the interference of the update calculation operation time fluctuation on the message sending period, suppresses the message sending period jitter, improves the stability and reliability of the system, and meets the strict requirements of industrial control on deterministic timing.

[0076] It can be seen that the master station first performs the reading operation, then performs the instruction sending operation, which is immediately carried out after the reading operation, can effectively avoid the additional delay introduced by the update calculation operation, directly sends the control instruction calculated in the last period to the slave station quickly, ensures that the slave station executes the latest command in time, and makes the data quickly transmitted in the current period, thereby improving the real-time performance. The update calculation operation is arranged after the instruction sending operation, which fully utilizes the remaining time of the control period to prepare the instruction for the next period, improves the calculation efficiency, reduces the delay influence on the previous link, avoids the disorder of the subsequent message sending time caused by the uncertainty of the update calculation execution time, and further suppresses the message sending period jitter. Therefore, in the low delay task (such as 1ms period task), the probability of jitter phenomenon is reduced.

[0077] In actual use, in the updating calculation step of the robot control system, the algorithm commonly used for the joint sequence adjustment step is usually implemented based on a traversal search. However, as the number of joints (n) in the robot and the number of target joints (m) in the received trajectory message increase, and the instruction complexity increases, the time consumption of the traversal search will increase sharply, and the time complexity reaches the O(m·n) level, which leads to unstable and long overall time consumption of the updating calculation step, and becomes a key bottleneck of the real-time and efficient operation of the entire system, and it is difficult to meet the requirements of fast and accurate generation of control instructions in industrial scenarios.

[0078] Therefore, in some embodiments, the control logic operation in step S303 includes a joint sequence adjustment algorithm; wherein the joint sequence adjustment algorithm specifically includes: S3031, the master station traverses the n internal joints preset in the robot control system, creates a joint index hash table with the name of each internal joint as the key and its corresponding internal index as the value;

[0079] The n internal joints preset in the robot control system refer to joint units with different functions and participating in motion control that are pre-set in the mechanical structure of the robot. The number of these joints is n, for example, the movable joints of the arms, legs and other parts of the robot, each joint has its unique name for identification, and also has a corresponding internal index. The internal index can be understood as a serial number or code for uniquely identifying the joint in the entire control system, which facilitates positioning and operation of the system. The joint index hash table is a data structure that uses a hash function to store the names (keys) and corresponding internal indexes (values) of the joints. In this way, the corresponding internal index can be quickly found according to the joint name in the future, and the feature is high search efficiency. Compared with the traditional traversal search method, the required information can be obtained in a shorter time.

[0080] The application scenario is mainly in the field of industrial automation such as robot collaborative control. When the robot needs to adjust the motion sequence of each joint according to the received trajectory message to achieve precise motion control, it is necessary to first create such a joint index hash table to prepare for subsequent fast lookup of joint index, such as execution of complex actions by a mechanical arm on an industrial production line, or high-precision assembly tasks by a multi-joint robot.

[0081] Specifically, the master station initiates a traversal operation on the n internal joints preset in the robot control system. It accesses these internal joints one by one in a predetermined order (e.g., in the physical order of the joints on the robot body structure or in the logical order in the control system, etc.). For each accessed internal joint, the master station extracts its name information and obtains the corresponding internal index, and then stores the joint name as the key and the corresponding internal index as the value in a newly created data structure, which is the joint index hash table, through a specific hash function algorithm. In this process, the hash function calculates a unique hash address according to the joint name, and stores the joint name and the corresponding internal index at the corresponding position of the address, facilitating subsequent rapid retrieval. By processing all n internal joints in this way, a complete joint index hash table is finally constructed, which covers the correspondence between the names and indexes of all internal joints of the robot, providing an efficient data basis for subsequent receipt of trajectory messages and rapid lookup of joint indexes.

[0082] S3032, the master station receives a trajectory message containing m target joint names and their corresponding target values;

[0083] The trajectory message containing m target joint names and their corresponding target values refers to the data information set sent from an external system (such as a host computer planning system, etc.) for indicating the motion trajectory of the robot, which explicitly indicates m target joint names that need to be focused on and controlled, and the target values corresponding to each target joint. The target value can be the angle, position, speed, etc. of the joint to be moved, which together constitute the motion trajectory requirements that the robot needs to follow. The master station needs to generate corresponding control instructions according to these information so that the robot can accurately complete the motion action according to the requirements.

[0084] S3033, for each target joint name in the trajectory message, the master station uses the joint index hash table to find the corresponding internal index, and obtains the mapping relationship between the target joint and the internal index;

[0085] The mapping relationship between the target joint and the internal index refers to the one-to-one correspondence between the target joint name and its corresponding internal index established through the lookup operation, which explicitly identifies the specific identification of each target joint in the control system, facilitating subsequent accurate filling of target values into the corresponding control instruction data structure.

[0086] In the process of motion control of the robot according to the received trajectory message, in order to accurately correspond the target values in the trajectory message to specific joint control instructions, the internal index of the target joint needs to be found through the joint index hash table to establish the mapping relationship.

[0087] Specifically, after receiving the trajectory message and extracting the m target joint names, the master station will perform 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 implemented based on the hash function used when creating the hash table earlier). The lookup function calculates the corresponding hash address according to the target joint name, and then obtains the stored internal index information corresponding to the address. For example, if the target joint name is the shoulder joint, the corresponding internal index value (assuming 10) can be quickly obtained through the hash table lookup, thus establishing the mapping relationship between the target joint of the shoulder joint and the internal index 10. The master station performs a lookup operation on each target joint name in the trajectory message in this way, obtaining the mapping relationship between all target joints and their respective internal indexes, and storing these mapping relationships in an internal temporary data structure (such as a mapping relationship list, etc.) to facilitate subsequent filling operations of the control instruction data structure.

[0088] 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.

[0089] The control instruction data structure is a pre-designed data format for storing control instruction related information, which contains various parameter information required for controlling each joint of the robot, such as the index of the target joint, the target value, the control mode, etc. By filling the target value into the corresponding position of this data structure, a complete control instruction that can be used to command the movement of each joint of the robot can be generated.

[0090] This step is executed after completing the S3033 step of obtaining the mapping relationship between the target joint and the internal index. The main application scenario is in the process of robot motion control, when it is necessary to generate specific control instructions according to the received trajectory message to drive the robot to move according to the required trajectory. The master station fills the target value into the control instruction data structure according to the mapping relationship established earlier, such as generating appropriate control instructions through this step when various industrial robots perform different production tasks, such as handling, machining, etc., to ensure the accuracy and precision of robot motion.

[0091] Specifically, after obtaining the mapping relationship between the target joints and the internal indexes and the target values in the trajectory message, the master station starts to fill the control instruction data structure. The master station first locates the position related to the internal index corresponding to the target joint in the control instruction data structure, which is determined according to the pre-set format specification of the control instruction data structure. For example, in a data structure in which the control instruction information is stored in the form of a table, the column corresponding to the internal index may be the position for storing the target value. Then, the master station fills the target value corresponding to each target joint in the trajectory message into the corresponding internal index position in the control instruction data structure in sequence according to the mapping relationship. For example, if the internal index of the elbow joint is 15 and the 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 the position with the index of 15 in the control instruction data structure. By sequentially filling the target values of all target joints in this way, a complete control instruction data structure is finally generated, which contains the control information of all target joints, and can be directly converted into specific control instructions to be sent to the slave stations corresponding to the joints of the robot, so as to realize accurate motion control of the robot according to the received trajectory message.

[0092] It can be seen that the key operation of creating a joint index hash table is introduced in the joint sequence adjustment algorithm. First, a hash table is constructed with the internal joint names preset by the robot control system as the key and the corresponding internal index as the value. Subsequently, when receiving a trajectory message containing a target joint name and its corresponding target value, the internal index is obtained by using the hash table to search for each target joint name, and then the mapping relationship is obtained and the control instruction data structure is filled. In this way, the originally computationally intensive traversal search operation is ingeniously transformed into a nearly constant time search operation, reducing the total adjustment time complexity from O(m・n) to O(m+n). The total length of the update calculation steps is fundamentally shortened, better meeting the needs of industrial control scenarios for accurate and fast instruction generation.

[0093] In actual use, a large number of INFO and DEBUG level log outputs for state monitoring are not closed in the production environment, and their frequent I / O operations become an implicit interference source, constantly causing unpredictable small interruptions to high-priority real-time tasks, and accumulating into significant periodic jitter.

[0094] Therefore, in some embodiments, the update calculation operation in step S303 further includes: S3034, managing the log records; wherein the master station receives a log record request containing an event severity level;

[0095] The log record refers to the record of various events, states, errors and the like generated in the system running process, used for system debugging, monitoring and troubleshooting and the like, such as recording task execution, data transmission state and the like. The management here refers to the control and specification of the generation, storage and the like of the log record, to ensure that the log record meets the requirements and does not affect the system performance. The event severity level refers to the classification identification of the severity of the event involved in the log record, usually including different levels such as DEBUG (debug), INFO (information), WARN (warning), ERROR (error), FATAL (fatal) and the like, and the higher the level, the more serious the event. The log record request refers to the request of a module or component in the system to record the information related to an event, which contains the severity level of the event and the data content to be recorded.

[0096] Specifically, in the updating calculation operation process, various functional modules (such as communication modules, calculation modules and the like) in the system will generate various events when running, and when a module considers that the event information needs to be recorded, a log record request will be generated. The request not only contains the specific description of the event, the occurrence time and the like, but also explicitly marks the severity level of the event. The master station receives these log record requests from various modules through its internal log management interface or related communication mechanism. In the receiving process, the master station performs preliminary format checking on the request to ensure that the request contains necessary information (such as the severity level of the event), so as to further process and judge, thereby realizing effective management of the log record and avoiding excessive log record affecting the system performance.

[0097] By receiving the log record request containing the event severity level, a basis is provided for the master station to subsequently judge whether the log record I / O operation needs to be performed according to the event severity, so that the master station can selectively process log requests of different levels, avoid indiscriminately recording all logs, and thus reduce unnecessary I / O operations to interfere with real-time tasks.

[0098] S3035, the master station compares the event severity level with a preset log record threshold;

[0099] S3036, if the event severity level is equal to or higher than the log record threshold, the master station performs the I / O operation of writing the data corresponding to the log record request;

[0100] S3037, if the event severity level is lower than the log record threshold, the master station directly discards the log record request.

[0101] It can be seen that by implementing strict log level filtering, unnecessary I / O interference is eliminated from the system level. This creates a cleaner and more deterministic operating environment for EtherCAT communication tasks, eliminating an important source of random jitter.

[0102] In actual use, in the motion control process of a controlled object such as a robot, the related trajectory interpolation method is difficult to accurately execute each related sub-step in order according to the real-time running state of the controlled object when generating control instructions, and may blindly generate or process instructions without considering the current actual running situation. At the same time, there is a lack of effective safety verification link for feedback control instructions, and it is impossible to detect whether it exceeds the safety threshold in time, which is easy to lead to the fact that once an abnormal control instruction appears in actual application, it may directly cause a fault and cannot be responded in time, thereby affecting the stable operation of the whole system, and the connection between steps is not close enough, so that the accuracy and timeliness of instruction generation cannot be guaranteed, and the demand for accurate and safe control of the controlled object in complex industrial scenarios cannot be well met.

[0103] Therefore, in some embodiments, the trajectory interpolation in step S303 specifically includes: S3038, the master station acquires current state data of the controlled object, and determines the current running state according to a preset state machine logic;

[0104] The controlled object is the execution subject of the present application, for example, a robot and the like, and the preset state machine logic refers to a set of logic rules that are set in advance in the system design stage according to different working modes of the controlled object, possible state changes and the like, and are used to determine the current running state of the controlled object according to the input related data (such as current state data), for example, the robot joint is set to be in a normal running state within a certain speed and angle range, and is abnormal when it exceeds the range, and it is the key logic support for accurate state determination. The current running state refers to the specific working state of the controlled object at the moment determined by the above-mentioned state machine logic, and common ones include running, stopping, fault and different state classifications, and the subsequent control operations will be different in different states.

[0105] Specifically, the master station first sends a request for obtaining current state data to the controlled object through the communication link established with the controlled object (such as through the corresponding slave station device) according to a predetermined communication protocol. After receiving the request, the controlled object sorts and packages the parameter information (such as position information obtained by a position sensor, joint angle information obtained by an angle sensor, etc.) reflecting the current state collected by each sensor of the controlled object, and then returns the parameter information to the master station. After receiving the data, the master station checks the integrity and accuracy of the data, such as checking whether the data format is correct, whether there is data loss, etc. After the verification is passed, the master station delivers the current state data of the controlled object as input to the preset state machine logic module. The state machine logic module contains a series of judgment rules and logic branches, which will determine the running state of the controlled object according to the specific values of each parameter in the current state data, and the different state judgment conditions (such as speed range, position interval, etc. corresponding to different state standards) preset in advance, such as determining that the robot is in a normal running state at this moment, and can continue to execute subsequent motion trajectory planning operations, so as to provide accurate state basis for the entire trajectory interpolation and subsequent control instruction generation operations.

[0106] When the running state is running, the following sub-steps are executed in sequence:

[0107] S3039, the master station generates a target motion instruction containing a target position;

[0108] Specifically, the master 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 upper computer (such as in an automated production line, the upper computer sets the working positions that the robot needs to reach according to the production process), or may be calculated according to the preset motion trajectory (for example, when the robot performs welding operation according to a fixed trajectory, the target position of each stage is calculated according to the trajectory planning). Then, the master station integrates the target position information and other necessary motion parameters (such as expected motion speed, acceleration, etc.) according to the actual state of the controlled object (such as the current motion speed, acceleration, etc.) and the system set motion control strategy (such as speed limit in different stages, acceleration curve, etc.), and encapsulates them into a target motion instruction containing a target position according to a predetermined instruction format. For example, for a joint of the robot, the target motion instruction will clearly indicate the angle position (target position) that the joint needs to move to and the speed and acceleration with which this movement is achieved, so that the controlled object can accurately move towards the target position according to the instruction.

[0109] S30310, the master station generates a feedback control instruction based on the error between the target position and the actual position;

[0110] Specifically, after generating the target motion instruction, the master station will continuously obtain the actual position information of the controlled object, which is collected by the position sensor (such as an encoder, etc.) on the controlled object in real time and fed back to the master station through the communication link. After receiving the actual position information, the master station compares and calculates the error value of the target position and the actual position in each dimension (such as the X, Y, Z axis direction of the spatial coordinate, or the joint angle, etc.) extracted from the target motion instruction. Then, according to the pre-set control algorithm (such as the PID control algorithm, etc.), the master station takes these error values as input parameters to determine how to adjust the motion parameters (such as the motion speed, acceleration, etc.) of the controlled object through the operation logic of the algorithm, and then generates the feedback control instruction. For example, if the error between the target position and the actual position in a certain direction is large, the control algorithm calculates that the motion speed in that direction needs to be increased, and the feedback control instruction will contain the corresponding speed adjustment information to command the controlled object to speed up the motion to reduce the position error, so that the motion of the controlled object can more accurately approach the target position, achieving precise motion control.

[0111] S30311、The master station performs safety verification on the feedback control instruction to determine whether it exceeds the pre-set safety threshold;

[0112] The pre-set safety threshold refers to the safety upper limit value or safety range of various parameters pre-set during the system design stage according to the mechanical performance of the controlled object, working environment, safety requirements, etc. For example, the maximum speed threshold and maximum torque threshold of the joint motion of the robot are set. Once the parameters in the feedback control instruction exceed these thresholds, there may be a safety risk.

[0113] Specifically, after generating the feedback control instruction, the master station extracts the key motion parameters (such as motion speed, acceleration, torque, etc.) contained in the instruction, and then compares these parameters with the pre-set corresponding safety thresholds. For example, for the motion speed of the controlled object set in the feedback control instruction, the master station will look up the pre-set maximum safety speed threshold of the controlled object in the current working mode in the system, and compare the speed parameter in the instruction with it. If the speed parameter is less than or equal to the safety speed threshold, it means that it is safe in terms of speed; otherwise, if the speed parameter is greater than the safety speed threshold, there may be a safety risk. Similarly, the master station will also perform such one-by-one comparison and verification on acceleration, torque and other key parameters. Through such comprehensive comparison and judgment of the parameters in the feedback control instruction with the pre-set safety thresholds, the master station can determine whether the feedback control instruction exceeds the safety range, thereby providing a basis for taking corresponding measures according to the judgment result to ensure that the controlled object performs motion control under the premise of safety.

[0114] S30312, if the result of the judgment is yes, the running state is updated to a fault state, and a preset braking instruction is designated as the final control instruction;

[0115] Specifically, when the master station determines in step S3034 that the safety check result of the feedback control instruction is yes (i.e., there is a parameter exceeding the safety threshold), the current running state of the controlled object will be first marked from running to fault in the running state management module of the system. This change of state will trigger the fault handling mechanism of the system, notifying the relevant monitoring module, alarm module, etc. (for example, sending a fault alarm information to the operator), and informing the entire system that the controlled object has an abnormal situation. At the same time, the master station will extract a preset braking instruction from the pre-stored instruction set. This braking instruction is carefully designed and tested, which can ensure that the controlled object stops moving or enters a safe protection state as soon as possible under various possible fault scenarios. The master station determines this braking instruction as the final control instruction, which will be sent to the slave station corresponding to the controlled object according to the communication protocol and other requirements. After receiving the braking instruction, the slave station will perform corresponding operations, such as controlling the joint motor of the robot to stop rotating quickly, locking the mechanical structure, etc., to prevent the controlled object from continuing to move according to the feedback control instruction with safety risks, thereby avoiding more serious faults or safety accidents that may occur.

[0116] When it is found that the feedback control instruction exceeds the safety threshold and has safety risks, by updating the running state to a fault state in time and designating the braking instruction as the final control instruction, the controlled object can be quickly stopped from dangerous movement, and the fault can be further expanded. The problem of being unable to respond to abnormal instructions in time in the prior art is solved, and the safety and stability of the entire system when an abnormal situation occurs are guaranteed.

[0117] S30313, if the result of the judgment is no, the feedback control instruction and the feedforward instruction are synthesized to generate the final control instruction;

[0118] Specifically, the master station first extracts the key motion parameters contained in the feedback control instruction and the feedforward instruction, such as the current speed adjustment amount in the feedback control instruction, the acceleration adjustment amount, and the preset expected speed and expected acceleration in the feedforward instruction. Then, according to the pre-set synthesis algorithm (for example, a weighted average algorithm, and the weights of each parameter are set according to different control requirements and system characteristics), the extracted corresponding motion parameters are synthesized and calculated. Taking the speed parameter as an example, if the speed adjustment amount required in the feedback control instruction is to increase by a certain value, and the expected speed in the feedforward instruction is a certain specific value, according to the set synthesis algorithm (assuming that the weight distribution is 0.4 for the feedback control instruction and 0.6 for the feedforward instruction), the final speed value after synthesis is calculated. The master station also synthesizes and calculates other key motion parameters (such as acceleration and position) in the same way, encapsulates these synthesized motion parameters according to the established instruction format, and generates the final control instruction. Through such synthesis operation, the final control instruction not only considers the error between the actual position and the target position of the controlled object (reflected through the feedback control instruction), but also combines the pre-planned motion requirements (reflected through the feedforward instruction), so that the controlled object can move under more accurate and efficient control, and better meet the requirements of motion control accuracy and efficiency in complex industrial scenarios.

[0119] In the case of safe and reasonable feedback control instruction, the final control instruction is generated by synthesizing it with the feedforward instruction, which combines the advantages of both, can further improve the accuracy and efficiency of motion control, solves the problems of difficult to guarantee the accuracy and timeliness of instruction generation and insufficient tightness between steps in the prior art, and realizes more practical and optimized motion control.

[0120] S30314、The master station stores the final control instruction.

[0121] It should be noted that the various data in the present application are used for the next control cycle.

[0122] It can be seen that the master station first acquires the current state data of the controlled object, and accurately judges the current running state according to the preset state machine logic, which lays a foundation for subsequent instruction generation and other operations, and ensures that each step is carried out in accordance with the actual situation. When the running state is running, a series of sub-steps are executed in sequence. First, a target motion instruction containing a target position is generated, and 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 safety checked. Through such a process, abnormal instructions that may exceed the preset safety threshold can be found in time. If it exceeds, the running state is updated to the fault state and the braking instruction is specified as the final control instruction, which ensures the safety of the system. If it does not exceed, the feedback control instruction and the feedforward instruction are combined to generate the final control instruction, and finally the final control instruction is stored. Each step is closely coordinated and linked, so that the generation of the control instruction not only considers the actual running state but also takes into account safety factors, which 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 for controlling the controlled object, and better serving the control needs in complex industrial scenarios.

[0123] In actual use, online reconfiguration tasks will be encountered. In the running system constructed by the related art, the idle time between the write() operation and the read() operation is used to carry out the online reconfiguration task. The reason why this can be done is that the time required by the write() operation and the read() operation is relatively stable in the normal running state. In this way, the idle period naturally occurring between the two operations can be reasonably utilized to execute the online reconfiguration task.

[0124] However, under the unique technical framework involved in the present application, the situation has changed significantly. The present application makes an adjustment that moves the update() operation to the end of the working cycle. Therefore, when trying to still use the way of using idle time in the related art to execute the online reconfiguration task, a resource conflict between the update() operation and the online reconfiguration task is extremely easy to occur. After all, the online reconfiguration task itself also needs to occupy computing resources, memory space and other key resources in the system to complete its important operation tasks such as configuration update. However, due to the uncertainty of the update() operation, it is difficult to clearly divide and arrange the update() operation and the online reconfiguration task in the time dimension like the write() operation and the read() operation.

[0125] The direct consequence of such resource conflict is that the update() operation will be interrupted or terminated abnormally, resulting in the failure of the corresponding data update task to be completed as scheduled. 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 the state that can be effectively controlled. Further, the length of the instruction buffer queue is increasing, leading to more and more serious delay, which is so serious that it deviates from the original intention of the application scenario of 1ms periodic task.

[0126] Please refer to Figure 4 , Figure 4 is another flowchart of the method for improving the real-time performance of EtherCAT in the embodiments of the present application;

[0127] Therefore, in some embodiments, in the step S303 in which the master station performs the update calculation operation using the remaining time of the current control period, the method further includes that the master station synchronously performs an online reconstruction task in S401, the scheduled time length of the online reconstruction task is less than the remaining time; and the task nodes of the online reconstruction task are selected from the nodes released by the update calculation operation.

[0128] The online reconstruction task represents a task of dynamically adjusting and updating part of the configurations and parameters of the system during system operation. The scheduled time length is the time length allowed to be spent by the online reconstruction task in advance, which is used to limit the time range of the task to reasonably occupy system resources without affecting other key operations. The remaining time is the time available after the execution of the previous related operations (such as sending instructions), which is determined according to the entire control period and the time already used. The task node is a basic unit involved in the execution of the online reconstruction task, such as a specific calculation module, a data storage area, etc., which constitutes the key elements to complete the online reconstruction task. The node released by the update calculation operation is a node that is no longer needed to be occupied during the execution of the update calculation operation by the master station after completing some stages or processing part of the data, which can be reasonably allocated to the online reconstruction task for use, so as to realize the effective use of resources.

[0129] It needs to be explained that, according to the conventional idea, the online reconstruction task and the update() operation will occupy system resources in the execution process. When facing this situation, the solution that people usually think of is to arrange them to carry out in different time periods, that is, to carry out them in turn in different time periods to avoid resource conflict, or to directly discard one party to ensure that the other party can be executed smoothly. However, the embodiment adopts a different processing method, breaks the conventional thinking, and presents a completely different approach.

[0130] S402, the master station judges the completion of the online reconstruction task and the number of selected task nodes after a preset time;

[0131] S403, when the completion 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 the selected task nodes in the control period; and changes the corresponding relationship of the online reconstruction task;

[0132] In the process of system executing the online reconstruction task, after monitoring and judging the completion of the online reconstruction task and the number of selected task nodes, when it is found that the completion is less than the preset completion threshold and the number of selected task nodes is less than the preset number threshold, this step is executed.

[0133] It needs to be understood that a general description is that in this process, the master station will pay close attention to the progress of the online reconstruction task and the resource occupation situation, if it is found that although a certain resource (that is, part of the task nodes are selected) has been invested to execute the online reconstruction task, but the completion progress of the task is far behind the expectation (the completion is less than the preset completion threshold), and the invested resource is obviously insufficient (the number of selected task nodes is less than the preset number threshold), at this time, it means that the update() operation itself faces great task pressure, and from the current situation, there is no sign of improvement, if the online reconstruction task and the update() operation continue to be carried out synchronously, it is likely to cause both parties to fail to complete the task, and then affect the normal operation of the whole system, so the master station needs to take the measures described in this step to adjust the online reconstruction task in time.

[0134] Specifically, when the master station finds that the completion condition of the online reconstruction task is less than the preset completion threshold and the number of selected task nodes is less than the preset number threshold through the corresponding monitoring mechanism (such as a task progress checking module, a resource usage statistical module, etc.), the master station will first start the termination process of the online reconstruction task. It will send a task cancellation instruction signal to each functional module in the system responsible for the specific execution of the online reconstruction task. After receiving the signal, these functional modules will immediately stop all ongoing specific operations related to the online reconstruction task, whether it is the ongoing configuration parameter update, network topology adjustment or other subtasks. All of them will be forcibly interrupted and will no longer continue to execute the subsequent part that has not been carried out, so as to avoid the online reconstruction task continuing to occupy the system's computing resources, memory resources, network bandwidth and other key resources.

[0135] Then, the master station will perform resource recycling operations on all task nodes previously allocated to the online reconstruction task. The master station will traverse the task node information related to the online reconstruction task recorded in the resource management system, and for each allocated task node, it will release the resources occupied by these task nodes by modifying the corresponding resource occupation flag (such as marking the corresponding memory block as free in the memory management table, releasing the occupation of the corresponding computing core in the computing resource allocation table, etc.), and re-integrate them into the system's available resource pool, so that these resources can be used by other running or subsequent tasks (especially tasks like update() operation that are crucial to the system's operation), to achieve rational allocation and efficient reuse of resources.

[0136] It should be noted that, considering that when the online reconstruction task is not well completed and the resources are insufficient, if it continues to maintain synchronization with the update() operation, both tasks will face the risk of being unable to complete due to resource shortage, thereby affecting the normal operation of the entire system. By canceling the online reconstruction task in time, releasing the resource nodes it occupies, and changing its corresponding relationship, it can prioritize the resources for the execution of critical tasks such as update() operation, while also preparing for the subsequent reasonable restart of the online reconstruction task, avoiding the system from falling into more serious operation problems due to the current online reconstruction task, thereby maintaining the stability and real-time performance of the system as a whole.

[0137] S404, when the completion condition 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.

[0138] Specifically, when the master station detects that the completion of the online reconstruction task is less than the preset completion threshold through relevant monitoring and statistical mechanisms, and the number of selected task nodes is greater than or equal to the preset number threshold, the master station will start the adjustment process of the online reconstruction task appointment duration. The original appointment duration is appropriately increased by a certain time unit (such as increasing several milliseconds or seconds, etc., the specific time increase is determined according to the threshold). In the process of increasing the appointment duration, the master station will monitor the change of the remaining time in real time to ensure that the increased appointment duration is always less than the remaining time, avoiding entering the next cycle.

[0139] It should be noted that when the online reconstruction task has sufficient resource input but the progress is not ideal, it means that it still has the potential to complete, and if the task is directly canceled, it will waste resources and be not conducive to system optimization. By appropriately increasing the appointment duration, the online reconstruction task is provided with more time to continue execution without affecting other key operations in the current cycle (limited by the remaining time), which can make full use of the resources already invested, increase the opportunity to complete the remaining tasks, avoid affecting the stability and subsequent operation of the system due to long-term stagnation or failure to complete the task, and achieve dynamic optimization and stable operation of the system. At the same time, it can also balance the resource utilization and task advancement relationship between the online reconstruction task and the update() operation to a certain extent.

[0140] It should be noted that in the embodiments of the present application, there is also a situation where the completion is not less than the preset completion threshold. This situation usually occurs in the scene where the update() operation bears less task pressure and the system resources are relatively abundant - because the update() operation can be easily pushed forward, it does not form fierce resource competition with the online reconstruction task, so the online reconstruction task can also be normally pushed forward and reach the expected completion progress, and generally can be completed smoothly. In view of the fact that this situation belongs to the normal ideal state of system operation, its processing logic is relatively simple and clear, and here it will not be expanded and described in detail.

[0141] It can be seen that when the master station performs the update calculation operation with the remaining time of the current control period, in view of the uncertainty of update(), the online reconstruction task is selected to be carried out in parallel, the nodes released by the update calculation operation are selected for the reconstruction task, the idle resources are utilized, and the conflict caused by excessive resource preemption is avoided, thereby ensuring that the two can start together in the initial stage. After a period of time, the overall situation is controlled by judging the completion of the online reconstruction task and the number of nodes. When the completion is not good and the number is not ideal, it means that the update() pressure is large and the trend has not improved. At this time, the online reconstruction task is directly cancelled, which does not affect the completion of update(). When the completion is not good and the number is ideal, it means that the trend of update() is gradually improved. In order to avoid affecting update(), the completion of the online reconstruction task is improved in another dimension by increasing the scheduled time of the online reconstruction task.

[0142] In actual use, once update() occurs extreme delay (for example, more than one period), at this time EtherCAT will forcibly enter the next period, which will cause the instructions to be overwritten, thereby causing the robot action to jump.

[0143] The step S301 of writing the control instruction of the last period to at least one slave station through EtherCAT is replaced by: S501, the master station takes the control instruction of the last period from the head of the instruction buffer queue and writes it to at least one slave station through EtherCAT;

[0144] The instruction buffer queue is a data structure for temporarily storing control instructions, which arranges the instructions according to the first-in first-out (FIFO) principle, like an instruction queue waiting for processing. New generated instructions will be added to the end of the queue, and instructions to be sent out will be taken from the head of the queue, which plays a role in buffering and buffering scheduling of instructions. The head refers to the end of the instruction buffer queue where the earliest instruction enters the queue. According to the first-in first-out principle, the instruction will be taken out first for subsequent operation.

[0145] The step S303 of storing the control instruction of the next period is replaced by: S502, the master station pushes the control instruction of the next period to the end of the instruction buffer queue.

[0146] Specifically, when the master station generates the next cycle control instruction through the update calculation operation and other related processes, it begins to store these instructions. The master station first organizes and encapsulates the generated next cycle control instruction to ensure the format specification and data integrity of the instruction, facilitating subsequent storage and retrieval for use. Then, according to the first-in-first-out rule of the instruction buffer queue, the master station finds the end position of the instruction buffer queue and adds the encapsulated next cycle control instruction to the end position through the corresponding queue operation interface or data storage mechanism. In this way, these newly generated instructions will be queued in order in the queue, and when the next control cycle arrives, they will be taken out from the head of the queue according to the first-in-first-out principle, and then sent to the corresponding slave station, realizing the continuous control of the slave station and ensuring that the control process of the entire system can proceed in a coherent and orderly manner, maintaining the stable operation of the system and the precise control of the industrial production process.

[0147] It can be seen that by introducing the instruction buffer queue, a decoupled buffer layer is established between the production (update calculation) and consumption (sending instructions) of instructions. This enhances the fault tolerance of the system, ensuring the continuity and integrity of control instructions even in the face of sudden calculation delays, and improves the stability and reliability of the system.

[0148] It should be noted that in some embodiments, once update() experiences extreme delay (e.g., more than one cycle), EtherCAT will forcibly enter the next cycle, which may result in the instructions being overwritten, causing the robot to jump.

[0149] The above describes the problem of multiple instruction conflicts. In addition to the technical problem of multiple instructions conflicting with each other, there is also a new challenge of no instructions. In some embodiments, the related technologies involved in the current cycle can be ingeniously integrated with other existing related technologies to create a comprehensive technical solution.

[0150] An EtherCAT cycle loop process includes:

[0151] S101, start;

[0152] S102, wait for cycle start;

[0153] S301, the master station performs a read operation to obtain current slave station real-time state data from at least one slave station and stores the slave station real-time state data in the memory of the master station;

[0154] SA, determine whether there is a last cycle control instruction;

[0155] If yes, execute steps S104 to S109;

[0156] S104, distributed clock synchronization is performed;

[0157] S105, control logic update-update() is performed;

[0158] S106, write control instruction-write() is performed;

[0159] S107, an EtherCAT data frame is sent;

[0160] S108, a ctrlc semaphore is listened to;

[0161] S109, a cycle ends, and the next cycle is prepared;

[0162] If no, steps S302, S303, S207, S208, S209 and S210 are performed;

[0163] S302, after the read operation is performed, the master station performs a send instruction operation, and writes the last cycle control instruction to at least one slave station through EtherCAT;

[0164] S303, after the send instruction operation is performed, the master station performs an update calculation operation using the remaining time of the current control cycle, the update calculation operation uses the real-time state data of the slave station to perform control logic operation and trajectory interpolation, to generate next cycle control instruction for the next control cycle, and stores the next cycle control instruction.

[0165] S207, distributed clock synchronization is performed;

[0166] S208, an EtherCAT data frame is sent;

[0167] S209, a ctrlc semaphore is listened to;

[0168] S210, a cycle ends, and the next cycle is prepared;

[0169] In this way, the advantages of the two methods can be retained at the same time, and they can be complementary to each other, so that the comprehensive technical solution has more advantages when dealing with various complex situations, better meets the diversified needs in actual application, and further improves the overall performance and effect.

[0170] In actual application, if the embodiments corresponding to steps S401-S405 and the embodiments corresponding to steps S501-S502 appear at the same time, a new problem will be caused. Specifically, since the embodiments represented by steps S401-S405 increase the probability of incomplete update() operation, it will cause the instruction buffer queue in the embodiments represented by steps S501-S502 to be constantly lengthened. With the continuous increase of the length of the instruction buffer queue, the delay rate gradually rises, and finally it is difficult to meet the requirement of low delay in actual application.

[0171] Therefore, in some embodiments, after the master station judges the completion of the online reconstruction task and the number of selected task nodes in step S401, the method further comprises:

[0172] S601, the master station judges whether the instruction buffer queue has control instructions;

[0173] S602, if there are control instructions, the master station judges whether the control instructions are generated in the current control period;

[0174] Specifically, when the master station determines that there are control instructions in the instruction buffer queue in step S601, it will further trace the source of these control instructions. The master station will check the relevant time stamp, generation mark or corresponding information recorded by the instruction generation module attached to each control instruction to determine whether the control instruction is generated in the current control period or left over from other periods. For example, the instruction will be labeled with a corresponding time tag when it is generated. The master station extracts this time tag and compares it with the time range of the current control period. If the time tag is between the start time of the current control period and the current time, it is determined that the control instruction is generated in the current control period. Otherwise, if the time corresponding to the time tag is before the current control period, it is determined that it is not generated in the current control period. Through such detailed judgment, the master station can more accurately master the source of the instruction and provide more detailed basis for making reasonable decisions in combination with the online reconstruction task situation.

[0175] S603, if it is generated in the current control period, when the completion 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 in the control period and releases all the selected task nodes; and changes the corresponding relationship of the online reconstruction task;

[0176] It should be noted that when it is determined that the control period is generated, formally, it is only equivalent to the case where only the embodiment corresponding to steps S401 to S405 appears, and no superposition effect is generated with the embodiment represented by steps S501 to S502. Based on such a premise, the processing idea of steps S401 to S405 is still followed to deal with it, which will not be repeated here.

[0177] S604, when the completion condition 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;

[0178] S605, if not the control period is generated; then when the completion condition is less than the preset completion threshold, the master station cancels the online reconstruction task in the control period and releases all the selected task nodes; and changes the corresponding relationship of the online reconstruction task.

[0179] It should be noted that when it is determined that the control period is not generated, the embodiment represented by steps S401 to S405 will increase the probability that the update() operation is not completed, which will cause the instruction buffer queue in the embodiment represented by steps S501 to S502 to be constantly lengthened;

[0180] Therefore, when the control instruction is not generated in the current period (there is old instruction backlog) and the online reconstruction task completion condition is not good, by canceling the task, releasing the resources and adjusting the corresponding relationship, the resource demand of the key operation such as update() can be preferentially guaranteed, the system delay risk caused by the old instruction backlog is reduced, and the online reconstruction task and the key operation are further avoided from competing for resources, thereby improving the fault tolerance capability and stability of the system in processing sudden situations.

[0181] It can be seen that the current length of the instruction buffer queue is taken into account to affect the severity of the judgment on the online reconstruction task. When the completion condition is less than the preset threshold and the number of selected task nodes is less than the preset threshold, it means that the online reconstruction task is difficult to complete even under the most lenient conditions, and the task is directly canceled according to the established strategy and the resources are released. When the completion condition is less than the preset threshold and the number of selected task nodes is greater than the preset threshold, considering that the task may not be completed although more resources are invested, it is further judged whether there is an instruction in the instruction buffer queue. If there is an instruction, it is further judged whether it is generated in the current control cycle. If it is generated in the current control cycle, it means that the update() has been completed, and the online reconstruction task can be normally completed. If it is not generated in the current control cycle, it means that there is an old instruction backlog, and the online reconstruction task is canceled and the resources are released, the corresponding relationship is changed, and the completion rate of the update() is improved.

[0182] An exemplary EtherCAT real-time improvement system 500 provided by the embodiments of the present application will be introduced below. Figure 5 FIG. 1 is an exemplary hardware structure schematic diagram of the EtherCAT real-time improvement system 500 provided by the embodiments of the present application.

[0183] In some embodiments, the EtherCAT real-time improvement system 500 is a computer device or includes a computer device in the EtherCAT real-time improvement system 500. The computer device includes a processor, a memory and a network interface connected through a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The database of the computer device is configured to store data. The network interface of the computer device is configured to communicate with other terminals or servers outside through a network connection. In some embodiments, the network interface can be a wired network interface, and in some embodiments, the network interface can also be a wireless network interface. The computer program is executed by the processor to implement the method in the embodiments of the present application.

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

[0185] The above-described embodiments merely serve to illustrate the technical solutions of the present application, rather than limit the present application; even though the present application has been described in detail with reference to the foregoing embodiments, those ordinarily skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or equivalently replace some of the technical features thereof; and these modifications or replacements do not cause the essence of the corresponding technical solutions to depart from the scope of the technical solutions of the embodiments of the present application.

[0186] In the above-described embodiments, the term "when" can be interpreted as meaning "if" or "after" or "in response to determining" or "in response to detecting" according to the context. Similarly, the phrase "upon determining" or "if detecting (the stated condition or event)" can be interpreted as meaning "if determining" or "in response to determining" or "upon detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)" according to the context.

[0187] In the above-described embodiments, all or some of the processes can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, the processes can be implemented 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 into and executed by a computer, all or some of the processes described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable apparatus. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through a wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium accessible by a computer or a data storage device such as a server, data center, etc. that includes one or more available media sets. The available media can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state disk), etc.

[0188] Those of ordinary skill in the art can understand that all or part of the processes in the above-described embodiments can be implemented by a computer program instructing relevant hardware, which can be stored in a computer-readable storage medium. The program can include the processes of the above-described embodiments when executed. The aforementioned storage medium includes ROM or random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

Claims

1. An EtherCAT real-time improvement method, characterized in that, The application relates to a method for updating control logic in an EtherCAT communication system. The method comprises the following steps in a preset control cycle: The master station performs a read operation to obtain current slave station real-time state data from at least one slave station and stores the slave station real-time state data in the memory of the master station; After the read operation, the master station performs a send instruction operation to write last cycle control instructions into the at least one slave station through EtherCAT; After the send instruction operation, the master station performs an update calculation operation using the remaining time of the current control cycle, the update calculation operation uses the slave station real-time state data to perform control logic operation and trajectory interpolation to generate next cycle control instructions for the next control cycle and stores the next cycle control instructions.

2. The method of claim 1, wherein, During the step of performing the update calculation operation using the remaining time of the current control cycle, the method further comprises: The master station synchronously performs an online reconstruction task, wherein the online reconstruction task has a preset time length which is less than the remaining time; and the task nodes of the online reconstruction task are selected from the nodes released by the update calculation operation; After the preset time, the master station judges the completion condition of the online reconstruction task and the number of selected task nodes; When the completion condition is less than a preset completion threshold value and the number of selected task nodes is less than a preset number threshold value, the master station cancels the online reconstruction task in the control cycle and releases all the selected task nodes; and the corresponding relationship of the online reconstruction task is changed; When the completion condition is less than the preset completion threshold value and the number of selected task nodes is greater than or equal to the preset number threshold value, the master station increases the preset time length of the online reconstruction task, and the increased preset time length is not greater than the remaining time.

3. The method of claim 2, wherein, The step of writing the last cycle control instructions into the at least one slave station through EtherCAT comprises the following steps: the master station takes the last cycle control instructions from the head of an instruction buffer queue and writes the last cycle control instructions into the at least one slave station through EtherCAT; The step of storing the next cycle control instructions comprises the following steps: the master station pushes the next cycle control instructions into the end of the instruction buffer queue.

4. The method of claim 3, wherein, After the step of judging the completion condition of the online reconstruction task and the number of selected task nodes after the preset time, the method further comprises: The master station judges whether the instruction buffer queue has control instructions; If the instruction buffer queue has control instructions, the master station judges whether the control instructions are generated in the current control cycle; If the control instructions are generated in the current control cycle, when the completion condition is less than the preset completion threshold value and the number of selected task nodes is less than the preset number threshold value, the master station cancels the online reconstruction task in the control cycle and releases all the selected task nodes; and the corresponding relationship of the online reconstruction task is changed. When the completion condition is less than a preset completion threshold and the number of selected task nodes is greater than a preset number threshold, the master station increases the appointment duration of the online reconstruction task, and the increased appointment duration is not greater than the remaining time; If not generated in the control cycle; when the completion condition is less than a preset completion threshold, the master station cancels the online reconstruction task and releases all selected task nodes in the control cycle; and changes the corresponding relationship of the online reconstruction task.

5. The method of claim 1, wherein, The control logic operation includes a joint sequence adjustment algorithm; The joint sequence adjustment algorithm specifically includes: the master station traverses n internal joints preset by a robot control system, creates a joint index hash table with the name of each internal joint as a key and its corresponding internal index as a value; The master station receives a trajectory message including 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 perform lookup to obtain the corresponding internal index, and obtains a mapping relationship between the target joint and the internal index; The master station fills the target values in the trajectory message into a control instruction data structure corresponding to the internal index according to the mapping relationship.

6. The method of claim 1, wherein, The update calculation operation further includes managing log records; wherein the master station receives a log record request including 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 of writing 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.

7. The method of claim 1, wherein, The trajectory interpolation specifically includes: The master station obtains current state data of a controlled object, and determines a current running state according to a preset state machine logic; When the running state is running, the following sub-steps are sequentially executed: The master station generates a target motion instruction including a target position; The master station generates a feedback control instruction based on an error between the target position and an actual position; The master station performs safety verification on the feedback control instruction to determine whether it exceeds a preset safety threshold; If the determination result is yes, the master station updates the running state to a fault state, and specifies the preset braking instruction as a final control instruction; If the determination result is no, the master station synthesizes the feedback control instruction and a feedforward instruction to generate a final control instruction; The master station stores the final control instruction.

8. An EtherCAT real-time improvement system, characterized by, The EtherCAT real-time improvement system includes one or more processors and a memory; the memory is coupled with the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors invoke the computer instructions to enable the EtherCAT real-time improvement system to perform the method in any one of claims 1-7.

9. A computer program product comprising instructions, characterized in that, The computer program product, when run on an EtherCAT real-time improvement system, causes the EtherCAT real-time improvement system to perform the method of any one of claims 1-7.

10. A computer-readable storage medium comprising instructions, characterized in that, The instructions, when run on an EtherCAT real-time improvement system, cause the EtherCAT real-time improvement system to perform the method of 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