Low-cost precise time keeping method, system and device based on gating circulation unit

By using a frequency drift prediction model based on GRU to monitor and compensate for the frequency drift of TCXO in real time, the problem of rapid error accumulation in PMU devices after BeiDou/GPS loss of lock is solved, achieving long-term high-precision synchronization, reducing hardware costs and improving the reliability of power grid monitoring.

CN121567060APending Publication Date: 2026-02-24SUQIAN POWER SUPPLY COMPANY OF JIANGSU PROVINCE POWER +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511839390.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-08
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

Existing PMU devices, after losing lock with BeiDou/GPS, rely on low-cost TCXOs, which cause frequency drift errors to accumulate rapidly and cannot maintain high-precision synchronization for a long time, resulting in timestamp errors quickly exceeding the standard.

Method used

A frequency drift prediction model based on gated cyclic unit (GRU) network is adopted to monitor the operating parameters of crystal oscillator in real time. Frequency error is predicted by the feature vectors of temperature, aging and thermal hysteresis effects, and time correction is used to compensate for crystal oscillator frequency drift to achieve accurate timekeeping.

Benefits of technology

It can maintain microsecond-level time synchronization accuracy even within 72 hours of BeiDou or GPS losing lock, reducing hardware costs and improving the reliability and adaptability of power grid monitoring, especially effective in harsh environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121567060A_ABST
    Figure CN121567060A_ABST
Patent Text Reader

Abstract

The invention discloses a low-cost precise time keeping method, system and device based on a gating circulation unit, and relates to the technical field of power grid measurement. The method is executed when the synchronous phasor measurement device cannot receive external signals, and comprises the following steps: monitoring operation parameters which influence the frequency stability of an internal crystal oscillator of the phasor measurement unit in real time; calculating a current frequency error of the crystal oscillator in real time by using a crystal oscillator frequency drift prediction model based on a gated cycle unit network based on the operation parameters; generating a time correction amount according to the current frequency error; and applying the time correction to a local clock of the phasor measurement unit to compensate the frequency drift of the crystal oscillator so as to realize accurate time keeping. According to the invention, through accurate prediction of crystal oscillator errors and lightweight software compensation, the synchronous phasor measurement device adopting a low-cost crystal oscillator can also realize long-time high-precision time keeping, the hardware cost is obviously reduced, and the reliability of power grid monitoring during the Beidou / GPS lock losing period is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a low-cost, accurate timekeeping method, system, and device based on a gated loop unit, which relates to the field of power grid measurement technology. Specifically, it relates to an internal accurate timekeeping method and related device applied to a phasor measurement unit (PMU) in the absence of an external time synchronization signal. Background Technology

[0002] The phasor measurement unit (PMU) is a key component of a wide-area measurement system (WAMS) used to synchronously monitor the voltage and current phasors of the power grid. Accurate measurements by the PMU are highly dependent on high-precision time synchronization, typically requiring time errors on the order of microseconds (µs).

[0003] Currently, PMU devices primarily rely on satellite navigation systems such as BeiDou or GPS to provide high-precision time synchronization signals (e.g., 1PPS), while using a local crystal oscillator to perform frequency division and acquisition of the synchronization signal. However, BeiDou / GPS signals can be susceptible to electromagnetic interference, malicious spoofing, or other conditions that can cause the PMU device to "lose lock".

[0004] After a lockout, the timekeeping performance of the PMU relies entirely on its internal local clock source, typically a crystal oscillator. To control cost and power consumption, low-cost PMUs commonly use temperature-compensated crystal oscillators (TCXOs) instead of expensive oven-controlled crystal oscillators (OCXOs) or atomic clocks.

[0005] The timekeeping accuracy of TCXOs is severely constrained by a variety of physical factors. The frequency drift caused by these factors is cumulative, eventually leading to a rapid exceedance of timestamp errors. The main causes of frequency errors and time drift in low-cost crystal oscillators include:

[0006] 1. Temperature Drift and Compensation Residual: Temperature is the most significant factor affecting the frequency stability of a crystal oscillator. Although the TCXO has an internal compensation network, this compensation is not perfect. The compensation curve simulated by the network cannot perfectly match the actual characteristic curve of the crystal oscillator, resulting in a fitting error—the "compensation residual"—that always exists across the entire temperature range (e.g., -40°C to 85°C). Furthermore, after temperature cycling (heating and then cooling), the crystal oscillator's frequency will not completely return to its initial value; this is known as the "thermal hysteresis" effect. When the operating environment temperature of the PMU changes, the compensation residual and thermal hysteresis are the main factors causing short- to medium-term time errors.

[0007] 2. Aging Effect: The aging effect is a key factor leading to long-term, unidirectional, and slow drift in crystal oscillator frequency. It is caused by physical and chemical processes such as mass migration of the wafer electrodes and stress release within the package. Aging drift is usually fastest in the initial stage of crystal oscillator use, and then tends to a slower rate. Although the annual aging rate (e.g., 1 ppm / year) is small, in cases where BeiDou / GPS lockout lasts for days or weeks, the aging effect is a non-negligible and continuously accumulating source of error.

[0008] 3. Other factors: These include power supply voltage fluctuations, mechanical vibrations, and shocks.

