EtherCAT master station clock synchronization method and system

By dynamically adjusting the EtherCAT master clock and predicting periodic data frame drift values, the problem of master and slave clock drift is solved, and the clock synchronization accuracy and dynamic adaptability are improved.

CN119892280AActive Publication Date: 2025-04-25SOUTH CHINA UNIV OF TECH
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411868073.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-25
Estimated Expiration
2044-12-18

AI Technical Summary

Technical Problem

In the prior art, the clock drift between the EtherCAT master and slave station is difficult to effectively solve, resulting in limited clock synchronization performance.

Method used

By determining whether the main station clock drift value is less than the threshold, dynamically adjust the main station clock, and by sending multiple periodic data frames, calculating and predicting the periodic data frame drift value, to adjust the period of the main station clock sending the periodic data frame.

Benefits of technology

Effectively reduce clock drift between the master station and the slave station, improve clock synchronization accuracy, and dynamically adjust the clock to adapt to system changes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119892280A_ABST
    Figure CN119892280A_ABST
Patent Text Reader

Abstract

The invention discloses an EtherCAT master station clock synchronization method and system. The method comprises the steps that whether a current master station clock drift value is smaller than a clock drift threshold value or not is judged; in response to the fact that the current master station clock drift value is not smaller than the clock drift threshold value, the master station clock is adjusted according to the master station clock drift value until the master station clock drift value is smaller than the clock drift threshold value; in response to the fact that the clock drift value of the current master station is smaller than the clock drift threshold value, multiple periodic data frames are sent through the master station, and the drift value of each periodic data frame is calculated; obtaining a predicted periodic data frame drift value based on each periodic data frame drift value; and adjusting the period of sending the periodic data frame by the master station clock based on the predicted periodic data frame drift value. By using the scheme of the invention, clock drift between the master station and the slave station can be reduced, and the clock synchronization precision is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application generally relates to the field of industrial Ethernet technology. More specifically, the present application relates to an EtherCAT master station clock synchronization method and system. Background Art

[0002] EtherCAT (Ethernet for Control Automation Technology) is a high-performance industrial Ethernet communication protocol designed to meet the needs of real-time control and automation systems. With its low latency, high precision and high reliability, it has gradually become one of the mainstream bus protocols in the industrial field. In an EtherCAT network, the master station sends a time reference signal and distributes it to all slave stations. Each slave station synchronizes with the master clock based on the signal it receives, thereby achieving time consistency for all nodes in the network. However, due to the complexity of the master station's operating system, the clocks between the master station and the slave station may deviate or drift.

[0003] In the prior art, the clock drift between the master station and the slave station is attributed to the drift of the initial clock. The time estimation method is generally used to adjust the master station clock. However, this method will cause the calculated result of the clock offset to be larger than the actual value, and has a limited effect on improving the synchronization performance between the master and slave stations.

[0004] In view of this, there is an urgent need to provide an EtherCAT master station clock synchronization solution to dynamically adjust clock drift and improve clock synchronization accuracy. Summary of the invention

[0005] In order to at least solve one or more of the technical problems mentioned above, the present application proposes an EtherCAT master station clock synchronization solution in multiple aspects.

[0006] In a first aspect, the present application provides an EtherCAT master station clock synchronization method, comprising: determining whether a current master station clock drift value is less than a clock drift threshold; in response to the current master station clock drift value being not less than the clock drift threshold, adjusting the master station clock according to the master station clock drift value until the master station clock drift value is less than the clock drift threshold; in response to the current master station clock drift value being less than the clock drift threshold, sending multiple periodic data frames through the master station and calculating the drift value of each periodic data frame; obtaining a predicted periodic data frame drift value based on each periodic data frame drift value; and adjusting the period of the master station clock sending the periodic data frame based on the predicted periodic data frame drift value.

[0007] In some embodiments, the drift value of each periodic data frame is calculated by using a calculation formula for the drift value of the periodic data frame. The calculation formula for the drift value of the periodic data frame is: ΔTdrift =T send -T recv , where △T drift is the periodic data frame drift value, T send The time T for the master station to send periodic data frames send , T recv The time taken by the master station to send periodic data frames to the reference slave station.

[0008] In some embodiments, obtaining a predicted periodic data frame drift value based on each periodic data frame drift value includes: obtaining an attenuation factor, where 0<attenuation factor≤1; and performing weighted calculation on each periodic data frame drift value based on the attenuation factor to obtain a predicted periodic data frame drift value.

