Clock synchronization method, device, equipment and medium

By using the second pulse signal reference of the satellite clock, the counting time gap of the sensor device and the clock correction is obtained, the problem of cumbersome clock synchronization in the power system is solved, and efficient time synchronization of the sensor device is achieved.

CN120415618APending Publication Date: 2025-08-01SOUTHERN POWER GRID SENSING TECHNOLOGY (GUANGDONG) CO LTD

Patent Information

Application Number
CN202510557231.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

In the prior art, the multi-device clock synchronization method in the power system is cumbersome, making it difficult to achieve efficient timing consistency of multi-sensor equipment.

Method used

Using the second pulse signal of the satellite clock as a reference, by receiving the second pulse signal of the satellite clock, the counting time gap of the counter in the sensor device is obtained, the time deviation is determined, and the sampling clock of the sensor device is corrected to align it with the satellite clock.

Benefits of technology

The clock synchronization process is simplified, and time synchronization of multi-sensor devices is realized, without communication between sensor devices, ensuring the accurate consistency of sampling clocks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120415618A_ABST
    Figure CN120415618A_ABST
Patent Text Reader

Abstract

The invention relates to a clock synchronization method and device, equipment and a medium. The method comprises the following steps: receiving a second pulse signal of a satellite clock sent by a satellite; obtaining a counting time slot of a counter in the sensor equipment in each second pulse signal period; determining the time deviation between the sensor equipment and the satellite clock according to the counting time slot corresponding to each second pulse signal period; according to the time deviation, a sampling clock of the sensor equipment is corrected, and the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal. By adopting the method, the multi-device clock synchronization process can be simplified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of power systems, and in particular, to a clock synchronization method, apparatus, device, and medium. Background Art

[0002] In a power system, a large number of sensing devices are required to implement the detection, control, and protection of the power system, which depends on the timing consistency of multi-terminal sensing devices when sampling data.

[0003] In related technologies, when implementing time synchronization of multiple sensor devices in a power system, it is usually dependent on the mutual communication between the sensor devices, or the master control device uniformly manages the multiple sensor devices to ensure clock synchronization between the sensor devices.

[0004] However, the implementation process of the multi-device clock synchronization method in related technologies is relatively cumbersome. Summary of the Invention

[0005] Based on this, it is necessary to provide a clock synchronization method, apparatus, device, and medium that can simplify the multi-device clock synchronization process for the above technical problems.

[0006] In a first aspect, this application provides a clock synchronization method, including:

[0007] Receiving the second pulse signal of the satellite clock sent by the satellite;

[0008] Obtaining the counting time gap of the counter in the sensor device in each second pulse signal period;

[0009] Determining the time deviation between the sensor device and the satellite clock according to the counting time gaps corresponding to each second pulse signal period;

[0010] Correcting the sampling clock of the sensor device according to the time deviation, and aligning the sampling edge of the corrected sampling clock with the edge of the second pulse signal.

[0011] In one embodiment, obtaining the counting time gap of the counter in the sensor device in each second pulse signal period includes:

[0012] For any second pulse signal period, recording the accumulated count value of the counter corresponding to the second pulse signal period;

[0013] Determining the counting time gap of the second pulse signal period based on the ratio between the second pulse signal period and the accumulated count value.

[0014] In one embodiment, for any second pulse signal period, recording the accumulated count value of the counter corresponding to the second pulse signal period includes:

[0015] When the second pulse signal is received, the counter is triggered to clear and start counting again;

[0016] When the next second pulse signal after the received second pulse signal is received, the count value of the counter is recorded as the accumulated count value corresponding to the period of the second pulse signal.

[0017] In one embodiment, determining the time deviation between the sensor device and the satellite clock according to the counting time gaps corresponding to the periods of each second pulse signal includes:

[0018] Obtaining a preset number of consecutive second pulse signal periods;

[0019] According to the counting time gaps corresponding to the consecutive second pulse signal periods of the counter, obtaining the actual timing period of the sensor device;

[0020] Based on the difference between the actual timing period and the consecutive second pulse signal periods, determining the time deviation between the sensor device and the satellite clock.

[0021] In one embodiment, obtaining the actual timing period of the sensor device according to the counting time gaps corresponding to the consecutive second pulse signal periods of the counter includes:

[0022] According to the counting time gaps corresponding to the consecutive second pulse signal periods of the counter, determining the average time gap;

[0023] Accumulating the count values of the counter in the consecutive second pulse signal periods;

[0024] Calculating the product of the accumulation result and the average time gap to obtain the actual timing period of the sensor device.

[0025] In one embodiment, determining the average time gap according to the counting time gaps corresponding to the consecutive second pulse signal periods of the counter includes:

[0026] Performing weighted fusion on the counting time gaps corresponding to the consecutive second pulse signal periods according to the weight values of the consecutive second pulse signal periods to obtain the average time gap; or,

[0027] Determining the average value of the counting time gaps corresponding to the consecutive second pulse signal periods as the average time gap.

[0028] In one embodiment, correcting the sampling clock of the sensor device according to the time deviation includes:

[0029] If the time deviation is positive, shifting the sampling edge of the sampling clock forward by a length matching the time deviation in the direction of the rising edge to obtain the corrected sampling clock;