[0009] In summary, after GPS lock-up is lost, the frequency of the PMU's low-cost TCXO is subject to complex, nonlinear, and time-varying coupled effects of temperature (nonlinear compensation residuals and thermal hysteresis) and aging (long-term cumulative drift). Existing TCXO self-compensation mechanisms cannot solve these problems, causing timekeeping errors to accumulate rapidly and exceed limits within hours or days.

[0010] Therefore, there is an urgent need in the field for a low-cost (i.e. still using TCXO) solution that can intelligently predict and proactively compensate for crystal frequency drift caused by temperature drift residuals, thermal hysteresis and aging effects, thereby achieving accurate timekeeping over a long period of time. Summary of the Invention

[0011] The purpose of this invention is to address the shortcomings of the prior art by providing a low-cost, accurate timekeeping method, system, and device based on a gated loop unit. Through accurate prediction of crystal oscillator errors and lightweight software compensation, the synchronous phasor measurement device using a low-cost crystal oscillator can also achieve high-precision timekeeping over a long period of time. This significantly reduces hardware costs and improves the reliability of power grid monitoring during BeiDou / GPS loss of lock. It solves the problems of poor timekeeping accuracy, rapid error accumulation, and inability to maintain synchronization for a long time when relying on a low-cost crystal oscillator (TCXO) after BeiDou or GPS loss of lock.

[0012] To achieve the above objectives, the present invention adopts the following technical solution:

[0013] A low-cost, accurate timekeeping method based on a gated loop unit includes the following steps:

[0014] When the phasor measurement unit is unable to receive an external time synchronization signal, the operating parameters affecting the frequency stability of the crystal oscillator inside the phasor measurement unit are monitored in real time.

[0015] Based on the operating parameters, the current frequency error of the crystal is calculated in real time using a crystal frequency drift prediction model based on a gated cyclic unit network.

[0016] Based on the current frequency error, a time correction amount is generated;

[0017] The time correction is applied to the local clock of the phasor measurement unit to compensate for the frequency drift of the crystal oscillator and achieve accurate timekeeping.

[0018] Furthermore, the operating parameters include the ambient temperature of the crystal oscillator, the cumulative operating time, and / or the rate and direction of temperature change, wherein the cumulative operating time is the cumulative operating time of the phasor measurement unit since it has been powered on.

[0019] Furthermore, the real-time ambient temperature is obtained by a sensor closely attached to the crystal oscillator and is used to characterize the baseline temperature drift;

[0020] The cumulative operating time is used to characterize the physical aging of the crystal oscillator over time;

[0021] The temperature change rate and direction are used to capture the thermal hysteresis effect of the crystal oscillator (i.e., the phenomenon that the frequency deviation of the crystal oscillator is different even when it is at the same temperature point during the heating and cooling process).

[0022] Furthermore, the operating parameters constitute the input feature vector of the crystal oscillator frequency drift prediction model, and the input feature vector includes at least: the current ambient temperature of the crystal oscillator and the cumulative operating time of the phasor measurement unit since power-on.

[0023] Furthermore, to improve the prediction accuracy of the crystal oscillator thermal hysteresis effect, the input feature vector also includes:

[0024] The rate of temperature change is the difference between the current temperature and the previous temperature.

[0025] Temperature change direction indicator, a binary feature or sign bit used to indicate whether the crystal oscillator is currently in a heating or cooling process.

[0026] Furthermore, the crystal oscillator frequency drift prediction model based on the gated cyclic unit network is pre-established and obtained during the training phase when the phasor measurement unit is able to receive external time synchronization signals, by performing the following steps:

[0027] Data alignment and acquisition specifically involves synchronously acquiring the operating parameters as input samples at a preset sampling period, and simultaneously obtaining the difference between the local clock time of the phasor measurement unit and the time of the external time synchronization signal.

[0028] Tag calculation specifically involves calculating the actual frequency error rate (FER) of the crystal oscillator under the current environment based on the time difference between two adjacent sampling times, and using the actual frequency error rate as the target tag corresponding to the input sample.

[0029] Sequence construction specifically employs a sliding window mechanism to combine input samples from multiple consecutive historical moments with their corresponding target labels to construct a time series training dataset.

[0030] Supervised learning specifically involves inputting the time-series training dataset into an initialized gated recurrent unit (GRU) network model and minimizing the loss function between the predicted output and the target label through the backpropagation algorithm, thereby optimizing the model parameters.

[0031] Furthermore, the crystal oscillator frequency drift prediction model based on gated recurrent unit networks has a network structure including an input layer, at least one hidden layer, and an output layer; the hidden layer consists of multiple gated recurrent units (GRUs), each GRU containing a reset gate and an update gate, and the GRU is configured to perform the following operations to capture the frequency drift characteristics of the crystal oscillator:

[0032] The reset gate is used to determine how much of the previous hidden state information should be forgotten when calculating the current candidate hidden state, in order to adapt to the rapid changes in the temperature characteristics of the crystal oscillator.

[0033] Using the update gate, it is determined how much of the previous hidden state information to retain and how much of the current candidate hidden state information to fuse into the current final hidden state, in order to maintain a long-term memory of the crystal oscillator aging effect.

[0034] The output layer is a fully connected layer used to map the final state of the hidden layer to a single scalar value, namely the current frequency error.

[0035] Furthermore, the low-cost and accurate timekeeping method based on gated cyclic units also includes an online adaptive optimization step. That is, after the phasor measurement unit recovers from a state without external signal to a state with external signal, the total time error accumulated during the period without signal is calculated, and the total time error is fed back to the crystal oscillator frequency drift prediction model based on the gated cyclic unit network. The weight parameters of the crystal oscillator frequency drift prediction model based on the gated cyclic unit network are fine-tuned through incremental learning to correct the model deviation caused by changes in the aging characteristics of the crystal oscillator.