[0009] In some embodiments, the calculation formula of the predicted periodic data frame drift value is: Among them, q is the attenuation factor, n is the number of periodic data frames sent by the master station, △T drift1 is the first periodic data frame drift value, △T drift2 is the second periodic data frame drift value, △T driftn is the nth periodic data frame drift value.

[0010] In some embodiments, the method further includes: the master station clock re-sends the periodic data frame after the adjusted period, and calculates the corresponding periodic data frame drift value; determines whether the periodic data frame drift value corresponding to the re-sent periodic data frame is the same as the predicted periodic data frame drift value; in response to the periodic data frame drift value corresponding to the re-sent periodic data frame being the same as the predicted periodic data frame drift value, the attenuation factor is not adjusted; in response to the periodic data frame drift value corresponding to the re-sent periodic data frame being different from the predicted periodic data frame drift value, the attenuation factor is adjusted.

[0011] In some embodiments, the method further includes: performing weighted calculation on the periodic data frame drift values ​​currently acquired for a set number of times based on a current attenuation factor to obtain a new predicted periodic data frame drift value; and using the new predicted periodic data frame drift value to adjust the period of the master station clock sending periodic data frames.

[0012] In some embodiments, the attenuation factor is adjusted using an attenuation factor adjustment condition.

[0013] In some embodiments, the attenuation factor adjustment condition is:

[0014] Where q is the attenuation factor, q′ is the adjusted attenuation factor, n is the number of periodic data frames sent by the master station before sending the periodic data frame again, [n / 2] is the maximum integer not exceeding n / 2, △T drifti The drift value of the periodic data frame corresponding to the periodic data frame sent by the master station for the i-th time, △T predicted is the predicted periodic data frame drift value.

[0015] In some embodiments, in the process of sending multiple periodic data frames through the master station, the following steps are performed: determine whether the number of times the current master station sends periodic data frames reaches a number threshold; in response to the number of times the current master station sends periodic data frames reaching the number threshold, the master station stops sending periodic data frames; in response to the number of times the current master station sends periodic data frames not reaching the number threshold, the master station continues to send periodic data frames until the number of times the current master station sends periodic data frames reaches the number threshold.

[0016] In a second aspect, the present application provides an EtherCAT master station clock synchronization system, which uses the EtherCAT master station clock synchronization method as described in any embodiment of the first aspect to perform clock synchronization, and the system includes: a judgment module, used to judge whether the current master station clock drift value is less than the clock drift threshold; a master station clock adjustment module, in response to the current master station clock drift value being not less than the clock drift threshold, adjusting the master station clock according to the master station clock drift value until the master station clock drift value is less than the clock drift threshold; a calculation module, in response to the current master station clock drift value being less than the clock drift threshold, sending multiple periodic data frames through the master station and calculating the drift value of each periodic data frame; a prediction module, used to obtain a predicted periodic data frame drift value based on each periodic data frame drift value; a period adjustment module, used to adjust the period of the master station clock sending the periodic data frame based on the predicted periodic data frame drift value.

[0017] Through the EtherCAT master station clock synchronization solution provided above, the embodiment of the present application can reduce the clock drift between the master station and the slave station and improve the clock synchronization accuracy by adjusting the period of the master station clock sending the periodic data frame based on the predicted periodic data frame drift value. Further, in some embodiments, the master station clock sends the periodic data frame again after the adjusted period, calculates the corresponding periodic data frame drift value, and adjusts the attenuation factor based on the comparison result of the periodic data frame drift value corresponding to the periodic data frame sent again and the predicted periodic data frame drift value, so that the period of the master station clock sending the periodic data frame can be dynamically adjusted, thereby further improving the clock synchronization accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:

[0019] Figure 1 An exemplary flow chart of the EtherCAT master station clock synchronization method according to an embodiment of the present application is shown;

[0020] Figure 2 An exemplary flow chart of a master station sending multiple periodic data frames according to an embodiment of the present application is shown;

[0021] Figure 3 An exemplary flow chart of adjusting the period of the master station clock sending periodic data frames again according to an embodiment of the present application is shown;

[0022] Figure 4 An exemplary structural block diagram of the EtherCAT master station clock synchronization system according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0024] It should be understood that the terms "include" and "comprising" used in the specification and claims of the present application indicate the presence of described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or collections thereof.

