Synchronization optimization method for ethercat master and slave stations

By recording and calculating the data frame time of EtherCAT master and slave stations, and using exponential moving average and double exponential smoothing algorithms to compensate for clock drift, the problem of large clock drift in the EtherCAT system is solved, and higher-precision synchronization optimization is achieved.

WO2025222623A1PCT designated stage Publication Date: 2025-10-30CHINA JILIANG UNIV
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/103186
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-04-26
Filing Date
2024-07-02
Publication Date
2025-10-30

AI Technical Summary

Technical Problem

In existing EtherCAT clock synchronization methods, the clock drift is relatively large, and the master station cannot quickly and effectively compensate for the clock drift of each slave station, resulting in a large synchronization error.

Method used

By recording the data frame times of the master station and the reference slave station, the transmission delay and clock offset are calculated. The clock drift is compensated using exponential moving average and double exponential smoothing algorithms. The compensated clock drift is then subtracted from the clock offset to complete the synchronization optimization.

Benefits of technology

This reduces the clock drift of each slave station, enabling the master station to compensate for clock drift more quickly and improving the synchronization accuracy of the EtherCAT system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024103186_30102025_PF_FP_ABST
    Figure CN2024103186_30102025_PF_FP_ABST
Patent Text Reader

Abstract

The present invention relates to the field of industrial automation. Provided is a synchronization optimization method for EtherCAT master and slave stations. The method comprises: recording the time at which a master station sends a data frame and the time at which the master station receives the data frame, and recording the time at which a reference slave station receives the data frame; calculating a transmission delay between the master station and the reference slave station; using exponential moving average to acquire a compensated transmission delay between the master station and the reference slave station; calculating the time for a data frame to return to a parent port of each non-reference slave station after leaving the parent port of the non-reference slave station; calculating the transmission delay, clock offset and clock drift of each non-reference slave station; using a double exponential smoothing algorithm to compensate for the clock drift, and subtracting the compensated clock drift from the clock offset to obtain a new clock offset; and writing the new clock offset into the slave station for compensation, so as to complete synchronization optimization. Thus, the clock drift of each slave station is reduced, and a master station can more rapidly compensate for the clock drift of each slave station.
Need to check novelty before this filing date? Find Prior Art

Description

A Synchronization Optimization Method for EtherCAT Master-Slave Stations Technical Field

[0001] This invention relates to the field of industrial automation, and more specifically to a synchronization optimization method for EtherCAT master-slave stations. Background Technology

[0002] EtherCAT (Ethernet for Control Automation Technology) is a high-performance real-time Ethernet communication protocol for real-time control and automation. It aims to provide low latency, high precision, and high reliability communication to meet the stringent real-time performance requirements of industrial automation. Due to its unique "distributed clock synchronization" technology, it enables the entire master-slave system to achieve nanosecond-level synchronization accuracy. In multi-axis control systems for robots, the ability to synchronize the control of each motor has a significant impact on control accuracy. EtherCAT uses a clock synchronization mechanism called DC (Distributed Clocks), which allows for highly synchronized clocks among the slave devices on the EtherCAT network. Clock synchronization is fundamental to ensuring coordinated operation between the controller and each actuator, as well as among the actuators themselves. The core idea of ​​DC is to achieve high-precision synchronization of the entire system by synchronizing the local clocks of the slave devices within the EtherCAT communication cycle. During system operation, due to factors such as the reference clock and the clock sources used by other slave clocks, their timing cycles may drift, leading to clock asynchrony and slave clock drift, known as clock drift. Traditional methods calculate the clock drift of non-reference slave stations and then only consider the sign of the drift, adjusting the clock speed based on the positive or negative value of the drift. In this clock drift compensation method, the compensation process only considers the direction of compensation, not the magnitude, which may reduce the effectiveness of drift compensation. Even if the master station periodically sends clock drift compensation data frames to each slave station, a considerable synchronization error can still be observed.