[0036] Furthermore, the step of applying the time correction amount to the local clock of the phasor measurement unit specifically includes: determining the compensation step value of the local counter of the phasor measurement unit based on the calculated current frequency error; writing the compensation step value into the hardware timer register of the phasor measurement unit to dynamically adjust the counting rate of the local clock so that the duration of "one second" of the local clock is physically close to one second of the standard time.

[0037] This invention also provides a low-cost, accurate timekeeping system based on a gated loop unit, used to implement the steps of the above-mentioned low-cost, accurate timekeeping method based on a gated loop unit. The system includes:

[0038] The operating parameter detection module is used to monitor the operating parameters of the crystal oscillator (crystal oscillator) inside the phasor measurement unit that affect its frequency stability;

[0039] The frequency error calculation module, based on the operating parameters obtained by the operating parameter detection module, uses a crystal oscillator frequency drift prediction model based on a gated cyclic unit network to calculate the current frequency error of the crystal oscillator in real time.

[0040] The time correction module is used to generate a time correction amount based on the current frequency error obtained by the frequency error calculation module.

[0041] The timekeeping implementation module is used to apply the time correction amount obtained by the time correction module to the local clock of the phasor measurement unit to compensate for the frequency drift of the crystal oscillator and achieve accurate timekeeping.

[0042] Furthermore, the low-cost, accurate timekeeping system based on gated cyclic units also includes an online adaptive optimization module. After the monitoring phasor measurement unit recovers from a state without external signals to a state with external signals, the module calculates the total time error accumulated during the period without signals and feeds this total time error back to the crystal oscillator frequency drift prediction model based on the gated cyclic unit network. The module then fine-tunes the weight parameters of the crystal oscillator frequency drift prediction model based on the gated cyclic unit network through incremental learning to correct the model deviation caused by changes in the aging characteristics of the crystal oscillator.

[0043] The present invention also provides a low-cost, accurate timekeeping device based on a gated loop unit, comprising:

[0044] The processor, as the core computing unit, is configured to execute a low-cost, accurate timekeeping method based on gated loop units;

[0045] The memory, coupled to the processor, is used to store the operating system, the weight parameter matrix of the GRU network model, and the historical running data queue.

[0046] The local clock source provides the basic clock pulse signal for the entire device and is directly connected to the clock input of the processor's internal hardware timer; the local clock source uses a low-cost temperature-compensated crystal oscillator (TCXO).

[0047] The temperature acquisition component uses a digital temperature sensor, which is physically attached to the surface of the local clock source.

[0048] An external time signal receiver outputs standard time information (UTC) and a high-precision second pulse signal, which is connected to the processor's external interrupt pin and the timer's input capture channel.

[0049] Furthermore, the processor is an embedded microcontroller (MCU) with a floating-point unit (FPU); the processor integrates hardware timers, SRAM and Flash memory.

[0050] Furthermore, the processor interacts with external information through a communication interface.

[0051] Compared with the prior art, the present invention has at least the following beneficial effects:

[0052] 1. Extremely high cost-effectiveness (low cost): This invention enables PMUs using ordinary, inexpensive TCXO crystal oscillators to achieve short-to-medium-term timekeeping performance approaching that of expensive OCXOs or even atomic clocks. This significantly reduces the hardware cost for large-scale deployment of wide-area measurement systems.

[0053] 2. Ultra-long-term timekeeping capability: Due to the effective integration of aging and thermal hysteresis effects in the GRU model, this invention can effectively suppress the long-term accumulation of errors. Even after 72 hours or longer of BeiDou or GPS lock-off, it can still maintain microsecond-level time synchronization accuracy, ensuring the effectiveness of power grid data in disaster scenarios.

[0054] 3. Balancing computational efficiency and accuracy: The GRU model is chosen instead of LSTM or complex Transformer models. While ensuring a strong ability to capture temporal features, it significantly reduces the computing power and memory requirements of embedded processors, making it easier to implement in engineering.

[0055] 4. Strong environmental adaptability: By introducing temperature change rate characteristics and online learning mechanism, this invention has a strong adaptability to harsh environments with drastic temperature differences (such as outdoor cabinets and desert areas). Attached Figure Description

[0056] Figure 1 This is a flowchart illustrating the low-cost, accurate timekeeping method based on a gated loop unit in this invention. Figure 1 ;

[0057] Figure 2 This is a flowchart illustrating the low-cost, accurate timekeeping method based on a gated loop unit in this invention. Figure 2 .

[0058] Figure 3 This is a structural block diagram of a low-cost, accurate timekeeping device based on a gated loop unit in an embodiment of the present invention.

[0059] Figure 4This is a schematic diagram illustrating the principle of crystal oscillator data acquisition and training sample construction in an embodiment of the present invention.

[0060] Figure 5 This is a schematic diagram of the error correction (software clock redirection) principle in an embodiment of the present invention.

[0061] Figure 6 This is a schematic diagram of the structure of a low-cost, accurate timekeeping system based on a gated loop unit in an embodiment of the present invention. Detailed Implementation

[0062] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0063] Example 1:

[0064] refer to Figure 1 In this embodiment, a low-cost, accurate timekeeping method based on a gated loop unit is provided, comprising the following steps:

[0065] S1, when the phasor measurement unit cannot receive an external time synchronization signal, monitor in real time the operating parameters that affect the frequency stability of the crystal oscillator inside the phasor measurement unit; in this embodiment, the operating parameters include the ambient temperature of the crystal oscillator and the cumulative operating time.

[0066] S2, based on the operating parameters, the crystal oscillator frequency drift prediction model based on gated cyclic unit network is used to predict the crystal oscillator drift phase shift and amplitude;

[0067] S3, Based on the prediction result of step S2, calculate the current frequency error of the crystal oscillator in real time;

[0068] S4, Generate a time correction amount based on the current frequency error;

[0069] S5, the time correction amount is applied to the local clock of the phasor measurement unit to compensate for the frequency drift of the crystal oscillator and achieve accurate timekeeping.

[0070] See attached document Figure 2 The low-cost, accurate timekeeping method based on gated cyclic units also includes an online adaptive optimization step. That is, after the phasor measurement unit recovers from a state without external signal to a state with external signal, the total time error accumulated during the period without signal is calculated, and the total time error is fed back to the crystal oscillator frequency drift prediction model based on the gated cyclic unit network. The weight parameters of the crystal oscillator frequency drift prediction model based on the gated cyclic unit network are fine-tuned through incremental learning to correct the model deviation caused by changes in the aging characteristics of the crystal oscillator.

[0071] Example 2:

[0072] See attached document Figure 3 This embodiment provides a low-cost, accurate timekeeping device based on a gated loop unit (GRU), comprising the following components:

[0073] The central processing unit 101, as the core computing unit, is an embedded microcontroller (MCU) with a floating-point unit (FPU), such as a processor based on the ARM Cortex-M7 core; the processor integrates hardware timers (Timer / Counter), SRAM and Flash memory.

[0074] The memory 102, coupled to the central processing unit 101, is used to store the operating system, the weight parameter matrix of the GRU network model, and the historical running data queue.

[0075] The local clock source (crystal oscillator) 103 is a low-cost temperature-compensated crystal oscillator (TCXO), and its nominal frequency is set to [value missing]. (e.g., 20MHz); the crystal oscillator provides the basic clock pulse signal for the entire device and is directly connected to the clock input of the internal hardware timer of the central processing unit 101.

[0076] The temperature acquisition component 104 uses a high-precision temperature sensor with a digital interface (e.g., a digital sensor with a resolution better than 0.01℃). In order to ensure that the acquired temperature can accurately reflect the temperature of the chip inside the crystal oscillator, the sensor is physically attached to the metal shell of the TCXO crystal oscillator through a thermally conductive medium (such as thermal grease or thermal pad).

[0077] An external time signal receiver 105, such as a GPS / BeiDou dual-mode receiver, outputs standard time information (UTC) and a high-precision pulse-of-seconds (1PPS) signal. The 1PPS signal is connected to the external interrupt pin of the central processing unit 101 and the input capture channel of the timer.

[0078] The central processing unit 101 interacts with external information through a communication interface.

[0079] Example 3:

[0080] The following is in conjunction with the appendix Figures 3-4 The examples provide a detailed explanation of the acquisition and preprocessing process of crystal oscillator operating data.

[0081] The acquisition and preprocessing of high-precision crystal oscillator operating data is fundamental to the operation of the entire device. During GPS signal lock-in, the central processing unit 101 not only records the data but also performs refined feature engineering and preprocessing to ensure the GRU network accurately understands the physical behavior of the crystal oscillator. The specific process includes:

[0082] 1. Synchronization triggering mechanism and raw data acquisition;

[0083] The rising edge of the 1PPS signal output by the GPS receiver is used as a hardware trigger source. Whenever a 1PPS rising edge is detected, the processor immediately triggers an input capture interrupt, latching the current count value of the local hardware timer, denoted as . .

[0084] 2. Calculation of the true frequency error rate (label);

[0085] Central Processing Unit 101 according to the current time and the previous moment The latched count value is used to calculate the actual increment of the local counter within this second. ,

[0086]

[0087] The nominal frequency of the crystal oscillator is known to be Ideally, the nominal count value within 1 second should be: .

[0088] The CPU 101 calculates the actual frequency error rate (FER) of the crystal oscillator under the current environment. This value serves as the target label for supervised learning:

[0089]

[0090] in, For example, if the calculation result is a dimensionless value, then... This indicates that the crystal oscillator is currently 0.5 ppm faster than its nominal speed.

[0091] 3. The principle and implementation of constructing multidimensional input feature vectors;

[0092] To enable the GRU model to decouple the complex physical error sources of the crystal oscillator, this embodiment constructs a feature vector with four dimensions. The introduction of each feature corresponds to a specific physical mechanism as follows:

[0093] Dimension 1: Real-time ambient temperature —Regarding static temperature drift characteristics, the frequency-temperature characteristics of crystal oscillators (especially AT-cut crystals) typically exhibit a cubic polynomial curve (S-shaped curve), and real-time temperature is the most significant factor determining frequency deviation. The central processing unit 101 reads the temperature register of the sensor 104 via the I2C interface to obtain a floating-point temperature value with a resolution of 0.01℃.