[0025] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in this application specification and claims, unless the context clearly indicates otherwise, the singular forms of "a", "an" and "the" are intended to include plural forms. It should also be further understood that the term "and / or" used in this application specification and claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.

[0026] As used in this specification and the claims, the term "if" can be interpreted as "when" or "once" or "in response to determining" or "in response to detecting" depending on the context. Similarly, the phrase "if it is determined" or "if [the described condition or event] is detected" can be interpreted as meaning "once it is determined" or "in response to determining" or "once [the described condition or event] is detected" or "in response to detecting [the described condition or event]" depending on the context.

[0027] The following will describe in detail the specific implementation manners of the present application with reference to the accompanying drawings.

[0028] Figure 1 An exemplary flowchart of the EtherCAT master clock synchronization method 100 according to an embodiment of the present application is shown.

[0029] As Figure 1 shown, in step S110, it is determined whether the current master clock drift value is less than the clock drift threshold.

[0030] In an embodiment of the present application, since the first slave station with DC (Distributed Clock) function connected to the master station is used as the reference slave station, the clock of the reference slave station is used as the reference clock, and the clocks of other devices are based on the reference clock. Therefore, it is necessary to adjust the clock reference of the master station. Specifically, during the process of adjusting the clock reference of the master station, it is necessary to adjust the master clock drift value to be less than the clock drift threshold. Thus, by determining whether the current master clock drift value is less than the clock drift threshold, it can be determined whether the process of adjusting the clock reference of the master station is completed.

[0031] In an embodiment of the present application, the master clock drift value is obtained through the following calculation formula:

[0032] △T init =T master -T reference where △T init is the master clock drift value, T master is the master clock, and T reference is the reference clock.

[0033] In an embodiment of the present application, the clock drift threshold can be set according to the following formula: where T is the period of the master clock sending periodic data frames, and N is the clock calibration accuracy, 1000 < N < 10000. Specifically, the user can set the clock drift threshold according to the period of the master clock sending periodic data frames within the range of the clock calibration accuracy, making it more applicable.

[0034] In an embodiment of the present application, N is taken as 500.

[0035] After executing step S110, in response to the current master station clock drift value being not less than the clock drift threshold, in step S120, the master station clock is adjusted according to the master station clock drift value until the master station clock drift value is less than the clock drift threshold.

[0036] After executing step S110 , in response to the current master station clock drift value being less than the clock drift threshold, in step S130 , multiple periodic data frames are sent through the master station, and the drift value of each periodic data frame is calculated.

[0037] In an embodiment of the present application, when the current master station clock drift value is less than the clock drift threshold, it indicates that the master station clock reference adjustment process is completed, and the periodic data frame drift compensation phase is entered at this time. Specifically, in the periodic data frame drift compensation phase, it is necessary to calculate several periodic data frame drift values, and obtain a predicted periodic data frame drift value based on the periodic data frame drift value, and compensate the master station clock according to the predicted periodic data frame drift value, thereby improving the accuracy of the master station clock.

[0038] In an embodiment of the present application, the number of times the master station sends the periodic data frame satisfies the number threshold condition. Specifically, the number threshold condition is that the number of times the master station sends the periodic data frame reaches the number threshold. The number threshold can be set according to actual needs and historical experience, but the number threshold must be at least 2 to avoid the obtained periodic data frame drift value being interfered by a series of factors.

[0039] In the embodiment of the present application, the process of sending multiple periodic data frames by the master station can be found in Figure 2 .

[0040] Figure 2 FIG. 2 shows an exemplary flow chart of a master station sending multiple periodic data frames according to an embodiment of the present application. Figure 2 As shown, in step S210, it is determined whether the number of times the current master station sends periodic data frames reaches the number threshold. In response to the number of times the current master station sends periodic data frames reaching the number threshold, in step S220, the master station stops sending periodic data frames. In response to the number of times the current master station sends periodic data frames not reaching the number threshold, the master station continues to send periodic data frames and returns to step S210, and then determines whether the number of times the current master station sends periodic data frames reaches the number threshold, until the number of times the current master station sends periodic data frames reaches the number threshold.

