Ethercat master station clock synchronization method and system
By dynamically adjusting the master station clock in the EtherCAT network and using a weighted average of the periodic data frame drift values, the problem of clock drift between the master and slave stations was solved, achieving higher-precision clock synchronization.
Patent Information
- Application Number
- CN202411868073.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-12-18
AI Technical Summary
In existing technologies, clock drift between EtherCAT master and slave stations leads to insufficient synchronization performance, and existing adjustment methods have limited effectiveness.
By judging the master station clock drift value, multiple periodic data frames are sent, and the drift value of the periodic data frames is calculated and weighted to dynamically adjust the master station clock sending period to improve synchronization accuracy.
It effectively reduces clock drift between the master and slave stations, improves clock synchronization accuracy, and ensures time consistency among all nodes in the network.
Smart Images

Figure CN119892280B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application generally relates to the technical field of industrial Ethernet. More particularly, the present application relates to an EtherCAT master clock synchronization method and system. BACKGROUND
[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. It has gradually become one of the mainstream bus protocols in the industrial field with its characteristics of low delay, high precision and high reliability. In the EtherCAT network, the master station distributes its time reference signal to all slave stations by sending it. Each slave station synchronizes with the master clock according to the signal it receives, thereby achieving time consistency of all nodes in the network. However, due to the complexity of the operating system of the master station, it may cause the clock between the master station and the slave station to deviate or drift.
[0003] In the prior art, the cause of the clock drift between the master station and the slave station is attributed to the drift of the initial clock, and a time prediction method is generally used to adjust the master station clock, but this method may cause the calculation result of the clock offset to be larger than the actual value, and has limited effect on improving the synchronization performance between the master and slave stations.
[0004] Therefore, there is an urgent need to provide an EtherCAT master clock synchronization scheme to dynamically adjust the clock drift and improve the clock synchronization accuracy. SUMMARY
[0005] In order to at least solve one or more technical problems as mentioned above, the present application proposes an EtherCAT master clock synchronization scheme in multiple aspects.
[0006] In a first aspect, the present application provides an EtherCAT master clock synchronization method, comprising: judging whether a current master station clock drift value is less than a clock drift threshold value; in response to the current master station clock drift value not being less than the clock drift threshold value, 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 value; in response to the current master station clock drift value being less than the clock drift threshold value, sending multiple periodic data frames by the master station and calculating a periodic data frame drift value of each time; obtaining a predicted periodic data frame drift value based on the periodic data frame drift value of each time; and adjusting the period of sending the periodic data frame by the master station clock based on the predicted periodic data frame drift value.
[0007] In some embodiments, the periodic data frame drift value of each time is calculated by a calculation formula of the periodic data frame drift value, and the calculation formula of the periodic data frame drift value is: ΔTdrift = T send - T recv wherein, ΔT drift is a periodic data frame drift value, T send is a time T send at which the master station transmits a periodic data frame, T recv is a time at which the master station transmits the periodic data frame to the reference slave station.
[0008] In some embodiments, the acquiring the predicted periodic data frame drift value based on the periodic data frame drift values comprises: acquiring a decay factor, wherein 0 < the decay factor ≤ 1; and calculating the predicted periodic data frame drift value based on the decay factor and the periodic data frame drift values.
[0009] In some embodiments, the calculation formula of the predicted periodic data frame drift value is: wherein, q is the decay factor, k is the number of the periodic data frames transmitted by the master station, ΔT drift1 is the first periodic data frame drift value of the master station, ΔT drift2 is the second periodic data frame drift value of the master station, ΔT driftn is the n-th periodic data frame drift value of the master station.
[0010] In some embodiments, the method further comprises: transmitting the periodic data frame again by the master station after the period of the adjusted master station clock, and calculating the corresponding periodic data frame drift value; determining whether the periodic data frame drift value corresponding to the periodic data frame transmitted again is same as the predicted periodic data frame drift value; in response to the periodic data frame drift value corresponding to the periodic data frame transmitted again being same as the predicted periodic data frame drift value, not adjusting the decay factor; and in response to the periodic data frame drift value corresponding to the periodic data frame transmitted again being different from the predicted periodic data frame drift value, adjusting the decay factor.
[0011] In some embodiments, the method further comprises: calculating a new predicted periodic data frame drift value based on the current decay factor and the set number of the current acquired periodic data frame drift values; and adjusting the period of the periodic data frame transmitted by the master station by using the new predicted periodic data frame drift value.
[0012] In some embodiments, the decay factor is adjusted by using a decay factor adjustment condition.
[0013] In some embodiments, the decay factor adjustment condition is:
[0014] wherein q is an attenuation factor, q' is an adjusted attenuation factor, n is the number of times the master station transmits the periodic data frame before transmitting the periodic data frame again, [n / 2] is the largest integer not exceeding n, and ΔT drifti is the periodic data frame drift value corresponding to the i-th periodic data frame transmitted by the master station, and ΔT predicted is the predicted periodic data frame drift value.
[0015] In some embodiments, the following steps are performed during the transmission of the periodic data frame by the master station multiple times: determining whether the number of times the master station transmits the periodic data frame currently reaches a number threshold; in response to the number of times the master station transmits the periodic data frame currently reaching the number threshold, the master station stops transmitting the periodic data frame; and in response to the number of times the master station transmits the periodic data frame currently not reaching the number threshold, the master station continues to transmit the periodic data frame until the number of times the master station transmits the periodic data frame currently reaches the number threshold.
[0016] In a second aspect, the present application provides an EtherCAT master station clock synchronization system, which adopts the EtherCAT master station clock synchronization method as described in any of the embodiments of the first aspect to perform clock synchronization. The system comprises: a determination module configured to determine whether a current master station clock drift value is less than a clock drift threshold; a master station clock adjustment module configured to, in response to the current master station clock drift value not being less than the clock drift threshold, adjust the master station clock based on the master station clock drift value until the master station clock drift value is less than the clock drift threshold; a calculation module configured to, in response to the current master station clock drift value being less than the clock drift threshold, transmit the periodic data frame by the master station multiple times and calculate periodic data frame drift values of each time; a prediction module configured to obtain a predicted periodic data frame drift value based on the periodic data frame drift values of each time; and a period adjustment module configured to adjust a period of the master station clock transmitting the periodic data frame based on the predicted periodic data frame drift value.
[0017] Through the EtherCAT master station clock synchronization scheme as provided above, the embodiments 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 transmitting the periodic data frame based on the predicted periodic data frame drift value. Further, in some embodiments, the master station clock transmits the periodic data frame again after the period of the master station clock is adjusted, the periodic data frame drift value corresponding to the periodic data frame is calculated, and the attenuation factor is adjusted based on the comparison result of the periodic data frame drift value corresponding to the periodic data frame transmitted again and the predicted periodic data frame drift value, so as to dynamically adjust the period of the master station clock transmitting the periodic data frame, thereby further improving the clock synchronization accuracy. BRIEF DESCRIPTION OF DRAWINGS
[0018] The above and other objects, features and advantages of the present application will become more apparent from the following detailed description read in conjunction with the accompanying drawings, in which:
[0019] Figure 1 An exemplary flowchart of the method for clock synchronization of an EtherCAT master station according to an embodiment of the present application is shown;
[0020] Figure 2 An exemplary flowchart of the method for the master station to send multiple periodic data frames according to an embodiment of the present application is shown;
[0021] Figure 3 An exemplary flowchart of the method for the master station to adjust the period of 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 clock synchronization system of an EtherCAT master station according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0023] The technical solutions in the embodiments of the present application will be apparently and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without any creative work fall within the protection scope of the present application.
[0024] It should be understood that the terms "comprise" and "include" used in the specification and claims of the present application indicate the presence of the described features, integers, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0025] It should also be understood that the terms used in the specification of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. As used in the specification and claims of the present application, the singular forms "a", "an" and "the" are intended to include the plural forms, unless the context clearly indicates otherwise. It should be further understood that the term "and / or" used in the specification and claims of the present application means any combination of one or more of the associated listed items and all possible combinations thereof, and includes these combinations.
[0026] As used in this specification and the claims, the term "if" may be construed, depending on the context, as "when" or "once" or "in response to determining" or "in response to detecting". Similarly, the phrase "if it is determined" or "if [the described condition or event] is detected" may be construed, depending on the context, to mean "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]".
[0027] The specific embodiments of the present application will be described in detail below 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 judged 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, the master clock drift value needs to be adjusted to be less than the clock drift threshold. Thus, by judging whether the current master clock drift value is less than the clock drift threshold, it can be judged 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: Δ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.
[0032] 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, N is the clock calibration accuracy, and 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.
[0033] In an embodiment of the present application, N is taken as 500.
[0034] After step S110 is performed, in response to the current master station clock drift value being not less than the clock drift threshold value, 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 value.
[0035] After step S110 is performed, in response to the current master station clock drift value being less than the clock drift threshold value, in step S130, the master station sends multiple periodic data frames, and calculates the periodic data frame drift value of each time.
[0036] In the embodiment of the present application, when the current master station clock drift value is less than the clock drift threshold value, it indicates that the clock reference adjustment process of the master station is completed, at this time, the periodic data frame drift compensation phase is entered. Specifically, in the periodic data frame drift compensation phase, a plurality of periodic data frame drift values need to be calculated, and a predicted periodic data frame drift value is obtained based on the periodic data frame drift value, and the master station clock is compensated according to the predicted periodic data frame drift value, thereby improving the accuracy of the master station clock.
[0037] In the embodiment of the present application, the number of times of sending the periodic data frame by the master station satisfies the number of times threshold condition. Specifically, the number of times threshold condition is that the number of times of sending the periodic data frame by the master station reaches the number of times threshold. The number of times threshold can be set according to actual needs and historical experience, but it is required to ensure that the number of times threshold is at least 2, so as to avoid that the obtained periodic data frame drift value is disturbed by a series of factors.
[0038] In the embodiment of the present application, the specific process of sending multiple periodic data frames by the master station can be referred to in Figure 2 .
[0039] Figure 2 An exemplary flowchart of the master station sending multiple periodic data frames in the embodiment of the present application is shown. As shown in Figure 2 , in step S210, it is judged whether the number of times of sending the periodic data frame by the current master station reaches the number of times threshold. In response to the number of times of sending the periodic data frame by the current master station reaching the number of times threshold, in step S220, the master station stops sending the periodic data frame. In response to the number of times of sending the periodic data frame by the current master station not reaching the number of times threshold, the master station continues to send the periodic data frame, and returns to step S210 to judge whether the number of times of sending the periodic data frame by the current master station reaches the number of times threshold, until the number of times of sending the periodic data frame by the current master station reaches the number of times threshold.
[0040] In the embodiment of the present application, the periodic data frame drift value of each time is calculated by 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 , wherein, ΔTdrift is the periodic data frame drift value, T send is the time T at which the master station transmits the periodic data frame send , T recv is the time at which the master station transmits the periodic data frame to the reference slave station.
[0041] In the embodiments of the present application, the time at which the master station transmits the periodic data frame to the reference slave station is obtained by reading a register of the reference slave station. Specifically, the address range of the register is from 0x900 to 0x90F.
[0042] After the periodic data frame drift values are calculated, in step S140, a predicted periodic data frame drift value is obtained based on the periodic data frame drift values.
[0043] 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, first, an attenuation factor is obtained. Then, the periodic data frame drift values are weighted 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.
[0044] Specifically, the predicted periodic data frame drift value is obtained by a calculation formula of the predicted periodic data frame drift value, and the calculation formula of the predicted periodic data frame drift value is:
[0045]
[0046] wherein q is the attenuation factor, k is the number of the periodic data frame transmitted by the master station, ΔT drift1 is the first periodic data frame drift value of the master station, ΔT drift2 is the second periodic data frame drift value of the master station, ΔT driftn is the nth periodic data frame drift value of the master station.
[0047] According to the above calculation formula of the predicted periodic data frame drift value, when the attenuation factor q is 1, the predicted periodic data frame drift value is obtained by averaging the periodic data frame drift values, which can smooth the influence of system jitter. When 0 < q < 1, the periodic data frame drift values obtained at more recent time are given higher weights, and the periodic data frame drift values are weighted and averaged. Since the periodic data frame drift values obtained at more recent time can better represent the current system behavior mode, by giving higher weights to the periodic data frame drift values obtained at more recent time and weighting and averaging the periodic data frame drift values, the predicted periodic data frame drift value obtained can have higher accuracy.
[0048] 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.
[0049] Specifically, since the periodic data frame drift value is affected by the master station control program execution time, data frame transmission time and data frame delay time, and the period of sending the periodic data frame by the master station is related to the jitter value of the control program execution time, when the sum of the master station control program execution time, data frame transmission time, data frame delay time and the jitter value of the control program execution time is taken as an advance of the timer running locally in the master station relative to the reference clock timing, the clock synchronization can be achieved. Thus, by obtaining the predicted periodic data frame drift value through these periodic data frame drift values, and making corresponding adjustment to the period of sending the periodic data frame, the accuracy of the master station clock can be significantly improved.
[0050] In the embodiments of the present application, in the process of adjusting the period of sending the periodic data frame by the master station clock 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 periodic data frame. Specifically, the master station sleeps using the local clock, and the master station sleep time is the period of sending the periodic data frame by the master station clock, which aims to send the periodic data frame once in each period. After waiting for the sleep to be completed, the master station will send the periodic data frame once.
[0051] In the embodiments of the present application, after step S150 is performed, a new predicted periodic data frame drift value is obtained through the attenuation factor, and the period of sending the periodic data frame by the master station clock is adjusted according to the new predicted periodic data frame drift value, so as to dynamically adjust the period of sending the periodic data frame by the master station clock, thereby achieving the clock synchronization. The specific process involved herein can refer to Figure 3 .
[0052] Figure 3 An exemplary flowchart of adjusting the period of sending the periodic data frame by the master station clock again is shown.
[0053] As Figure 3As shown, in step S310, the master clock sends the periodic data frame again after the period is adjusted, and calculates the corresponding periodic data frame drift value. Then, in step S320, it is judged 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.
[0054] When the attenuation factor is not adjusted, in step S350, the newly predicted periodic data frame drift value is calculated by weighting the set number of periodic data frame drift values obtained currently based on the attenuation factor not adjusted. When the attenuation factor is adjusted, in step S350, the newly predicted periodic data frame drift value is calculated by weighting the set number of periodic data frame drift values obtained currently based on the adjusted attenuation factor. Then, in step S360, the newly predicted periodic data frame drift value is used to adjust the period of the periodic data frame sent by the master clock, and the process returns to step S310 for circulation, so as to dynamically adjust the period of the periodic data frame sent by the master clock.
[0055] In the embodiments 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 is not described herein again.
[0056] In the embodiments of the present application, when 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, it is indicated that the predicted periodic data frame drift value obtained by the current attenuation factor has higher accuracy, and the attenuation factor does not need to be adjusted again. When the periodic data frame drift value corresponding to the periodic data frame sent again is different from the predicted periodic data frame drift value, it is indicated that the predicted periodic data frame drift value obtained by the current attenuation factor has lower accuracy, and the attenuation factor needs to be adjusted again, so that the newly obtained predicted periodic data frame drift value has higher accuracy.
[0057] In the embodiments of the present application, the attenuation factor is adjusted by using the attenuation factor adjustment condition. Specifically, the attenuation factor adjustment condition is: Wherein, 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 the periodic data frame is sent again, [n / 2] is the maximum integer not exceeding n / 2, ΔT driftiΔT is a periodic data frame drift value corresponding to a periodic data frame transmitted by the master station for the i-th time predicted ΔT is a predicted periodic data frame drift value.
[0058] By the above attenuation factor adjustment condition, when the sum of the differences between the periodic data frame drift values of the first [n / 2] times and the predicted periodic data frame drift value is less than the sum of the differences between the periodic data frame drift values of the last n-[n / 2] times and the predicted periodic data frame drift value, the attenuation factor is adjusted to be larger. This indicates that the prediction effect of the periodic data frame drift values far from the current time is better, and thus the attenuation factor is adjusted to be larger, so that the next predicted periodic data frame drift value has a prediction effect on the periodic data frame drift values close to the current time, thereby making the new predicted periodic data frame drift value closer to the actual periodic data frame drift value corresponding thereto.
[0059] When the sum of the differences between the periodic data frame drift values of the first [n / 2] times and the predicted periodic data frame drift value is greater than or equal to the sum of the differences between the periodic data frame drift values of the last 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 values close to the current time is better, and thus the attenuation factor is adjusted to be smaller, so that the next predicted periodic data frame drift value has a prediction effect on the periodic data frame drift values far from the current time, thereby making the new predicted periodic data frame drift value closer to the actual periodic data frame drift value corresponding thereto.
[0060] In the embodiments of the present application, the aforementioned set number of times can be the same as or different from the aforementioned number threshold, which is not limited in the present application. When the aforementioned set number of times is the same as the aforementioned number threshold, only the periodic data frame drift values corresponding to the m periodic data frame acquirers close to the current time need to be acquired, 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 numbers of times at which the master station transmits periodic data frames at the current time, only the periodic data frame drift values corresponding to the a periodic data frame acquirers close to the current time need to be acquired, 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 numbers of times at which the master station transmits periodic data frames at the current time, the periodic data frame drift values corresponding to all the periodic data frame acquirers of the periodic data frames transmitted by the master station need to be acquired.
[0061] In the embodiments of the present application, the aforementioned calculation formula of the predicted periodic data frame drift value is used when the new predicted periodic data frame drift value is calculated by weighting the set number of times of the periodic data frame drift values acquired at the current time based on the adjusted or unadjusted attenuation factor, which is not described herein again.
[0062] In summary, by using the EtherCAT master clock synchronization scheme provided above, the embodiments of this application adjust the periodic data frame transmission period of the master clock based on the predicted periodic data frame drift value, thereby reducing clock drift between the master and slave stations and improving clock synchronization accuracy. Furthermore, in some embodiments, after the master clock has adjusted its period, it retransmits periodic data frames, calculates the corresponding periodic data frame drift value, and adjusts the attenuation factor based on the comparison between the retransmitted periodic data frame drift value and the predicted periodic data frame drift value. This dynamically adjusts the periodic data frame transmission period of the master clock, further improving clock synchronization accuracy.
[0063] This application also provides an EtherCAT master clock synchronization system, which can use the aforementioned EtherCAT master clock synchronization method 100 to synchronize the EtherCAT master clock, or other EtherCAT master clock synchronization methods. This application does not impose any restrictions on this method.
[0064] Figure 4 An exemplary structural block diagram of the EtherCAT master clock synchronization system according to an embodiment of this application is shown.
[0065] 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 embodiments of this 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 may be separate units or integrated into an integrated circuit; this application does not impose any restrictions here.
[0066] Specifically, the judgment module 410 is used to determine whether the current master station clock drift value is less than the clock drift threshold.
[0067] Specifically, the master station clock adjustment module 420 responds to the current master station clock drift value being not less than the clock drift threshold by 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.
[0068] 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.
[0069] Specifically, the prediction module 440 is used to obtain the predicted periodic data frame drift value based on the periodic data frame drift value of each periodic data frame.
[0070] In particular, the period adjustment module 450 is configured to adjust the period of sending the periodic data frame by the master station clock based on the predicted periodic data frame drift value.
[0071] When the system 400 performs the EtherCAT master station clock synchronization by using the aforementioned EtherCAT master station clock synchronization method 100, the determining module 410 performs the aforementioned step S110, the master station clock adjustment module 420 performs the aforementioned step S120, the calculating module 430 performs the aforementioned step S130, the predicting module 440 performs the aforementioned step S140, and the period adjustment module 450 performs the aforementioned step S150. The specific execution process can refer to the foregoing, and will not be described here again.
[0072] Although a number of embodiments of the present application have been illustrated and described, it will be clear to those skilled in the art that various changes, modifications and alternative can be made thereto without departing from the spirit and scope of the present application. It is intended that the appended claims be construed to cover all such changes, modifications and alternatives.
Claims
1. An EtherCAT master clock synchronization method, characterized in that, include: Determine whether the current main station clock drift value is less than the clock drift threshold; In response to the current master station clock drift value being no less than the clock drift threshold, 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; In response to the current master station clock drift value being less than the clock drift threshold, multiple periodic data frames are sent through the master station, and the drift value of each periodic data frame is calculated. The predicted periodic data frame drift value is obtained based on the drift value of each periodic data frame. The period of the master station clock sending periodic data frames is adjusted based on the predicted periodic data frame drift value; The predicted periodic data frame drift values obtained based on the periodic data frame drift values for each period include: Obtain the attenuation factor, where 0 < attenuation factor ≤ 1; The predicted periodic data frame drift value is obtained by weighting the drift values of each periodic data frame based on the attenuation factor. After the master station clock has been adjusted, it sends periodic data frames again and calculates the corresponding periodic data frame drift value. Determine whether the periodic data frame drift value corresponding to the retransmission of the periodic data frame is the same as the predicted periodic data frame drift value; In response to the fact that the periodic data frame drift value corresponding to the retransmission of the periodic data frame is the same as the predicted periodic data frame drift value, the attenuation factor is not adjusted. In response to the fact that the periodic data frame drift value corresponding to the retransmission of the periodic data frame is different from the predicted periodic data frame drift value, the attenuation factor is adjusted. The attenuation factor is adjusted using attenuation factor adjustment conditions; The attenuation factor adjustment condition is as follows: 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 retransmitting the periodic data frame, [n / 2] is the largest integer not exceeding n / 2, and ΔT drifti Let ΔT be the periodic data frame drift value corresponding to the i-th periodic data frame sent by the master station. predicted This represents the predicted periodic data frame drift value.
2. The EtherCAT master station clock synchronization method according to claim 1, characterized in that, The periodic data frame drift value is calculated using the formula for calculating the periodic data frame drift value: ΔT drift =T send -T recv , where ΔT drift T represents the periodic data frame drift value. 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 formula for calculating the predicted periodic data frame drift value is as follows: Where q is the attenuation factor, k is the number of periodic data frames sent by the master station, and ΔT drift1 The first periodic data frame drift value of the main station, ΔT drift2 The second periodic data frame drift value of the main station, ΔT driftn This is the drift value of the nth periodic data frame of the main station.
4. The EtherCAT master station clock synchronization method according to claim 1, characterized in that, The method further includes: The new predicted periodic data frame drift value is obtained by weighting the periodic data frame drift value obtained for a set number of times based on the current decay factor. The period of the periodic data frames sent by the master station clock is adjusted using the new predicted periodic data frame drift value.
5. The EtherCAT master station clock synchronization method according to claim 1, characterized in that, During the process of sending multiple periodic data frames through the main station, the following steps are performed: Determine whether the current number of times the main station sends periodic data frames has reached the threshold. In response to the current master station sending a periodic data frame reaching the threshold number of times, the master station stops sending periodic data frames; If the number of times the current master station sends periodic data frames has not reached the 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 threshold.
6. An EtherCAT master clock synchronization system, characterized in that, Clock synchronization is performed using the EtherCAT master clock synchronization method as described in any one of claims 1-5, and the system comprises: The judgment module is used to determine whether the current master station clock drift value is less than the clock drift threshold; The master station clock adjustment module, in response to the current master station clock drift value not being 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; The 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; The prediction module is used to obtain the predicted periodic data frame drift value based on the drift value of each periodic data frame. The period adjustment module is used to adjust the period of the master station clock sending periodic data frames 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
Cited By
EtherCAT master-slave clock synchronization method based on master-slave station integration
CN121814252A
EtherCAT Master-Slave Clock Synchronization Method Based on Master-Slave Station Integration
CN121814252B