[0003] In summary, existing clock drift compensation techniques suffer from the problem that the clock drift of each slave station is relatively large, and the master station cannot quickly compensate for the clock drift of each slave station.

[0004] Summary of the Invention

[0005] To address the shortcomings of the existing technology, this invention provides a synchronization optimization method for EtherCAT master-slave stations, which reduces the clock drift of each slave station and enables the master station to compensate for the clock drift of each slave station more quickly.

[0006] This invention provides a synchronization optimization method for EtherCAT master-slave stations, comprising:

[0007] Record the time when the master station sends and receives the data frame, and record the time when the reference slave station receives the data frame. Calculate the transmission delay between the master station and the reference slave station, and use an exponential moving average to obtain the compensated transmission delay between the master station and the reference slave station.

[0008] Calculate the time it takes for a data frame to return to the parent port of a non-reference slave after leaving the parent port of the slave. Calculate the transmission delay, clock offset, and clock drift of the non-reference slave.

[0009] A dual exponential smoothing algorithm is used to compensate for the clock drift. The compensated clock drift is then subtracted from the clock offset to obtain a new clock offset. This new clock offset is written to the slave station for compensation, thus completing the synchronization optimization.

[0010] Furthermore, before recording the time when the master station sends and receives the data frame, the process includes: the master station sending the data frame, recording the number of slave stations, the port on which each slave station first receives the data frame, and the active port of the slave station; and determining the parent and parent port of the slave station based on the number of connected slave stations and the port transmission order.

[0011] Furthermore, the compensated transmission delay between the master station and the reference slave station is obtained, including: using an exponential moving average to obtain the compensated transmission delay between the master station and the reference slave station.

[0012] Furthermore, before calculating the transmission delay of the non-reference slave station, the following steps are taken: if the number of slave stations connected to the non-reference slave station i is greater than 1, then the transmission time of the subsequent slave stations of that slave station is calculated.

[0013] Furthermore, before calculating the clock offset of the non-reference slave, the calculation also includes: calculating the clock offset of the reference slave clock.

[0014] Furthermore, a dual exponential smoothing algorithm is employed to compensate for the clock drift, including:

[0015] Initialization level: L1 = Δt1, trend T1 = Δt2 - Δt1, where Δt1 is the clock drift amount calculated for the first time and Δt2 is the clock drift amount calculated for the second time;

[0016] Level Update: L k =α·Δt k +(1-α)·(L k-1 +T k-1 )

[0017] Trend Update: T k =β·(L k -L k-1 )+(1-β)·Tk-1

[0018] Compensated clock drift: ΔCt i,k =L k +T k

[0019] Where L k It is the kth level; T k It is the trend at the k-th time; ΔCt i,k It is the clock drift amount after the k-th compensation from slave station i; α and β are attenuation factors.

[0020] Further, calculating the transmission delay between the master station and the reference slave station includes:

[0021] Let the transmission delay between the master station and the reference slave station be td. m ;

[0022] In the formula, t m,0 The time when the master station sends a data frame, t m,1 The time when the master station receives the returned data frame, t r,0 t is the time when the data frame arrives at reference slave port 0. r,1 This is the time when the data frame arrives at reference slave port 1.

[0023] Furthermore, an exponential moving average is used to obtain the compensated transmission delay between the master station and the reference slave station, including:

[0024] Let TD m,k It is the transmission delay between the master station and the reference slave station after the kth compensation;

[0025] TD m,k =α·td m,k +(1-α)TD m,k-1 In the formula, α is a smoothing factor, whose value ranges between (0,1), and td m,k This refers to the uncompensated transmission delay between the master station and the reference slave station, TD. m,k-1 It is the transmission delay obtained from the previous compensation.

[0026] Furthermore, the time it takes for a data frame to return to the parent port of a non-reference slave station after leaving its parent port includes:

[0027] Let R i,parent The time it takes for a data frame to return to the parent port of non-reference slave i after leaving its parent;

[0028] R i,parent =t i,parent -pt i,parent In the formula, ti,parent pt represents the time when the parent port of non-reference slave i receives a data frame. i,parent For t i,parent The time when the previous active port received a data frame.

[0029] Furthermore, the transmission delay of the non-reference slave station is calculated, including:

[0030] Let the transmission delay of non-reference slave station i be TD. i ;

[0031] TD parent The transmission delay of the parent slave of non-reference slave i; D i,follow For the transmission time of subsequent slaves after non-reference slave i;

[0032] D i,follow =pt i,first -t i,first ;t i,first pt is the time when the first port of non-reference slave i receives data to receive a data frame. i,first For t i,first The time when the previous active port received a data frame.

[0033] Compared with the prior art, the beneficial effects of this invention are as follows:

[0034] This invention provides a synchronization optimization method for EtherCAT master-slave stations. It records the time the master station sends and receives data frames, and the time the reference slave station receives data frames. The transmission delay between the master and reference slave stations is calculated, and an exponential moving average is used to obtain the compensated transmission delay. The time it takes for a data frame to return from the parent port of a non-reference slave station to its parent port is calculated. The transmission delay, clock offset, and clock drift of the non-reference slave station are calculated. A double exponential smoothing algorithm is used to compensate for the clock drift. The compensated clock drift is subtracted from the original clock offset to obtain a new clock offset. This new clock offset is written to the slave station for compensation, completing the synchronization optimization. This reduces the clock drift of each slave station and enables the master station to compensate for the clock drift of each slave station more quickly. Attached Figure Description

[0035] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. Some specific embodiments of the invention will be described in detail below with reference to the accompanying drawings in an exemplary and non-limiting manner. The same reference numerals in the drawings designate the same or similar parts or components. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the drawings:

[0036] Figure 1 is a flowchart illustrating a synchronization optimization method for EtherCAT master-slave stations according to an embodiment of the present invention.

[0037] Figure 2 is a schematic diagram of the transmission sequence of the EtherCAT slave chip port in an embodiment of the present invention;

[0038] Figure 3 is an example diagram of calculating transmission delay between the master station and the reference slave station in an embodiment of the present invention. Detailed Implementation

[0039] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0040] Referring to Figures 1-3, this embodiment of the invention provides a synchronization optimization method for EtherCAT master-slave stations, comprising the following steps:

[0041] Record the time when the master station sends and receives the data frame, and record the time when the reference slave station receives the data frame. Calculate the transmission delay between the master station and the reference slave station, and use an exponential moving average to obtain the compensated transmission delay between the master station and the reference slave station.

[0042] Calculate the time it takes for a data frame to return to the parent port of a non-reference slave after leaving the parent port of the slave. Calculate the transmission delay, clock offset, and clock drift of the non-reference slave.

[0043] A dual exponential smoothing algorithm is used to compensate for the clock drift. The compensated clock drift is then subtracted from the clock offset to obtain a new clock offset. This new clock offset is written to the slave station for compensation, thus completing the synchronization optimization.

[0044] It should be noted that in this embodiment, by recording the time the master station sends and receives data frames, and recording the time the reference slave station receives data frames, the transmission delay between the master station and the reference slave station is calculated. An exponential moving average is used to obtain the compensated transmission delay between the master station and the reference slave station. The time it takes for a data frame to return from the parent port of a non-reference slave station to the parent port of that slave station is calculated. The transmission delay, clock offset, and clock drift of the non-reference slave station are calculated. A double exponential smoothing algorithm is used to compensate for the clock drift. The compensated clock drift is then subtracted from the clock offset to obtain a new clock offset. This new clock offset is written to the slave station for compensation, completing synchronization optimization and reducing the clock drift of each slave station. This allows the master station to compensate for the clock drift of each slave station more quickly. It can be understood that in this embodiment, a double exponential smoothing algorithm is used to predict and compensate for clock drift. By considering the magnitude and sign of the drift, the effect of drift compensation is maximized, thereby reducing the clock drift of each slave station. Furthermore, due to jitter in the master station clock, the transmission delay is uncertain, and the transmission delay itself also varies. In this embodiment, an exponential moving average (EMA) filtering method is used to obtain the transmission delay, thereby determining the transmission delay.