[0041] In the embodiment of the present application, the drift value of each periodic data frame is calculated by using the calculation formula of the periodic data frame drift value, and the calculation formula of the periodic data frame drift value is: △T drift =T send -T recv, where, △T drift is the periodic data frame drift value, and T send is the time T for the master station to send the periodic data frame send , and T recv is the time taken for the master station to send the periodic data frame to the reference slave station.

[0042] In the embodiments of the present application, the time taken for the master station to send the periodic data frame to the reference slave station is obtained by reading the register of the reference slave station. Specifically, the address range of the register is from 0x900 to 0x90F.

[0043] After calculating the periodic data frame drift values for each time, in step S140, a predicted periodic data frame drift value is obtained based on the periodic data frame drift values for each time.

[0044] In the embodiments of the present application, in the process of obtaining the predicted periodic data frame drift value based on the periodic data frame drift values for each time, first, an attenuation factor is obtained. Then, the periodic data frame drift values for each time are weighted and calculated based on the attenuation factor to obtain the predicted periodic data frame drift value. Specifically, 0 < attenuation factor ≤ 1, and the user can set the attenuation factor according to actual needs and experience.

[0045] Specifically, the predicted periodic data frame drift value is obtained through the calculation formula of the predicted periodic data frame drift value. The calculation formula of the predicted periodic data frame drift value is:

[0046]

[0047] where q is the attenuation factor, n is the number of periodic data frames sent by the master station, and △T drift1 is the first periodic data frame drift value, △T drift2 is the second periodic data frame drift value, and △T driftn is the nth periodic data frame drift value.

[0048] According to the above calculation formula of the predicted periodic data frame drift value, when the attenuation factor q is 1, the average value of the periodic data frame drift values for each time is obtained as the predicted periodic data frame drift value, which can smooth out the influence of system jitter. When 0 < q < 1, the periodic data frame drift values for each time are weighted and averaged by assigning higher weights to the periodic data frame drift values obtained at closer times. Since the periodic data frame drift values obtained at closer times can better represent the current system behavior pattern, by assigning higher weights to the periodic data frame drift values obtained at closer times and weighting and averaging the periodic data frame drift values for each time, the obtained predicted periodic data frame drift value can be more accurate.

[0049] After the predicted periodic data frame drift value is obtained, in step S150, the period of sending the periodic data frame by the master station clock is adjusted based on the predicted periodic data frame drift value.

[0050] Specifically, since the periodic data frame drift value is affected by the execution time of the master station control program, the data frame transmission time and the data frame delay time, and the period of the master station sending the periodic data frame is related to the jitter value of the control program execution time, when the sum of the jitter values ​​of the master station control program execution time, the data frame transmission time, the data frame delay time and the control program execution time is used as an advance amount of the timer running locally at the master station relative to the reference clock timing, clock synchronization can be achieved. Therefore, by obtaining the predicted periodic data frame drift value through these periodic data frame drift values ​​and adjusting the period of sending the periodic data frame accordingly, the accuracy of the master station clock can be significantly improved.

[0051] In an embodiment of the present application, in the process of adjusting the period of the master station clock sending the periodic data frame based on the predicted periodic data frame drift value, the predicted periodic data frame drift value is used to adjust the master station sleep time, so that the master station clock sends the period of the periodic data frame. Specifically, the master station uses the local clock to sleep, and the master station sleep time is the period of the master station clock sending the periodic data frame, in order to send a periodic data frame once in each cycle. After waiting for the sleep to complete, the master station will send a periodic data frame.

[0052] In the embodiment of the present application, after executing step S150, a new predicted periodic data frame drift value is obtained through the attenuation factor, and the period of the master station clock sending the periodic data frame is adjusted according to the new predicted periodic data frame drift value, and the period of the master station clock sending the periodic data frame is dynamically adjusted in this cycle, thereby achieving clock synchronization. The specific process involved here can be found in Figure 3 .

[0053] Figure 3 An exemplary flow chart of an embodiment of the present application for re-adjusting the period of the master station clock to send periodic data frames is shown.

[0054] like Figure 3As shown, in step S310, the master station clock sends the periodic data frame again after the adjusted period, and calculates the corresponding periodic data frame drift value. Then, in step S320, it is determined whether the periodic data frame drift value corresponding to the periodic data frame sent again is the same as the predicted periodic data frame drift value. In response to the periodic data frame drift value corresponding to the periodic data frame sent again being the same as the predicted periodic data frame drift value, in step S330, the attenuation factor is not adjusted. In response to the periodic data frame drift value corresponding to the periodic data frame sent again being different from the predicted periodic data frame drift value, in step S340, the attenuation factor is adjusted.