[0030] If the time deviation is negative, the sampling edge of the sampling clock is shifted backward by a length matching the time deviation in the direction of the falling edge to obtain the corrected sampling clock.

[0031] In a second aspect, the present application further provides a clock synchronization device, including:

[0032] A signal receiving module, configured to receive the second pulse signal of the satellite clock sent by the satellite;

[0033] A gap acquisition module, configured to acquire the counting time gap of the counter in the sensor device in each second pulse signal period;

[0034] A deviation determination module, configured to determine the time deviation between the sensor device and the satellite clock according to the counting time gaps corresponding to the respective second pulse signal periods;

[0035] A clock correction module, configured to correct the sampling clock of the sensor device according to the time deviation, and the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.

[0036] In a third aspect, the present application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the steps of the method in any one of the embodiments in the first aspect are implemented.

[0037] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method in any one of the embodiments in the first aspect are implemented.

[0038] In a fifth aspect, the present application further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps of the method in any one of the embodiments in the first aspect are implemented.

[0039] For the above clock synchronization method, device, equipment and medium, by receiving the second pulse signal of the satellite clock sent by the satellite, the counting time gap of the counter in the sensor device in each second pulse signal period is acquired; then, according to the counting time gaps corresponding to the respective second pulse signal periods, the time deviation between the sensor device and the satellite clock is determined; and according to the time deviation, the sampling clock of the sensor device is corrected, and the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal. In this way, based on the second pulse information sent by each satellite clock, the time error between the sensor and the satellite clock is determined, and the sampling clock of the sensor device is corrected, so that the sampling clocks of each sensor device are all aligned with the satellite clock, while achieving the clock synchronization of each sensor device, without introducing communication between sensor devices, and simplifying the clock synchronization process. Description of the Drawings

[0040] To more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the accompanying drawings required for the description of the embodiments of the present application or related technologies. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other related accompanying drawings can also be obtained based on these drawings.

[0041] Figure 1 It is an application environment diagram of the clock synchronization method in an embodiment;

[0042] Figure 2 It is a schematic flowchart of the clock synchronization method in an embodiment;

[0043] Figure 3 It is a schematic diagram of the internal modules of the sensor device in an embodiment;

[0044] Figure 4 It is a schematic flowchart of the counting time interval obtaining step in an embodiment;

[0045] Figure 5 It is a schematic flowchart of the time deviation obtaining step in an embodiment;

[0046] Figure 6 It is a schematic flowchart of the actual timing period obtaining step of the sensor device in an embodiment;

[0047] Figure 7 It is a timing schematic diagram of the second pulse signal period in an embodiment;

[0048] Figure 8 It is a timing comparison diagram of the second pulse signal period in an embodiment;

[0049] Figure 9 It is a structural block diagram of the clock synchronization device in an embodiment;

[0050] Figure 10 It is an internal structure diagram of the sensor device in an embodiment. Detailed implementation manners

[0051] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the following further details the present application in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0052] In a power system, a large number of sensing devices are required to achieve the detection, control, and protection of the power system, which depends on the timing consistency of multi-terminal sensing devices when sampling data. However, due to different hardware parameters, service life, and usage environments of sensor devices, the sampling time is offset, which will cause the collected data to be asynchronous and affect the later multi-modal data fusion and algorithm development. In this case, ensuring the sampling clock synchronization of multiple sensor devices is crucial for the fault monitoring, operation and maintenance, etc. of the power system.

[0053] In related technologies, when realizing time synchronization of multi-sensor devices in a power system, it is usually dependent on a communication device for mutual communication between each sensor device, or the master control device uniformly manages multiple sensor devices to ensure clock synchronization between each sensor device, and there is a problem of cumbersome steps in the clock synchronization method.

[0054] Based on this, the present application provides a clock synchronization method, device, equipment, and medium, which uses the second pulse signal (1 Pulse Per Second) of the satellite clock sent by the satellite as a reference signal to achieve the whole-second synchronization of multi-sensor devices.

[0055] Next, the technical solution of the present application and how the technical solution of the present application solves the above technical problems will be specifically described through embodiments in combination with the accompanying drawings. These specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments.

[0056] The clock synchronization method provided by the embodiments of the present application can be applied to, for example, Figure 1 the application environment shown. Among them, the satellite system 102 communicates with the sensor device 104 in the power system through an antenna. The power system includes multiple sensor devices 104, such as pressure sensors, temperature sensors, humidity sensors, etc.

[0057] In an exemplary embodiment, as Figure 2 shown, a clock synchronization method is provided. Taking this method applied to Figure 1 any one of the sensor devices as an example, the method includes the following steps:

[0058] S201, receive the second pulse signal of the satellite clock sent by the satellite.

[0059] Among them, the second pulse signal (1 Pulse Per Second) of the satellite clock is a time reference signal, which is the second pulse signal output by the satellite and has the characteristics of high precision and whole-second transmission. In the embodiments of the present application, the second pulse signal is used as the reference signal for multi-device sampling in the power system.