[0045] It should also be noted that the synchronization optimization method for EtherCAT master-slave stations provided in this embodiment may include the following steps in its specific implementation:

[0046] First, the master station sends data frames, records the number of slave stations, the port on which each slave station first receives a data frame, and the active port of the slave station. Based on the number of connected slave stations and the slave station chip port transmission order "0-3-1-2" as shown in Figure 2, the parent of each slave station and its parent port are determined.

[0047] Second, record the time when the master station sends and receives data frames, as well as the time when the reference slave station receives data frames on ports 0 and 1, and calculate the transmission delay td between the master station and the reference slave station. m The calculation formula (1) is expressed as follows:

[0048] In the formula, t m,0 The time when the master station sends a data frame, t m,1 The time when the master station receives the returned data frame, t r,0 t is the time when the data frame arrives at reference slave port 0. r,1 This is the time when the data frame arrives at reference slave port 1.

[0049] Thirdly, due to clock jitter in the master station, the transmission delay is uncertain, and the transmission delay itself also varies. To solve this problem, this embodiment uses the exponential moving average (EMA) to obtain the compensated transmission delay between the master station and the reference slave station, as shown in Figure 3, and writes it into register 0x928:0x92B. The calculation formula (2) is expressed as follows: TD m,k =α·td m,k +(1-α)TD m,k-1 (2)

[0050] TD m,k td is the transmission delay between the master station and the reference slave station after the k-th compensation, α is the smoothing factor, and its value ranges between (0,1). m,k This refers to the uncompensated transmission delay between the master station and the reference slave station, TD. m,k-1 It is the transmission delay obtained from the previous compensation.

[0051] 4. Calculate the time it takes for a data frame to return to the parent port of slave i after leaving the parent of slave i (non-reference slave). The calculation formula is shown in formula (3): R i,parent =t i,parent -pt i,parent (3)

[0052] In the formula, R i,parent t is the time it takes for a data frame to return to the parent port of slave i after leaving its parent. i,parent pt is the time when a data frame is received from the parent port of station i. i,parent For t i,parent The time when the previous active port received a data frame.

[0053] Furthermore, in one embodiment, step 5 is also included: if the number of slave stations connected to the slave station is greater than 1, then the transmission time of subsequent slave stations needs to be calculated. The formula (4) for calculating the transmission time of subsequent slave stations is as follows: D i,follow =pt i,first -t i,first (4)

[0054] Where D i,follow t represents the transmission time of subsequent slave stations after slave station i. i,first The time when the first port to receive data from station i receives a data frame, pt i,first For t i,first The time when the previous active port received a data frame.

[0055] 6. Calculate the transmission delay TD of non-reference slave i. iThe calculated transmission delay is written into register 0x928:0x92B, and formula (5) is expressed as follows:

[0056] TD i For the transmission delay of slave station i, TD parent The transmission delay of the parent slave station of slave station i.

[0057] Furthermore, in one embodiment, step 7 is included: calculating the clock offset of the reference slave clock. When the master station sends a data frame, the slave station latches the time in a register when the data frame arrives at the data processing unit of each slave station. Let the reference clock time (reference_time) when the data frame arrives at the reference slave station's data processing unit be T. r,recv The time is determined by reading the slave register 0x918:0x91F to obtain the reception time T of the data frame arriving at the data processing unit. r,recv .