[0055] When the attenuation factor is not adjusted, in step S350, the drift value of the periodic data frame currently acquired for the set number of times is weighted and calculated based on the unadjusted attenuation factor to obtain a new predicted drift value of the periodic data frame. When the attenuation factor is adjusted, in step S350, the drift value of the periodic data frame currently acquired for the set number of times is weighted and calculated based on the adjusted attenuation factor to obtain a new predicted drift value of the periodic data frame. Then, in step S360, the period of the master station clock sending the periodic data frame is adjusted using the new predicted drift value of the periodic data frame, and the process returns to step S310 for a loop to dynamically adjust the period of the master station clock sending the periodic data frame.

[0056] In the embodiment of the present application, the periodic data frame drift value corresponding to the periodic data frame sent again is obtained by the aforementioned calculation formula of the periodic data frame drift value, which will not be repeated here.

[0057] In an embodiment of the present application, when the drift value of the periodic data frame corresponding to the periodic data frame sent again is the same as the predicted drift value of the periodic data frame, it means that the predicted drift value of the periodic data frame obtained by the current attenuation factor is more accurate, and there is no need to adjust the attenuation factor. When the drift value of the periodic data frame corresponding to the periodic data frame sent again is different from the predicted drift value of the periodic data frame, it means that the predicted drift value of the periodic data frame obtained by the current attenuation factor is not accurate, and the attenuation factor needs to be adjusted again, so that the new predicted drift value of the periodic data frame obtained again is more accurate.

[0058] In the embodiment of the present application, the attenuation factor is adjusted using an attenuation factor adjustment condition. Specifically, the attenuation factor adjustment condition is: Where q is the attenuation factor, q′ is the adjusted attenuation factor, n is the number of periodic data frames sent by the master station before sending the periodic data frame again, [n / 2] is the maximum integer not exceeding n / 2, △T driftiThe drift value of the periodic data frame corresponding to the periodic data frame sent by the master station for the i-th time, △T predicted is the predicted periodic data frame drift value.

[0059] Through the above attenuation factor adjustment conditions, when the sum of the differences between the periodic data frame drift values ​​of the previous [n / 2] times and the predicted periodic data frame drift values ​​is less than the difference between the periodic data frame drift values ​​of the next n-[n / 2] times and the predicted periodic data frame drift values, the attenuation factor is adjusted to be larger. This indicates that the prediction effect of the periodic data frame drift value far from the current moment is better, so adjusting the attenuation factor to be larger can make the next predicted periodic data frame drift value have a prediction effect on the periodic data frame drift value close to the current moment, thereby making the new predicted periodic data frame drift value closer to the actual periodic data frame drift value corresponding thereto.

[0060] When the sum of the difference between the periodic data frame drift value of the previous [n / 2] times and the predicted periodic data frame drift value is greater than or equal to the difference between the periodic data frame drift value of the next n-[n / 2] times and the predicted periodic data frame drift value, the attenuation factor is adjusted to be smaller. This indicates that the prediction effect of the periodic data frame drift value close to the current moment is better, so adjusting the attenuation factor to be smaller can make the next predicted periodic data frame drift value have a prediction effect on the periodic data frame drift value far from the current moment, thereby making the new predicted periodic data frame drift value closer to the actual periodic data frame drift value corresponding thereto.

[0061] In an embodiment of the present application, the aforementioned set number of times may be the same as or different from the aforementioned number threshold, and the present application is not limited here. When the aforementioned set number of times is the same as the aforementioned number threshold, it is only necessary to obtain the periodic data frame drift value corresponding to the m-time periodic data frame acquirer close to the current moment, where m is the number threshold. When the aforementioned set number of times is different from the aforementioned number threshold and the set number of times is less than all the times the main station sends periodic data frames at the current moment, it is only necessary to obtain the periodic data frame drift value corresponding to the a-time periodic data frame acquirer close to the current moment, where a is the set number of times. When the aforementioned set number of times is different from the aforementioned number threshold and the set number of times is equal to all the times the main station sends periodic data frames at the current moment, it is necessary to obtain the periodic data frame drift value corresponding to all the periodic data frame acquirers sent by the main station.

