Dynamic time keeping method for clock monitoring of super-large scale metering device
By collecting and processing battery health, voltage, temperature, and load rate data in a large-scale metering device, calculating crystal oscillator frequency offset using Kalman filtering and mapping models, and combining linear regression to predict synchronization error, the calibration strategy is dynamically adjusted to solve the clock drift problem caused by battery aging and achieve high-precision and stable time synchronization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 国网安徽省电力有限公司营销服务中心
- Filing Date
- 2025-12-29
- Publication Date
- 2026-05-12
AI Technical Summary
Existing technologies suffer from crystal oscillator frequency shift and clock drift issues caused by battery aging in ultra-large-scale metering devices. This makes it difficult to achieve accurate calibration and avoid error accumulation, especially in low-power scenarios, resulting in difficulty in guaranteeing time synchronization accuracy.
Battery health, voltage, temperature, and load rate data are collected by sensors at each node in a distributed network. Kalman filtering is used to generate crystal oscillator offset correlation parameters. The crystal oscillator frequency offset is calculated by combining a multi-dimensional mapping model. In low-power scenarios, the synchronization error is predicted based on linear regression of drift rate and time. The calibration strategy is dynamically adjusted, and multi-source clock data is integrated for time synchronization.
It significantly improves the clock synchronization accuracy and stability of metering devices in distributed networks, ensures data consistency and system reliability, and achieves accurate time synchronization in low-power scenarios.
Smart Images