[0058] During master-slave synchronization, the master station and the reference clock need to be synchronized. This is because the system time of the master station sending data frames is... m As it is a global time, there is a clock offset between the master clock and the reference clock. r and transmission delay TD m,k (The master station clock has jitter, so the compensated transmission delay TD is used) m,k Then there are clock offsets for the master station and the reference clock. r And write it to the slave register 0x920:0x927. Calculation formula (6): offset r =system m -T r,recv -TD m,k (6)

[0059] 8. Calculate the clock offset of the non-reference slave station. When a data frame arrives at the data processing unit of slave station i, the local clock time of that slave station, local_time, is T. i,recv The transmission delay from the reference clock slave to slave i is TD. i .

[0060] Specifically, the slave register 0x918:0x91F is read to obtain the reception time T of the data frame arriving at the data processing unit. i,recv Calculate the clock offset between the slave station and the reference clock. r And write it to the slave register 0x920:0x927. The calculation formula (7) is expressed as follows: offset i =system m -TDm,k -T i,recv -TD i (7)

[0061] 9. Calculate the clock drift of the non-reference slave station. The formula (8) for calculating the clock drift Δt of slave station i is: Δt = system_time i -(reference_time i +TD i (8)

[0062] In the formula, system_time i The system time and reference_time of the slave station i clock. i Reference time for the slave station clock.

[0063] 10. After calculating the clock drift of the non-reference slave, the compensated clock drift amount ΔCt is obtained using a double exponential smoothing algorithm. i,k .

[0064] In a preferred example, the calculation steps are as follows:

[0065] Initialization, level: L1 = Δt1, trend: T1 = Δt2 - Δt1, where Δt1 is the clock drift amount calculated for the first time using formula (8), and Δt2 is the clock drift amount calculated for the second time.

[0066] Prediction, Level Update: L k =α·Δt k +(1-α)·(L k-1 +T k-1 (9)

[0067] Trend Update: T k =β·(L k -L k-1 )+(1-β)·T k-1 (10)

[0068] Compensated clock drift: ΔCt i,k =L k +T k (11)

[0069] Where L k It is the kth level; T k It is the trend at the k-th time; ΔCt i,kIt is the clock drift amount after the k-th compensation of slave station i; α and β are attenuation factors, with values ​​ranging from 0 to 1.

[0070] Step 11: After obtaining the compensated clock drift, subtract the clock offset from the offset to obtain the new clock offset new_offset. The calculation formula is shown in formula (11). Finally, write new_offset into the slave register 0x920:0x927 for compensation. i =offset i -ΔCt i,k (12)

[0071] It should be noted that the above embodiments are merely preferred embodiments of the present invention, and the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention, and the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A synchronization optimization method for EtherCAT master-slave stations, characterized in that, include: Record the time when the master station sends and receives the data frame, and record the time when the reference slave station receives the data frame. Calculate the transmission delay between the master station and the reference slave station, and use an exponential moving average to obtain the compensated transmission delay between the master station and the reference slave station. Calculate the time it takes for a data frame to return to the parent port of a non-reference slave after leaving the parent port of the slave. Calculate the transmission delay, clock offset, and clock drift of the non-reference slave. A dual exponential smoothing algorithm is used to compensate for the clock drift. The compensated clock drift is then subtracted from the clock offset to obtain a new clock offset. This new clock offset is written to the slave station for compensation, thus completing the synchronization optimization.

2. The synchronization optimization method for EtherCAT master-slave stations as described in claim 1, characterized in that, Before recording the time when the master station sends and receives a data frame, the process includes: the master station sending the data frame, recording the number of slave stations, the port on which each slave station first receives the data frame, and the active port of the slave station; and determining the parent and parent port of the slave station based on the number of connected slave stations and the port transmission order.

3. The synchronization optimization method for EtherCAT master-slave stations as described in claim 1, characterized in that, Obtain the compensated transmission delay between the master station and the reference slave station, including: using an exponential moving average to obtain the compensated transmission delay between the master station and the reference slave station.

4. The synchronization optimization method for EtherCAT master-slave stations as described in claim 1, characterized in that, Before calculating the transmission delay of a non-reference slave station, the following steps are taken: if the number of slave stations connected to non-reference slave station i is greater than 1, then the transmission time of subsequent slave stations of that slave station is calculated.

5. The synchronization optimization method for EtherCAT master-slave stations as described in claim 1, characterized in that, Before calculating the clock offset of the non-reference slave, the calculation of the clock offset of the reference slave clock is also included.

6. The synchronization optimization method for EtherCAT master-slave stations as described in claim 1, characterized in that, A dual exponential smoothing algorithm is used to compensate for the clock drift, including: Initialization level: L1 = Δt1, trend T1 = Δt2 - Δt1, where Δt1 is the clock drift amount calculated for the first time and Δt2 is the clock drift amount calculated for the second time; Level Update: L k =α·Δt k +(1-α)·(L k-1 +T k-1 ) Trend Update: T k =β·(L k -L k-1 )+(1-β)·T k-1 Compensated clock drift: ΔCt i,k =L k +T k Where L k It is the kth level; T k It is the trend at the k-th time; ΔCt i,k It is the clock drift amount after the k-th compensation from slave station i; α and β are attenuation factors.

7. The synchronization optimization method for EtherCAT master-slave stations as described in any one of claims 1-6, characterized in that, Calculating the transmission delay between the master station and the reference slave station includes: Let the transmission delay between the master station and the reference slave station be td. m ; In the formula, t m,0 The time when the master station sends a data frame, t m,1 The time when the master station receives the returned data frame, t r,0 The time when the data frame arrives at reference slave port 0. t r,1 This is the time when the data frame arrives at reference slave port 1.

8. The synchronization optimization method for EtherCAT master-slave stations as described in any one of claims 1-6, characterized in that, An exponential moving average is used to obtain the compensated transmission delay between the master station and the reference slave station, including: Let TD m,k It is the transmission delay between the master station and the reference slave station after the kth compensation; TD m,k =α·td m,k +(1-α)TD m,k-1 In the formula, α is a smoothing factor, whose value ranges between (0,1), and td m,k This refers to the uncompensated transmission delay between the master station and the reference slave station, TD. m,k-1 It is the transmission delay obtained from the previous compensation.

9. The synchronization optimization method for EtherCAT master-slave stations as described in any one of claims 1-6, characterized in that, The calculation of the time it takes for a data frame to return to the parent port of a non-reference slave after leaving its parent port includes: Let R i,parent The time it takes for a data frame to return to the parent port of non-reference slave i after leaving its parent; R i,parent =t i,parent -pt i,parent In the formula, t i,parent pt represents the time when the parent port of non-reference slave i receives a data frame. i,parent For t i,parent The time when the previous active port received a data frame.

10. The synchronization optimization method for EtherCAT master-slave stations as described in claim 9, characterized in that, Calculate the transmission delay of the non-reference slave station, including: Let the transmission delay of non-reference slave station i be TD. i ; TD parent Parent slave of non-reference slave i Transmission delay; D i,follow For the transmission time of subsequent slaves after non-reference slave i; D i,follow =pt i,first -t i,first ;t i,first pt is the time when the first port of non-reference slave i receives data to receive a data frame. i,first For t i,first The time when the previous active port received a data frame.

Citation Information

Patent Citations

  • Mean filtering method for adjusting EtherCAT synchronous clock

    CN109412733A

  • Master-slave station clock synchronization method based on EtherCAT real-time Ethernet

    CN111181681A

  • Implementation method for clock synchronization of master and slave systems based on EtherCAT

    CN117411579A

  • Synchronous optimization method for EtherCAT master and slave stations

    CN118174816A

  • Synchronization error compensating system and method for EtherCAT

    KR101771612B1