[0062] In an embodiment of the present application, when weighted calculation is performed on the periodic data frame drift values ​​currently acquired for a set number of times based on an adjusted or unadjusted attenuation factor to obtain a new predicted periodic data frame drift value, the aforementioned calculation formula for the predicted periodic data frame drift value is adopted, which will not be repeated here.

[0063] In summary, through the EtherCAT master station clock synchronization solution provided above, the embodiment of the present application can reduce the clock drift between the master station and the slave station and improve the clock synchronization accuracy by adjusting the period of the master station clock sending the periodic data frame based on the predicted periodic data frame drift value. Further, in some embodiments, the master station clock sends the periodic data frame again after the adjusted period, calculates the corresponding periodic data frame drift value, and adjusts the attenuation factor based on the comparison result of the periodic data frame drift value corresponding to the periodic data frame sent again and the predicted periodic data frame drift value, so as to dynamically adjust the period of the master station clock sending the periodic data frame, thereby further improving the clock synchronization accuracy.

[0064] The embodiment of the present application also provides an EtherCAT master station clock synchronization system, which can use the aforementioned EtherCAT master station clock synchronization method 100 to perform EtherCAT master station clock synchronization, and can also use other EtherCAT master station clock synchronization methods to perform EtherCAT master station clock synchronization, which is not limited in the present application.

[0065] Figure 4 An exemplary structural block diagram of the EtherCAT master station clock synchronization system in an embodiment of the present application is shown.

[0066] like Figure 4 As shown, the system 400 includes a judgment module 410, a master station clock adjustment module 420, a calculation module 430, a prediction module 440, and a period adjustment module 450. In the embodiment of the present application, the judgment module 410, the master station clock adjustment module 420, the calculation module 430, the prediction module 440, and the period adjustment module 450 can be separate units or integrated in an integrated circuit, and the present application does not limit this.

[0067] Specifically, the determination module 410 is used to determine whether the current master station clock drift value is less than the clock drift threshold.

[0068] Specifically, in response to the current master station clock drift value being not less than the clock drift threshold, the master station clock adjustment module 420 adjusts the master station clock according to the master station clock drift value until the master station clock drift value is less than the clock drift threshold.

[0069] Specifically, in response to the current master station clock drift value being less than the clock drift threshold, the calculation module 430 sends multiple periodic data frames through the master station and calculates the drift value of each periodic data frame.

[0070] Specifically, the prediction module 440 is used to obtain a predicted periodic data frame drift value based on each periodic data frame drift value.

[0071] Specifically, the period adjustment module 450 is used to adjust the period of the master station clock sending the periodic data frame based on the predicted periodic data frame drift value.

[0072] When the system 400 uses the aforementioned EtherCAT master station clock synchronization method 100 to perform EtherCAT master station clock synchronization, the judgment module 410 executes the aforementioned step S110, the master station clock adjustment module 420 executes the aforementioned step S120, the calculation module 430 executes the aforementioned step S130, the prediction module 440 executes the aforementioned step S140, and the cycle adjustment module 450 executes the aforementioned step S150. The specific execution process can be referred to the above, which will not be repeated here.

[0073] Although multiple embodiments of the present application have been shown and described herein, it is obvious to those skilled in the art that such embodiments are provided only by way of example. Those skilled in the art can think of many changes, modifications and alternatives without departing from the thought and spirit of the present application. It should be understood that in the process of practicing the present application, various alternatives to the embodiments of the present application described herein can be adopted. The attached claims are intended to limit the scope of protection of the present application, and therefore cover equivalents or alternatives within the scope of these claims.

Claims

1. An EtherCAT master station clock synchronization method, characterized in that: include: Determine whether the current master station clock drift value is less than the clock drift threshold; In response to the current master station clock drift value being not less than the clock drift threshold, adjusting the master station clock according to the master station clock drift value until the master station clock drift value is less than the clock drift threshold; In response to the current master station clock drift value being less than the clock drift threshold, sending multiple periodic data frames through the master station, and calculating the drift value of each periodic data frame; Acquire a predicted periodic data frame drift value based on each periodic data frame drift value; The period of sending the periodic data frame by the master station clock is adjusted based on the predicted periodic data frame drift value.

