Ethercat servo driver multi-stage interpolation and instruction buffer synchronization control method
Patent Information
- Application Number
- CN202610979625.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-02
- Publication Date
- 2026-10-13
AI Technical Summary
[0006]传统方案中,每个控制周期均需执行完整的插补计算,即使在同步周期内的中间控制周期,目标位置并未更新,计算结果也完全相同,造成了大量冗余计算开销
[0048]有益效果:即使经过数百万次周期累积,实际位置与指令位置之间的偏差仍被控制在±1个脉冲以内,从根本上解决了低速运行时的位置漂移问题,这是传统方法无法实现的。
Smart Images

Figure CN122902425A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of motion control for servo drives, and more particularly to a method for multi-level interpolation and command buffer synchronization control of EtherCAT servo drives. Background Technology
[0002] With the rapid advancement of intelligent manufacturing, real-time Ethernet technology, represented by EtherCAT, has become the mainstream communication architecture for servo motion control systems. In applications such as multi-axis linkage and high-precision positioning, the host controller typically broadcasts target position commands with a fixed Ethernet synchronization cycle, while the current loop, speed loop, and position loop within the servo drive operate with shorter control cycles. This non-integer multiple relationship between the synchronization cycle and the internal control cycle makes accurately and smoothly decomposing the periodic target position increments issued by the host computer into each internal control cycle a core problem of the servo drive interpolation algorithm.
[0003] Traditional digital differential analyzer (DDA) interpolation and linear interpolation methods perform well in single-cycle, fixed-step scenarios. However, their accuracy, real-time performance, and robustness face severe challenges when dealing with complex operating conditions such as multi-level nested cycles, communication jitter, and dynamic load changes. Meanwhile, the instruction buffer mechanism, as a bridge between synchronous communication and real-time control, directly determines the system's behavior when communication is interrupted or delayed.
[0004] In existing technologies, when the Ethernet synchronization period and the internal control loop period are not integer multiples or are large integer multiples, the traditional approach is to simply divide the total position increment by an integer and then distribute the result, discarding the remainder or performing only simple rounding. While this method provides controllable error in the short term, after accumulating a large number of cycles, the systematic loss of the remainder leads to a non-negligible steady-state deviation between the actual and commanded positions, especially manifesting as significant position drift and chattering during low-speed operation.
[0005] Existing servo drivers typically employ simple FIFO queues or double-buffered structures for their instruction buffers, resulting in fixed operating modes and an inability to adaptively adjust strategies based on buffer fill status. When brief fluctuations in Ethernet communication cause the buffer to empty, the system either crashes with an error or uses the oldest data, leading to significant shifts in the target position. Conversely, overfilling the buffer introduces unnecessary instruction latency. This lack of smooth transition mechanisms for intermediate states renders the system's behavior uncontrollable during communication quality fluctuations.
[0006] In traditional schemes, a complete interpolation calculation must be performed in each control cycle. Even in intermediate control cycles within a synchronization cycle, where the target position is not updated, the calculation results are identical, resulting in significant redundant computational overhead. At high control frequencies, this overhead consumes the computational resources of the control loop, impacting the system's real-time performance and scalability.
[0007] Therefore, we propose a multi-level interpolation and instruction buffer synchronization control method for EtherCAT servo drives to solve the above problems. Summary of the Invention
[0008] This invention provides a multi-level interpolation and instruction buffer synchronization control method for EtherCAT servo drives, which can improve the instruction tracking performance and operational stability of servo systems under non-ideal communication conditions.
[0009] The first aspect of this invention provides a multi-level interpolation and command buffering synchronization control method for an EtherCAT servo drive. The method includes: determining a cycle ratio based on the ratio of the communication synchronization cycle to the control cycle of the control loop; receiving the current target position; generating a first position increment based on the difference between the current target position and the target position recorded in the previous cycle; and obtaining the remainder from the previous cycle as an initial remainder; forming an allocation base based on the first position increment, the initial remainder, and the historical error accumulation value formed by the accumulation of tracking errors from previous cycles; allocating the allocation base according to the cycle ratio to obtain an average allocation amount for each control cycle; and updating the remainder; within each control cycle, performing remainder compensation and error prediction correction on the average allocation amount to obtain the final position command and updating the... Historical error accumulation value; compare the equivalent speed corresponding to the final position command with the amplitude limiting threshold. If the equivalent speed exceeds the amplitude limiting threshold, amplitude limiting processing is performed, and the value exceeding the amplitude limiting threshold is recycled into the remainder; set up a command buffer between the communication synchronization interruption side and the control ring, obtain the filling status of the command buffer in real time, and adaptively switch the working mode according to the filling status to provide the currently required target position. The working mode includes an extrapolation estimation mode that uses historical position increments to infer the currently required target position; coordinate the timing of the synchronization event and the control ring through a counter. The counter loads the cycle ratio when the synchronization event arrives and updates it in each control cycle. When the counter meets the preset trigger condition, a new interpolation calculation is triggered; otherwise, the previous allocation result is reused.
[0010] Optionally, in a first implementation of the first aspect of the present invention, the method includes:
[0011] The position increment in the user coordinate system is obtained by subtracting the current target position from the target position recorded in the previous cycle.
[0012] The position increment in the user coordinate system is converted using the electronic gear ratio to obtain the first position increment in the internal pulse unit;
[0013] The first position increment is accumulated into the position instruction accumulator, which is used to store the remaining amount of instructions that have not yet been executed.
[0014] Optionally, in a second implementation of the first aspect of the present invention, the method includes:
[0015] The first position increment, the initial remainder, and the historical error accumulation value are added together, and the sum of the three is used as the allocation base.
[0016] The step of allocating the allocation base according to the cycle ratio to obtain the average allocation amount for each control cycle, and updating the remainder, includes:
[0017] The average allocation amount is obtained by uniformly dividing the allocation base according to the cycle ratio, and the remaining value after dividing the allocation base by the cycle ratio is used as the new remainder.
[0018] The step of performing remainder compensation and error prediction correction on the average allocation to obtain the final position command includes:
[0019] Based on the sign and direction of the current remainder, perform beat-by-beat remainder compensation on the average allocation amount and deduct the remainder accordingly;
[0020] Based on the difference between the actual output position and the reference position in the previous control cycle, and combined with the average trend of the historical error accumulation value, the first-order prediction correction is calculated.
[0021] The average allocation amount after the step-by-step remainder compensation is added to the first-order prediction correction amount to obtain the final position command.
[0022] Optionally, in a third implementation of the first aspect of the present invention, the updating of the historical error accumulation value adopts a limited accumulation method:
[0023] After each control cycle ends, the current tracking error value is obtained and added to the historical error accumulation value of the previous cycle;
[0024] If the absolute value of the sum exceeds the preset upper limit, the historical error accumulation value is updated to the value corresponding to the preset upper limit; otherwise, the sum is retained as the updated historical error accumulation value.
[0025] Optionally, in a fourth implementation of the first aspect of the present invention, the method includes:
[0026] If the equivalent speed exceeds the limiting threshold calculated in advance based on the maximum speed of the motor, the final position command is reduced to the limiting threshold, and the value of the portion exceeding the limiting threshold is recorded in a separate recovery counter.
[0027] The value in the recycling counter is used first to compensate for the average allocation in subsequent control cycles until the recycling counter returns to zero, at which point the remainder is used for compensation.
[0028] The final position command, whether or not it has undergone amplitude limiting, is output as the actual output command to the control loop, while the value of the actual output command is subtracted from the position command accumulator.
[0029] Optionally, in a fifth implementation of the first aspect of the present invention, the instruction buffer is a circular instruction buffer equipped with a write pointer and a read pointer; the filling state is the filling depth corresponding to the difference between the write pointer and the read pointer;
[0030] The adaptive switching of the working mode based on the filling status to provide the currently required target position includes:
[0031] If the filling depth meets the first preset condition, the system enters the start filling mode. In the start filling mode, the read pointer follows the write pointer to read the initial data.
[0032] If the filling depth meets the second preset condition, then enter the normal buffer mode. In the normal buffer mode, the step size of the read pointer is dynamically adjusted according to the specific value of the filling depth.
[0033] If the filling depth meets the third preset condition, then enter the extrapolation estimation mode;
[0034] If the fill depth drops to zero, then a pass-through mode is entered, in which the latest written target position is directly used as the currently required target position provided to the backend.
[0035] Optionally, in a sixth implementation of the first aspect of the present invention, in the extrapolation estimation mode, the advance of the read pointer is paused;
[0036] The step of using historical location increments to infer the current target location includes:
[0037] Obtain the historical position increment recorded when the last successful read was made in the normal buffer mode, and add the historical position increment to the latest read target position to generate the inferred target position;
[0038] The inferred target position replaces the target position that should have been read from the instruction buffer, and is used as the current target position when generating the first position increment;
[0039] Simultaneously, the fill depth is continuously monitored. When the fill depth recovers to meet the second preset condition, the system switches back to the normal buffer mode and resumes advancing the read pointer.
[0040] Optionally, in the seventh implementation of the first aspect of the present invention, the counter is a decrementing counter;
[0041] The method of coordinating the timing of synchronization events with the control loop through a counter includes:
[0042] When each of the aforementioned synchronization events arrives, the value of the decrementing counter is reset to the period ratio;
[0043] At the beginning of each control cycle, the decrement counter is checked: if the value of the decrement counter is greater than one, the decrement counter is decremented by one, and the previous allocation result is directly reused without triggering the new interpolation calculation;
[0044] If the value of the decrement counter is equal to one, then a decrement operation is performed to return the decrement counter to zero, and the zeroed state is used as a condition to trigger a new interpolation calculation to generate a new final position instruction.
[0045] Optionally, in an eighth implementation of the first aspect of the present invention, it further includes:
[0046] When the servo driver switches to zero-return mode, the limiting threshold and the compensation mechanism for the remainder remain in effect, and the instruction buffer is forcibly switched to the pass-through mode.
[0047] After the zero-return mode is completed, the state variables of the remainder and the historical error accumulation value are cleared, and the instruction buffer is restored to the normal buffer mode.
[0048] Beneficial effects: Even after millions of cycles, the deviation between the actual position and the commanded position is still controlled within ±1 pulse, fundamentally solving the position drift problem during low-speed operation, which is something that traditional methods cannot achieve.
[0049] By using the difference between the actual output and the reference value from the previous cycle, combined with the average trend of historical error accumulation values, a limited first-order predictive correction is calculated and superimposed on the allocation result. This is equivalent to making a miniature prediction in each control cycle, so that the system does not correct after the error occurs, but compensates in advance when the error trend becomes apparent.
[0050] By using the position increment recorded during the last normal read to generate the inferred target position through linear extrapolation, the system can still output continuous and smooth position commands when the buffer is temporarily idle, instead of jumping or stopping. The system has a true tolerance for Ethernet communication jitter, and users feel the continuity of motion rather than interruption, which is especially critical in multi-axis linkage scenarios.
[0051] During the intermediate control cycle within the synchronization cycle, computing resources are completely released to higher priority control tasks such as the current loop and speed loop. The system can support higher control frequencies without increasing the processor burden, which has practical engineering value for multi-axis intensive control scenarios.
[0052] The first cycle after mode switching outputs clean and correct instructions, with no jumps in the motion trajectory. This is directly practical for automated production lines that need to frequently switch working modes. Attached Figure Description
[0053] Figure 1 This is a schematic diagram of an embodiment of the periodic synchronization position multi-level interpolation and instruction buffering method for servo drivers in this invention.
[0054] Figure 2 This is a timing coordination diagram of EtherCAT synchronization events and internal control cycles in an embodiment of the present invention. Detailed Implementation
[0055] This invention provides a multi-level interpolation and instruction buffer synchronization control method for EtherCAT servo drives, which improves the instruction tracking performance and operational stability of servo systems under non-ideal communication conditions. The terms first, second, third, fourth, etc. (if present) in the specification, claims, and accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms include or have, and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0056] For ease of understanding, the specific process of the embodiments of the present invention is described below. Please refer to [link / reference]. Figure 1 and Figure 2 One embodiment of the servo driver periodic synchronization position multi-level interpolation and instruction buffering method in this invention includes:
[0057] 101. At the beginning of each Ethernet synchronization cycle, the synchronization cycle ratio is determined based on the ratio of the synchronization cycle to the internal control loop cycle. The user coordinate position increment is generated based on the difference between the current target position and the target position of the previous cycle. This increment is converted into a position increment in internal pulse units and accumulated in the position command accumulator. At the same time, the remainder left over from the previous cycle is obtained as the initial remainder.
[0058] It is understood that the execution subject of this invention can be a periodic synchronization position multi-level interpolation and instruction buffer device for a servo driver, or it can be a terminal or a server; the specific implementation is not limited here. This embodiment of the invention will be described using a server as an example.
[0059] Specifically, at the start of the synchronization cycle, the synchronization cycle duration is read from the slave controller, and the integer ratio between the two is calculated based on the internal control loop cycle duration. This ratio is used as the synchronization cycle ratio. The current target position is received from the controller and subtracted from the target position recorded in the previous cycle to obtain the position increment in the user coordinate system. The position increment in the user coordinate system is converted using the electronic gear ratio to obtain the position increment in the internal pulse unit. The position increment in the internal pulse unit is accumulated into a position instruction accumulator that stores the remaining amount of instructions that have not yet been executed. At the same time, the remaining value after the end of the previous cycle is read as the initial remainder for subsequent use.
[0060] It should be noted that in industrial Ethernet networks, the communication synchronization cycle of the servo drive is set to 1000μs, while the control loop cycle, which is fixed in the underlying hardware, is set to 250μs. The system divides these two values to establish a synchronization cycle ratio of four for this stage. Although the instruction data is extracted at this moment, due to the existence of the circular instruction buffer, the target position used in this calculation is actually data prepared in advance by the system for the current cycle.
[0061] The system retrieves the current absolute target position of 5050U from the buffer and extracts the target position of 5000U recorded in the previous cycle. Subtracting the two yields a position increment of 50U in the user coordinate system for this synchronization cycle. Combining this with the electronic gear ratio of the current mechanical transmission configuration (set to be equivalent to 16 pulses per 1U), the system calculates a pure internal pulse position increment of 800 pulses.
[0062] To ensure the absolute closure of the instruction ledger, a position instruction accumulator is introduced to monitor the remaining capacity. Assume that at the end of the previous cycle, due to factors such as amplitude limiting, the system has 5 pulses of unexecuted capacity (including remainder and hysteresis error). The initial value of the accumulator is 5. The system adds the newly generated 800 pulses, precisely updating the total accumulator value to 805. The system accesses a dedicated remainder register, extracts the 3 pulses remaining from the end of the previous cycle as the initial remainder, and reads the historical error accumulation value of 2 pulses, temporarily storing it in the arithmetic unit.
[0063] 102. Add the position increment of the internal pulse unit to the initial remainder, and add the historical error accumulation value obtained from the historical tracking error accumulation to form the allocation base. Distribute the average allocation amount for each control cycle according to the synchronization cycle ratio and update the remainder. In each control cycle, perform beat-by-beat remainder compensation on the average allocation amount. At the same time, calculate the first-order prediction correction amount based on the difference between the actual output and the reference value of the previous control cycle and the average trend of the historical error accumulation value. Superimpose the compensated average allocation amount and the correction amount to obtain the final position increment command and update the historical error accumulation value.
[0064] Specifically, the position increment of the internal pulse unit is added to the initial remainder, and the historical error accumulation value formed by the accumulation of tracking errors in all control cycles within the previous synchronization cycle is added. The sum of these three is used as the allocation base. The allocation base is evenly divided according to the synchronization cycle ratio to obtain the average allocation amount for each control cycle. The remaining value after dividing the allocation base by the synchronization cycle ratio is updated as the new remainder. In each control cycle, the average allocation amount is compensated for by each pulse unit, i.e., based on the sign and direction of motion of the current remainder, at most one pulse unit is added or subtracted per cycle, and the remainder is deducted accordingly. The difference between the actual output position and the reference position in the previous control cycle is recorded. Combined with the average trend of the historical error accumulation value, a first-order prediction correction is calculated. The magnitude of this correction is limited to less than or equal to one pulse unit. The average allocation amount after pulse unit remainder compensation is added to the first-order prediction correction to obtain the final position increment command. The historical error accumulation value is updated using the new difference between the actual output and the reference value corresponding to this command. The updated historical error accumulation value is used for the calculation of the next synchronization cycle.
[0065] Furthermore, the historical error accumulation value is updated using a limited accumulation method: after each control cycle ends, the current tracking error value is added to the historical error accumulation value of the previous cycle. If the absolute value of the sum exceeds the preset upper limit, the historical error accumulation value is set to the sign value corresponding to the upper limit; otherwise, the sum is retained. The limited historical error accumulation value is used as the input for the allocation base calculation in the next synchronization cycle.
[0066] It should be noted that the newly generated 800 pulses, the initial remainder of 3 pulses, and the historical error accumulation value of 2 pulses are combined and added together to establish the total allocation base of 805 pulses for this synchronization cycle. The system divides this base by the synchronization cycle ratio of four to obtain the basic average allocation amount of 201 pulses for each control cycle. The remaining part that is not divisible causes the regular remainder to be updated to 1 pulse.
[0067] In the first control cycle within the current synchronization period, the system first extracts the basic allocation quantity 201pulse. Upon detecting a 1pulse with a positive conventional remainder, the system performs beat-by-beat remainder compensation, adding this pulse to the allocation quantity and deducting and clearing the conventional remainder to zero. Simultaneously, it is assumed that the first-order prediction correction calculated for this beat is zero. The system then adds all the components together to calculate the provisional final position increment command as 202pulse. It is important to note that this 202pulse is not directly sent to the lower layer but is instead fed into the subsequent amplitude limiting verification stage.
[0068] After completing the amplitude limiting and actual output, the system compares the difference between the reference command (202 pulses) and the actual output for this cycle. Assuming the actual output is limited to 200 pulses due to amplitude limiting, this results in a 2-pulse increase in tracking error. The system adds these 2 pulses to the previous historical error and updates it, continuously accumulating the error as long as it doesn't exceed the set upper limit threshold. In the subsequent three control cycles, since the normal remainder was cleared in the first frame, the base value of the provisional command will remain at 201 pulses and continue to participate in subsequent amplitude limiting and error correction cycles.
[0069] 103. Compare the equivalent speed of the final position increment command with the limit threshold corresponding to the maximum allowable speed of the motor. If it exceeds the limit, the limit is executed and the excess part is recycled into the remainder. At the same time, the output position increment is subtracted from the position command accumulator to monitor the command execution progress.
[0070] Specifically, the final position increment command is converted into an equivalent speed value and compared with a pre-calculated limiting threshold based on the motor's maximum speed and electronic gear ratio. If the equivalent speed value exceeds the limiting threshold, the final position increment command is reduced to the limiting threshold, and the excess pulses are recycled into the current remainder. The pulses recycled into the remainder are gradually released in subsequent beat-by-beat remainder compensation. If the equivalent speed value does not exceed the limiting threshold, the final position increment command remains unchanged. The final position increment command, whether limited or unlimited, is output as the actual output command to the servo control loop. At the same time, the value of the actual output command is subtracted from the position command accumulator. The updated position command accumulator value is used to monitor the remaining position commands that have not yet been executed and serves as the basis for determining whether to trigger abnormal handling when coordinating synchronization events with the control loop timing.
[0071] Furthermore, when the final position increment command is limited, the number of pulses exceeding the limit is recorded in a separate recovery counter. The value of this recovery counter is used preferentially in the subsequent step-by-step remainder compensation process. That is, one pulse is deducted from the recovery counter for compensation in each control cycle until the recovery counter is zero, and then the normal remainder is used for step-by-step compensation.
[0072] It should be noted that the system pre-calculates the safety boundary based on the physical limit speed of the servo motor and sets the amplitude limit threshold within a single control cycle (250μs) to a fixed 200 pulses.
[0073] In the first control cycle, the provisional final position increment sent in step 102 is 202 pulses. The system compares this and finds it exceeds the 200 pulses threshold, immediately triggering a limiting mechanism to forcibly reduce it to 200 pulses and execute it as a real command under the generator. The 2 pulses that were reduced are not lost but are safely stored in a separate recycling counter for later use. Simultaneously, the system accesses the position command accumulator (currently valued at 805), subtracts the actual output of 200 pulses, and the accumulator accurately drops to 605, accurately reflecting the remaining unexecuted total.
[0074] Entering the second control cycle, the base instruction generated in step 102 is 201 pulses. Before verification, the system first checks the recycling counter (currently containing 2 pulses). The system extracts 1 pulse from it and compensates it to the base instruction, making it 202 pulses. After comparing with the threshold, the limiting is triggered again, and the output is still clamped at 200 pulses. At this time, the ledger of the recycling counter changes: the original 2 pulses minus the extracted 1 pulse, plus the 2 pulses generated by this reduction, is updated to 3 pulses. The accumulator continues to subtract 200 pulses, decreasing to 405.
[0075] This mechanism repeats itself in subsequent cycles. As long as the instruction is still on the edge of overspeed, the system will, like a comb, smoothly push excess pulses to the recycling counter, ensuring that every issued instruction is absolutely safe. At the same time, the accumulator closely controls the macroscopic instruction progress to avoid instruction loss or the accumulator overdraft resulting in a negative value.
[0076] 104. Set up a ring-shaped command buffer between the Ethernet synchronization interrupt and the internal control loop, and adaptively switch the working mode according to the buffer filling depth. The working modes include start filling, normal buffering, extrapolation estimation and pass-through mode. In the extrapolation estimation mode, linear inference is performed using the previously recorded position increment to generate a reference position.
[0077] Specifically, a ring-shaped command buffer with a fixed depth of eight slots is set between the Ethernet synchronization interrupt side and the control ring calculation side. The buffer is equipped with independent write and read pointers. When each synchronization event is triggered, the latest received target position is stored in the slot pointed to by the write pointer and the write pointer is incremented. At the beginning of each control cycle, the target position is obtained through the read pointer. The difference between the write pointer and the read pointer is calculated in real time as the current fill depth. The working mode is adaptively switched based on the historical fill depth values of two consecutive control cycles: In the start-fill mode, the read pointer follows the write pointer, and the initial data is read sequentially for two consecutive cycles. After completion, it switches to the normal buffer mode. In the normal buffer mode, if the fill depth is greater than three slots for two consecutive cycles, it is determined to be too deep, and the read pointer jumps to the write pointer. For the first two slots, the read pointer is incremented by one slot normally if the fill depth is two or three slots. If the fill depth is one slot, the read pointer is entered into extrapolation estimation mode. In extrapolation estimation mode, the read pointer is not advanced. Instead, the position increment recorded when the normal target position was read from the buffer is added to the current target position to generate a speculative target position. This speculative target position replaces the target position that should have been read from the buffer. At the same time, the fill depth is continuously monitored. When the fill depth recovers to two or more slots, the read pointer is automatically switched back to normal buffering mode and advanced. If the fill depth drops to zero, the read pointer is entered into pass-through mode and the latest written target position is used directly without going through the buffer. The speculative target position is used as the source of the current target position when calculating the position increment.
[0078] Furthermore, the previous position increment used in the extrapolation estimation mode is calculated from the difference between the currently read target position and the previous normally read target position each time the target position is successfully read from the buffer in normal buffer mode. This difference is stored separately as an increment variable. When the extrapolation estimation mode is activated, this increment variable is added to the latest normally read target position to generate the predicted target position. This predicted target position replaces the target position that the buffer should currently read and is used as the input when calculating the position increment.
[0079] It should be noted that the driver internally constructs a ring-shaped buffer structure with a total capacity of eight data slots. Under optimal network communication conditions, new data is written to the Ethernet every 1000μs, and the system maintains a state where the write pointer leads the read pointer by two slots (i.e., the fill depth is two), which is in normal buffering mode. During the last read, the system records that the target position changed from 5000UU to 5050UU, and properly stores this 50UU difference as an incremental variable for future use.
[0080] When the external industrial network experiences a sudden congestion, new Ethernet packets fail to reach the driver as scheduled. As the underlying read operation continues, the write pointer stalls while the read pointer approaches, causing the fill depth to rapidly drop to a slot. The system immediately detects the risk of a data interruption and seamlessly switches to extrapolation estimation mode. At this point, the read pointer pauses its advance, and the system retrieves the previously stored 50UU increment, adds it to the current 5050UU, derives a virtual target position of 5100UU, and sends it to the downstream interpolation calculation, ensuring continuous and uninterrupted motor operation.
[0081] Once the congestion was cleared, the backlogged network packets arrived in rapid succession, causing the write pointer to jump quickly and the fill depth to surge to four slots. Due to continuous detection of excessive buffer depth, the system automatically executed a latency compression command, forcibly jumping the read pointer to two slots after the write pointer. This discarded some outdated historical backlog data, quickly pulled the fill depth back to the standard state, and restored the system to normal buffer mode, ensuring real-time tracking of position control.
[0082] 105. The timing of the synchronization event and the control loop is coordinated by decrementing the counter. The counter loads the synchronization cycle ratio during the synchronization event and decrements in each control cycle. When the counter returns to zero, a new interpolation calculation is triggered. The results of the previous allocation are directly reused in the intermediate cycles.
[0083] Specifically, an integer counter is set up, and its value is reset to the synchronization cycle ratio when each synchronization event arrives. At the beginning of each control cycle, the counter is checked: if the counter value is greater than one, the counter is decremented by one, and the allocation result generated in the previous synchronization cycle is directly reused without triggering a new interpolation calculation; if the counter value is equal to one, the decrement operation is performed to make the counter zero, and a new interpolation calculation is triggered. This new interpolation calculation uses the target position provided by the circular instruction buffer and the aforementioned process to regenerate the final position increment instruction. After the counter is zeroed, it remains zero until the next synchronization event arrives, waiting for the next load. The counter value is read in each control cycle to determine whether to perform a new interpolation calculation in the current cycle. This judgment result serves as the basis for control loop timing coordination.
[0084] It should be noted that a dedicated state machine decrement counter is configured to precisely align the asynchronously arriving Ethernet communication data with the fixed-frequency underlying control loop within the driver. In this embodiment, the synchronization period is 1000μs, the control loop period is 250μs, and the ratio is four.
[0085] Due to the pre-read mechanism of the circular buffer, new interpolation calculations must be triggered before the data in the current cycle is exhausted. Table 1 below details the absolutely self-consistent process of the control loop timing and counter operation within a single network synchronization cycle:
[0086] Table 1
[0087]
[0088] At time node 0μs, a new network packet arrives along with a synchronization event, writing data into the buffer and fully loading the counter to four. The control loop then starts, detects that the counter is four (greater than one), decrements it to three, and directly extracts the previously calculated pulse data for transmission. This multiplexing action is completely replicated at 250μs and 500μs, with the counter smoothly decreasing to two and one respectively.
[0089] When the time reaches 750μs, which is the last micro-control loop of this communication cycle, the control loop detects that the counter's current value is only one. After the system completes the routine decrement to bring it completely to zero, in addition to outputting the final instruction for this cycle, it immediately determines that the pre-calculated trigger condition has been met. The arithmetic unit immediately intervenes, reads the new target position belonging to the next 1000μs cycle from the buffer, re-runs the massive process of generating the base and allocating, and temporarily stores the calculated result in memory. At this point, when the timing returns to the next 0μs, the system has readily available data that can be directly reused, achieving a perfect closed loop at the timing level.
[0090] 106. When the servo drive's operating mode is switched to homing mode, the limiting threshold and the frame-by-frame remainder compensation mechanism continue to be effective. The position increment during the homing process is constrained by the limiting threshold, and the position increment during the homing process is output as the homing position command. After the homing is completed, all interpolation state variables, including the position command accumulator, remainder, and historical error accumulation value, are cleared to generate a clean initial state for subsequent cycle synchronization position mode restart.
[0091] Furthermore, in zero-return mode, the circular instruction buffer is switched to pass-through mode, in which the read pointer always points to the latest written target position, and adaptive switching and extrapolation estimation based on fill depth are no longer performed; after zero-return is completed, the circular instruction buffer is restored to normal buffer mode.
[0092] It should be noted that in order to locate the physical origin of the mechanical equipment, the actuator switches from the normal position mode to the homing mode. Locating the origin must be an extremely slow and highly safe process. Therefore, the system not only disables the complex pre-read mechanism of the circular buffer (locking it into the most direct pass-through mode), but also imposes an independent and extremely stringent safety threshold for the homing phase, setting it to a maximum of 15 pulses per control cycle (far lower than the normal 200 pulse limit).
[0093] The built-in zero-return generator takes over and generates low-speed position increments at a specified speed, while the underlying limiting and compensation defenses continue to operate during this period. Table 2 below shows the processing status for three consecutive control cycles during the zero-return phase:
[0094] Table 2
[0095]
[0096] In cycle 1, the 12 pulses generated at an extremely low speed safely pass the verification and are output directly. In cycle 2, a sudden change in speed planner due to mechanical friction may cause a tiny jump to 18 pulses, immediately hitting the hard red line of 15 pulses. The system forces the output at the maximum allowed safe speed of 15 pulses and stores the overflowing 3 pulses in the recycling ledger. In cycle 3, the original increment falls back to 10 pulses, and the system uses a compensation mechanism to smoothly release the temporarily stored pulses to 11 pulses, ensuring that the speed never exceeds the limit throughout the return to zero.
[0097] Once the driver successfully captures the edge signal from the origin sensor, the motor smoothly stops, marking the end of the homing process. At this point, the system executes a thorough cleanup procedure: forcibly erasing all backlogged position command accumulators, all remainder registers, and residual historical error accumulation values to zero. Subsequently, the buffer's pass-through lock is released, restoring its adaptive adjustment capability. This series of actions completely resets the interpolation core, clearing away all historical data interference for the potentially upcoming periodic synchronous position mode.
[0098] The present invention also provides a periodic synchronization position multi-level interpolation and instruction buffering device for a servo driver. The periodic synchronization position multi-level interpolation and instruction buffering device for a servo driver includes a memory and a processor. The memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the processor performs the steps of the periodic synchronization position multi-level interpolation and instruction buffering method for a servo driver in the above embodiments.
[0099] The present invention also provides a computer-readable storage medium, which can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium, wherein the computer-readable storage medium stores instructions that, when the instructions are executed on a computer, cause the computer to perform the steps of the periodic synchronization position multi-level interpolation and instruction buffering method of the servo driver.
[0100] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0101] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0102] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for multi-level interpolation and command buffer synchronization control of an EtherCAT servo driver, characterized in that, include: The cycle ratio is determined based on the ratio of the communication synchronization cycle to the control cycle of the control loop. The current target position is received, and the first position increment is generated based on the difference between the current target position and the target position recorded in the previous cycle. The remainder left over from the previous cycle is obtained as the initial remainder. An allocation base is formed based on the first position increment, the initial remainder, and the historical error accumulation value formed by the accumulation of tracking errors in each cycle. The allocation base is allocated according to the cycle ratio to obtain the average allocation amount for each control cycle, and the remainder is updated. In each control cycle, the average allocation amount is compensated for the remainder and the error prediction is corrected to obtain the final position command, and the historical error accumulation value is updated. The equivalent speed corresponding to the final position command is compared with the limiting threshold. If the equivalent speed exceeds the limiting threshold, the limiting process is performed, and the value exceeding the limiting threshold is returned to the remainder. An instruction buffer is set between the communication synchronization interruption side and the control ring. The filling status of the instruction buffer is obtained in real time, and the working mode is adaptively switched according to the filling status to provide the target position required at present. The working mode includes an extrapolation estimation mode that uses historical position increments to infer the target position required at present. The timing of the synchronization event and the control loop is coordinated by a counter. The counter loads the cycle ratio when the synchronization event arrives and is updated in each control cycle. When the counter meets the preset trigger condition, a new interpolation calculation is triggered; otherwise, the previous allocation result is reused.
2. The EtherCAT servo driver multi-level interpolation and command buffer synchronization control method according to claim 1, characterized in that, include: The position increment in the user coordinate system is obtained by subtracting the current target position from the target position recorded in the previous cycle. The position increment in the user coordinate system is converted using the electronic gear ratio to obtain the first position increment in the internal pulse unit; The first position increment is accumulated into the position instruction accumulator, which is used to store the remaining amount of instructions that have not yet been executed.
3. The multi-level interpolation and command buffer synchronization control method for EtherCAT servo drivers according to claim 1, characterized in that, include: The first position increment, the initial remainder, and the historical error accumulation value are added together, and the sum of the three is used as the allocation base. The step of allocating the allocation base according to the cycle ratio to obtain the average allocation amount for each control cycle, and updating the remainder, includes: The average allocation amount is obtained by uniformly dividing the allocation base according to the cycle ratio, and the remaining value after dividing the allocation base by the cycle ratio is used as the new remainder. The step of performing remainder compensation and error prediction correction on the average allocation to obtain the final position command includes: Based on the sign and direction of the current remainder, perform beat-by-beat remainder compensation on the average allocation amount and deduct the remainder accordingly; Based on the difference between the actual output position and the reference position in the previous control cycle, and combined with the average trend of the historical error accumulation value, the first-order prediction correction is calculated. The average allocation amount after the step-by-step remainder compensation is added to the first-order prediction correction amount to obtain the final position command.
4. The multi-level interpolation and command buffer synchronization control method for EtherCAT servo drivers according to claim 1, characterized in that, The updated historical error accumulation value is achieved using a limited accumulation method: After each control cycle ends, the current tracking error value is obtained and added to the historical error accumulation value of the previous cycle; If the absolute value of the sum exceeds the preset upper limit, the historical error accumulation value is updated to the value corresponding to the preset upper limit; otherwise, the sum is retained as the updated historical error accumulation value.
5. The EtherCAT servo driver multi-level interpolation and command buffer synchronization control method according to claim 2, characterized in that, include: If the equivalent speed exceeds the limiting threshold calculated in advance based on the maximum speed of the motor, the final position command is reduced to the limiting threshold, and the value of the portion exceeding the limiting threshold is recorded in a separate recovery counter. The value in the recycling counter is used first to compensate for the average allocation in subsequent control cycles until the recycling counter returns to zero, at which point the remainder is used for compensation. The final position command, whether or not it has undergone amplitude limiting, is output as the actual output command to the control loop, while the value of the actual output command is subtracted from the position command accumulator.
6. The multi-level interpolation and command buffer synchronization control method for EtherCAT servo drivers according to claim 1, characterized in that, The instruction buffer is a circular instruction buffer equipped with a write pointer and a read pointer; the filling state is the filling depth corresponding to the difference between the write pointer and the read pointer; The adaptive switching of the working mode based on the filling status to provide the currently required target position includes: If the filling depth meets the first preset condition, the system enters the start filling mode. In the start filling mode, the read pointer follows the write pointer to read the initial data. If the filling depth meets the second preset condition, then enter the normal buffer mode. In the normal buffer mode, the step size of the read pointer is dynamically adjusted according to the specific value of the filling depth. If the filling depth meets the third preset condition, then enter the extrapolation estimation mode; If the fill depth drops to zero, then a pass-through mode is entered, in which the latest written target position is directly used as the currently required target position provided to the backend.
7. The EtherCAT servo driver multi-level interpolation and command buffer synchronization control method according to claim 6, characterized in that, In the extrapolation estimation mode, the advance of the read pointer is paused; The step of using historical location increments to infer the current target location includes: Obtain the historical position increment recorded when the last successful read was made in the normal buffer mode, and add the historical position increment to the latest read target position to generate the inferred target position; The inferred target position replaces the target position that should have been read from the instruction buffer, and is used as the current target position when generating the first position increment; Simultaneously, the fill depth is continuously monitored. When the fill depth recovers to meet the second preset condition, the system switches back to the normal buffer mode and resumes advancing the read pointer.
8. The multi-level interpolation and command buffer synchronization control method for EtherCAT servo drivers according to claim 1, characterized in that, The counter is a decrementing counter; The method of coordinating the timing of synchronization events with the control loop through a counter includes: When each of the aforementioned synchronization events arrives, the value of the decrementing counter is reset to the period ratio; At the beginning of each control cycle, check the decrement counter: if the value of the decrement counter is greater than one, decrement the decrement counter by one, and directly reuse the previous allocation result without triggering the new interpolation calculation; If the value of the decrement counter is equal to one, then a decrement operation is performed to return the decrement counter to zero, and the zeroed state is used as a condition to trigger a new interpolation calculation to generate a new final position instruction.
9. The multi-level interpolation and command buffer synchronization control method for EtherCAT servo drivers according to claim 6, characterized in that, Also includes: When the servo driver switches to zero-return mode, the limiting threshold and the compensation mechanism for the remainder remain in effect, and the instruction buffer is forcibly switched to the pass-through mode. After the zero-return mode is completed, the state variables of the remainder and the historical error accumulation value are cleared, and the instruction buffer is restored to the normal buffer mode.