[0060] In an actual application scenario, the sensor device receives the second pulse signal sent by the satellite clock system through the antenna. Specifically, the internal structure schematic diagram of the sensor device is as Figure 3 shown, including a satellite signal receiving module, a timing module, and a data acquisition module. Among them, the satellite signal receiving module is used to capture or receive the second pulse signal sent by the satellite clock system through the antenna. The timing module includes an external crystal oscillator and a counter. The external crystal oscillator is connected to the satellite signal receiving module and is used to trigger the counter in the timing module to perform a counting operation according to the second pulse signal sent by the satellite signal receiving module. The data acquisition module includes a clock offset unit and a sampling clock. The clock offset unit determines the time deviation between the sampling clock and the satellite clock according to the count value of the counter in the timing module, and adjusts the sampling edge of the sampling clock to ensure the time consistency between the sampling clock and the satellite clock. In addition, the counting module also includes a standard time information calculation module, which is used to receive the standard time sent by the satellite signal receiving module through the serial port message, timestamp the collected data in seconds as the minimum unit, and obtain the sampled data.

[0061] S202, obtain the counting time gap of the counter in the sensor device in each second pulse signal period.

[0062] The second pulse signal period refers to the time interval between two adjacent second pulse messages, that is, one second. The counting time gap refers to the time interval between two adjacent counts of the counter. It should be known that the counter is continuously counting, and the counting frequency is usually higher than the sending frequency of the second pulse signal, which means that the counter will count multiple times in each second pulse signal period. In addition, due to factors such as the aging of the counter and the use environment, the counting frequency of the computer may fluctuate.

[0063] Record the initial count value and the termination count value of the counter in each second pulse signal period, take the difference between the termination count value and the initial count value as the cumulative count value of the counter in each second pulse signal period, calculate the ratio between each second pulse signal period and the cumulative count value, and obtain the counting time gap of the counter in each second pulse signal period.

[0064] S203, determine the time deviation between the sensor device and the satellite clock according to the counting time gap corresponding to each second pulse signal period.

[0065] Determine the actual time of the sensor device according to the counting time interval corresponding to each second pulse signal period and the count value of the internal counter of the sensor device in each second pulse signal period. Then, take the sum of each second pulse signal period as the reference time of the sensor device, and then calculate the difference between the actual time and the reference time of the sensor device to obtain the time deviation between the sensor device and the satellite clock.

[0066] S204. Correct the sampling clock of the sensor device according to the time deviation, and the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.

[0067] Move the sampling edge of the sampling clock of the sensor device forward by a length matching the time deviation in the rising edge direction of the sampling clock to obtain the corrected sampling clock, so that the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.

[0068] In the embodiment of the present application, by receiving the second pulse signal of the satellite clock sent by the satellite, obtain the counting time interval of the counter in the sensor device in each second pulse signal period; then determine the time deviation between the sensor device and the satellite clock according to the counting time interval corresponding to each second pulse signal period; correct the sampling clock of the sensor device according to the time deviation, and the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal. In this way, based on the second pulse information sent by each satellite clock as a reference, determine the time error between the sensor and the satellite clock, and correct the sampling clock of the sensor device, so that the sampling clock of each sensor device is aligned with the satellite clock, while realizing the clock synchronization of each sensor device, without introducing communication between sensor devices, simplifying the clock synchronization process.

[0069] As can be seen from the foregoing embodiments, the counting time interval of the counter in each second pulse signal period is an important basis for determining the time deviation. Then, in an exemplary embodiment, as Figure 4 shown, obtaining the counting time interval of the counter in the sensor device in each second pulse signal period includes the following steps:

[0070] S401. For any second pulse signal period, record the cumulative count value of the counter corresponding to the second pulse signal period.

[0071] The cumulative count value of the counter corresponding to the second pulse signal period is the cumulative value of the counter in the second pulse signal period. Generally, the count value of the counter increases continuously. Then, in the case where the counter is not cleared, it can be to record the initial count value of the counter at the initial moment of the second pulse signal period and the termination count value of the counter at the end moment of the second pulse signal period, and take the absolute value of the difference between the initial count value and the termination count value as the cumulative count value of the counter corresponding to the second pulse signal period.

[0072] In an actual application scenario, the cumulative count value can also be obtained by adjusting the counting condition of the counter. Exemplarily, when a second pulse signal is received, the counter is triggered to be cleared and re-counted; when the next second pulse signal after the second pulse signal is received, the count value of the counter is recorded as the cumulative count value corresponding to the second pulse signal period.

[0073] When a second pulse signal is received, the second pulse signal of the satellite clock is used to trigger the counting module inside the sensor device circuit to be cleared and reset for counting. In this way, at the moment of the next second pulse signal after the second pulse signal is received, that is, the moment when the calculation module of the sensor device needs to be triggered to be cleared again, the count value of the counter at the current moment is recorded as the cumulative count value of the counter corresponding to the second pulse signal period.

[0074] In the embodiment of the present application, the second pulse signal of the satellite clock is used to trigger the counting module inside the sensor device circuit to be cleared and reset for counting. By recording the count value of the timer at the end of the second pulse signal period, the cumulative count value of the counter corresponding to the second pulse signal period can be directly obtained, improving the acquisition speed of the cumulative count value.

[0075] S402. Determine the counting time interval of the second pulse signal period based on the ratio between the second pulse signal period and the cumulative count value.

[0076] Calculate the ratio between the second pulse signal period and the cumulative count value to obtain the counting interval when the counter works in the second pulse period, that is, the calculation time interval of the counter in this second pulse signal period.