2. The EtherCAT master station clock synchronization method according to claim 1, characterized in that: The drift value of each periodic data frame is calculated by using the calculation formula of the periodic data frame drift value, and the calculation formula of the periodic data frame drift value is: △T drift =T send -T recv , where △T drift is the periodic data frame drift value, T send The time T for the master station to send periodic data frames send , T recv The time taken by the master station to send periodic data frames to the reference slave station.

3. The EtherCAT master station clock synchronization method according to claim 1, characterized in that: The predicted periodic data frame drift value is obtained based on each periodic data frame drift value, including: Get the attenuation factor, where 0<attenuation factor≤1; The predicted periodic data frame drift value is obtained by performing weighted calculation on each periodic data frame drift value based on the attenuation factor.

4. The EtherCAT master station clock synchronization method according to claim 3, characterized in that: The calculation formula of the predicted periodic data frame drift value is: Among them, q is the attenuation factor, n is the number of periodic data frames sent by the master station, △T drift1 is the first periodic data frame drift value, △T drift2 is the second periodic data frame drift value, △T driftn is the nth periodic data frame drift value.

5. The EtherCAT master station clock synchronization method according to claim 3, characterized in that: The method further comprises: The master station clock sends the periodic data frame again after the adjusted period, and calculates the corresponding periodic data frame drift value; Determine whether the periodic data frame drift value corresponding to the periodic data frame sent again is the same as the predicted periodic data frame drift value; In response to the periodic data frame drift value corresponding to the periodic data frame sent again being the same as the predicted periodic data frame drift value, the attenuation factor is not adjusted; In response to the periodic data frame drift value corresponding to the resent periodic data frame being different from the predicted periodic data frame drift value, the attenuation factor is adjusted.

6. The EtherCAT master station clock synchronization method according to claim 5, characterized in that: The method further comprises: Based on the current attenuation factor, weighted calculation is performed on the periodic data frame drift values ​​currently acquired for a set number of times to obtain a new predicted periodic data frame drift value; The new predicted periodic data frame drift value is used to adjust the period of the master station clock sending the periodic data frame.

7. The EtherCAT master station clock synchronization method according to claim 6, characterized in that: The attenuation factor is adjusted using the attenuation factor adjustment condition.

8. The EtherCAT master station clock synchronization method according to claim 7, characterized in that: The attenuation factor adjustment condition is: Where q is the attenuation factor, q′ is the adjusted attenuation factor, n is the number of periodic data frames sent by the master station before sending the periodic data frame again, [n / 2] is the maximum integer not exceeding n / 2, △T drifti The drift value of the periodic data frame corresponding to the periodic data frame sent by the master station for the i-th time, △T predicted is the predicted periodic data frame drift value.

9. The EtherCAT master station clock synchronization method according to claim 1, characterized in that: In the process of sending multiple periodic data frames through the master station, the following steps are performed: Determine whether the number of times the current master station sends periodic data frames reaches a threshold; In response to the number of times the current master station sends the periodic data frame reaching a number threshold, the master station stops sending the periodic data frame; In response to the current master station sending periodic data frames for a number of times that does not reach the number threshold, the master station continues to send periodic data frames until the current master station sends periodic data frames for a number of times that reaches the number threshold.

10. An EtherCAT master station clock synchronization system, characterized in that: The EtherCAT master station clock synchronization method according to any one of claims 1 to 9 is used for clock synchronization, and the system comprises: A judgment module is used to judge whether the current master station clock drift value is less than the clock drift threshold; A master station clock adjustment module, in response to the current master station clock drift value being not less than the clock drift threshold, adjusts the master station clock according to the master station clock drift value until the master station clock drift value is less than the clock drift threshold; A calculation module, in response to the current master station clock drift value being less than the clock drift threshold, sends multiple periodic data frames through the master station, and calculates the drift value of each periodic data frame; A prediction module, used for obtaining a predicted periodic data frame drift value based on each periodic data frame drift value; The period adjustment module is used to adjust the period of the master station clock sending the periodic data frame based on the predicted periodic data frame drift value.

Citation Information

Patent Citations

  • Clock synchronization method and device, wireless earphone and readable storage medium

    CN112787742A

  • Industrial robot driver EtherCAT master station clock synchronization method

    CN118101116A

  • Method For Protection From Cyber Attacks To A Vehicle Based Upon Time Analysis, And Corresponding Device

    US20230080521A1

  • Clock generation apparatus, clock generation method, adjustment apparatus, adjustment method, and non-transitory computer readable medium

    US20240146243A1