[0094] Dimension Two: Rate of Temperature Change —Regarding the dynamic thermal hysteresis effect, crystal oscillators exhibit a "thermal hysteresis" phenomenon, meaning that the frequency-temperature curve of the crystal oscillator does not coincide with the curve during the heating process and the cooling process, exhibiting a hysteresis. This means that even at the exact same temperature point... If one is "rising from low temperature to..." The other is "from high temperature to..." The frequency errors of the two are different. The central processing unit 101 calculates the difference between the current temperature and the previous temperature. This feature In fact, it represents the first derivative of temperature (rate of change). It not only reflects the direction of change through its positive or negative sign, but also reflects the severity of thermal shock through its absolute value. The GRU model uses this feature to distinguish between heating and cooling paths, thereby compensating for hysteresis errors.

[0095] Dimension Three: Temperature Trend Direction Indicator – Auxiliary Hysteresis Detection. To enhance the neural network's sensitivity to state transitions, explicitly introducing directional features can accelerate model convergence. Perform binarization or ternary transformation:

[0096]

[0097] in, The anti-shake threshold (e.g., 0.02℃).

[0098] Dimension 4: Cumulative Running Time —Regarding the long-term aging effect, the quartz crystal inside the crystal oscillator undergoes mass migration or stress release over time, resulting in a monotonic long-term frequency drift (typically a logarithmic curve or linear trend). This error is independent of temperature and depends only on time. The central processing unit 101 maintains a total system runtime counter (in hours) in non-volatile memory. This feature allows the GRU model to learn the trend of the "reference frequency" slowly shifting over time, i.e. .

[0099] Based on the above four dimensions, construct the original feature vector at the current time t. for: .

[0100] 4. Data normalization processing;

[0101] Because the physical dimensions of the input features differ greatly (e.g., temperature) The temperature range is approximately -40°C to 85°C, and the aging time (Age) can be as high as 10,000 hours and changes extremely slowly. Directly inputting these values ​​into a neural network could lead to difficulties in gradient descent convergence or excessively large weights for certain features. Therefore, standardization is necessary. In this embodiment, Z-Score standardization is used. Specifically, the central processing unit 101 reads the statistical parameters of the training set pre-stored in Flash memory: the mean vector. and standard deviation vector For the current vector Each component Perform the following calculations to obtain the normalized vector. :

[0102]

[0103] in, To prevent small constants from being divided by zero (such as...) In timed mode (inference phase), the exact same method as in the training phase must be used. and The parameters are processed.

[0104] 5. Time series construction and sliding window mechanism;

[0105] GRU is a recurrent neural network whose input is not data from a single moment, but a time series. The model needs to infer the current state based on the historical temperature changes over a period of time.

[0106] In order for the model to "see" the trajectory of temperature changes (e.g., "the temperature rose rapidly from 20 degrees to 25 degrees in the past 60 seconds"), a time window of length L needs to be constructed.

[0107] The specific steps are as follows:

[0108] (1) The central processing unit 101 allocates a first-in-first-out (FIFO) queue or a ring buffer in SRAM with a capacity of L vectors (e.g., L=60).

[0109] (2) Enqueue operation: Whenever a new normalized feature vector x(t) is generated, it is pushed to the end of the queue.

[0110] (3) Dequeue operation: Simultaneously remove the earliest vector from the head of the queue. Remove (if the queue is full).

[0111] (4) Sample formation: All data in the current queue constitute the GRU model at time step [time]. Input tensor Its shape is ,Right now:

[0112]

[0113] Through this sliding window mechanism, the GRU model can obtain complete historical context information during each inference, thereby achieving accurate prediction of dynamic errors.

[0114] Example 4:

[0115] The following examples illustrate in detail the construction of a GRU-based crystal oscillator error prediction model.

[0116] The model is designed as a lightweight time-series regression model, establishing a multidimensional environmental feature sequence. Crystal oscillator frequency error rate The nonlinear mapping relationship.

[0117] The neural network model used in this embodiment contains three functional layers from bottom to top: a sequence input layer, a GRU hidden layer, and a fully connected output layer.

[0118] Input tensor dimension: The input to the model is the time series samples constructed in step one. Its dimensions are ,in:

[0119] L is the sequence length, and in this embodiment, L=60 (i.e., reviewing the past 60 seconds of history);

[0120] In this embodiment, the feature dimensions are 4 (including temperature, temperature change rate, orientation, and aging time);

[0121] Hidden layer configuration: Contains at least one GRU layer. To balance accuracy and latency on embedded processors, this embodiment sets the dimension of the hidden state vector to [missing value]. (For example, set to 32 or 64).

[0122] Output tensor dimension: The output is a single scalar, i.e., the prediction frequency error rate.

[0123] The core of GRU lies in controlling the flow of information through gating mechanisms. For each time step in the sequence... (where t=1,2,…,L), the GRU receives the feature input at the current time step. The hidden state of the previous time step and output the current hidden state. .

[0124] The specific computational steps within GRU are as follows:

[0125] (1) Reset the door — Screening for short-term mutation characteristics;

[0126] The function of resetting the door is to determine its hidden state at the previous moment. How much information needs to be "ignored"? In a crystal oscillator model, this corresponds to the need for the model to quickly discard old state memories and focus on the current rapid change when a drastic temperature change occurs (such as when a high-power device is turned on).

[0127] The calculation formula is as follows: ,

[0128] in, , represents the weight matrix input to the reset gate;

[0129] , represents the weight matrix from the hidden state to the reset gate;

[0130] , represents the bias vector;