[0077] In the embodiment of the present application, the cumulative count value of the counter corresponding to the second pulse signal period is recorded, and the counting time interval of the second pulse signal period is determined based on the ratio between the second pulse signal period and the cumulative count value, accurately monitoring the working state of the counter and providing a reliable basis for subsequent evaluation of the time deviation between the sensor device to which the counter belongs and the satellite clock.

[0078] In an exemplary embodiment, as Figure 5 shown, determining the time deviation between the sensor device and the satellite clock according to the counting time intervals corresponding to each second pulse signal period includes:

[0079] S501. Obtain a preset number of consecutive second pulse signal periods.

[0080] During the counting process of the counter in the sensor device, a time window with a preset length is determined, and this time window includes a preset number of consecutive second pulse signal periods.

[0081] S502. Obtain the actual timing period of the sensor device according to the counting time intervals corresponding to the counter in each consecutive second pulse signal period.

[0082] In the case of obtaining the counting time intervals corresponding to the counter in each period, perform a normalized weighting process on the counting time intervals corresponding to each consecutive second pulse signal period to obtain the average counting time interval of the counter. Take the average counting time interval as the time interval of the counter within each consecutive second pulse signal period, and calculate the product between the average counting time interval and the cumulative count values corresponding to the counter in each consecutive second pulse signal period to obtain the actual timing period of the sensor device.

[0083] S503. Determine the time deviation between the sensor device and the satellite clock based on the difference between the actual timing period and each consecutive second pulse signal period.

[0084] Accumulate the times of each consecutive second pulse signal period, and the accumulated result is the standard period. Take the calculation result of the difference between the actual timing period and the standard period as the total time deviation between the sensor device and the satellite clock corresponding to multiple consecutive second pulse signal periods. Then calculate the ratio between the total time deviation and each consecutive second pulse signal period as the time deviation between the sensor device and the satellite clock per unit time.

[0085] It should be noted that the time deviation is a vector value with a sign. In the embodiments of the present application, if the sign of the time deviation is positive, it indicates that the counting time interval of the counter in the sensor device is short, and the sampling time of the sensor is earlier than the standard time of the satellite clock; if the sign of the time deviation is negative, it indicates that the counting time interval of the counter in the sensor device is long, and the sampling time of the sensor is later than the standard time of the satellite clock.

[0086] In the embodiments of the present application, the actual timing period of the sensor device is obtained according to the counting time intervals corresponding to the counter in each consecutive second pulse signal period, the time deviation between the sensor device and the satellite clock is determined based on the difference between the actual timing period and each consecutive second pulse signal period, and the cumulative time deviation between the counter and the satellite clock corresponding to each consecutive second pulse signal period is determined by using the time sliding window method, so as to accurately determine the time deviation between the sensor device and the satellite clock per unit time and improve the accuracy of the time deviation.

[0087] In an exemplary embodiment, another implementation manner of the foregoing step S502, "Obtain the actual timing period of the sensor device according to the counting time intervals corresponding to the counter in each consecutive second pulse signal period", is described as follows Figure 6 shown, including the following steps:

[0088] S601. Determine the average time interval according to the counting time intervals corresponding to each consecutive second pulse signal period.

[0089] Taking each second pulse signal period as a time window, taking the current window as window C as an example, please refer to Figure 7 , Figure 7 is a schematic diagram of Q consecutive second pulse signal periods, where Q is a positive integer greater than 2, and C is a positive integer greater than (Q + 3). Assign weights to the counting time intervals corresponding to each consecutive second pulse signal period, calculate the weighted calculation results of each counting time interval, and obtain the average time interval.

[0090] Taking Q consecutive second pulse signal periods as an example, the average time interval has the following expression:

[0091] (Formula 1)

[0092] In the above formula, , and respectively represent the weights of the counting time intervals of the first period, the second period, and the Qth period in the consecutive second pulse signal periods; , and respectively represent the cumulative count values of the first period, the second period, and the Qth period in the consecutive second pulse signal periods.

[0093] In an exemplary embodiment, determining the average time interval according to the counting time intervals corresponding to each consecutive second pulse signal period includes:

[0094] Performing weighted fusion on the counting time intervals corresponding to each consecutive second pulse signal period according to the weight values of each consecutive second pulse signal period to obtain the average time interval; or, determining the average value of the counting time intervals corresponding to each consecutive second pulse signal period as the average time interval.

[0095] Optionally, calculate the average value of the counting time intervals corresponding to each consecutive second pulse signal period according to the number of consecutive pulse signal periods to obtain the average time interval. Taking the consecutive second pulse signal periods including three as an example, the average time interval has the following expression:

[0096] (Formula 2)

[0097] Optionally, based on the time of the window of the period distance of each consecutive second pulse signal period from the current second pulse signal period, the weight value of each second pulse signal period is gradually increased in the order from far to near. The closer the second pulse signal period is to the current moment, the greater the corresponding weight value. Taking the case where the consecutive second pulse signal periods include three as an example, the corresponding weight values are: 1 / 4, 1 / 3, 5 / 12, and the average time gap The expression of

[0098] (Formula 3)

[0099] In the embodiments of the present application, based on the counting time gap of multiple consecutive second pulse signal periods, the time gap is determined by using the average value or the weighted average method.

