Clock synchronization methods, devices, equipment and media
By receiving the second pulse signal from the satellite clock, the counter time interval of the sensor device is obtained, the time deviation is determined, and the sampling clock is corrected. This solves the cumbersome problem of clock synchronization for multiple devices in the power system and achieves time consistency synchronization of the sensor devices.
Patent Information
- Application Number
- CN202510557231.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-29
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2045-04-29
AI Technical Summary
In existing technologies, the methods for synchronizing the clocks of multiple devices in power systems are cumbersome and make it difficult to achieve clock synchronization for multiple sensor devices.
Using the second pulse signal transmitted by the satellite clock as a reference, the time deviation is determined by receiving, counting and correcting the time gap of the counter of the sensor device, and the sampling clock of the sensor device is corrected to align it with the satellite clock.
It simplifies the clock synchronization process, enables clock synchronization of multiple sensor devices, eliminates the need for communication between sensor devices, and ensures the time consistency of sampling clocks.
Smart Images

Figure CN120415618B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of power system technology, and in particular to a clock synchronization method, apparatus, device, and medium. Background Technology
[0002] In power systems, a large number of sensing devices are needed to realize 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 synchronizing the time of multiple sensor devices in a power system, it is usually done by relying on the mutual communication between the individual sensor devices, or by having a master control device manage multiple sensor devices in a unified manner to ensure clock synchronization between the individual sensor devices.
[0004] However, the implementation process of multi-device clock synchronization methods in related technologies is quite cumbersome. Summary of the Invention
[0005] Therefore, it is necessary to provide a clock synchronization method, apparatus, device, and medium that can simplify the clock synchronization process for multiple devices, addressing the aforementioned technical problems.
[0006] In a first aspect, this application provides a clock synchronization method, including:
[0007] Receive the second pulse signal of the satellite clock transmitted by the satellite;
[0008] Obtain the counting time interval of the counter in the sensor device in each second pulse signal cycle;
[0009] The time deviation between the sensor device and the satellite clock is determined based on the counting time interval corresponding to each second pulse signal period;
[0010] The sampling clock of the sensor device is corrected according to the time deviation, and the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.
[0011] In one embodiment, obtaining the counting time interval of the counter in the sensor device in each second pulse signal cycle includes:
[0012] For any second pulse signal period, record the accumulated count value of the counter corresponding to the second pulse signal period;
[0013] The counting time interval of the second pulse signal period is determined based on the ratio between the period of the second pulse signal and the accumulated count value.
[0014] In one embodiment, for any given second pulse signal period, the accumulated count value of the record counter during that second pulse signal period includes:
[0015] Upon receiving a second pulse signal, the counter is triggered to reset to zero and start counting again;
[0016] Upon receiving the next second pulse signal of the second pulse signal, the counter value is recorded as the accumulated count value corresponding to the second pulse signal period.
[0017] In one embodiment, determining the time deviation between the sensor device and the satellite clock based on the counting time interval corresponding to each second pulse signal period includes:
[0018] Obtain a preset number of continuous second pulse signal cycles;
[0019] The actual timing cycle of the sensor device is obtained by the counting time interval corresponding to each consecutive second pulse signal cycle of the counter.
[0020] The time deviation between the sensor device and the satellite clock is determined based on the difference between the actual timing period and the period of each continuous second pulse signal.
[0021] In one embodiment, the actual timing cycle of the sensor device is obtained based on the counting time interval corresponding to each consecutive second pulse signal period of the counter, including:
[0022] The average time interval is determined based on the counting time interval corresponding to each consecutive second pulse signal period of the counter;
[0023] The counter counts are accumulated during each consecutive second pulse signal cycle;
[0024] The actual timing cycle of the sensor device is obtained by multiplying the accumulated result with the average time interval.
[0025] In one embodiment, determining the average time interval based on the counting time interval corresponding to each consecutive second pulse signal period of the counter includes:
[0026] Based on the weight values of each consecutive second pulse signal period, the counting time intervals corresponding to each consecutive second pulse signal period are weighted and fused to obtain the average time interval; or,
[0027] The average time gap is determined by the average value of the counting time gaps corresponding to each consecutive second pulse signal period.
[0028] In one embodiment, the sampling clock of the sensor device is corrected according to the time deviation, including:
[0029] 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.
[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] Secondly, this application also provides a clock synchronization device, comprising:
[0032] The signal receiving module is used to receive the second pulse signal of the satellite clock transmitted by the satellite;
[0033] The gap acquisition module is used to acquire the counting time gap of the counter in the sensor device in each second pulse signal cycle;
[0034] The deviation determination module is used to determine the time deviation between the sensor device and the satellite clock based on the counting time interval corresponding to each second pulse signal period;
[0035] The clock correction module is used 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] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method in any of the embodiments of the first aspect described above.
[0037] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method in any of the embodiments of the first aspect described above.
[0038] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method in any of the embodiments of the first aspect described above.
[0039] The aforementioned clock synchronization method, apparatus, device, and medium obtain the counting time interval of the counter in the sensor device in each second pulse signal period by receiving the second pulse signal of the satellite clock transmitted by the satellite; then, based on the counting time interval corresponding to each second pulse signal period, determine the time deviation between the sensor device and the satellite clock; and correct the sampling clock of the sensor device according to the time deviation, aligning the sampling edge of the corrected sampling clock with the edge of the second pulse signal. In this way, using the second pulse information transmitted by each satellite clock as a reference, the time error between the sensor and the satellite clock is determined, and the sampling clock of the sensor device is corrected, ensuring that the sampling clock of each sensor device is aligned with the satellite clock. This achieves clock synchronization of all sensor devices without introducing communication between the sensor devices, simplifying the clock synchronization process. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0041] Figure 1 This is a diagram illustrating the application environment of a clock synchronization method in one embodiment;
[0042] Figure 2 This is a flowchart illustrating a clock synchronization method in one embodiment;
[0043] Figure 3 This is a schematic diagram of the internal modules of a sensor device in one embodiment;
[0044] Figure 4 This is a flowchart illustrating the step of obtaining the counting time gap in one embodiment;
[0045] Figure 5 This is a flowchart illustrating the time deviation acquisition steps in one embodiment;
[0046] Figure 6 This is a flowchart illustrating the steps for obtaining the actual timing cycle of a sensor device in one embodiment;
[0047] Figure 7 This is a timing diagram of the second pulse signal period in one embodiment;
[0048] Figure 8 This is a timing comparison diagram of the period of the second pulse signal in one embodiment;
[0049] Figure 9 This is a structural block diagram of the clock and co-processor in one embodiment;
[0050] Figure 10 This is an internal structural diagram of a sensor device in one embodiment. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0052] In power systems, numerous sensors are required for detection, control, and protection, which relies on the time consistency of data sampling across multiple sensors. However, due to differences in hardware parameters, age, and operating environments, sensor sampling times can shift, leading to asynchronous data collection and impacting subsequent multimodal data fusion and algorithm development. Therefore, ensuring clock synchronization across multiple sensors is crucial for power system fault monitoring and maintenance.
[0053] In related technologies, when realizing time synchronization of multiple sensor devices in a power system, communication devices are usually used to facilitate communication between the various sensor devices, or a main control device manages multiple sensor devices in a unified manner to ensure clock synchronization between the various sensor devices. However, this method involves cumbersome steps.
[0054] Based on this, this application provides a clock synchronization method, apparatus, device, and medium that uses the second pulse signal (1 Pulse Per Second) of the satellite clock transmitted by the satellite as a reference signal to achieve whole-second synchronization of multi-sensor devices.
[0055] The technical solutions of this application and how they solve the aforementioned technical problems will be described in detail below through embodiments and in conjunction with the accompanying drawings. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments.
[0056] The clock synchronization method provided in this application can be applied to, for example, Figure 1 In the application environment shown, the satellite system 102 communicates with sensor devices 104 in the power system via an antenna. The power system includes multiple sensor devices 104, such as pressure sensors, temperature sensors, and humidity sensors.
[0057] In one exemplary embodiment, such as Figure 2 As shown, a clock synchronization method is provided, which can be applied to... Figure 1 Taking any of the sensor devices in the diagram as an example, the following steps are included:
[0058] S201 receives the second pulse signal of the satellite clock transmitted by the satellite.
[0059] The satellite clock's 1 Pulse Per Second (PPS) signal is a time reference signal, a PPS signal output by the satellite, characterized by high precision and transmission in whole seconds. In this embodiment, the PPS signal is used as the reference signal for multi-device sampling in the power system.
[0060] In practical applications, sensor devices receive second pulse signals transmitted by a satellite clock system via an antenna. Specifically, a schematic diagram of the internal structure of the sensor device is shown below. Figure 3 As shown, the system includes a satellite signal receiving module, a timing module, and a data acquisition module. The satellite signal receiving module captures or receives second pulse signals transmitted by a satellite clock system via an 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 triggers the counter in the timing module to perform a counting operation based on the second pulse signal transmitted 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 based on the count value of the counter in the timing module and adjusts the sampling edge of the sampling clock to ensure time consistency between the sampling clock and the satellite clock. Additionally, the timing module includes a standard time information calculation module, which receives the standard time transmitted by the satellite signal receiving module via serial port messages and timestamps the acquired data in seconds to obtain the sampled data.
[0061] S202, Obtain the counting time interval of the counter in the sensor device in each second pulse signal cycle.
[0062] The second pulse signal period refers to the time interval between two adjacent second pulse messages, which is one second. The counting interval refers to the time interval between two consecutive counts by the counter. It should be noted that the counter counts continuously, and the counting frequency is usually higher than the transmission frequency of the second pulse signal, meaning that the counter counts multiple times per second pulse signal period. Furthermore, due to factors such as counter aging and the operating environment, the computer's counting frequency may fluctuate.
[0063] Record the initial and final count values of the counter in each second pulse signal cycle. Use the difference between the final count value and the initial count value as the accumulated count value of the counter in each second pulse signal cycle. Calculate the ratio between each second pulse signal cycle and the accumulated count value to obtain the counting time interval of the counter in each second pulse signal cycle.
[0064] S203, determine the time deviation between the sensor device and the satellite clock based on the counting time gap corresponding to each second pulse signal period.
[0065] Based on the counting time gap corresponding to each second pulse signal period and the count value of the internal counter of the sensor device corresponding to each second pulse signal period, the actual time of the sensor device is determined. Then, the sum of each second pulse signal period is used as the reference time of the sensor device. Finally, the difference between the actual time of the sensor device and the reference time is calculated to obtain the time deviation between the sensor device and the satellite clock.
[0066] S204, 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.
[0067] According to the rising edge direction of the sampling clock, the sampling edge of the sampling clock of the sensor device is moved forward by a length matching the time deviation 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 this embodiment, the counting time interval of the counter in the sensor device in each second pulse signal period is obtained by receiving the second pulse signal of the satellite clock transmitted by the satellite. Then, based on the counting time interval corresponding to each second pulse signal period, the time deviation between the sensor device and the satellite clock is determined. 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, the time error between the sensor and the satellite clock is determined based on the second pulse information transmitted by each satellite clock, and the sampling clock of the sensor device is corrected so that the sampling clock of each sensor device is aligned with the satellite clock. This achieves clock synchronization of each sensor device without introducing communication between the 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 cycle is an important basis for determining the time deviation. Therefore, in an exemplary embodiment, such as... Figure 4 As shown, obtaining the counting time interval of the counter in the sensor device in each second pulse signal cycle includes the following steps:
[0070] S401, for any second pulse signal period, record the accumulated count value of the counter corresponding to the second pulse signal period.
[0071] The accumulated count value of the counter during the second pulse signal period is the cumulative value of the counter during that period. Normally, the counter's count value continuously increases. Therefore, without resetting the counter, the initial count value at the beginning of the second pulse signal period and the final count value at the end of the second pulse signal period can be recorded. The absolute value of the difference between the initial and final count values can be used as the accumulated count value of the counter during the second pulse signal period.
[0072] In practical applications, the accumulated count value can also be obtained by adjusting the counting conditions of the counter. For example, upon receiving a second pulse signal, the counter is triggered to reset and start counting again; upon receiving the next second pulse signal, the counter's count value is recorded as the accumulated count value corresponding to the second pulse signal period.
[0073] Upon receiving a second pulse signal, the second pulse signal from the satellite clock triggers the counting module inside the sensor device circuit to clear and reset the count. Thus, at the moment when the next second pulse signal is received, which is the moment when the sensor device's calculation module needs to be cleared again, the counter value at the current moment is recorded as the cumulative count value of the counter corresponding to the second pulse signal cycle.
[0074] In this embodiment, the second pulse signal of the satellite clock triggers the counting module inside the sensor device circuit to clear and reset the count. By recording the count value of the timer at the end of the second pulse signal period, the accumulated count value of the counter corresponding to the second pulse signal period is directly obtained, thereby improving the acquisition speed of the accumulated count value.
[0075] S402, based on the ratio between the period of the second pulse signal and the accumulated count value, determine the counting time interval of the second pulse signal period.
[0076] Calculate the ratio between the second pulse signal period and the accumulated count value to obtain the counting interval of the counter when it operates during the second pulse period, which is the calculation time interval of the counter during that second pulse signal period.
[0077] In this embodiment, the accumulated count value of the counter is recorded in the second pulse signal period, 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 accumulated count value. This accurately monitors the working status of the counter and provides 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 one exemplary embodiment, such as Figure 5 As shown, the time deviation between the sensor device and the satellite clock is determined based on the counting time interval corresponding to each second pulse signal period, including:
[0079] S501, obtain a preset number of continuous second pulse signal cycles.
[0080] During the counting process of the counter in the sensor device, a time window of a preset length is defined, which includes a preset number of continuous second pulse signal cycles.
[0081] S502, based on the counting time interval corresponding to each consecutive second pulse signal cycle of the counter, obtain the actual timing cycle of the sensor device.
[0082] Given the counter's counting time interval for each cycle, the counting time intervals for each consecutive second pulse signal cycle are normalized and weighted to obtain the average counting time interval of the counter. The average counting time interval is then used as the counter's time interval within each consecutive second pulse signal cycle. The product of the average counting time interval and the accumulated count value of the counter within each consecutive second pulse signal cycle is calculated to obtain the actual timing cycle of the sensor device.
[0083] S503 determines the time deviation between the sensor device and the satellite clock based on the difference between the actual timing period and the period of each continuous second pulse signal.
[0084] The times of each consecutive second pulse signal period are accumulated, and the accumulated result is the standard period. The difference between the actual timing period and the standard period is calculated as the total time deviation between the sensor device and the satellite clock for multiple consecutive second pulse signal periods. Then, the ratio between the total time deviation and each consecutive second pulse signal period is calculated 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 this 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 this embodiment, the actual timing cycle of the sensor device is obtained based on the counting time interval corresponding to each consecutive second pulse signal cycle of the counter. Based on the difference between the actual timing cycle and each consecutive second pulse signal cycle, the time deviation between the sensor device and the satellite clock is determined. By using a time sliding window method, the cumulative time deviation between the counter and the satellite clock corresponding to each consecutive second pulse signal cycle is determined, thereby accurately determining the time deviation between the sensor device and the satellite clock within a unit time, so as to improve the accuracy of the time deviation.
[0087] In one exemplary embodiment, another implementation of the aforementioned step S502, "obtaining the actual timing cycle of the sensor device based on the counting time interval corresponding to each consecutive second pulse signal cycle of the counter," will be described, such as... Figure 6 As shown, it includes the following steps:
[0088] S601 determines the average time interval based on the counting time interval corresponding to each consecutive second pulse signal period of the counter.
[0089] Taking each second pulse signal period as a time window, and the current window as window C, please refer to [link to relevant documentation]. Figure 7 , Figure 7 This diagram illustrates Q consecutive second pulse signal cycles, where Q is a positive integer greater than 2 and C is a positive integer greater than (Q+3). Weights are assigned to the counter for each consecutive second pulse signal cycle's counting time interval, and the weighted calculation results for each counting time interval are obtained to obtain the average time interval.
[0090] Taking the period of a continuous second pulse signal as Q as an example, the average time interval The expression is as follows:
[0091] (Formula 1)
[0092] In the above formula, , as well as These represent the weights of the counting time gaps in the first, second, and Qth cycles of a continuous second pulse signal, respectively. , as well as These represent the accumulated count values for the first cycle, the second cycle, and the Qth cycle of the continuous second pulse signal, respectively.
[0093] In an exemplary embodiment, determining the average time interval based on the counting time interval corresponding to each consecutive second pulse signal period of the counter includes:
[0094] The average time gap is obtained by weighting and fusing the counting time gaps corresponding to each consecutive second pulse signal period according to the weight value of each consecutive second pulse signal period; or, the average value of the counting time gaps corresponding to each consecutive second pulse signal period is determined as the average time gap.
[0095] Optionally, the average time gap is obtained by calculating the average of the counting time gaps corresponding to each consecutive second pulse signal period, based on the number of consecutive pulse signal periods. Taking three consecutive second pulse signal periods as an example, the average time gap... The expression is as follows:
[0096] (Formula 2)
[0097] Optionally, based on the time window between each consecutive second pulse signal period and the current second pulse signal period, the weight values of each second pulse signal period are gradually increased in order from farthest to nearest, with the weight value of the second pulse signal period being larger the closer it is to the current time. Taking three consecutive second pulse signal periods as an example, the corresponding weight values are 1 / 4, 1 / 3, and 5 / 12, respectively, representing the average time interval. The expression is as follows:
[0098] (Formula 3)
[0099] In this embodiment of the application, the time interval is determined based on the counting time interval of multiple consecutive second pulse signal cycles, using an average value or a weighted average method.
[0100] S602 accumulates the count value of the counter in each consecutive second pulse signal cycle.
[0101] With the period of the continuous second pulse signal as This is an example of the cumulative result. The expression is as follows:
[0102] (Formula 4)
[0103] In the above formula, This represents the accumulated count value of the counter during the i-th consecutive second pulse signal period.
[0104] S603 calculates the product of the accumulated result and the average time interval to obtain the actual timing cycle of the sensor device.
[0105] With the period of the continuous second pulse signal as This illustrates the actual timing cycle of a sensor device. The expression is as follows:
[0106] (Formula 5)
[0107] Furthermore, the time deviation between the sensor device and the satellite clock The expression is:
[0108] (Formula 6)
[0109] In the above formula, Indicates satellite clock at The reference time for a continuous second pulse signal cycle. This indicates the number of periods in a continuous second pulse signal.
[0110] In this embodiment, the average time gap is determined based on the counting time gap corresponding to each consecutive second pulse signal period of the counter. 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 sampling clock inside the sensor device.
[0111] The foregoing embodiments described the method for obtaining clock deviation. Next, a feasible method for correcting the sampling clock of the sensor device based on the clock deviation will be further described. In one 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 see Figure 8 , Figure 8 This is a timing comparison diagram of the satellite clock's second pulse signal, the sensor device's sampling clock, and the internal counter of the sensor device. Figure 8 It can be seen that the period of the second pulse signal, that is, within one second, includes multiple sampling points of the sampling clock, and the sampling period of the sampling clock matches the counting time interval of the counter. In this application, when the time deviation is positive, it means that the time of the sampling clock is earlier than the time of the satellite clock. Therefore, the sampling edge of the sampling clock is offset by a length matching the time deviation in the direction of the rising edge 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 time of the satellite clock. Therefore, the sampling edge of the sampling clock is offset by a length matching the time deviation in the opposite direction of the rising edge, that is, the direction of the falling edge, to obtain the corrected sampling clock.
[0114] In this embodiment of the application, when 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 one specific embodiment, a clock synchronization method is provided, comprising the following steps:
[0116] (1) In response to the trigger request of the second pulse signal, the counter inside the sensor device is triggered to reset the count and the accumulated count value of the counter in each second pulse signal cycle is obtained.
[0117] For any given second pulse signal period, upon receiving the second pulse signal, the counter is triggered to reset and start counting again. Upon receiving the next second pulse signal, the counter's count value is recorded as the accumulated count value corresponding to the second pulse signal period.
[0118] (2) Determine the counting time interval of the second pulse signal period based on the ratio between the second pulse signal period and the accumulated count value.
[0119] (3) Determine the average time gap based on the counting time gap corresponding to multiple consecutive second pulse signal cycles of the counter.
[0120] For example, the counting time gaps corresponding to each consecutive second pulse signal period are weighted and fused according to the weight value of each consecutive second pulse signal period to obtain the average time gap; or, the average value of the counting time gaps corresponding to each consecutive second pulse signal period is determined as the average time gap.
[0121] (4) Accumulate the count value of the counter in each consecutive second pulse signal cycle.
[0122] (5) Calculate the product of the accumulated result and the average time interval to obtain the actual timing cycle of the sensor device.
[0123] (6) Determine the time deviation between the sensor device and the satellite clock based on the difference between the actual timing period and the period of each continuous second pulse signal.
[0124] (7) Correct the sampling clock of the sensor device according to the time deviation, and align the sampling edge of the corrected sampling clock with the edge of the second pulse signal.
[0125] 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.
[0126] 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.
[0127] (8) Calculate the Coordinated Universal Time (UTC) of the satellite clock based on the serial port message, and timestamp the collected data in seconds as the smallest unit.
[0128] In this way, each sensor device has the same sampling time, which is the world standard time, enabling synchronous sampling of multiple devices.
[0129] In this embodiment, the time error between the sensor and the satellite clock is determined based on the second pulse information sent by each satellite clock, and the sampling clock of the sensor device is corrected so that the sampling clock of each sensor device is aligned with the satellite clock. This achieves clock synchronization of each sensor device without introducing communication between the sensor devices, thus simplifying the clock synchronization process.
[0130] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0131] Based on the same inventive concept, this application also provides a clock synchronization device for implementing the clock synchronization method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more clock synchronization device embodiments provided below can be found in the limitations of the clock synchronization method described above, and will not be repeated here.
[0132] In one exemplary embodiment, such as Figure 9 As shown, a clock synchronization device is provided, including: a signal receiving module 901, a gap acquisition module 902, a deviation determination module 903, and a clock correction module 904, wherein:
[0133] The signal receiving module 901 is used to receive the second pulse signal of the satellite clock transmitted by the satellite;
[0134] The gap acquisition module 902 is used to acquire the counting time gap of the counter in the sensor device in each second pulse signal cycle;
[0135] The deviation determination module 903 is used to determine the time deviation between the sensor device and the satellite clock based on the counting time gap corresponding to each second pulse signal period;
[0136] The clock correction module 904 is used 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, wherein:
[0138] The counting value recording unit is used to record the accumulated count value of the counter in any given second pulse signal period;
[0139] The gap calculation unit is used 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 reset subunit and an accumulated value determination subunit, wherein:
[0141] The counter reset subunit is used to trigger the counter to reset and start counting again upon receiving a second pulse signal;
[0142] The cumulative value determination subunit is used to record the counter value as the cumulative count value corresponding to the second pulse signal period when the next second pulse signal is received.
[0143] In an exemplary embodiment, the deviation determination module 903 includes: a window determination unit, a period acquisition unit, and a deviation calculation unit, wherein:
[0144] A window determination unit is used to acquire a preset number of continuous second pulse signal cycles;
[0145] The period acquisition unit is used to obtain the actual timing period of the sensor device based on the counting time interval corresponding to each consecutive second pulse signal period of the counter.
[0146] The deviation calculation unit is used to determine the time deviation between the sensor device and the satellite clock based on the difference between the actual timing period and the period of each continuous second pulse signal.
[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, wherein:
[0148] The average gap calculation subunit is used to determine the average time gap based on the counting time gap corresponding to each consecutive second pulse signal period of the counter.
[0149] The count value accumulation subunit is used to accumulate the count value of the counter in each consecutive second pulse signal cycle;
[0150] The period calculation subunit is used to calculate the product of the accumulated result and the average time interval to obtain the actual timing period of the sensor device.
[0151] In an exemplary embodiment, the average gap calculation subunit is further configured to perform weighted fusion of the counting time gaps corresponding to each consecutive second pulse signal period according to the weight value of each consecutive second pulse signal period to obtain the average time gap; or, determine the average value of the counting time gaps corresponding to each consecutive second pulse signal period 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, wherein:
[0153] The first correction unit is used to shift the sampling edge of the sampling clock forward by a length matching the time deviation in the direction of the rising edge when the time deviation is positive, so as to obtain the corrected sampling clock.
[0154] The first correction unit is used to offset the sampling edge of the sampling clock by a length matching the time deviation in the direction of the falling edge, when the time deviation is zero, so as to obtain the corrected sampling clock.
[0155] Each module in the aforementioned clock synchronization device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0156] In one exemplary embodiment, a computer device is provided, which may be a sensor device, and its internal structure diagram may be as follows: Figure 10As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, 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 is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0157] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0158] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0159] Receive the second pulse signal of the satellite clock transmitted by the satellite;
[0160] Obtain the counting time interval of the counter in the sensor device in each second pulse signal cycle;
[0161] The time deviation between the sensor device and the satellite clock is determined based on the counting time interval corresponding to each second pulse signal period;
[0162] The sampling clock of the sensor device is corrected according to the time deviation, and the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal.
[0163] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0164] For any second pulse signal period, record the accumulated count value of the counter corresponding to the second pulse signal period;
[0165] The counting time interval of the second pulse signal period is determined based on the ratio between the period of the second pulse signal and the accumulated count value.
[0166] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0167] Upon receiving a second pulse signal, the counter is triggered to reset to zero and start counting again;
[0168] Upon receiving the next second pulse signal of the second pulse signal, the counter value is recorded as the accumulated count value corresponding to the second pulse signal period.
[0169] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0170] Obtain a preset number of continuous second pulse signal cycles;
[0171] The actual timing cycle of the sensor device is obtained by the counting time interval corresponding to each consecutive second pulse signal cycle of the counter.
[0172] The time deviation between the sensor device and the satellite clock is determined based on the difference between the actual timing period and the period of each continuous second pulse signal.
[0173] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0174] The average time interval is determined based on the counting time interval corresponding to each consecutive second pulse signal period of the counter;
[0175] The counter counts are accumulated during each consecutive second pulse signal cycle;
[0176] The actual timing cycle of the sensor device is obtained by multiplying the accumulated result with the average time interval.
[0177] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0178] Based on the weight values of each consecutive second pulse signal period, the counting time intervals corresponding to each consecutive second pulse signal period are weighted and fused to obtain the average time interval; or,
[0179] The average time gap is determined by the average value of the counting time gaps corresponding to each consecutive second pulse signal period.
[0180] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0181] 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.
[0182] 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.
[0183] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0184] Receive the second pulse signal of the satellite clock transmitted by the satellite;
[0185] Obtain the counting time interval of the counter in the sensor device in each second pulse signal cycle;
[0186] The time deviation between the sensor device and the satellite clock is determined based on the counting time interval corresponding to each second pulse signal period;
[0187] The sampling clock of the sensor device is corrected according to the time deviation, and 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, it also performs the following steps:
[0189] For any second pulse signal period, record the accumulated count value of the counter corresponding to the second pulse signal period;
[0190] The counting time interval of the second pulse signal period is determined based on the ratio between the period of the second pulse signal and the accumulated count value.
[0191] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0192] Upon receiving a second pulse signal, the counter is triggered to reset to zero and start counting again;
[0193] Upon receiving the next second pulse signal of the second pulse signal, the counter value is recorded 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, it also performs the following steps:
[0195] Obtain a preset number of continuous second pulse signal cycles;
[0196] The actual timing cycle of the sensor device is obtained by the counting time interval corresponding to each consecutive second pulse signal cycle of the counter.
[0197] The time deviation between the sensor device and the satellite clock is determined based on the difference between the actual timing period and the period of each continuous second pulse signal.
[0198] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0199] The average time interval is determined based on the counting time interval corresponding to each consecutive second pulse signal period of the counter;
[0200] The counter counts are accumulated during each consecutive second pulse signal cycle;
[0201] The actual timing cycle of the sensor device is obtained by multiplying the accumulated result with the average time interval.
[0202] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0203] Based on the weight values of each consecutive second pulse signal period, the counting time intervals corresponding to each consecutive second pulse signal period are weighted and fused to obtain the average time interval; or,
[0204] The average time gap is determined by the average value of the counting time gaps corresponding to each consecutive second pulse signal period.
[0205] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0206] 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.
[0207] 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.
[0208] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:
[0209] Receive the second pulse signal of the satellite clock transmitted by the satellite;
[0210] Obtain the counting time interval of the counter in the sensor device in each second pulse signal cycle;
[0211] The time deviation between the sensor device and the satellite clock is determined based on the counting time interval corresponding to each second pulse signal period;
[0212] The sampling clock of the sensor device is corrected according to the time deviation, and 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 a processor, it also performs the following steps:
[0214] For any second pulse signal period, record the accumulated count value of the counter corresponding to the second pulse signal period;
[0215] The counting time interval of the second pulse signal period is determined based on the ratio between the period of the second pulse signal and the accumulated count value.
[0216] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0217] Upon receiving a second pulse signal, the counter is triggered to reset to zero and start counting again;
[0218] Upon receiving the next second pulse signal of the second pulse signal, the counter value is recorded as the accumulated count value corresponding to the second pulse signal period.
[0219] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0220] Obtain a preset number of continuous second pulse signal cycles;
[0221] The actual timing cycle of the sensor device is obtained by the counting time interval corresponding to each consecutive second pulse signal cycle of the counter.
[0222] The time deviation between the sensor device and the satellite clock is determined based on the difference between the actual timing period and the period of each continuous second pulse signal.
[0223] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0224] The average time interval is determined based on the counting time interval corresponding to each consecutive second pulse signal period of the counter;
[0225] The counter counts are accumulated during each consecutive second pulse signal cycle;
[0226] The actual timing cycle of the sensor device is obtained by multiplying the accumulated result with the average time interval.
[0227] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0228] Based on the weight values of each consecutive second pulse signal period, the counting time intervals corresponding to each consecutive second pulse signal period are weighted and fused to obtain the average time interval; or,
[0229] The average time gap is determined by the average value of the counting time gaps corresponding to each consecutive second pulse signal period.
[0230] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0231] 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.
[0232] 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.
[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 used for analysis, data stored, data displayed, 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 the relevant data must comply with relevant regulations.
[0234] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this 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), magnetic 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 take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0235] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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, they should be considered to be within the scope of this application.
[0236] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A clock synchronization method, characterized in that, The method includes: Receive the second pulse signal of the satellite clock transmitted by the satellite; The counting time interval of the counter in the sensor device in each second pulse signal cycle is obtained; wherein, the counting time interval is the time interval between two adjacent counts of the counter, and the counting frequency of the counter is higher than the transmission frequency of the second pulse signal; Based on the counting time gap corresponding to each of the second pulse signal periods, the time deviation between the sensor device and the satellite clock is determined; wherein, the time deviation is a vector value with a sign, when the sign of the time deviation is positive, it indicates that the sampling time of the sensor is earlier than the standard time of the satellite clock; when the sign of the time deviation is negative, it indicates that the sampling time of the sensor is later than the standard time of the satellite clock. 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. 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.
2. The method according to claim 1, characterized in that, The step of obtaining the counting time interval of the counter in the sensor device in each second pulse signal cycle includes: For any second pulse signal period, record the accumulated count value of the counter corresponding to that second pulse signal period; The counting time interval of the second pulse signal period is determined based on the ratio between the second pulse signal period and the accumulated count value.
3. The method according to claim 2, characterized in that, For any given second pulse signal period, recording the accumulated count value of the counter corresponding to that second pulse signal period includes: Upon receiving the second pulse signal, the counter is triggered to be reset to zero and start counting again; Upon receiving the next second pulse signal of the second pulse signal, the count value of the counter is recorded as the accumulated count value corresponding to the period of the second pulse signal.
4. The method according to any one of claims 1-3, characterized in that, The step of determining the time deviation between the sensor device and the satellite clock based on the counting time interval corresponding to each of the second pulse signal periods includes: Obtain a preset number of continuous second pulse signal cycles; The actual timing cycle of the sensor device is obtained based on the counting time interval corresponding to each of the consecutive second pulse signal cycles of the counter. The time deviation between the sensor device and the satellite clock is determined based on the difference between the actual timing period and the period of each of the continuous second pulse signals.
5. The method according to claim 4, characterized in that, The step of obtaining the actual timing period of the sensor device based on the counting time interval corresponding to each of the consecutive second pulse signal periods includes: The average time gap is determined based on the counting time gap corresponding to each of the consecutive second pulse signal periods of the counter; The count value of the counter is accumulated in each of the consecutive second pulse signal cycles; The actual timing cycle of the sensor device is obtained by multiplying the accumulated result with the average time interval.
6. The method according to claim 5, characterized in that, The step of determining the average time interval based on the counting time interval corresponding to each of the consecutive second pulse signal periods includes: According to the weight value of each of the continuous second pulse signal periods, the counting time intervals corresponding to each of the continuous second pulse signal periods are weighted and fused to obtain the average time interval; or, The average time gap is determined by the average value of the counting time gaps corresponding to each of the continuous second pulse signal periods.
7. A clock synchronization device, characterized in that, The device includes: The signal receiving module is used to receive the second pulse signal of the satellite clock transmitted by the satellite; The gap acquisition module is used to acquire the counting time gap of the counter in the sensor device in each second pulse signal cycle; wherein, the counting time gap is the time interval between two adjacent counts of the counter, and the counting frequency of the counter is higher than the transmission frequency of the second pulse signal; The deviation determination module is used to determine the time deviation between the sensor device and the satellite clock based on the counting time gap corresponding to each second pulse signal period; wherein, the time deviation is a vector value with a sign, when the sign of the time deviation is positive, it indicates that the sampling time of the sensor is earlier than the standard time of the satellite clock; when the sign of the time deviation is negative, it indicates that the sampling time of the sensor is later than the standard time of the satellite clock. A clock correction module is used to correct the sampling clock of the sensor device according to the time deviation, wherein the sampling edge of the corrected sampling clock is aligned with the edge of the second pulse signal; wherein, if the time deviation is positive, the sampling edge of the sampling clock is shifted 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, the sampling edge of the sampling clock is shifted backward in the direction of the falling edge by a length matching the time deviation to obtain the corrected sampling clock.
8. A sensor device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Remote sensing camera time system error compensation method based on satellite broadcast
CN117850202A