[0131] The Sigmoid activation function is given by the formula: This will compress the output to the (0, 1) range.

[0132] (2) Update the door —Maintaining long-term trend characteristics;

[0133] The purpose of updating the door is to determine its hidden state in the previous moment. How much is directly retained to the current moment? In the crystal oscillator model, this corresponds to the aging effect of the crystal oscillator, a trend that changes very slowly over time, requiring the model to have long-term memory capabilities (i.e., Approaching 1). Update Gate The calculation formula is as follows: ;

[0134] in, This represents the weight matrix input to the update gate;

[0135] This represents the weight matrix from the hidden state to the update gate;

[0136] (3) Candidate hidden state —Nonlinear extraction of the current state;

[0137] This step is based on the current input. Using historical information filtered through the reset gate, the "candidate" activation states at the current moment are calculated. This step introduces nonlinearity through the tanh function, enabling the model to fit the complex S-Curve frequency temperature drift curve of the crystal oscillator.

[0138] Candidate hidden state The calculation formula is as follows:

[0139] ,

[0140] in, This represents the Hadamard product, which is element-wise multiplication. This mathematically implements the logic of "cutting off historical information if the reset gate is close to 0";

[0141] The hyperbolic tangent activation function is given by the formula: The output range is (-1, 1).

[0142] (4) Final hidden state —Soft weighted fusion of information;

[0143] This is the most crucial step in GRU, through updating the gates. Linear interpolation is performed between "historical memory" and "current new knowledge".

[0144] Final hidden state The calculation formula is as follows: ,

[0145] Among them, if ,but The model ignores the current input and retains long-term memory (corresponding to aging prediction); if ,but The model is rewritten to the state (corresponding to a drastic temperature change response).

[0146] After the output layer mapping is cyclically computed over L time steps in the sequence, the model obtains the hidden state vector at the last time step. (dimension is) This vector is a high-dimensional abstract feature representation that contains all the physical state information of the crystal oscillator at the current moment. To obtain the final frequency error rate prediction, a fully connected layer is used to compress the high-dimensional vector into a one-dimensional scalar.

[0147] The formula for calculating the predicted frequency error rate is as follows: ;

[0148] in, , represents the output layer weight matrix;

[0149] , represents the output layer bias scalar;

[0150] The final predicted output is in the form of a dimensionless ratio (e.g., ppm).

[0151] To prevent gradient vanishing or exploding and to speed up convergence, this embodiment performs specific initialization of the network weights:

[0152] All weight matrices Use Xavier initialization or Orthogonal initialization.

[0153] Update the door offset Initialize to a positive value (e.g., +1) to encourage the model to retain long-term memory and adapt to the aging characteristics of the crystal oscillator in the early stages of training.

[0154] All other biases are initialized to 0.

[0155] Through the above construction process, the prediction model of the present invention can accurately simulate and predict the frequency drift behavior of crystal oscillators in complex environments with extremely low computational overhead (involving only matrix multiplication and simple element-level operations).

[0156] Example 5:

[0157] This embodiment provides a detailed explanation of the training method for the crystal oscillator error prediction model based on GRU.

[0158] The central processing unit 101 runs training tasks in the background or exports data to a host computer for training and then writes back the parameters. The goal of training is to minimize the prediction error.

[0159] 1. Loss function definition: The mean squared error is used as the loss function L:

[0160]

[0161] in, Represents the set of all learnable weight parameters in the network. .

[0162] 2. Parameter Optimization: The Adam optimization algorithm is used for backpropagation. The parameters are optimized based on the loss function L. gradient To update the weights:

[0163]

[0164] in, For learning rate, , These are the corrected first and second moments of the gradient, respectively.

[0165] Example 6:

[0166] This embodiment combines Figure 5 The error compensation method (software clock redirection) is described in detail.

[0167] When a low-cost, precise timekeeping device based on a gated loop unit (GRU) detects a loss of BeiDou or GPS signal, it enters timekeeping mode and performs closed-loop compensation based on "software clock reversal." The specific steps are as follows:

[0168] 1. Real-time inference and prediction;

[0169] The processor collects current environmental parameters at fixed intervals (e.g., 1 second), inputs them into the trained GRU model, and calculates the prediction frequency error rate of the crystal oscillator at the current moment. .

[0170] 2. Compensation calculation;

[0171] The PMU's local clock is driven by a hardware timer, which generates a second interrupt when it reaches a reload value; let the nominal reload value be... In order to compensate for the frequency drift of the crystal oscillator, the processor needs to dynamically adjust the reload value.

[0172] Derivation of the compensation principle: If the crystal oscillator speed increases ( ), actual oscillation frequency To ensure logical seconds The total number of pulses the counter needs to count remains unchanged. It should meet the following requirements:

[0173]

[0174] Therefore, the processor calculates the corrected reload value. :

[0175]

[0176] 3. Implementation will be dynamically adjusted;

[0177] The processor will calculate Write to the reload register of the hardware timer. In the next counting cycle, the timer will count according to the new threshold. In this way, although the frequency of the physical crystal oscillator drifts, by dynamically lengthening or shortening the counting cycle, the second pulse and timestamp output by the PMU always keep up with the standard time, achieving lossless software compensation.

[0178] Example 7:

[0179] The low-cost, precise timekeeping device based on a gated loop unit can be logically divided into the following modules, which are implemented by the processor executing instructions from memory:

[0180] 1. The status monitoring module is configured to monitor the lock status signal of the GPS receiver in real time; when the status changes from "locked" to "unlocked", a signal is sent to trigger the error compensation module to start; when the status changes from "unlocked" to "locked", the online training module is triggered.

[0181] 2. The data acquisition and feature engineering module's input interface is responsible for driving the digital temperature sensor via the I2C bus protocol to acquire temperature data T; simultaneously, it reads the time increment from the hardware counter register. The feature calculation module is responsible for executing the formulas... Normalization operations are performed to construct a feature matrix that conforms to the input dimension of the GRU network.

[0182] 3. GRU prediction and inference module: This module contains a pre-trained GRU network structure and weight parameters. The GRU prediction and inference module has the following features:

[0183] Tensor operation unit: Utilizes the processor's FPU or DSP instruction set to efficiently execute the matrix multiplication described in step S3. Addition and activation functions Calculation.

[0184] State Management Unit: Responsible for maintaining the hidden state vectors of the GRU network in RAM. And update the vector after each inference for use in the next time step.

[0185] 4. Error compensation control module, which has:

[0186] Step calculation unit: responsible for execution Figure 1 The steps described in step S5 The calculation formula converts the predicted floating-point error rate into an integer counter register value.

[0187] Register operation interface: Responsible for directly accessing the MCU's hardware timer register address through the underlying driver, writing the calculated compensation value, and completing the physical adjustment of the clock rate.

[0188] 5. The online model maintenance module is configured to calculate the total time drift during the timekeeping period after the external signal is recovered. If the drift exceeds a preset threshold, the incremental learning process is initiated to update the weight matrix of the GRU network using newly acquired data. and bias .

[0189] Example 8:

[0190] Reference Figure 6 This embodiment provides a low-cost, accurate timekeeping system based on a gated loop unit, used to implement the steps of the aforementioned low-cost, accurate timekeeping method based on a gated loop unit. The system includes:

[0191] The operating parameter detection module is used to monitor the operating parameters of the crystal oscillator (crystal oscillator) inside the phasor measurement unit that affect its frequency stability;

[0192] The frequency error calculation module, based on the operating parameters obtained by the operating parameter detection module, uses a crystal oscillator frequency drift prediction model based on a gated cyclic unit network to calculate the current frequency error of the crystal oscillator in real time.

[0193] The time correction module is used to generate a time correction amount based on the current frequency error obtained by the frequency error calculation module.

[0194] The timekeeping implementation module is used to apply the time correction amount obtained by the time correction module to the local clock of the phasor measurement unit to compensate for the frequency drift of the crystal oscillator and achieve accurate timekeeping.

[0195] Furthermore, the low-cost, accurate timekeeping device based on gated cyclic units also includes an online adaptive optimization module. After the monitoring phasor measurement unit recovers from a state without external signals to a state with external signals, the module calculates the total time error accumulated during the period without signals and feeds this total time error back to the crystal oscillator frequency drift prediction model based on the gated cyclic unit network. The module then fine-tunes the weight parameters of the crystal oscillator frequency drift prediction model based on the gated cyclic unit network through incremental learning to correct the model deviation caused by changes in the aging characteristics of the crystal oscillator.

[0196] While preferred embodiments of the present invention have been described above, those skilled in the art, upon learning the basic inventive concept, can make further changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the present invention. Clearly, those skilled in the art can make various alterations and modifications to the present invention without departing from its spirit and scope. Thus, if these modifications and modifications of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention also intends to include these modifications and modifications.

Claims

1. A low-cost, accurate timekeeping method based on a gated loop unit, characterized in that, When the phasor measurement unit cannot receive an external time synchronization signal, this is implemented, including the following steps: Real-time monitoring of operating parameters affecting the frequency stability of the crystal oscillator inside the phasor measurement unit; Based on the operating parameters, the current frequency error of the crystal is calculated in real time using a crystal frequency drift prediction model based on a gated cyclic unit network. Based on the current frequency error, a time correction amount is generated; The time correction is applied to the local clock of the phasor measurement unit to compensate for the frequency drift of the crystal oscillator and achieve accurate timekeeping.

2. The low-cost, accurate timekeeping method based on a gated loop unit according to claim 1, characterized in that, The operating parameters include the ambient temperature of the crystal oscillator, the cumulative operating time, and / or the rate and direction of temperature change. The cumulative operating time is the cumulative operating time of the phasor measurement unit since it has been powered on.

3. The low-cost, accurate timekeeping method based on a gated loop unit according to claim 2, characterized in that, The real-time ambient temperature is acquired by a sensor attached to the crystal oscillator and is used to characterize the basic temperature drift; the cumulative running time is used to characterize the physical aging of the crystal oscillator over time; the temperature change rate and direction are used to capture the thermal hysteresis effect of the crystal oscillator.

4. The low-cost, accurate timekeeping method based on a gated loop unit according to claim 2, characterized in that, The operating parameters constitute the input feature vector of the crystal oscillator frequency drift prediction model. The input feature vector includes at least: the current ambient temperature of the crystal oscillator and the cumulative operating time of the phasor measurement unit since power-on.

5. The low-cost, accurate timekeeping method based on a gated loop unit according to claim 4, characterized in that, The input feature vector also includes the rate of temperature change and / or the direction of temperature change.