[0100] S602, accumulate the count values of the counter in each consecutive second pulse signal period.

[0101] Taking the consecutive second pulse signal period as as an illustration, the accumulation result The expression of

[0102] (Formula 4)

[0103] In the above formula, represents the accumulated count value corresponding to the i-th consecutive second pulse signal period of the counter.

[0104] S603, calculate the product of the accumulation result and the average time gap to obtain the actual timing period of the sensor device.

[0105] Taking the consecutive second pulse signal period as as an illustration, the actual timing period The expression of

[0106] (Formula 5)

[0107] Furthermore, the time deviation between the sensor device and the satellite clock is expressed as:

[0108] (Formula 6)

[0109] In the above formula, represents the reference time of the satellite clock in consecutive second pulse signal periods, represents the number of periods of the consecutive second pulse signal period.

[0110] In the embodiments of the present application, according to the counting time gaps corresponding to the counter in each consecutive second pulse signal period, the average time gap is determined, and the average time gap is used as the counting time gap of the counter in multiple consecutive second pulse signal periods. The product of the accumulated result and the average time gap is calculated to obtain the actual timing period of the internal sampling clock of the sensor device.

[0111] The foregoing embodiments have described the method for obtaining the clock deviation. Next, a feasible implementation manner for correcting the sampling clock of the sensor device according to the clock deviation will be further described. In an exemplary embodiment, correcting the sampling clock of the sensor device according to the time deviation includes:

[0112] If the time deviation is positive, the sampling edge of the sampling clock is shifted forward by a length matching the time deviation in the direction of the rising edge to obtain the corrected sampling clock; if the time deviation is negative, the sampling edge of the sampling clock is shifted backward by a length matching the time deviation in the direction of the falling edge to obtain the corrected sampling clock.

[0113] Please refer to Figure 8 , Figure 8 as the timing comparison diagram of the second pulse signal of the satellite clock, the sampling clock of the sensor device, and the counter inside the sensor device. It can be seen from Figure 8 that within the second pulse signal period, that is, within one second, there are multiple sampling points of the sampling clock, and the sampling period of the sampling clock matches the counting time gap of the counter. In the present application, when the time deviation is positive, it means that the time of the sampling clock is earlier than the satellite clock time. Then, in the direction of the rising edge, the sampling edge of the sampling clock is shifted by a length matching the time deviation to obtain the corrected sampling clock. When the time deviation is negative, it means that the time of the sampling clock is later than the satellite clock time. Then, in the direction opposite to the rising edge, that is, in the direction of the falling edge, the sampling edge of the sampling clock is shifted by a length matching the time deviation to obtain the corrected sampling clock.

[0114] In the embodiments of the present application, in the case where there is a time deviation between the sensor device and the satellite clock, the sampling clock of the sensor device is corrected based on the sign and length of the time deviation to ensure the time consistency between the sampling clock of the sensor device and the satellite clock.

[0115] In a specific embodiment, a clock synchronization method is provided, including the following steps:

[0116] (1) In response to the trigger request of the second pulse signal, trigger the counter inside the sensor device to reset the count, and obtain the accumulated count value corresponding to the counter in each second pulse signal period.

[0117] For any second pulse signal period, when the second pulse signal is received, the counter is triggered to be cleared and re - counted. When the next second pulse signal after the received second pulse signal is received, the count value of the counter is recorded as the cumulative count value corresponding to the second pulse signal period.

[0118] (2)Based on the ratio between the second pulse signal period and the cumulative count value, determine the counting time interval of the second pulse signal period.

[0119] (3)According to the counting time intervals corresponding to multiple consecutive second pulse signal periods of the counter, determine the average time interval.

[0120] Exemplarily, according to the weight values of each consecutive second pulse signal period, perform weighted fusion on the counting time intervals corresponding to each consecutive second pulse signal period to obtain the average time interval; or, determine the average value of the counting time intervals corresponding to each consecutive second pulse signal period as the average time interval.

[0121] (4)Accumulate the count values of the counter in each consecutive second pulse signal period.

[0122] (5)Calculate the product of the accumulation result and the average time interval to obtain the actual timing period of the sensor device.

[0123] (6)Based on the difference between the actual timing period and each consecutive second pulse signal period, determine the time deviation between the sensor device and the satellite clock.

[0124] (7)According to the time deviation, correct the sampling clock of the sensor device so that the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.

[0125] If the time deviation is positive, shift the sampling edge of the sampling clock forward by a length matching the time deviation in the direction of the rising edge to obtain the corrected sampling clock.

[0126] If the time deviation is negative, shift the sampling edge of the sampling clock backward by a length matching the time deviation in the direction of the falling edge to obtain the corrected sampling clock.

[0127] (8)According to the serial port message, calculate the Coordinated Universal Time (UTC) of the satellite clock, and timestamp the collected data in seconds as the minimum unit.

[0128] In this way, the sampling time of each sensor device is the same, which is the Coordinated Universal Time, realizing synchronous sampling of multi - terminal devices.

[0129] In the embodiments of the present application, based on the second pulse information sent by each satellite clock, the time error between the sensor and the satellite clock is determined, and the sampling clock of the sensor device is corrected so that the sampling clocks of each sensor device are aligned with the satellite clock. While achieving the clock synchronization of each sensor device, it is not necessary to introduce communication between sensor devices, simplifying the clock synchronization process.