Figure CN122018636A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of information technology, and in particular to a dynamic timekeeping method for clock monitoring of ultra-large-scale metering devices. Background Technology
[0002] In the long-term operation of ultra-large-scale metering devices, time synchronization of all equipment is crucial to ensuring the normal operation of the system. Otherwise, data timestamp errors may occur, leading to subsequent decision-making errors. For example, in smart grids, time asynchrony can cause errors in power allocation calculations and even equipment failures. The core of achieving time synchronization is controlling the clock accuracy of the equipment, which is mainly determined by the crystal oscillator frequency. A stable crystal oscillator frequency ensures accurate timekeeping; a frequency deviation results in clock drift. Existing technologies typically maintain time synchronization using fixed-period calibration, such as correcting the local clock every hour using satellite time signals. However, this method has a critical problem, making it difficult to guarantee synchronization accuracy. Firstly, existing methods do not consider the impact of battery status on the crystal oscillator; fixed calibration cannot adapt to changes caused by battery aging. Most metering devices rely on battery power, and batteries age over time. Aging batteries lead to unstable supply voltage, and voltage fluctuations directly cause crystal oscillator frequency deviations, thus increasing the clock drift rate. Because existing methods calibrate at fixed intervals, regardless of battery aging or crystal oscillator misalignment, the same intervals are applied for correction. This easily leads to a mismatch between calibration and actual requirements, ultimately resulting in increasingly larger time synchronization errors. Furthermore, in low-power scenarios, such as when some sensors reduce communication frequency with other devices to extend battery life and only operate when necessary, the above problems are further exacerbated. In low-power scenarios, devices reduce communication frequency to save power, meaning fewer opportunities to acquire external reference signals and transmit calibration data. Fixed-period calibration, already insufficient to address crystal oscillator misalignment caused by battery aging, now struggles to obtain the necessary calibration data in a timely manner. This not only fails to accurately correct clock drift but may also consume more power by forcibly communicating to obtain calibration data, creating a vicious cycle of error accumulation, calibration difficulties, and increased power consumption. Therefore, the core requirement is to first resolve the correlation between battery status and crystal oscillator misalignment, and then specifically adapt to low-power scenarios, enabling metering devices to dynamically adjust clock calibration strategies based on battery status, while simultaneously achieving accurate calibration and avoiding error accumulation under low power conditions. Summary of the Invention
[0003] This invention provides a dynamic timekeeping method for clock monitoring in ultra-large-scale metering devices, mainly comprising: Raw data from the ultra-large-scale metering device is collected by sensors at each node in the distributed network. The raw data includes battery health parameters, power supply voltage data, ambient temperature data, and load rate data. The raw data is filtered to obtain crystal oscillator offset correlation parameters, which include battery health indicators, voltage stability values, temperature compensation coefficients, and load influence weights. The crystal oscillator offset correlation parameters are input into a preset mapping model to calculate the crystal oscillator frequency offset, and the clock drift rate is evaluated based on the crystal oscillator frequency offset. In low-power scenarios, based on the clock drift rate and historical reference signal history, the relationship between the drift rate and time is fitted to predict subsequent synchronization errors; Based on the subsequent synchronization error prediction results, the node synchronization error status is determined. If the synchronization error is greater than or equal to the preset tolerance threshold, the correction frequency is adjusted, and time synchronization data of adjacent nodes are collected based on the adjusted correction frequency. Based on the time synchronization data of the adjacent nodes, multi-source clock data is fused, including network time protocol data, precision time protocol data and local clock data. A weight allocation algorithm is used to determine the comprehensive correction magnitude and generate a correction instruction. The correction instructions are distributed to the clock modules of each node, the multi-source clock data is fused, and a time synchronization operation is performed using a reference signal broadcasting mechanism to obtain the synchronized clock state. Based on the synchronized clock state, the distributed network performance indicators are monitored, calibration parameters are adjusted, and the original data acquisition is performed cyclically to form a continuous dynamic clock calibration cycle.
[0004] Furthermore, the raw data of the ultra-large-scale metering device is collected by sensors at each node in the distributed network, and the raw data is filtered to obtain crystal oscillator offset correlation parameters. These parameters include battery health indicators, voltage stability values, temperature compensation coefficients, and load influence weights. The raw data is collected by sensors at each node in the distributed network according to a preset period. The raw data includes battery internal resistance, depth of discharge, number of charge and discharge cycles, instantaneous value of power supply voltage, ambient temperature value and device load rate, generating a multi-dimensional dataset with timestamps. The device load rate is calculated by monitoring CPU utilization, memory usage and data transmission volume of communication module. The multidimensional dataset is processed by Kalman filtering. The battery internal resistance and discharge depth are set as state variables, and the instantaneous supply voltage and ambient temperature are set as observation variables. The state value at the next moment is predicted by the state transition equation. The measurement residual is calculated according to the observation equation. The state estimate is updated by Kalman gain to obtain the battery health index and voltage stability value. The change rate is calculated based on the battery health index. If the change rate exceeds the preset change rate threshold, the standard deviation of the voltage stability value is extracted. The temperature compensation coefficient is generated by multiplying the difference between the ambient temperature value and the nominal temperature of the crystal oscillator by the preset temperature coefficient. The load influence weight is generated by combining the equipment load rate and the crystal oscillator frequency offset correlation coefficient quantified using the Pearson correlation coefficient. The preset change rate threshold is determined based on the monthly change rate of the battery health index, and the standard deviation of the voltage stability value is calculated from the voltage data within a continuous minute time window. The battery health index, voltage stability value, temperature compensation coefficient, and load influence weight are processed using a normalization method to generate the crystal oscillator offset correlation parameters.
[0005] Furthermore, the step of inputting the crystal oscillator offset correlation parameters into a preset mapping model to calculate the crystal oscillator frequency offset includes: The crystal oscillator offset correlation parameters are input into a preset mapping model to calculate the crystal oscillator frequency offset. The preset mapping model is established by a multiple linear regression method, and the regression coefficients corresponding to each parameter are obtained by fitting with the least squares method. Based on the crystal oscillator frequency offset, the crystal oscillator frequency value is recorded at a fixed sampling interval within a preset time window. The difference between the frequency offset of each sampling point and the frequency offset of the previous sampling point is calculated and then divided by the sampling interval to obtain the frequency change rate of each sampling point. If the average frequency change rate of each sampling point exceeds the preset stability threshold, the frequency offset change is obtained by subtracting the frequency offset of the first sampling point from the frequency offset of the last sampling point within the time window. The frequency offset change is then divided by the time window length to generate the clock drift rate.
[0006] Furthermore, in low-power scenarios, the method of fitting the relationship between the drift rate and time based on the clock drift rate and the historical reference signal history to predict subsequent synchronization errors includes: Based on the device's sleep cycle and wake-up time, extract the timing data of the clock drift rate, calculate the synchronization deviation, and generate a drift rate numerical sequence; Using the aforementioned drift rate numerical sequence, a linear regression model is constructed. The regression coefficients, including the slope parameter and the intercept parameter, are calculated using the least squares method to obtain the linear relationship between the drift rate and time. Based on the linear relationship, any time within a day from the current time is substituted into the calculation to obtain the predicted drift rate at that time. The predicted drift rate is multiplied by the time interval from the current time to the arbitrary time to calculate the cumulative synchronization error during that period, and the subsequent synchronization error prediction value is obtained.
[0007] Furthermore, based on the subsequent synchronization error prediction results, the node synchronization error status is determined. If the synchronization error is greater than or equal to a preset tolerance threshold, the correction frequency is adjusted, and time synchronization data of adjacent nodes is collected based on the adjusted correction frequency, including: The subsequent synchronization error prediction value is compared with a preset tolerance threshold. If it is greater than or equal to the tolerance threshold, the correction frequency is adjusted by multiplying the correction frequency parameter by a preset adjustment factor to generate an updated correction frequency value. The adjustment factor is dynamically determined based on the ratio of the prediction error value to the tolerance threshold. Based on the updated correction frequency value, a time synchronization request is broadcast to neighboring nodes in the distributed network to collect time synchronization data from neighboring nodes. The time synchronization data is preprocessed to remove abnormal data and generate a preprocessed synchronization dataset.
[0008] Furthermore, the step of fusing multi-source clock data based on the time synchronization data of adjacent nodes, determining the comprehensive correction magnitude using a weighted allocation algorithm, and generating a correction instruction includes: Based on the time synchronization data of the adjacent nodes, network time protocol data, precision time protocol data and local clock data are obtained. The data and the data of the adjacent nodes are formatted and time zone aligned to generate a standardized multi-source clock dataset. For the multi-source clock dataset, calculate the standard deviation of the time deviation of each clock source and generate an adaptive weight allocation result; Based on the adaptive weight allocation result, the weighted average time value is calculated, the comprehensive correction magnitude is generated, and it is determined whether the time deviation of each node after correction is less than the preset consistency threshold. If the overall correction magnitude meets the consistency requirement and does not exceed the preset single adjustment limit, then the correction instruction containing the correction magnitude is directly generated. If the overall correction magnitude exceeds the preset single adjustment limit, it is decomposed into multiple small-amplitude adjustments, a time interval for gradual correction is set, and a step-by-step correction instruction is generated.
[0009] Furthermore, the step of distributing the correction instruction to each node clock module, fusing the multi-source clock data, and performing time synchronization using a reference signal broadcast mechanism to obtain the synchronized clock state includes: Based on the node load status and communication quality, determine the distribution order of the correction instruction or step-by-step correction instruction, and record the distribution completion status; Each node parses the correction instruction, merges the multi-source clock data, and generates a merged reference time value; Using the fused reference time value, a synchronization signal is broadcast, and the deviation between the reference timestamp and the local clock is calculated. When the deviation is less than a preset deviation threshold, the clock frequency is adjusted to gradually synchronize the clock. When the deviation is greater than or equal to the preset deviation threshold, the clock phase is directly adjusted to generate clock adjustment trajectory data. Based on the clock adjustment trajectory data, the frequency change rate and time deviation fluctuation range of each node after adjustment are calculated. If the evaluation results of all nodes are within the preset range, the synchronized clock state is generated.
[0010] Furthermore, the step of monitoring distributed network performance indicators, adjusting calibration parameters, and cyclically performing the original data acquisition based on the synchronized clock state includes: Based on the synchronized clock state, extract the time deviation value and synchronization accuracy data of each node, calculate the mean and variance of the time deviation as a consistency index, and count the maximum time difference between nodes as a dispersion index. Compare the consistency index and dispersion index with the values before synchronization to obtain the degree of performance improvement. Based on the degree of performance improvement, if the consistency index improvement exceeds the preset improvement threshold and the dispersion reduction reaches or exceeds the preset reduction, then the current calibration parameters are confirmed to be valid, and the valid correction frequency, weight allocation scheme and calibration cycle parameters are recorded. These parameters are used as the initial configuration for the next round of calibration to generate an optimized calibration parameter set. Based on the optimized calibration parameter set, the acquisition period and filtering parameters are configured, the original data acquisition is re-executed, the original data is processed by Kalman filtering to generate the crystal oscillator offset correlation parameters, and clock calibration is performed cyclically.
[0011] Furthermore, if the average frequency change rate of each sampling point exceeds a preset stability threshold, the frequency offset change is obtained by subtracting the frequency offset of the first sampling point from the frequency offset of the last sampling point within the time window. The clock drift rate is then generated by dividing the frequency offset change by the time window length. This process further includes: If the average frequency change rate of each sampling point does not exceed the preset stability threshold, the average frequency offset of all sampling points within the time window is used as the reference offset, and the clock drift rate is generated by combining the average historical drift rate output by the mapping model. The historical drift rate mean is calculated by extracting drift rate data from periods in the past day where the average rate of frequency change is less than or equal to a preset stability threshold, and then using the arithmetic mean method.
[0012] Furthermore, determining the distribution order of the correction instruction or step-by-step correction instruction based on the node load status and communication quality, and recording the distribution completion status, includes: If the node's CPU utilization rate is less than or equal to the preset utilization rate value and the memory utilization rate is less than or equal to the preset utilization rate value, the load is considered normal. If the CPU utilization rate is greater than the preset utilization rate value or the memory utilization rate is greater than the preset utilization rate value, it is determined that the load is too high; If the packet loss rate between the node and the distribution node is less than or equal to the preset packet loss rate threshold and the average latency is less than or equal to the preset time, the communication quality is deemed to be qualified. If the packet loss rate is greater than the preset packet loss rate or the average latency is greater than the preset time, the communication quality is deemed to be unqualified. Instructions are first distributed to key metering nodes, including electricity metering nodes and billing nodes, and are only distributed to ordinary metering nodes that are only used for status monitoring after the key metering nodes send back a confirmation message containing the node identifier and the receiving timestamp. If a critical metering node is determined to be overloaded or has unqualified communication quality, its load and communication status must be retested at fixed intervals until the load is normal and the communication is qualified before issuing instructions.
[0013] The technical solutions provided by the embodiments of the present invention may include the following beneficial effects: This invention discloses a dynamic timekeeping method for clock monitoring in ultra-large-scale metering devices, solving the problem of inter-node time synchronization errors caused by crystal oscillator frequency drift. The invention collects raw data such as battery health, voltage, temperature, and load rate from sensors at each node, uses Kalman filtering to smooth noise, generates crystal oscillator drift correlation parameters, and calculates the crystal oscillator frequency drift using a multi-dimensional operating condition mapping model to assess the clock drift rate. In low-power scenarios, synchronization errors are predicted based on linear regression of drift rate and time. When the error is greater than or equal to a preset tolerance threshold, the correction frequency in the variable-period calibration strategy is dynamically adjusted. Multi-source data, including NTP, PTP, and local clocks, are integrated, and an adaptive weight allocation algorithm is used to determine the comprehensive correction magnitude, ensuring data consistency. The invention distributes correction commands to the node clock modules, combining a reference signal broadcast mechanism to optimize time synchronization, continuously monitors network performance indicators, and dynamically adjusts them, forming a closed-loop calibration cycle. This invention significantly improves the clock synchronization accuracy and stability of metering devices in distributed networks, ensuring data consistency and system reliability. Attached Figure Description
[0014] Figure 1 This is a flowchart of a dynamic timekeeping method for clock monitoring of an ultra-large-scale metering device according to the present invention. Detailed Implementation
[0015] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.
[0016] like Figure 1 This embodiment of a dynamic timekeeping method for clock monitoring of an ultra-large-scale metering device may specifically include: S101. The raw data of the ultra-large-scale metering device, including battery health parameters, power supply voltage data, real-time ambient temperature data and load rate data of each node, are collected by the sensors of each node in the distributed network. The raw data is processed by Kalman filtering to remove noise and obtain crystal oscillator offset correlation parameters. The crystal oscillator offset correlation parameters include smoothed battery health indicators, voltage stability values, temperature compensation coefficients and load influence weights.
[0017] Raw data from a large-scale metering device is acquired by sensors at each node in a distributed network according to a preset acquisition cycle. This includes battery internal resistance, depth of discharge, and charge / discharge cycle count as battery health parameters. Instantaneous power supply voltage and its fluctuation amplitude are also collected. Ambient temperature and equipment load rate at each node are recorded. The collected data are arranged in a time series to obtain a multi-dimensional raw dataset with timestamps. Kalman filtering is applied to this multi-dimensional raw dataset. Battery internal resistance and depth of discharge are set as state variables, while instantaneous power supply voltage and ambient temperature are observed variables. The state value at the next moment is predicted using a state transition equation. The measurement residual is calculated based on the observation equation, and the state estimate is updated using Kalman gain. Measurement noise is filtered out to obtain smoothed battery health indicators and voltage stability values. The rate of change of the smoothed battery health indicators is calculated. If the rate of change exceeds a preset threshold, the standard deviation of the voltage stability value is extracted. The temperature compensation coefficient is obtained by multiplying the difference between the ambient temperature and the nominal temperature of the crystal oscillator by a preset temperature coefficient. The correlation coefficient between equipment load rate and crystal oscillator frequency offset is used as the load influence weight. The battery health index, voltage stability value, temperature compensation coefficient, and load influence weight are processed using a normalization method to bring all parameters into the same order of magnitude range, forming a crystal oscillator offset correlation parameter group, which includes the smoothed battery health index, voltage stability value, temperature compensation coefficient, and load influence weight.
[0018] Specifically, in one implementation, clock calibration of a large-scale metering device requires accurate acquisition of various parameters affecting the crystal oscillator frequency. Sensors at each node in the distributed network perform data acquisition tasks according to a preset acquisition cycle, which is set according to the application scenario of the metering device; in power metering systems, it is typically set to acquire data once per minute. The battery health parameters acquired by the sensors include battery internal resistance, depth of discharge, and charge-discharge cycle count; these parameters directly reflect the degree of battery aging.
[0019] Specifically, the battery's internal resistance is obtained by applying an AC signal of known frequency to both ends of the battery and measuring the response voltage. An increase in internal resistance indicates the degradation of the battery's internal chemical composition. Depth of discharge records the percentage of battery capacity used during each discharge cycle, while the charge-discharge cycle count accumulates the number of complete cycles from fully charged to fully discharged and then fully charged again. Supply voltage data includes two dimensions: instantaneous value and fluctuation amplitude. The instantaneous value reflects the voltage level at a specific moment, while the fluctuation amplitude is obtained by calculating the standard deviation of the voltage over a certain time window. These two parameters together describe the impact of power supply quality on the crystal oscillator's operating state.
[0020] It's important to note that collecting data on ambient temperature and device load rate is equally crucial. Temperature sensors are deployed at critical locations on the metering device, particularly near the crystal oscillator, as the crystal's frequency characteristics are extremely sensitive to temperature changes. Device load rate is calculated by monitoring CPU utilization, memory usage, and data transmission volume of the communication module. High load conditions increase device power consumption, leading to localized temperature increases and impacting power supply stability. All collected data is arranged in a time series, with each data point accompanied by a precise timestamp, forming a multi-dimensional raw dataset.
[0021] In one possible implementation, Kalman filtering is a key step in eliminating measurement noise. The core of the Kalman filter lies in establishing a state-space model, setting the battery's internal resistance and depth of discharge as state variables, because these two parameters change relatively slowly and continuously. The state transition equation describes the evolution of the state variables from the current moment to the next. For the battery's internal resistance, its growth typically follows a linear or exponential law, which can be expressed as the internal resistance at the next moment equal to the current internal resistance plus the aging increment. The observation equation establishes the relationship between the observed variables and the state variables. The instantaneous supply voltage is affected by the battery's internal resistance; when the internal resistance increases, the voltage drop under the same load also increases. Ambient temperature, as another observed variable, is related to the battery's electrochemical reaction rate; increased temperature accelerates the battery aging process.
[0022] Preferably, the iterative process of Kalman filtering includes two stages: prediction and update. In the prediction stage, a prior estimate of the state at the next time step is calculated based on the state transition equation, while simultaneously updating the error covariance matrix. In the update stage, the measurement residual is calculated using new observation data; that is, the difference between the observed value and the predicted value based on the prior estimate. The Kalman gain is determined based on the ratio of the prediction error covariance to the observation noise covariance; a larger gain indicates greater confidence in the observed value, while a smaller gain indicates greater confidence in the predicted value. The prior estimate is corrected using the Kalman gain to obtain the posterior estimate, i.e., the smoothed battery health indicators and voltage stability values. This filtering method is particularly suitable for processing time-series data in metering devices because it can track the true changes in the system state even in the presence of measurement noise.
[0023] For example, after obtaining the smoothed parameters, the system needs to assess the impact of these parameters on the crystal oscillator frequency. The rate of change of the battery health index is calculated by the difference between values at adjacent time points. When the rate of change exceeds a preset threshold, it indicates that the battery is aging faster, and its impact on the crystal oscillator needs to be closely monitored. The preset threshold is determined based on the specific metering device type and application environment. In smart meters, an alarm is triggered when the monthly decline rate of the battery health index exceeds two percent.
[0024] In one embodiment, the standard deviation extraction process for voltage stability values involves sliding window calculation. The system collects voltage data within consecutive time windows, calculating the mean and standard deviation for each window. A larger standard deviation indicates more severe voltage fluctuations and a greater threat to crystal oscillator frequency stability. The temperature compensation coefficient is obtained based on the crystal oscillator's temperature characteristic curve, typically provided by the crystal oscillator manufacturer, which describes the frequency shift at different temperatures. The system calculates the difference between the current ambient temperature and the crystal oscillator's nominal temperature, multiplies it by a temperature coefficient to obtain the temperature compensation coefficient, which is used to correct for temperature-induced frequency shifts.
[0025] For example, in a practical smart grid metering system, the nominal temperature of a crystal oscillator at a metering node is 25 degrees Celsius, with a temperature coefficient of 0.5 ppm per degree Celsius. When the ambient temperature rises to 35 degrees Celsius, the temperature difference is 10 degrees Celsius, and the temperature compensation coefficient is calculated to be 5 ppm, meaning that the crystal oscillator frequency will deviate by five parts per million. The load impact weight is derived by analyzing the correlation between equipment load rate and crystal oscillator frequency deviation in historical data, typically using the Pearson correlation coefficient to quantify this relationship.
[0026] Understandably, normalization is a necessary step to ensure that all parameters are compared and integrated on the same scale. Because battery health indicators, voltage stability values, temperature compensation coefficients, and load influence weights have significantly different dimensions and numerical ranges, directly using the raw values would lead to some parameters being ignored in subsequent processing. Normalization methods map all parameters to the range of 0 to 1; commonly used methods include max-min normalization and Z-score normalization. After normalization, the resulting crystal oscillator offset-related parameter set contains four key elements. These parameters are interrelated and jointly determine the actual operating frequency of the crystal oscillator, providing accurate input data for subsequent clock drift rate calculations and dynamic calibration strategy formulation.
[0027] S102. Input the crystal oscillator offset correlation parameters into the preset multi-dimensional working condition and crystal oscillator offset mapping model, calculate the current crystal oscillator frequency offset, trigger clock drift rate evaluation based on the current crystal oscillator frequency offset, and obtain the clock drift rate.
[0028] The battery health index, voltage stability value, temperature compensation coefficient, and load influence weight from the crystal oscillator offset associated parameter group are input into a preset mapping relationship. This mapping relationship is established using a multiple linear regression method, with historical runtime parameter values as independent variables and the measured crystal oscillator frequency offset at the corresponding moment as the dependent variable for fitting, to obtain the regression coefficients corresponding to each parameter. The current parameter value is multiplied by the regression coefficients and accumulated to obtain the current crystal oscillator frequency offset. Based on the current crystal oscillator frequency offset, the crystal oscillator frequency value is recorded at a fixed sampling interval within a preset time window. The difference between the frequency offset at each sampling point and the frequency offset at the previous sampling point is calculated and then divided by the sampling interval to obtain the frequency change rate at each sampling point. If the average frequency change rate exceeds a preset stability threshold, the clock drift rate evaluation process is triggered. The frequency offset change is obtained by subtracting the frequency offset at the first sampling point from the frequency offset at the last sampling point within the time window. The frequency offset change is then divided by the time window length to obtain the clock drift rate.
[0029] Specifically, in one implementation, the mapping relationship between the crystal oscillator offset correlation parameter and the crystal oscillator frequency offset is established through training with historical data.
[0030] Specifically, the system collects historical data from ultra-large-scale metering devices under different operating conditions, including battery health indicators, voltage stability values, temperature compensation coefficients, load influence weights, and corresponding measured crystal oscillator frequency offsets at each time point. This data forms a training sample set, where the parameters serve as the independent variable matrix and the frequency offset serves as the dependent variable vector.
[0031] It should be noted that the multiple linear regression method uses the least squares method to solve for the regression coefficients. In smart meter applications, the regression coefficients for battery health indicators are typically negative, indicating that the higher the battery aging level, the greater the negative shift in crystal oscillator frequency. The regression coefficient for voltage stability reflects the impact of power supply fluctuations on frequency, while the regression coefficient for temperature compensation reflects the frequency drift characteristics caused by temperature changes. When new crystal oscillator offset correlation parameters are input, the system multiplies each parameter value by its corresponding regression coefficient, and sums them to obtain the predicted value of the current crystal oscillator frequency offset.
[0032] Preferably, the frequency change rate is monitored using a sliding time window mechanism. The system continuously records the crystal oscillator frequency value within the time window according to a preset sampling interval. The frequency offset of each sampling point is obtained by comparing it with the nominal frequency, and the difference in frequency offset between adjacent sampling points divided by the sampling interval is the instantaneous frequency change rate. When the average frequency change rate of multiple consecutive sampling points exceeds the stability threshold, it indicates that the crystal oscillator's operating state has changed abnormally, triggering the precise clock drift rate assessment process.
[0033] In one possible implementation, the clock drift rate is calculated based on the cumulative frequency offset over the entire time window. The system records the frequency offset at the start and end of the time window; the difference between the two reflects the total frequency offset change during that period. Dividing the total frequency offset change by the time window length yields the average clock drift rate. This drift rate directly reflects the rate of clock error accumulation under the current operating conditions, providing a quantitative basis for subsequent synchronization error prediction and calibration strategy adjustments.
[0034] S103. In low-power scenarios, based on the historical records of clock drift rate and reference signal, a linear regression model is used to fit the relationship between drift rate and time, and the subsequent synchronization error is predicted based on the fitting results.
[0035] In low-power scenarios, based on the device's sleep cycle and wake-up time, time-series data of clock drift rate is extracted. The difference between the reference signal reception timestamp and the local clock timestamp at each wake-up is recorded as the synchronization deviation. The increment of the synchronization deviation between adjacent wake-up cycles is calculated and divided by the cycle duration to obtain the drift rate numerical sequence for each cycle. A linear regression model is constructed using the drift rate numerical sequence, with historical time points as independent variables and the drift rate at the corresponding time as the dependent variable. The regression coefficients are calculated using the least squares method to obtain the slope and intercept parameters. The slope reflects the trend of drift rate change over time, and the intercept reflects the initial drift rate level, thus obtaining a linear relationship between drift rate and time. Based on this linear relationship, the predicted drift rate for that time is calculated by substituting future times. The predicted drift rate is multiplied by the time interval from the current time to the future time to calculate the cumulative synchronization error within that time period, and the subsequent predicted synchronization error value is output.
[0036] Specifically, in one implementation, clock drift rate monitoring in low-power scenarios presents unique challenges. To extend battery life, the metering device employs a periodic sleep-wake mechanism, where the device remains in sleep mode most of the time, only briefly waking up at predetermined intervals to perform data acquisition and communication tasks. This operating mode significantly reduces opportunities to acquire reference signals, rendering traditional continuous calibration methods inapplicable.
[0037] Specifically, each time the device wakes up from sleep mode, it immediately records the current timestamp of its local clock and simultaneously receives a reference time signal from the gateway or base station. The difference between the two timestamps reflects the synchronization deviation at that moment. By recording the deviation over multiple consecutive wake-up cycles, the system calculates the increment of the deviation between adjacent cycles, divides it by the cycle duration, and obtains the actual drift rate for each cycle. These drift rate values are arranged in chronological order to form timing data reflecting changes in the stability of the crystal oscillator frequency.
[0038] It should be noted that the linear regression model is constructed based on the assumption that the drift rate changes linearly over time. In smart meter applications, due to the relatively slow impact of battery aging and environmental factors, the drift rate exhibits an approximately linear trend in the short term. The system uses historical time points as independent variables and the corresponding drift rate as the dependent variable, solving the regression equation using the least squares method. The slope parameter in the regression coefficients quantifies the rate of change of the drift rate; a positive slope indicates a gradual increase in the drift rate, while a negative slope indicates a gradual decrease. The intercept parameter represents the drift rate value of the regression line at time zero, reflecting the crystal oscillator frequency offset characteristics in the initial state.
[0039] Preferably, the synchronization error prediction is achieved using an extrapolation method. Based on the established linear relationship, the time value at a future moment is substituted into the equation to calculate the predicted drift rate at that moment. The product of the predicted drift rate and the time interval is the cumulative synchronization error during that period.
[0040] In one possible implementation, the system dynamically adjusts the wake-up frequency based on the accumulated predicted synchronization error. When the predicted error is greater than or equal to a preset tolerance threshold, the number of wake-ups is temporarily increased to obtain more reference signals for calibration. When the predicted error is much smaller than the threshold, the sleep time is appropriately extended to save power. This predictive adjustment mechanism achieves dynamic optimization of power consumption while ensuring time synchronization accuracy.
[0041] S104. Based on the prediction results of subsequent synchronization errors, determine the node synchronization error situation. If the synchronization error is about to exceed the tolerance limit, increase the correction frequency in the preset variable period calibration strategy according to the original correction frequency, and start the collection and preprocessing of time synchronization data of adjacent nodes in the distributed network based on the updated correction frequency parameters.
[0042] Based on the prediction results of subsequent synchronization errors, the predicted error value is compared with a preset tolerance threshold. If the predicted error value is greater than or equal to the preset tolerance threshold, a calibration frequency adjustment process is triggered. The current corrected frequency parameter is obtained, and the corrected frequency parameter is multiplied by a preset adjustment factor to obtain the updated corrected frequency value. According to the updated corrected frequency value, a time synchronization request message is broadcast to neighboring nodes in the distributed network. After receiving the request, the neighboring nodes return their own timestamp data and clock status information. Time synchronization data from multiple neighboring nodes are collected to form an original synchronization dataset. The original synchronization dataset is preprocessed to remove data whose transmission delay exceeds a preset threshold. The mean and variance of the timestamps of the remaining data are calculated. Abnormal timestamp data that deviates from the mean by more than a preset multiple of the standard deviation are identified and marked. Time synchronization data within the normal range is retained to obtain the preprocessed synchronization dataset.
[0043] Specifically, in one implementation, the synchronization error is determined based on a real-time comparison of the predicted error value with a tolerance threshold. The tolerance threshold is pre-set according to the application scenario of the metering device; in smart grids, this threshold is typically set at the millisecond level to meet the stringent time synchronization requirements of power dispatch. When the predicted error value is greater than or equal to the tolerance threshold, the system determines that the current calibration frequency is insufficient to maintain synchronization accuracy and triggers an adaptive adjustment mechanism.
[0044] Specifically, the adjustment of the correction frequency is achieved using a multiplication factor. The current correction frequency parameter is obtained, and then multiplied by a preset adjustment factor, which is 1.2-1.5. This preset adjustment factor is dynamically selected based on the ratio of the prediction error value to the tolerance threshold, resulting in the updated correction frequency value.
[0045] It should be noted that time synchronization data acquisition in a distributed network involves a multi-hop communication mechanism. When a node broadcasts a time synchronization request message to its neighboring nodes, the message includes a local timestamp of the sending time. Upon receiving the request, a neighboring node records the timestamp of the receiving time and includes its own clock state information in the returned message, including the current time, the last calibration time, and the estimated drift rate. By collecting response data from multiple neighboring nodes, a raw synchronization dataset containing timestamp pairs and transmission delay information is formed.
[0046] Preferably, the preprocessing process employs statistical methods to identify and remove outlier data. The system first calculates the median of all transmission delays, marking data exceeding a preset multiple of the median as transmission anomalies and removing them. For the remaining data, the mean and standard deviation of the timestamps are calculated, and the three-sigma criterion is used to identify outlier timestamps; data points deviating from the mean by more than three times the standard deviation are considered outliers.
[0047] In one possible implementation, preprocessing also includes clock quality assessment. The system evaluates the clock reliability based on the clock state information returned by each node, assigning different weights to subsequent time fusion. The preprocessed synchronization dataset contains filtered, high-quality timestamp data that reflects the true clock state of each node in the network, providing a reliable data foundation for subsequent multi-source clock fusion.
[0048] S105. Based on the preprocessed time synchronization data of adjacent nodes, the multi-source clock data of NTP, PTP and local clock are fused, and the comprehensive correction magnitude is determined by the fusion algorithm with adaptive weight allocation. It is then determined whether the magnitude is sufficient to maintain the data consistency of the distributed network, and the correction instruction is obtained.
[0049] Based on the timestamp deviation values in the preprocessed adjacent node time synchronization data, the network timestamp and its round-trip delay provided by the NTP protocol are obtained, as well as the hardware timestamp and its link delay provided by the PTP protocol. The current time value and historical drift rate of the local clock are read. The three types of clock source data and adjacent node data are formatted and time zone aligned to obtain a standardized multi-source clock dataset. Using the multi-source clock dataset, the standard deviation of the time deviation of each clock source within the past time window is calculated as a precision index. The reciprocal of the precision index is used as the initial weight, with the PTP hardware timestamp receiving the largest weight due to its highest precision. The NTP weight is adjusted according to network latency jitter, the local clock weight is adjusted according to the crystal oscillator aging degree, and the adjacent node data weight is determined according to the inter-node communication quality. Normalization is used to make the sum of the weights equal to one, resulting in an adaptive weight allocation result. Based on the adaptive weight allocation result, the time value of each clock source is multiplied by its corresponding weight and then summed to calculate a weighted average time value. The difference between the weighted average time value and the local clock is used as the comprehensive correction magnitude. It is then determined whether the time deviation of each node after correction is less than a preset consistency threshold. If the overall correction magnitude meets the consistency requirement and does not exceed the single adjustment limit, a correction instruction containing the correction magnitude is directly generated; if the correction magnitude exceeds the preset single adjustment limit, it is decomposed into multiple small-amplitude adjustments, and the time interval for progressive correction is set to obtain a step-by-step correction instruction.
[0050] Specifically, in one implementation, a multi-source clock data fusion mechanism is the core technology for achieving high-precision time synchronization in ultra-large-scale metering devices. The system needs to simultaneously process time sources from different protocols and accuracy levels, including millisecond-level precision time provided by the Network Time Protocol (NTP), microsecond-level precision time provided by the Precision Time Protocol (PTP), the local crystal clock, and pre-processed time data from neighboring nodes. These time sources each have their own characteristics: NTP uses software timestamps, which are easy to deploy but whose accuracy is affected by network latency; PTP uses hardware timestamps, offering high accuracy but requiring dedicated hardware support; the local clock is continuously available but suffers from cumulative drift; and neighboring node data reflects the time state of the local network.
[0051] Specifically, the standardization process first addresses the format differences between different time sources. NTP timestamps use a 64-bit format, with the high 32 bits representing the number of seconds since 1900 and the low 32 bits representing the fractional part of the seconds; PTP timestamps contain a 48-bit second field and a 32-bit nanosecond field; local clocks typically use the system time format; and data from adjacent nodes has already been preprocessed to form a unified format. The system converts all time data into a unified timestamp format with nanosecond precision and performs time zone alignment to eliminate deviations caused by differences in time zone settings. It also records additional information for each time source, including NTP round-trip time, PTP link latency, the historical drift rate of the local clock, and communication quality metrics for adjacent nodes.
[0052] It's important to note that the core of the adaptive weight allocation mechanism lies in dynamically evaluating the reliability of each time source. Within past time windows, the system continuously records the deviation between the time values provided by each time source and the final fusion time, calculating the standard deviation of the deviation sequence as the accuracy index for that time source. The smaller the accuracy index, the more stable and reliable the time source. Weight calculation uses the reciprocal of the accuracy index, meaning that time sources with higher accuracy receive greater weight. In practical applications, PTP, due to its hardware timestamp characteristics, typically has an accuracy index in the nanosecond range, thus receiving the highest weight; NTP's accuracy index is affected by network conditions, fluctuating in the millisecond range, resulting in a relatively lower weight; the weight of the local clock gradually decreases with increasing runtime, reflecting the impact of crystal oscillator aging on accuracy; the weight of adjacent node data is dynamically adjusted based on the physical distance between nodes and the quality of the communication link.
[0053] Preferably, the dynamic adjustment of weights also considers handling abnormal situations. When an anomaly is detected in a time source, such as an unresponsive NTP server, a PTP master clock switch, or a neighboring node losing connection, the system temporarily reduces the weight of that time source to zero to prevent abnormal data from affecting the fusion result. Weight normalization ensures that the sum of all weights is always 1, so that the fusion result is always a weighted average of all time sources, maintaining numerical stability.
[0054] In one possible implementation, the weighted fusion calculation employs a real-time processing mechanism. The system multiplies the current time value of each time source with its corresponding weight, and then sums all the multiplications to obtain the weighted average time. This weighted average time represents the most likely true time after comprehensively considering all available time sources. The overall correction magnitude is calculated by subtracting the weighted average time from the local clock; this difference directly reflects the amount of adjustment required for the local clock.
[0055] For example, the consistency assessment process evaluates the corrected network time synchronization status. The system predicts whether the time deviation of each node in the network can be controlled within an acceptable range if the local clock is adjusted according to the calculated comprehensive correction magnitude. The consistency threshold is set according to specific application requirements; in smart grid metering systems, the time deviation of all nodes is typically required to be no more than 1 millisecond. If the predicted deviation meets this requirement, it indicates that the current correction magnitude is appropriate and can be directly implemented. Furthermore, a step-by-step correction mechanism is used to handle situations where the correction magnitude is too large. When the comprehensive correction magnitude exceeds the upper limit of a single adjustment, directly performing a large-scale time adjustment may lead to system oscillation or data timing disorder.
[0056] For example, if the local clock is 10 seconds behind, jumping forward 10 seconds directly would cause the timestamps of the data within those 10 seconds to overlap, affecting the causal relationship of the data. Therefore, if the correction exceeds the preset single adjustment limit of 100 milliseconds, the system will break down the large correction into multiple small adjustments, each adjustment not exceeding the preset safety range, gradually eliminating the time deviation through gradual correction.
[0057] For example, in the actual deployment of an electricity metering network, when a metering node that has been offline for a long time comes back online, its local clock may have developed a deviation of several seconds. The system calculates that a 5-second deviation needs to be corrected through multi-source clock fusion, but directly adjusting by 5 seconds would affect the ongoing electricity calculation. Therefore, the system breaks down the correction process into 50 small adjustments of 100 milliseconds each, executed once per minute, gradually completing time synchronization within 50 minutes. This ensures the final synchronization accuracy while avoiding disruption to business operations.
[0058] Understandably, the final formation of the correction instruction also includes optimization of the execution timing. The system chooses to perform the correction during periods of low business load to reduce the impact on normal metering services. The correction instruction includes not only information on the correction magnitude, but also the start time, step interval, and completion deadline, forming a complete correction execution plan.
[0059] S106. Under the requirement of system stability, the correction command is distributed to the clock module of each node. The data fusion method is used to fuse multi-source data including NTP, PTP and local clock. The reference signal broadcast mechanism is used to perform dynamic adjustment and optimized time synchronization operation to obtain the synchronized clock state.
[0060] Under system stability requirements, the current load status and communication link quality of each node are checked. The distribution order is determined according to the importance of each node in the metering network, with key metering nodes receiving correction instructions first. The instruction reception timestamp and acknowledgment response of each node are recorded to obtain the instruction distribution completion status. Based on the instruction distribution completion status, the clock module of each node parses the correction amplitude parameter in the correction instruction, obtains the NTP server timestamp, PTP master clock hardware timestamp, and the current value of the local crystal oscillator clock, and fuses the NTP, PTP, and local clock data using a weighted average method. The weights are dynamically allocated according to the real-time accuracy of each time source to obtain the fused reference time value. Using the fused reference time value, a synchronization signal containing the reference timestamp and sequence number is sent to all nodes in the network through a reference signal broadcast mechanism. Each receiving node calculates the deviation between the reference timestamp and the local clock. When the deviation is less than a preset deviation threshold, the clock frequency is adjusted to gradually synchronize it. When the deviation is greater than or equal to the preset deviation threshold, the clock phase is directly adjusted to obtain clock adjustment trajectory data. Based on the clock adjustment trajectory data, the frequency change rate and time deviation fluctuation range of each node after adjustment are calculated as the basis for stability evaluation. If the evaluation results of all nodes are within the preset range, the synchronized clock state containing the final time value and synchronization accuracy of each node is output.
[0061] Specifically, in one implementation, the distribution process of correction instructions needs to consider system stability constraints. A large-scale metering network contains thousands of nodes, each with varying degrees of importance. Critical metering nodes are responsible for energy metering and billing, and their time accuracy directly affects billing accuracy; ordinary monitoring nodes are only used for status monitoring, and their time accuracy requirements are relatively low. The system dynamically determines the distribution priority by evaluating the node's service type, historical failure rate, and network topology location. Load status checks include processor utilization, memory usage, and communication queue length. When a node's load is too high, the transmission of correction instructions is delayed to avoid instruction loss or execution failure due to insufficient processing capacity.
[0062] Specifically, the instruction distribution employs a hierarchical propagation mechanism. The master node first sends correction instructions to primary critical nodes, which are typically regional aggregation points or metering devices in important substations. After acknowledging receipt, the primary nodes forward the instructions to the secondary nodes under their jurisdiction. Each node generates an acknowledgment response upon receiving an instruction, including its node identifier, reception timestamp, and current clock status. The master node maintains an instruction tracking table, recording the response status of each node. For nodes that fail to respond within a timeout period, a retransmission mechanism ensures instruction delivery. This hierarchical distribution method guarantees priority processing by critical nodes while avoiding network congestion.
[0063] It's important to note that multi-source clock data fusion is a crucial step in achieving high-precision synchronization. The NTP protocol achieves time synchronization through software, and its accuracy is significantly affected by network latency jitter. While it typically achieves millisecond-level accuracy in a local area network (LAN) environment, it can drop to tens of milliseconds in a wide area network (WAN). The PTP protocol utilizes dedicated hardware timestamps to precisely record the sending and receiving times of data packets, eliminating software processing latency and achieving sub-microsecond accuracy on network devices that support hardware timestamps. Although local crystal oscillators experience cumulative drift, they exhibit good stability over short periods and can maintain basic time continuity when external time sources are temporarily unavailable.
[0064] Preferably, the weighted average fusion method dynamically adjusts the weights based on the real-time accuracy of each time source. The system maintains a sliding time window, recording the accuracy performance of each time source over a period of time. For NTP time sources, the system analyzes the changes in round-trip delay, assigning higher weights to sources with stable and low delays, and lower weights to sources with drastic delay fluctuations. The weights of PTP time sources mainly depend on the quality level of the master clock and the number of transparent clocks in the path; the shorter the path and the fewer the intermediate devices, the higher the weight. The weight of the local clock decreases as the time since the last calibration increases, reflecting the cumulative effect of crystal drift. Normalization ensures that the sum of all weights is 1, and the fusion result is always a weighted combination of all time sources.
[0065] In one possible implementation, the reference signal broadcast mechanism uses a tree topology to propagate synchronization information. The fused reference time value is first adjusted at the local node and then broadcast to neighboring nodes. Broadcast messages are sent using multicast addresses to reduce network overhead. The message content includes a reference timestamp, sending node identifier, sequence number, and message authentication code. The sequence number is used to detect duplicate and out-of-order messages, and the message authentication code prevents time spoofing attacks. After verifying the message's legitimacy, the receiving node extracts the reference timestamp and compares it with its local clock to calculate the time deviation.
[0066] For example, the clock adjustment strategy selects different adjustment methods based on the magnitude of the time deviation. A deviation threshold of 100 milliseconds is set. When the time deviation is less than 100 milliseconds, frequency adjustment is used, fine-tuning the crystal oscillator frequency to gradually catch up with or slow down the local clock, achieving smooth synchronization. This method does not cause time jumps, ensuring the monotonicity of time and is suitable for applications with strict time continuity requirements. Frequency adjustment is achieved by modifying the clock interrupt interval or adjusting the crystal oscillator divider coefficient. The adjustment range is typically limited to a few parts per million to avoid frequency abrupt changes impacting the system. Furthermore, when the time deviation exceeds 100 milliseconds, the system uses phase adjustment, directly modifying the current value of the local clock. Although phase adjustment causes time jumps, it can quickly eliminate large deviations, suitable for rapid recovery after system initialization or prolonged loss of synchronization. To reduce the impact of jumps, the system records the adjustment amount and time before performing phase adjustment for application queries and compensation.
[0067] For example, in the metering system of a smart substation, a remote terminal unit experiences a clock deviation of 5 seconds due to a communication interruption. Upon detecting the deviation, the system first adjusts the phase to bring the clock back to within 1 second of the deviation range, then switches to frequency adjustment mode to gradually eliminate the remaining deviation over the next 10 minutes. This combined adjustment strategy ensures both rapid response and stable system operation.
[0068] Understandably, stability assessment judges synchronization effectiveness by monitoring the adjusted clock behavior. The system calculates the frequency change rate, i.e., the amount of change in crystal oscillator frequency per unit time, reflecting the clock's frequency stability. The time deviation fluctuation range is obtained by statistically analyzing the difference between the maximum and minimum clock deviations over a period of time, reflecting the clock's phase stability. When the stability indicators of all nodes meet the requirements, it indicates that the entire network has achieved time synchronization. The system outputs a complete status report containing the final time value, synchronization accuracy, and stability score of each node, providing a basis for network management and fault diagnosis.
[0069] S107. Based on the obtained synchronized clock status, monitor the overall distributed network performance indicators, confirm the effectiveness of the calibration strategy based on the consistency improvement effect of the performance indicators, and dynamically monitor and correct the clock of the metering equipment through real-time fusion of multi-source clock data and dynamic adjustment of optimized time synchronization operation, and cycle back to the original data acquisition link to form a continuous dynamic ultra-large-scale metering device clock calibration cycle.
[0070] Based on the synchronized clock state, the time deviation value and synchronization accuracy data of each node are extracted. The mean and variance of the time deviation of the entire network are calculated as consistency indicators, and the maximum time difference between nodes is counted as the dispersion indicator. The consistency and dispersion indicators are compared with the values before synchronization to determine the degree of performance improvement and obtain the network time synchronization quality assessment result. Using the network time synchronization quality assessment result, if the consistency indicator improvement exceeds the preset improvement threshold and the dispersion reduction reaches the preset range, the current calibration strategy is confirmed to be effective. The effective correction frequency, weight allocation scheme, and calibration cycle parameters are recorded, and these parameters are used as the initial configuration for the next round of calibration to obtain the optimized calibration parameter set. Based on the optimized calibration parameter set, the acquisition cycle and filtering parameters are configured, and a new round of data acquisition process is started to reacquire battery health parameters, power supply voltage data, ambient temperature, and load rate. Kalman filtering is used to process the raw data to obtain the crystal oscillator offset correlation parameter. This parameter is input into the subsequent frequency offset calculation and clock drift rate evaluation process to form a continuous dynamic clock calibration cycle.
[0071] Specifically, in one implementation, network time synchronization quality assessment achieves precise quantification of synchronization effects by constructing a multi-dimensional evaluation system.
[0072] Specifically, the system first extracts the synchronized time deviation value from each clock node, which represents the time difference between each node and the reference clock source.
[0073] For example, in a power system protection equipment network, node A has a time deviation of +2.3 microseconds, node B has a deviation of -1.7 microseconds, and node C has a deviation of +0.9 microseconds. Simultaneously, the synchronization accuracy data of each node is acquired; this accuracy data reflects the stability and reliability indicators of the node clocks.
[0074] It should be noted that the calculation of the consistency index involves a statistical analysis of the time deviation across the entire network. The system calculates the arithmetic mean of the time deviations of all nodes as the overall network deviation mean, and uses variance calculation to reflect the dispersion of the deviation distribution. The smaller the variance value, the more consistent the time deviations of each node are, and the higher the network synchronization quality.
[0075] For example, when the network contains 50 protection device nodes, the system calculates that the mean deviation is 0.2 microseconds and the variance is 1.8 squared microseconds. These values form the quantitative basis for network time consistency.
[0076] Preferably, the dispersion index is used to assess the degree of synchronization dispersion by statistically analyzing the maximum time difference between nodes. The system iterates through all node pairs, calculates the absolute value of the time difference between any two nodes, and takes the maximum value as the network time dispersion index.
[0077] In one possible implementation, if node A's time is 10:00:00.000123 and node B's time is 10:00:00.000089, the time difference between them is 34 microseconds. When the maximum time difference between nodes in the entire network is 67 microseconds, this value is the current network dispersion index. Furthermore, the dynamic optimization of calibration parameters is based on a quantitative evaluation of the performance improvement. The system compares the current consistency index with historical benchmark values. When the consistency index improves by more than a preset 15% threshold and the dispersion decreases by more than 20% compared to before, the effectiveness of the current calibration strategy is confirmed.
[0078] Understandably, the effective correction frequency is usually set in the range of 100 to 1000 times per second. The weight allocation scheme determines the allocation ratio based on the clock stability of the nodes and the location of the network topology. The calibration cycle parameter is dynamically adjusted in the range of 1 to 60 seconds based on the frequency of network load and environmental changes.
[0079] In one embodiment, the continuous dynamic calibration cycle is achieved through multi-source data fusion and adaptive filtering. The system reconfigures the data acquisition cycle based on optimized calibration parameters, typically set to an acquisition interval of 100 milliseconds to 5 seconds. The Kalman filter receives multi-dimensional inputs such as battery health parameters, supply voltage fluctuation data, ambient temperature changes, and system load rate, and processes raw data noise and uncertainty through two stages: state prediction and measurement update.
[0080] Specifically, the filter establishes a correlation model between crystal oscillator frequency offset and environmental factors. When the ambient temperature changes by 1 degree Celsius, the crystal oscillator frequency offset varies from approximately 0.1 ppm to 1 ppm. This correlation parameter directly affects the accuracy of subsequent frequency offset calculations and clock drift rate evaluation results.
[0081] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the concept of this application. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this application.
Claims
1. A dynamic timekeeping method for clock monitoring in an ultra-large-scale metering device, characterized in that, include: Raw data from the ultra-large-scale metering device is collected by sensors at each node in the distributed network. The raw data includes battery health parameters, power supply voltage data, ambient temperature data, and load rate data. The raw data is filtered to obtain crystal oscillator offset correlation parameters, which include battery health indicators, voltage stability values, temperature compensation coefficients, and load influence weights. The crystal oscillator offset correlation parameters are input into a preset mapping model to calculate the crystal oscillator frequency offset, and the clock drift rate is evaluated based on the crystal oscillator frequency offset. In low-power scenarios, based on the clock drift rate and historical reference signal history, the relationship between the drift rate and time is fitted to predict subsequent synchronization errors; Based on the subsequent synchronization error prediction results, the node synchronization error status is determined. If the synchronization error is greater than or equal to the preset tolerance threshold, the correction frequency is adjusted, and time synchronization data of adjacent nodes are collected based on the adjusted correction frequency. Based on the time synchronization data of the adjacent nodes, multi-source clock data is fused, including network time protocol data, precision time protocol data and local clock data. A weight allocation algorithm is used to determine the comprehensive correction magnitude and generate a correction instruction. The correction instructions are distributed to the clock modules of each node, the multi-source clock data is fused, and a time synchronization operation is performed using a reference signal broadcast mechanism to obtain the synchronized clock state. Based on the synchronized clock state, the distributed network performance indicators are monitored, calibration parameters are adjusted, and the original data acquisition is performed cyclically to form a continuous dynamic clock calibration cycle.
2. The dynamic timekeeping method for clock monitoring of ultra-large-scale metering devices according to claim 1, characterized in that, The process involves collecting raw data from the ultra-large-scale metering device via sensors at each node in a distributed network. This raw data is then filtered to obtain crystal oscillator offset correlation parameters. These parameters include battery health indicators, voltage stability values, temperature compensation coefficients, and load influence weights. The raw data is collected by sensors at each node in the distributed network according to a preset period. The raw data includes battery internal resistance, depth of discharge, number of charge and discharge cycles, instantaneous value of power supply voltage, ambient temperature value and device load rate, generating a multi-dimensional dataset with timestamps. The device load rate is calculated by monitoring CPU utilization, memory usage and data transmission volume of communication module. The multidimensional dataset is processed by Kalman filtering. The battery internal resistance and discharge depth are set as state variables, and the instantaneous supply voltage and ambient temperature are set as observation variables. The state value at the next moment is predicted by the state transition equation. The measurement residual is calculated according to the observation equation. The state estimate is updated by Kalman gain to obtain the battery health index and voltage stability value. The change rate is calculated based on the battery health index. If the change rate exceeds the preset change rate threshold, the standard deviation of the voltage stability value is extracted. The temperature compensation coefficient is generated by multiplying the difference between the ambient temperature value and the nominal temperature of the crystal oscillator by the preset temperature coefficient. The load influence weight is generated by combining the equipment load rate and the crystal oscillator frequency offset correlation coefficient quantified using the Pearson correlation coefficient. The preset change rate threshold is determined based on the monthly change rate of the battery health index, and the standard deviation of the voltage stability value is calculated from the voltage data within a continuous minute time window. The battery health index, voltage stability value, temperature compensation coefficient, and load influence weight are processed using a normalization method to generate the crystal oscillator offset correlation parameters.
3. The dynamic timekeeping method for clock monitoring of ultra-large-scale metering devices according to claim 1, characterized in that, The step of inputting the crystal oscillator offset correlation parameters into a preset mapping model and calculating the crystal oscillator frequency offset includes: The crystal oscillator offset correlation parameters are input into a preset mapping model to calculate the crystal oscillator frequency offset. The preset mapping model is established by a multiple linear regression method, and the regression coefficients corresponding to each parameter are obtained by fitting with the least squares method. Based on the crystal oscillator frequency offset, the crystal oscillator frequency value is recorded at a fixed sampling interval within a preset time window. The difference between the frequency offset of each sampling point and the frequency offset of the previous sampling point is calculated and then divided by the sampling interval to obtain the frequency change rate of each sampling point. If the average frequency change rate of each sampling point exceeds the preset stability threshold, the frequency offset change is obtained by subtracting the frequency offset of the first sampling point from the frequency offset of the last sampling point within the time window. The frequency offset change is then divided by the time window length to generate the clock drift rate.
4. The dynamic timekeeping method for clock monitoring of ultra-large-scale metering devices according to claim 1, characterized in that, In low-power scenarios, based on the clock drift rate and historical reference signal history, the relationship between the drift rate and time is fitted to predict subsequent synchronization errors, including: Based on the device's sleep cycle and wake-up time, extract the timing data of the clock drift rate, calculate the synchronization deviation, and generate a drift rate numerical sequence; Using the aforementioned drift rate numerical sequence, a linear regression model is constructed. The regression coefficients, including the slope parameter and the intercept parameter, are calculated using the least squares method to obtain the linear relationship between the drift rate and time. Based on the linear relationship, any time within a day from the current time is substituted into the calculation to obtain the predicted drift rate at that time. The predicted drift rate is multiplied by the time interval from the current time to the arbitrary time to calculate the cumulative synchronization error during that period, and the subsequent synchronization error prediction value is obtained.
5. The dynamic timekeeping method for clock monitoring of ultra-large-scale metering devices according to claim 1, characterized in that, The step of determining the node synchronization error status based on the subsequent synchronization error prediction result, and adjusting the correction frequency if the synchronization error is greater than or equal to a preset tolerance threshold, and collecting time synchronization data of adjacent nodes based on the adjusted correction frequency, includes: The subsequent synchronization error prediction value is compared with a preset tolerance threshold. If it is greater than or equal to the tolerance threshold, the correction frequency is adjusted by multiplying the correction frequency parameter by a preset adjustment factor to generate an updated correction frequency value. The adjustment factor is dynamically determined based on the ratio of the prediction error value to the tolerance threshold. Based on the updated correction frequency value, a time synchronization request is broadcast to neighboring nodes in the distributed network to collect time synchronization data from neighboring nodes. The time synchronization data is preprocessed to remove abnormal data and generate a preprocessed synchronization dataset.
6. The dynamic timekeeping method for clock monitoring of ultra-large-scale metering devices according to claim 1, characterized in that, The step of fusing multi-source clock data based on the time synchronization data of adjacent nodes, determining the comprehensive correction magnitude using a weighted allocation algorithm, and generating a correction instruction includes: Based on the time synchronization data of the adjacent nodes, network time protocol data, precision time protocol data and local clock data are obtained. The data and the data of the adjacent nodes are formatted and time zone aligned to generate a standardized multi-source clock dataset. For the multi-source clock dataset, calculate the standard deviation of the time deviation of each clock source and generate an adaptive weight allocation result; Based on the adaptive weight allocation result, the weighted average time value is calculated, the comprehensive correction magnitude is generated, and it is determined whether the time deviation of each node after correction is less than the preset consistency threshold. If the overall correction magnitude meets the consistency requirement and does not exceed the preset single adjustment limit, then the correction instruction containing the correction magnitude is directly generated. If the overall correction magnitude exceeds the preset single adjustment limit, it is decomposed into multiple small-amplitude adjustments, a time interval for gradual correction is set, and a step-by-step correction instruction is generated.
7. The dynamic timekeeping method for clock monitoring of ultra-large-scale metering devices according to claim 6, characterized in that, The process of distributing the correction instructions to the clock modules of each node, fusing the multi-source clock data, and performing time synchronization using a reference signal broadcast mechanism to obtain the synchronized clock state includes: Based on the node load status and communication quality, determine the distribution order of the correction instruction or step-by-step correction instruction, and record the distribution completion status; Each node parses the correction instruction, merges the multi-source clock data, and generates a merged reference time value; Using the fused reference time value, a synchronization signal is broadcast, and the deviation between the reference timestamp and the local clock is calculated. When the deviation is less than a preset deviation threshold, the clock frequency is adjusted to gradually synchronize the clock. When the deviation is greater than or equal to the preset deviation threshold, the clock phase is directly adjusted to generate clock adjustment trajectory data. Based on the clock adjustment trajectory data, the frequency change rate and time deviation fluctuation range of each node after adjustment are calculated. If the evaluation results of all nodes are within the preset range, the synchronized clock state is generated.
8. The dynamic timekeeping method for clock monitoring of ultra-large-scale metering devices according to claim 7, characterized in that, The step of monitoring distributed network performance indicators, adjusting calibration parameters, and cyclically performing the original data acquisition based on the synchronized clock state includes: Based on the synchronized clock state, extract the time deviation value and synchronization accuracy data of each node, calculate the mean and variance of the time deviation as a consistency index, and count the maximum time difference between nodes as a dispersion index. Compare the consistency index and dispersion index with the values before synchronization to obtain the degree of performance improvement. Based on the degree of performance improvement, if the consistency index improvement exceeds the preset improvement threshold and the dispersion reduction reaches or exceeds the preset reduction, then the current calibration parameters are confirmed to be valid, and the valid correction frequency, weight allocation scheme and calibration cycle parameters are recorded. These parameters are used as the initial configuration for the next round of calibration to generate an optimized calibration parameter set. Based on the optimized calibration parameter set, the acquisition period and filtering parameters are configured, the original data acquisition is re-executed, the original data is processed by Kalman filtering to generate the crystal oscillator offset correlation parameters, and clock calibration is performed cyclically.
9. The dynamic timekeeping method for clock monitoring of ultra-large-scale metering devices according to claim 3, characterized in that, If the average frequency change rate of each sampling point exceeds a preset stability threshold, the frequency offset change is obtained by subtracting the frequency offset of the first sampling point from the frequency offset of the last sampling point within the time window. The frequency offset change is then divided by the time window length to generate the clock drift rate. The method further includes: If the average frequency change rate of each sampling point does not exceed the preset stability threshold, the average frequency offset of all sampling points within the time window is used as the reference offset, and the clock drift rate is generated by combining the average historical drift rate output by the mapping model. The historical drift rate mean is calculated by extracting drift rate data from periods in the past day where the average rate of frequency change is less than or equal to a preset stability threshold, and then using the arithmetic mean method.
10. The dynamic timekeeping method for clock monitoring of ultra-large-scale metering devices according to claim 7, characterized in that, The process of determining the distribution order of the correction instruction or step-by-step correction instruction based on node load status and communication quality, and recording the distribution completion status, includes: If the node's CPU utilization rate is less than or equal to the preset utilization rate value and the memory utilization rate is less than or equal to the preset utilization rate value, the load is considered normal. If the CPU utilization rate is greater than the preset utilization rate value or the memory utilization rate is greater than the preset utilization rate value, it is determined that the load is too high; If the packet loss rate between the node and the distribution node is less than or equal to the preset packet loss rate threshold and the average latency is less than or equal to the preset time, the communication quality is deemed to be qualified. If the packet loss rate is greater than the preset packet loss rate or the average latency is greater than the preset time, the communication quality is deemed to be unqualified. Instructions are first distributed to key metering nodes, including electricity metering nodes and billing nodes, and are only distributed to ordinary metering nodes that are only used for status monitoring after the key metering nodes send back a confirmation message containing the node identifier and the receiving timestamp. If a critical metering node is determined to be overloaded or has unqualified communication quality, its load and communication status must be retested at fixed intervals until the load is normal and the communication is qualified before issuing instructions.