6. The low-cost, accurate timekeeping method based on a gated loop unit according to claim 1, characterized in that, The crystal oscillator frequency drift prediction model based on the gated cyclic unit network is pre-established and obtained by training it during the training phase when the phasor measurement unit can receive external time synchronization signals, through the following steps: Data alignment and acquisition specifically involves synchronously acquiring the operating parameters as input samples at a preset sampling period, and simultaneously obtaining the difference between the local clock time of the phasor measurement unit and the time of the external time synchronization signal. Tag calculation specifically involves calculating the actual frequency error rate (FER) of the crystal oscillator under the current environment based on the time difference between two adjacent sampling times, and using the actual frequency error rate as the target tag corresponding to the input sample. Sequence construction specifically employs a sliding window mechanism to combine input samples from multiple consecutive historical moments with their corresponding target labels to construct a time series training dataset. Supervised learning specifically involves inputting the time-series training dataset into an initialized gated recurrent unit network model, and optimizing the model parameters by minimizing the loss function between the predicted output and the target label through the backpropagation algorithm.

7. The low-cost, accurate timekeeping method based on a gated loop unit according to claim 1, characterized in that, The crystal oscillator frequency drift prediction model based on a gated recurrent unit network has a network structure including an input layer, at least one hidden layer, and an output layer. The hidden layer consists of multiple gated recurrent units (GRUs), each of which contains a reset gate and an update gate. The gated recurrent units are configured to perform the following operations to capture the frequency drift characteristics of the crystal oscillator: The reset gate is used to determine how much of the previous hidden state information should be forgotten when calculating the current candidate hidden state, in order to adapt to the rapid changes in the temperature characteristics of the crystal oscillator. Using the update gate, it is determined how much of the previous hidden state information to retain and how much of the current candidate hidden state information to fuse into the current final hidden state, in order to maintain a long-term memory of the crystal oscillator aging effect. The output layer is a fully connected layer used to map the final state of the hidden layer to a single scalar value, namely the current frequency error.

8. The low-cost, accurate timekeeping method based on a gated loop unit according to claim 1, characterized in that, The method also includes an online adaptive optimization step, which involves calculating the total time error accumulated during the signal-free period after the phasor measurement unit recovers from a state without external signals to a state with external signals, and feeding this total time error back to the crystal oscillator frequency drift prediction model based on the gated cyclic unit network. The weight parameters of the crystal oscillator frequency drift prediction model based on the gated cyclic unit network are fine-tuned through incremental learning to correct the model deviation caused by changes in the aging characteristics of the crystal oscillator.

9. The low-cost, accurate timekeeping method based on a gated loop unit according to claim 1, characterized in that, The step of applying the time correction to the local clock of the phasor measurement unit specifically includes: determining the compensation step value of the local counter of the phasor measurement unit based on the calculated current frequency error; writing the compensation step value into the hardware timer register of the phasor measurement unit to dynamically adjust the counting rate of the local clock so that the duration of "one second" of the local clock is physically close to one second of the standard time.

10. A low-cost, accurate timekeeping system based on a gated loop unit, used to implement the steps of the low-cost, accurate timekeeping method based on a gated loop unit as described in any one of claims 1 to 7, characterized in that, The system includes: The operating parameter detection module is used to monitor the operating parameters of the crystal oscillator (crystal oscillator) inside the phasor measurement unit that affect its frequency stability; The frequency error calculation module, based on the operating parameters obtained by the operating parameter detection module, uses a crystal oscillator frequency drift prediction model based on a gated cyclic unit network to calculate the current frequency error of the crystal oscillator in real time. The time correction module is used to generate a time correction amount based on the current frequency error obtained by the frequency error calculation module. The timekeeping implementation module is used to apply the time correction amount obtained by the time correction module to the local clock of the phasor measurement unit to compensate for the frequency drift of the crystal oscillator and achieve accurate timekeeping.

11. The low-cost, precise timekeeping system based on a gated loop unit according to claim 10, characterized in that, The low-cost, accurate timekeeping system based on gated cyclic units also includes an online adaptive optimization module. After the monitoring phasor measurement unit recovers from a state without external signals to a state with external signals, the module calculates the total time error accumulated during the period without signals and feeds this total time error back to the crystal oscillator frequency drift prediction model based on the gated cyclic unit network. The module then fine-tunes the weight parameters of the crystal oscillator frequency drift prediction model based on the gated cyclic unit network through incremental learning to correct the model deviation caused by changes in the aging characteristics of the crystal oscillator.

12. A low-cost, precise timekeeping device based on a gated loop unit, characterized in that, include: The processor, as the core computing unit, is configured to execute a low-cost, accurate timekeeping method based on gated loop units; The memory, coupled to the processor, is used to store the operating system, the weight parameter matrix of the gated recurrent unit network model, and the historical running data queue; The local clock source provides the basic clock pulse signal for the entire device and is directly connected to the clock input of the processor's internal hardware timer. The temperature acquisition component uses a digital temperature sensor, which is physically attached to the surface of the local clock source. An external time signal receiver outputs standard time information and a high-precision second pulse signal, which is connected to the processor's external interrupt pin and the timer's input capture channel.

13. The low-cost, precise timekeeping device based on a gated loop unit according to claim 12, characterized in that, The local clock source uses a low-cost temperature-compensated crystal oscillator; the processor uses an embedded microcontroller with a floating-point unit; the processor integrates a hardware timer, SRAM and Flash memory.

Citation Information

Cited By

  • Synchronous phasor standard source system based on high-precision harmonic source and phase control method

    CN122150955A