[0130] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are sequentially shown according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same moment, but can be executed at different moments. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or steps or stages in other steps.

[0131] Based on the same inventive concept, the embodiments of the present application also provide a clock synchronization device for implementing the clock synchronization method involved above. The implementation solution provided by this device to solve the problem is similar to the implementation solution described in the above method. Therefore, the specific limitations in one or more embodiments of the following clock synchronization devices can refer to the limitations on the clock synchronization method in the above text and will not be repeated here.

[0132] In an exemplary embodiment, as Figure 9 shown, a clock synchronization device is provided, including: a signal receiving module 901, a gap obtaining module 902, a deviation determining module 903, and a clock correction module 904, where:

[0133] The signal receiving module 901 is configured to receive the second pulse signal of the satellite clock sent by the satellite;

[0134] The gap obtaining module 902 is configured to obtain the counting time gap of the counter in the sensor device in each second pulse signal period;

[0135] The deviation determining module 903 is configured to determine the time deviation between the sensor device and the satellite clock according to the counting time gaps corresponding to each second pulse signal period;

[0136] The clock correction module 904 is configured to correct the sampling clock of the sensor device according to the time deviation, and the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.

[0137] In an exemplary embodiment, the gap acquisition module 902 includes a count value recording unit and a gap calculation unit, where:

[0138] The count value recording unit is configured to record the accumulated count value of the counter corresponding to the second pulse signal period for any second pulse signal period.

[0139] The gap calculation unit is configured to determine the counting time gap of the second pulse signal period based on the ratio between the second pulse signal period and the accumulated count value.

[0140] In an exemplary embodiment, the count value recording unit includes a counter clearing subunit and an accumulated value determination subunit, where:

[0141] The counter clearing subunit is configured to trigger the counter to clear and re - count when receiving the second pulse signal.

[0142] The accumulated value determination subunit is configured to record the count value of the counter as the accumulated count value corresponding to the second pulse signal period when receiving the next second pulse signal after receiving the second pulse signal.

[0143] In an exemplary embodiment, the deviation determination module 903 includes a window determination unit, a period acquisition unit, and a deviation calculation unit, where:

[0144] The window determination unit is configured to obtain a preset number of consecutive second pulse signal periods.

[0145] The period acquisition unit is configured to obtain the actual timing period of the sensor device according to the counting time gaps corresponding to the counter in each consecutive second pulse signal period.

[0146] The deviation calculation unit is configured to determine the time deviation between the sensor device and the satellite clock based on the difference between the actual timing period and each consecutive second pulse signal period.

[0147] In an exemplary embodiment, the period acquisition unit includes an average gap calculation subunit, a count value accumulation subunit, and a period calculation subunit, where:

[0148] The average gap calculation subunit is configured to determine the average time gap according to the counting time gaps corresponding to the counter in each consecutive second pulse signal period.

[0149] The count value accumulation subunit is configured to accumulate the count values of the counter in each consecutive second pulse signal period.

[0150] The period calculation subunit is configured to calculate the product of the accumulation result and the average time gap to obtain the actual timing period of the sensor device.

[0151] In an exemplary embodiment, the average gap calculation sub-unit is further configured to perform weighted fusion on the counting time gaps corresponding to the continuous second pulse signal periods according to the weight values of the continuous second pulse signal periods to obtain an average time gap; or determine the average value of the counting time gaps corresponding to the continuous second pulse signal periods as the average time gap.

[0152] In an exemplary embodiment, the clock correction module 904 includes a first correction unit and a second correction unit, where:

[0153] The first correction unit is configured to, when the time deviation is positive, shift the sampling edge of the sampling clock forward by a length matching the time deviation in the direction of the rising edge to obtain a corrected sampling clock;

[0154] The first correction unit is configured to, when the time deviation is [not specified in the original, please check], shift the sampling edge of the sampling clock backward by a length matching the time deviation in the direction of the falling edge to obtain a corrected sampling clock.

[0155] Each module in the above clock synchronization device can be implemented in whole or in part by software, hardware, and their combination. Each of the above modules can be embedded in the processor in the computer device in hardware form or be independent of it, or can be stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to each of the above modules.

[0156] In an exemplary embodiment, a computer device is provided. The computer device can be a sensor device, and its internal structure diagram can be as Figure 10As shown in the figure. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, near field communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a clock synchronization method. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the outer shell of the computer device, or an external keyboard, touchpad, or mouse, etc.

[0157] Those skilled in the art can understand that Figure 10 the structure shown in the figure is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0158] In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the following steps are implemented:

[0159] Receive the second pulse signal of the satellite clock sent by the satellite;

[0160] Obtain the counting time gap of the counter in the sensor device in each second pulse signal period;

[0161] Determine the time deviation between the sensor device and the satellite clock according to the counting time gaps corresponding to each second pulse signal period;

[0162] According to the time deviation, correct the sampling clock of the sensor device, and the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.

[0163] In one embodiment, when the processor executes the computer program, the following steps are further implemented:

[0164] For any second pulse signal period, record the cumulative count value of the counter corresponding to the second pulse signal period;

[0165] Based on the ratio between the second pulse signal period and the cumulative count value, determine the counting time interval of the second pulse signal period.

[0166] In one embodiment, when the processor executes the computer program, the following steps are further implemented:

[0167] When receiving the second pulse signal, trigger the counter to clear and start counting again;

[0168] When receiving the next second pulse signal after receiving the second pulse signal, record the count value of the counter as the cumulative count value corresponding to the second pulse signal period.

[0169] In one embodiment, when the processor executes the computer program, the following steps are further implemented:

[0170] Obtain a preset number of consecutive second pulse signal periods;

[0171] According to the counting time intervals of the counter corresponding to each consecutive second pulse signal period, obtain the actual timing period of the sensor device;

[0172] Based on the difference between the actual timing period and each consecutive second pulse signal period, determine the time deviation between the sensor device and the satellite clock.

[0173] In one embodiment, when the processor executes the computer program, the following steps are further implemented:

[0174] According to the counting time intervals of the counter corresponding to each consecutive second pulse signal period, determine the average time interval;

[0175] Accumulate the count values of the counter for each consecutive second pulse signal period;

[0176] Calculate the product of the accumulation result and the average time interval to obtain the actual timing period of the sensor device.

[0177] In one embodiment, when the processor executes the computer program, the following steps are further implemented:

[0178] According to the weight values of each consecutive second pulse signal period, perform weighted fusion on the counting time intervals corresponding to each consecutive second pulse signal period to obtain the average time interval; or,

[0179] Determine the average value of the counting time intervals corresponding to each consecutive second pulse signal period as the average time interval.

[0180] In one embodiment, when the processor executes the computer program, the following steps are further implemented:

[0181] If the time deviation is positive, the sampling edge of the sampling clock is offset forward by a length matching the time deviation in the direction of the rising edge to obtain a corrected sampling clock;

[0182] If the time deviation is negative, the sampling edge of the sampling clock is offset backward by a length matching the time deviation in the direction of the falling edge to obtain a corrected sampling clock.

[0183] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0184] Receive the second pulse signal of the satellite clock sent by the satellite;

[0185] Obtain the counting time gap of the counter in each second pulse signal period in the sensor device;

[0186] Determine the time deviation between the sensor device and the satellite clock according to the counting time gaps corresponding to each second pulse signal period;

[0187] According to the time deviation, correct the sampling clock of the sensor device so that the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.

[0188] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:

[0189] For any second pulse signal period, record the accumulated count value of the counter corresponding to the second pulse signal period;

[0190] Based on the ratio between the second pulse signal period and the accumulated count value, determine the counting time gap of the second pulse signal period.

[0191] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:

[0192] When the second pulse signal is received, trigger the counter to be cleared and start counting again;

[0193] When the next second pulse signal after receiving the second pulse signal is received, record the count value of the counter as the accumulated count value corresponding to the second pulse signal period.

[0194] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:

[0195] Obtain a preset number of consecutive second pulse signal periods;

[0196] Based on the counting time intervals corresponding to the counter in each consecutive second pulse signal period, obtain the actual timing period of the sensor device;

[0197] Based on the difference between the actual timing period and each consecutive second pulse signal period, determine the time deviation between the sensor device and the satellite clock.

[0198] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:

[0199] Based on the counting time intervals corresponding to the counter in each consecutive second pulse signal period, determine the average time interval;

[0200] Accumulate the count values of the counter in each consecutive second pulse signal period;

[0201] Calculate the product of the accumulation result and the average time interval to obtain the actual timing period of the sensor device.

[0202] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:

[0203] According to the weight values of each consecutive second pulse signal period, perform weighted fusion on the counting time intervals corresponding to each consecutive second pulse signal period to obtain the average time interval; or,

[0204] Determine the average value of the counting time intervals corresponding to each consecutive second pulse signal period as the average time interval.

[0205] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:

[0206] If the time deviation is positive, shift the sampling edge of the sampling clock forward by a length matching the time deviation in the direction of the rising edge to obtain the corrected sampling clock;

[0207] If the time deviation is negative, shift the sampling edge of the sampling clock backward by a length matching the time deviation in the direction of the falling edge to obtain the corrected sampling clock.

[0208] In one embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0209] Receive the second pulse signal of the satellite clock sent by the satellite;

[0210] Obtain the counting time interval of the counter in the sensor device in each second pulse signal period;

[0211] Based on the counting time intervals corresponding to each second pulse signal period, determine the time deviation between the sensor device and the satellite clock;

[0212] According to the time deviation, correct the sampling clock of the sensor device so that the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.

[0213] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented:

[0214] For any second pulse signal period, record the cumulative count value of the counter corresponding to the second pulse signal period;

[0215] Based on the ratio between the second pulse signal period and the cumulative count value, determine the counting time gap of the second pulse signal period.

[0216] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented:

[0217] When receiving the second pulse signal, trigger the counter to clear and start counting again;

[0218] When receiving the next second pulse signal after receiving the second pulse signal, record the count value of the counter as the cumulative count value corresponding to the second pulse signal period.

[0219] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented:

[0220] Obtain a preset number of consecutive second pulse signal periods;

[0221] According to the counting time gaps of the counter corresponding to each consecutive second pulse signal period, obtain the actual timing period of the sensor device;

[0222] Based on the difference between the actual timing period and each consecutive second pulse signal period, determine the time deviation between the sensor device and the satellite clock. [[ID=3II]]

[0223] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented:

[0224] According to the counting time gaps of the counter corresponding to each consecutive second pulse signal period, determine the average time gap;

[0225] Accumulate the count values of the counter in each consecutive second pulse signal period;

[0226] Calculate the product of the accumulated result and the average time gap to obtain the actual timing period of the sensor device.

[0227] In one embodiment, when the computer program is executed by the processor, the following steps are further implemented: [

[0228] According to the weight values of each consecutive second pulse signal period, perform weighted fusion on the counting time gaps corresponding to each consecutive second pulse signal period to obtain the average time gap; or,

[0229] Determine the average of the counting time intervals corresponding to the periods of each consecutive second pulse signal as the average time interval.

[0230] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:

[0231] If the time deviation is positive, shift the sampling edge of the sampling clock forward in the direction of the rising edge by a length matching the time deviation to obtain a corrected sampling clock;

[0232] If the time deviation is negative, shift the sampling edge of the sampling clock backward in the direction of the falling edge by a length matching the time deviation to obtain a corrected sampling clock.

[0233] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.

[0234] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, data processing logics based on quantum computing, artificial intelligence (AI) processors, etc., without limitation.

[0235] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in the present application.

[0236] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims

1. A clock synchronization method, characterized in that, The method includes: Receiving the second pulse signal of the satellite clock sent by the satellite; Obtaining the counting time gap of the counter in the sensor device in each second pulse signal period; Determining the time deviation between the sensor device and the satellite clock according to the counting time gaps corresponding to the respective second pulse signal periods; Correcting the sampling clock of the sensor device according to the time deviation, and aligning the sampling edge of the corrected sampling clock with the edge of the second pulse signal.

2. The method according to claim 1, characterized in that, The obtaining the counting time gap of the counter in the sensor device in each second pulse signal period includes: For any second pulse signal period, recording the cumulative count value of the counter corresponding to the second pulse signal period; Determining the counting time gap of the second pulse signal period based on the ratio between the second pulse signal period and the cumulative count value.

3. The method according to claim 2, wherein The for any second pulse signal period, recording the cumulative count value of the counter corresponding to the second pulse signal period includes: When receiving the second pulse signal, triggering the counter to be cleared and re-counted; When receiving the next second pulse signal after receiving the second pulse signal, recording the count value of the counter as the cumulative count value corresponding to the second pulse signal period.

4. The method according to any one of claims 1-3, characterized in that, The determining the time deviation between the sensor device and the satellite clock according to the counting time gaps corresponding to the respective second pulse signal periods includes: Obtaining a preset number of consecutive second pulse signal periods; Obtaining the actual timing period of the sensor device according to the counting time gaps of the counter corresponding to the respective consecutive second pulse signal periods; Determining the time deviation between the sensor device and the satellite clock based on the difference between the actual timing period and the respective consecutive second pulse signal periods.

5. The method according to claim 4, wherein The obtaining the actual timing period of the sensor device according to the counting time gaps of the counter corresponding to the respective consecutive second pulse signal periods includes: Determining the average time gap according to the counting time gaps of the counter corresponding to the respective consecutive second pulse signal periods; Accumulating the count values of the counter in the respective consecutive second pulse signal periods; Calculating the product of the accumulation result and the average time gap to obtain the actual timing period of the sensor device.

6. The method according to claim 5, characterized in that, The determining the average time gap according to the counting time gaps of the counter corresponding to the respective consecutive second pulse signal periods includes: Performing weighted fusion on the counting time gaps corresponding to the respective consecutive second pulse signal periods according to the weight values of the respective consecutive second pulse signal periods to obtain the average time gap; or, Determining the average value of the counting time gaps corresponding to the respective consecutive second pulse signal periods as the average time gap.

7. The method according to any one of claims 1 to 3, characterized in that, The correcting the sampling clock of the sensor device according to the time deviation includes: If the time deviation is positive, shifting the sampling edge of the sampling clock forward in the direction of the rising edge by a length matching the time deviation to obtain the corrected sampling clock; If the time deviation is negative, offset the sampling edge of the sampling clock in the direction of the falling edge by a length matching the time deviation to obtain a corrected sampling clock.

8. A clock synchronization device, characterized in that The device includes: a signal receiving module, configured to receive the second pulse signal of the satellite clock sent by a satellite; a gap obtaining module, configured to obtain the counting time gap of a counter in a sensor device in each second pulse signal period; a deviation determining module, configured to determine the time deviation between the sensor device and the satellite clock according to the counting time gaps corresponding to the respective second pulse signal periods; a clock correction module, configured to correct the sampling clock of the sensor device according to the time deviation, and the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.

9. A sensor device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Time synchronization system and method of satellite signal simulator, and satellite signal simulator

    CN111007537A

  • Time synchronization method, sensor and system

    CN113572556A

  • Unmanned aerial vehicle platform multi-sensor data synchronous acquisition system based on ZYNQ

    CN116577802A

  • Remote sensing camera time system error compensation method based on satellite broadcast

    CN117850202A

Cited By

  • Pulse synchronization method, electronic device, storage medium and program product

    CN121173448A

  • On-satellite time synchronization method and system based on pulse per second

    CN121785086A