A UWB clock synchronization method and system based on Beidou time service

By adding a combination of calendar expansion and Beidou timing in the UWB clock counter, and selecting trusted periods for synchronization calibration, the UWB clock synchronization delay and error problems are solved, and the high precision and reliability time synchronization of the base station is achieved.

CN120110585BActive Publication Date: 2025-08-05HEBEI BEIDOU TIANHUI TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510561130.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-30
Publication Date
2025-08-05
Estimated Expiration
2045-04-30

AI Technical Summary

Technical Problem

The existing UWB clocks require long-term synchronization during base station access, and traditional synchronization technology cannot meet the high-precision requirements of submicroseconds, and accidental errors in satellite timing lead to synchronization abnormalities.

Method used

By adding calendar extensions to the UWB clock counter output results, combining Beidou timer for time difference calculation, selecting trusted local unit time period for synchronization calibration, eliminating accidental errors in Beidou timer, and using the stable local time of the base station for correction and synchronization.

Benefits of technology

It realizes high accuracy and reliability synchronization of the local time of the base station, reduces synchronization delay during access to new base stations, and improves the accuracy and reliability of the system's time synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120110585B_ABST
    Figure CN120110585B_ABST
Patent Text Reader

Abstract

The present invention discloses a UWB clock synchronization method and system based on Beidou timing, which relates to the field of time synchronization technology. The present invention includes adding a calendar extension to the output result of the clock counter to continuously update the local time, selecting a trusted local unit period; taking the average of the pre-synchronization time difference of each local time in the trusted local unit period as the synchronization calibration time difference of the trusted local unit period; matching the pre-synchronization time difference of each local time in the previous local unit period adjacent to the current local time with all the trusted local unit periods to obtain several target trusted local unit periods; obtaining the synchronization calibration time difference of the current local time based on the synchronization calibration time difference of all the target trusted local unit periods, and performing clock synchronization on the current local time. The present invention improves the response speed of newly accessed base stations and improves the accuracy and reliability of local time synchronization of base stations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of time synchronization, and in particular relates to a UWB clock synchronization method and system based on Beidou timing. Background Art

[0002] In distributed wireless communication systems, such as sensor networks, drone fleets, and the Industrial Internet of Things (IIoT), high-precision clock synchronization between nodes is a necessary condition to ensure functions such as data fusion and collaborative control.

[0003] The existing UWB clock uses a 40-bit clock counter with a timing period of 17.2s. Since the UWB clock is essentially a counter without calendar properties, the base station needs to respond to the time for clock synchronization after powering on and accessing.

[0004] Furthermore, the UWB clocks in base stations can drift over time, and high-precision positioning requires sub-microsecond synchronization. Traditional synchronization technologies, such as NTP, offer only millisecond accuracy, making it difficult to meet these requirements. Using satellite timing to synchronize the base station's local time can lead to occasional errors, particularly seconds-level lock loss, which can cause serious anomalies in the base station's time synchronization. Summary of the Invention

[0005] The purpose of the present invention is to provide a UWB clock synchronization method and system based on Beidou timing, which improves the accuracy and reliability of base station local time synchronization.

[0006] To solve the above technical problems, the present invention is achieved through the following technical solutions:

[0007] The present invention provides a UWB clock synchronization method based on Beidou timing, comprising:

[0008] Add calendar extension based on the clock counter output, continuously count the clock counter pulse updates to obtain the local time, and simultaneously obtain Beidou timing;

[0009] The difference between the local time and Beidou time obtained at the same time is calculated as the pre-synchronization time difference of each local time;

[0010] Divide the multiple local time points into multiple local unit time periods in equal proportion according to the temporal order;

[0011] Select a trusted local unit period based on the pre-synchronization time difference of each local moment within each local unit period;

[0012] The average of the pre-synchronization time differences of each local moment in the trusted local unit period is used as the synchronization calibration time difference of the trusted local unit period;

[0013] Obtaining a plurality of target trusted local unit time periods by matching the pre-synchronization time difference of each local time in the previous local unit time period adjacent to the current local time with all trusted local unit time periods;

[0014] Obtain the synchronization calibration time difference of the current local time according to the synchronization calibration time difference of all target trusted local unit periods;

[0015] The clock is synchronized with the current local time based on the Beidou time service obtained at the same time.

[0016] The present invention also discloses a UWB clock synchronization method based on Beidou timing, comprising:

[0017] Determine whether Beidou timing can be obtained;

[0018] If so, performing satellite timing clock synchronization according to a UWB clock synchronization method based on Beidou timing;

[0019] If not, request clock synchronization from the adjacent base station and obtain the local time of the adjacent base station including the calendar extension.

[0020] The present invention also discloses a UWB clock synchronization system based on Beidou timing, comprising:

[0021] The main base station is used to add calendar extensions based on the clock counter output, continuously count the clock counter pulse updates to obtain the local time, and simultaneously obtain Beidou timing;

[0022] The difference between the local time and Beidou time obtained at the same time is calculated as the pre-synchronization time difference of each local time;

[0023] Divide the multiple local time points into multiple local unit time periods in equal proportion according to the temporal order;

[0024] Select a trusted local unit period based on the pre-synchronization time difference of each local moment within each local unit period;

[0025] The average of the pre-synchronization time differences of each local moment in the trusted local unit period is used as the synchronization calibration time difference of the trusted local unit period;

[0026] Obtaining a plurality of target trusted local unit time periods by matching the pre-synchronization time difference of each local time in the previous local unit time period adjacent to the current local time with all trusted local unit time periods;

[0027] The synchronization calibration time difference of the current local time is obtained based on the synchronization calibration time difference of all target trusted local unit periods, and the clock of the current local time is synchronized with the Beidou time obtained at the same time;

[0028] The slave base station requests clock synchronization from the master base station and obtains the local time including the calendar extension of the neighboring base station.

[0029] This invention adds a calendar extension to the output of the base station's clock counter, ensuring that different base stations share the same time synchronization standard. New base stations no longer need to undergo time synchronization upon access and can directly operate. This solution also compares and analyzes the base station's local time with the acquired Beidou timing, eliminating and correcting any significant occasional errors in Beidou timing based on the base station's stable local time. The corrected Beidou timing is then used to synchronize the local time. This reduces both the systematic error of the local time and the occasional error of Beidou timing, improving the accuracy and reliability of the base station's local time synchronization.

[0030] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0032] Figure 1 A schematic diagram of the functional units and information flow of a Beidou-based UWB clock synchronization system according to an embodiment of the present invention;

[0033] Figure 2 A schematic flow chart of the steps for performing time synchronization after a master base station receives Beidou timing according to an embodiment of the present invention;

[0034] Figure 3 A schematic flow chart of steps for performing time synchronization from a base station according to an embodiment of the present invention;

[0035] Figure 4 This is a schematic diagram of the process flow of step S4 in one embodiment of the present invention;

[0036] Figure 5 This is a schematic diagram of the process flow of step S44 in one embodiment of the present invention;

[0037] Figure 6 This is a schematic diagram of the process flow of step S6 in one embodiment of the present invention;

[0038] Figure 7 This is a schematic diagram of the process flow of step S7 in one embodiment of the present invention;

[0039] In the accompanying drawings, the components represented by the reference numerals are as follows:

[0040] 1-Master base station, 2-Slave base station. DETAILED DESCRIPTION

[0041] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0042] It should be noted that the terms "first," "second," and the like in this application are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are merely examples of devices and methods consistent with certain aspects of the present application as detailed in the appended claims.

[0043] See also Figures 1 to 3 As shown, the present invention provides a UWB clock synchronization system based on Beidou timing, which is divided into a main base station 1 and a slave base station 2 from the functional unit. The main base station 1 refers to a base station that can receive the timing signal of the Beidou satellite, and the slave base station 2 refers to a base station that cannot directly receive the timing signal and can only communicate and synchronize time with the main base station 1. Due to the influence of various factors, whether a base station belongs to a main base station or a slave base station is not fixed. Therefore, when performing time synchronization, the base station can first execute step S01 to determine whether it can obtain Beidou timing. If so, the subsequent steps S1 to S8 can be executed to synchronize the satellite timing clock. If not, step S02 can be executed to request clock synchronization from the adjacent base station.

[0044] The timing module in the traditional UWB solution uses a high-precision calibrated crystal oscillator, with a timing pulse interval of 15.65ps and a complete timing cycle of 17.2s. The output of the timing module does not have calendar properties, which means that it takes a long time to synchronize the time when a new base station is connected. In view of this, please continue to refer to Figure 1 As shown in Figure 1, the base station in this solution adds 32 extension bits to the 40-bit output of the clock counter, forming a 72-bit local time composed of calendar and pulse timing. This ensures that the base station's local time has complete calendar attributes, including the full year, month, day, hour, minute, second, microsecond, nanosecond, and picosecond. Furthermore, because the base station's local time has calendar attributes, new base stations do not need to synchronize their time upon access and can directly perform tasks such as tag positioning.

[0045] In this system, the main base station 1 performs time synchronization during the tag positioning process to maintain the accuracy of the tag positioning. The local time in the base station is generated by a crystal oscillator signal processed by a calibration chip, which has high stability and small accidental errors. However, the frequency of the crystal oscillator is limited, and factors such as the temperature, humidity, and air pressure of the base station's environment can cause systematic errors in the crystal oscillator's operation. Beidou timing is derived from atomic clocks with sub-nanosecond accuracy. It also receives continuous timing calibration from various timing centers, so the systematic error can be considered extremely small. However, the timing signals generated by Beidou satellites need to pass through the ionosphere and dense atmosphere, and are also subject to various interferences from the ground and near space, which may occasionally produce millisecond or even second-level errors, that is, second-level loss of lock. Therefore, it is impossible to directly use Beidou timing time.

[0046] As discussed above, the base station's local time and Beidou timing each have their own advantages and disadvantages. To eliminate and correct the large, occasional errors in Beidou timing by relying on the base station's stable local time, step S1 can be performed to continuously acquire the local time and Beidou timing simultaneously. Next, step S2 can be performed to calculate the difference between the simultaneously acquired local time and Beidou timing as the pre-synchronization time difference for each local time. Next, step S3 can be performed to evenly divide the multiple local times into multiple local unit time periods based on their temporal order.

[0047] See also Figure 3 and 4 As shown, in the process of mutual correction and synchronization of the local time and Beidou timing within each local time period, step S4 can be executed to select a trusted local unit period based on the pre-synchronization time difference of each local time within each local unit period. Specifically, step S41 can be first executed to calculate and obtain the mean and standard deviation of the pre-synchronization time difference of each local time contained in each local unit period. Next, step S42 can be executed to accumulate the difference between the mean and standard deviation of the pre-synchronization time difference of each local time contained in any two local unit periods to obtain the timing quality difference of any two local unit periods. Next, step S43 can be executed to select two local unit periods from all local unit periods as marked local unit periods. It can be randomly selected, or two local unit periods with relatively accurate and relatively inaccurate Beidou timing can be selected manually or automatically by a program as marked local unit periods, or it can be randomly selected.

[0048] See also Figure 4 and 5As shown, in order to classify numerous local unit periods into two categories: stable and accurate Beidou timing and fluctuating and inaccurate, step S44 can be executed to classify all local unit periods into two local unit period sets based on the timing quality difference between each marked local unit period and each other local unit period. Specifically, step S441 can be executed to classify all local unit periods other than each marked local unit period into the same local unit period set with the marked local unit period having the smallest timing quality difference. Next, it can be determined whether the timing quality of the local unit periods included in each local unit period set is consistent. Specifically, step S442 can be executed to calculate, for each local unit period set, the mean and standard deviation of the pre-synchronization time difference for each local moment included in all local unit periods in the local unit period set as the representative pre-synchronization time difference and representative standard deviation of the local unit period set. Next, step S443 can be executed to determine whether the local unit period with the smallest timing quality difference between each local unit period set and the representative pre-synchronization time difference and representative standard deviation is the marked local unit period. If yes, then step S444 may be executed to obtain two local unit time period sets having internal timing quality consistency.

[0049] If the value is not correct, it indicates that the timing quality of the local unit periods included in each local unit period set is inconsistent. Therefore, step S445 may be executed to reselect the marked local unit period. Specifically, within each local unit period set, the local unit period with the smallest difference in timing quality between the representative pre-synchronization time difference and the representative standard deviation is selected as the reselected marked local unit period. The local unit period set is then repartitioned based on the reselected marked local unit period until two local unit period sets with consistent timing quality are obtained.

[0050] To supplement the implementation of step S4 above, the source code of some functional modules is provided, and the annotations provide a comparative explanation. To prevent the leakage of confidential data related to geographic surveying and communication, some data that does not affect the implementation of the solution is desensitized, the same applies below.

[0051] #include <iostream>

[0052] #include <vector>

[0053] #include <algorithm>

[0054] #include <numeric>

[0055] #include <cmath>

[0056] #include <limits>

[0057] #include <utility>

[0058] / / Pre-synchronization time difference structure

[0059] struct SyncData {

[0060] double local_time; / / local time (simplified representation)

[0061] double pre_sync_diff; / / Pre-synchronization time difference (local-Beidou)

[0062] };

[0063] / / Period statistics structure

[0064] struct PeriodStats {

[0065] double mean; / / mean

[0066] double stddev; / / standard deviation

[0067] std::vector <syncdata>data; / / original data

[0068] };

[0069] class TrustedPeriodSelector {

[0070] private:

[0071] std::vector <std::vector <syncdata>>all_periods_; / / All local unit periods

[0072] const double diff_threshold_ = 0.2; / / Timing quality difference threshold

[0073] public:

[0074] / / Set all time period data

[0075] void SetPeriodsData(const std::vector <std::vector <syncdata>>&periods){

[0076] all_periods_ = periods;

[0077] }

[0078] / / Execute the main process of selecting the trusted period

[0079] std::vector <std::vector <syncdata>>SelectTrustedPeriods() {

[0080] if (all_periods_.size()<2) return {};

[0081] / / Step 1: Calculate statistical characteristics for each time period

[0082] std::vector <periodstats>period_stats;

[0083] for (const auto&period : all_periods_) {

[0084] if (period.empty()) continue;

[0085] period_stats.push_back(CalculatePeriodStats(period));

[0086] }

[0087] / / Step 2: Calculate the timing quality difference matrix

[0088] auto diff_matrix = CalculateDiffMatrix(period_stats);

[0089] / / Step 3-8: Iteratively select a trusted period

[0090] auto [set1, set2] = IterativeSelectPeriods(period_stats, diff_matrix);

[0091] / / Step 9: Select the set with the smaller mean as the credible period

[0092] return SelectFinalTrustedPeriods(set1, set2);

[0093] }

[0094] private:

[0095] / / Calculate the statistical characteristics of a single period

[0096] PeriodStats CalculatePeriodStats(const std::vector <syncdata>&period){

[0097] PeriodStats stats;

[0098] stats.data = period;

[0099] / / Calculate the mean

[0100] double sum = 0.0;

[0101] for (const auto&data : period) {

[0102] sum += data.pre_sync_diff;

[0103] }

[0104] stats.mean = sum / period.size();

[0105] / / Calculate the standard deviation

[0106] double variance = 0.0;

[0107] for (const auto&data : period) {

[0108] variance += pow(data.pre_sync_diff - stats.mean, 2);

[0109] }

[0110] stats.stddev = sqrt(variance / period.size());

[0111] return stats;

[0112] }

[0113] / / Calculate the timing quality difference matrix

[0114] std::vector <std::vector <double>>CalculateDiffMatrix(const std::vector <periodstats>&stats) {

[0115] size_t n = stats.size();

[0116] std::vector<std::vector <double>>matrix(n, std::vector <double>(n,0.0));

[0117] for (size_t i = 0; i <n; ++i) {

[0118] for (size_t j = i + 1; j <n; ++j) {

[0119] / / Difference = absolute value of mean difference + absolute value of standard deviation

[0120] double mean_diff = fabs(stats[i].mean - stats[j].mean);

[0121] double stddev_diff = fabs(stats[i].stddev - stats[j].stddev);

[0122] matrix[i][j]= matrix[j][i]= mean_diff + stddev_diff;

[0123] }

[0124] }

[0125] return matrix;

[0126] }

[0127] / / Iterate and select the time period collection

[0128] std::pair <std::vector<size_t> , std::vector<size_t> >IterativeSelectPeriods(

[0129] const std::vector <periodstats>&stats,

[0130] const std::vector<std::vector <double>>&diff_matrix) {

[0131] size_t n = stats.size();

[0132] std::vector<size_t> marked_indices;

[0133] / / Step 3: Initially select the two periods with the largest difference as marking periods

[0134] double max_diff = 0.0;

[0135] size_t mark1 = 0, mark2 = 1;

[0136] for (size_t i = 0; i <n; ++i) {

[0137] for (size_t j = i + 1; j <n; ++j) {

[0138] if (diff_matrix[i][j]>max_diff) {

[0139] max_diff = diff_matrix[i][j];

[0140] mark1 = i;

[0141] mark2 = j;

[0142] }

[0143] }

[0144] }

[0145] marked_indices.push_back(mark1);

[0146] marked_indices.push_back(mark2);

[0147] std::vector<size_t> set1, set2;

[0148] bool changed = true;

[0149] / / Iterate until convergence

[0150] while (changed) {

[0151] changed = false;

[0152] / / Step 4: Assign each time period to the nearest marked time period

[0153] set1.clear();

[0154] set2.clear();

[0155] set1.push_back(marked_indices[0]);

[0156] set2.push_back(marked_indices[1]);

[0157] for (size_t i = 0; i <n; ++i) {

[0158] if (i == marked_indices[0] || i == marked_indices[1]) continue;

[0159] double diff1 = diff_matrix[i][marked_indices[0]];

[0160] double diff2 = diff_matrix[i][marked_indices[1]];

[0161] if (diff1 <diff2) {

[0162] set1.push_back(i);

[0163] } else {

[0164] set2.push_back(i);

[0165] }

[0166] }

[0167] / / Steps 5-7: Check if the marking period needs to be updated

[0168] auto new_mark1 = FindRepresentativePeriod(set1, stats, diff_matrix);

[0169] auto new_mark2 = FindRepresentativePeriod(set2, stats, diff_matrix);

[0170] if (new_mark1 != marked_indices[0] || new_mark2 != marked_indices[1]){

[0171] marked_indices[0] = new_mark1;

[0172] marked_indices[1] = new_mark2;

[0173] changed = true;

[0174] }

[0175] }

[0176] return {set1, set2};

[0177] }

[0178] / / Find the representative period in the set (with the smallest difference)

[0179] size_t FindRepresentativePeriod(const std::vector<size_t> &period_set,

[0180] const std::vector <periodstats>&stats,

[0181] const std::vector<std::vector <double>>&diff_matrix) {

[0182] / / Calculate the average statistical characteristics of the set

[0183] double mean_sum = 0.0, stddev_sum = 0.0;

[0184] for (auto idx : period_set) {

[0185] mean_sum += stats[idx].mean;

[0186] stddev_sum += stats[idx].stddev;

[0187] }

[0188] double avg_mean = mean_sum / period_set.size();

[0189] double avg_stddev = stddev_sum / period_set.size();

[0190] / / Find the period closest to the average characteristics

[0191] size_t best_idx = period_set[0];

[0192] double min_diff = std::numeric_limits <double>::max();

[0193] for (auto idx : period_set) {

[0194] double mean_diff = fabs(stats[idx].mean - avg_mean);

[0195] double stddev_diff = fabs(stats[idx].stddev - avg_stddev);

[0196] double total_diff = mean_diff + stddev_diff;

[0197] if (total_diff <min_diff) {

[0198] min_diff = total_diff;

[0199] best_idx = idx;

[0200] }

[0201] }

[0202] return best_idx;

[0203] }

[0204] / / Select the final credible period (the set with the smaller mean)

[0205] std::vector <std::vector <syncdata>>SelectFinalTrustedPeriods(

[0206] const std::vector<size_t> &set1,

[0207] const std::vector<size_t> &set2) {

[0208] / / Calculate the average of two sets

[0209] double mean1 = 0.0, mean2 = 0.0;

[0210] for (auto idx : set1) {

[0211] for (const auto&data : all_periods_[idx]) {

[0212] mean1 += data.pre_sync_diff;

[0213] }

[0214] }

[0215] mean1 / = set1.size();

[0216] for (auto idx : set2) {

[0217] for (const auto&data : all_periods_[idx]) {

[0218] mean2 += data.pre_sync_diff;

[0219] }

[0220] }

[0221] mean2 / = set2.size();

[0222] / / Select the set with the smaller mean

[0223] const auto&selected_set = (mean1 <mean2) ? set1 : set2;

[0224] std::vector <std::vector <syncdata>>trusted_periods;

[0225] for (auto idx : selected_set) {

[0226] trusted_periods.push_back(all_periods_[idx]);

[0227] }

[0228] return trusted_periods;

[0229] }

[0230] };

[0231] / / Example usage

[0232] int main() {

[0233] TrustedPeriodSelector selector;

[0234] / / Construct test data (3 periods, 5 data points each period)

[0235] std::vector <std::vector <syncdata>>test_periods = {

[0236] {{1.0, 10.1}, {1.1, 10.2}, {1.2, 10.0}, {1.3, 10.3}, {1.4, 10.1}}, / / Stable period 1

[0237] {{2.0, 15.5}, {2.1, 15.6}, {2.2, 15.4}, {2.3, 15.7}, {2.4, 15.3}}, / / Stable period 2

[0238] {{3.0, 12.0}, {3.1, 18.0}, {3.2, 8.0}, {3.3, 16.0}, {3.4, 10.0}} / / Unstable period

[0239] };

[0240] selector.SetPeriodsData(test_periods);

[0241] auto trusted_periods = selector.SelectTrustedPeriods();

[0242] std::cout << "Number of trusted periods: " << trusted_periods.size() << std::endl;

[0243] for (size_t i = 0; i < trusted_periods.size(); ++i) {

[0244] double mean = 0.0;

[0245] for (const auto& data : trusted_periods[i]) {

[0246] mean += data.pre_sync_diff;

[0247] }

[0248] mean / = trusted_periods[i].size();

[0249] std::cout << "Period " << i + 1 << " average pre - sync difference: " << mean << std::endl;

[0250] }

[0251] return 0;

[0252] }

[0253] This code implements a statistically-based algorithm for selecting trusted UWB clock synchronization periods. The algorithm first calculates the mean and standard deviation of the pre-synchronization time difference for each period. It then constructs a timing quality variance matrix between periods. It then uses an iterative clustering method to partition the periods into two quality consistency sets. Finally, the set with the smaller mean is selected as the final trusted period. The algorithm employs a variance metric and iterative optimization strategy to effectively identify periods with high and stable clock synchronization quality, providing a reliable data foundation for subsequent precise clock synchronization. The code includes complete statistical calculations, variance matrix construction, iteration, and result selection logic, making it directly applicable to the trusted period screening module of a time synchronization system.

[0254] Please continue reading Figure 3 and 4 As shown, after the two local unit time period sets are classified, since the two local unit time period sets are respectively divided into two categories of relatively accurate and relatively inaccurate Beidou timing, step S45 can be finally executed to take the local unit time period in the local unit time period set with the smaller average value of the pre-synchronization time difference of all local moments contained in the two local unit time period sets as the trusted local unit time period.

[0255] Please continue reading Figure 3 and 6 As shown, after selecting a trusted local unit period with stable and reliable Beidou timing, step S5 can be executed to use the average of the pre-synchronization time differences of each local moment within the trusted local unit period as the synchronization calibration time difference for that trusted local unit period. Next, step S6 can be executed to match the pre-synchronization time differences of each local moment within the previous local unit period adjacent to the current local moment with all trusted local unit periods to obtain several target trusted local unit periods. Specifically, step S61 can be executed to use the previous local unit period adjacent to the current local moment as the reference local unit moment. Next, step S62 can be executed to calculate the difference between the reference local unit moment and each trusted local unit period as the time asynchrony rate. Specifically, the difference between the pre-synchronization time differences of each pair of local moments with the same temporal sequence within two local unit periods can be accumulated as the time asynchrony rate between the two local unit periods, and the time asynchrony rate between the reference local unit moment and each trusted local unit period can be calculated. Next, step S63 can be executed to obtain a set maximum value for the time asynchrony rate. Finally, step S64 may be executed to set several trusted local unit time periods whose time asynchrony rates with the reference local unit time are less than a set maximum value as target trusted local unit time periods.

[0256] See also Figure 3 and 7 As shown, after matching the target trusted local unit time period, since different target trusted local unit time periods have different credibility, that is, different time asynchrony rates, step S7 can be executed to obtain the synchronization calibration time difference of the current local time based on the synchronization calibration time differences of all target trusted local unit time periods. Specifically, step S71 can be executed to use the time asynchrony rate between each target trusted local unit time period and the reference local unit time as the weight coefficient of the target trusted local unit time period. Then, step S72 can be executed to calculate the weighted average of the synchronization calibration time differences of all target trusted local unit time periods as the synchronization calibration time difference of the current local time. In the final operation of synchronizing the local time of the master base station 1, step S8 can be executed to synchronize the clock of the current local time based on the Beidou timing obtained at the same time as the current local time.

[0257] In order to provide supplementary explanation for the implementation process of the above-mentioned step S6 to step S7, the source code of some functional modules is provided, and a comparative explanation is provided in the comment section.

[0258] #include <iostream>

[0259] #include <vector>

[0260] #include <algorithm>

[0261] #include <numeric>

[0262] #include <cmath>

[0263] #include <limits>

[0264] #include <utility>

[0265] / / Local time data structure

[0266] struct LocalMoment {

[0267] double timestamp; / / local timestamp

[0268] double pre_sync_diff; / / Pre-synchronization time difference (local-Beidou)

[0269] };

[0270] / / Local unit period structure

[0271] struct TimePeriod {

[0272] std::vector <localmoment>moments; / / All local moments within the period

[0273] double async_rate; / / Time asynchronous rate with reference period

[0274] double avg_sync_diff; / / Average synchronization calibration time difference during the period

[0275] };

[0276] class SyncCalibrationCalculator {

[0277] private:

[0278] std::vector <timeperiod>trusted_periods_; / / All trusted local unit periods

[0279] const double max_async_rate_ = 5.0; / / Maximum threshold of time asynchronous rate

[0280] public:

[0281] / / Set the trusted period data

[0282] void SetTrustedPeriods(const std::vector <timeperiod>&periods) {

[0283] trusted_periods_ = periods;

[0284] / / Precalculate the average synchronization difference for each trusted period

[0285] for (auto&period : trusted_periods_) {

[0286] period.avg_sync_diff = CalculateAverageSyncDiff(period);

[0287] }

[0288] }

[0289] / / Calculate the synchronization calibration time difference of the current local time

[0290] double CalculateCurrentCalibration(const TimePeriod&reference_period){

[0291] / / Step 1: Match the target trusted period

[0292] auto target_periods = MatchTargetPeriods(reference_period);

[0293] if (target_periods.empty()) {

[0294] std::cerr<<"Warning: No matching trusted period found, returning the default value 0"< <std::endl;

[0295] return 0.0;

[0296] }

[0297] / / Step 2: Calculate the weighted average synchronization calibration time difference

[0298] return CalculateWeightedAverage(target_periods);

[0299] }

[0300] private:

[0301] / / Calculate the average synchronization difference during the period

[0302] double CalculateAverageSyncDiff(const TimePeriod&period) {

[0303] if (period.moments.empty()) return 0.0;

[0304] double sum = 0.0;

[0305] for (const auto&moment : period.moments) {

[0306] sum += moment.pre_sync_diff;

[0307] }

[0308] return sum / period.moments.size();

[0309] }

[0310] / / Match the target trusted period

[0311] std::vector <timeperiod>MatchTargetPeriods(const TimePeriod&reference_period) {

[0312] std::vector <timeperiod>target_periods;

[0313] / / Calculate the average synchronization difference of the reference period

[0314] double ref_avg_diff = CalculateAverageSyncDiff(reference_period);

[0315] / / Calculate the time asynchrony rate for each trusted period and filter

[0316] for (const auto&trusted_period : trusted_periods_) {

[0317] double async_rate = CalculateAsyncRate(reference_period, trusted_period);

[0318] / / Filtering conditions: The asynchronous rate is less than the threshold and the average synchronization difference is close to the reference period

[0319] if (async_rate <max_async_rate_&&

[0320] fabs(trusted_period.avg_sync_diff - ref_avg_diff)<2.0 * max_async_rate_) {

[0321] TimePeriod matched = trusted_period;

[0322] matched.async_rate = async_rate;

[0323] target_periods.push_back(matched);

[0324] }

[0325] }

[0326] / / Sort by asynchronous rate from small to large (the smaller the asynchronous rate, the higher the weight)

[0327] std::sort(target_periods.begin(), target_periods.end(),

[0328] [](const TimePeriod&a, const TimePeriod&b) {

[0329] return a.async_rate <b.async_rate;

[0330] });

[0331] return target_periods;

[0332] }

[0333] / / Calculate the time asynchrony rate of two periods

[0334] double CalculateAsyncRate(const TimePeriod&period1, const TimePeriod&period2) {

[0335] double total_diff = 0.0;

[0336] size_t matched_pairs = 0;

[0337] size_t i = 0, j = 0;

[0338] / / Use the double pointer algorithm to align the timestamp to the closest moment

[0339] while (i <period1.moments.size()&&j<period2.moments.size()) {

[0340] double time_diff = period1.moments[i].timestamp - period2.moments[j].timestamp;

[0341] if (fabs(time_diff)<0.01) { / / Timestamp alignment threshold

[0342] total_diff += fabs(period1.moments[i].pre_sync_diff -

[0343] period2.moments[j].pre_sync_diff);

[0344] matched_pairs++;

[0345] i++;

[0346] j++;

[0347] }

[0348] else if (time_diff<0) {

[0349] i++;

[0350] }

[0351] else {

[0352] j++;

[0353] }

[0354] }

[0355] / / Return the average asynchronous rate (total difference / number of matching pairs)

[0356] return matched_pairs>0 ? total_diff / matched_pairs :

[0357] std::numeric_limits <double>::max();

[0358] }

[0359] / / Calculate the weighted average synchronization calibration time difference

[0360] double CalculateWeightedAverage(const std::vector <timeperiod>&target_periods) {

[0361] double weighted_sum = 0.0;

[0362] double weight_sum = 0.0;

[0363] for (const auto&period : target_periods) {

[0364] / / Weight coefficient = 1 / (asynchronous rate + epsilon) to avoid division by zero

[0365] double weight = 1.0 / (period.async_rate + 1e-6);

[0366] weighted_sum += weight * period.avg_sync_diff;

[0367] weight_sum += weight;

[0368] }

[0369] return weighted_sum / weight_sum;

[0370] }

[0371] };

[0372] / / Example usage

[0373] int main() {

[0374] SyncCalibrationCalculator calculator;

[0375] / / Construct test data - trusted period set

[0376] std::vector <timeperiod>trusted_periods = {

[0377] / / Trusted period 1 (stable low latency)

[0378] {

[0379] {{1.0, 10.1}, {1.1, 10.2}, {1.2, 10.0}, {1.3, 10.3}, {1.4, 10.1}},

[0380] 0.0, / / async_rate is initially 0 and will be filled after calculation

[0381] 0.0 / / avg_sync_diff is initially 0, the constructor will calculate

[0382] },

[0383] / / Trusted period 2 (stable delay)

[0384] {

[0385] {{2.0, 15.5}, {2.1, 15.6}, {2.2, 15.4}, {2.3, 15.7}, {2.4, 15.3}},

[0386] 0.0, 0.0

[0388] },

[0389] / / Trusted Period 3 (similar to Period 1 but with minor fluctuations)

[0390] {

[0391] {{1.05, 10.3}, {1.15, 10.1}, {1.25, 10.4}, {1.35, 10.2}, {1.45,10.5}},

[0392] 0.0, 0.0

[0394] }

[0395] };

[0396] calculator.SetTrustedPeriods(trusted_periods);

[0397] / / Construct reference period (similar to trusted periods 1 and 3)

[0398] TimePeriod reference_period = {

[0399] {{1.02, 10.2}, {1.12, 10.3}, {1.22, 10.1}, {1.32, 10.4}, {1.42,10.2}},

[0400] 0.0, 0.0

[0402] };

[0403] / / Calculate the current synchronization calibration time difference

[0404] double calibration = calculator.CalculateCurrentCalibration(reference_period);

[0405] std::cout<<"The synchronization calibration time difference of the current local time: "< <calibration<<std::endl;

[0406] return 0;

[0407] }

[0408] This code implements a complete clock synchronization calibration algorithm based on trusted period matching. During operation, the previous period is first used as a reference period. Timestamp alignment is then used to calculate the time asynchrony rate with each trusted period. Target trusted periods with asynchrony rates below a threshold are then selected. Finally, a weighted average synchronization calibration value is calculated, using the inverse of the asynchrony rate as weight. The algorithm uses a dual-pointer timestamp alignment strategy to ensure data matching accuracy. By integrating calibration information from multiple trusted periods through weighted averaging, clock synchronization accuracy is effectively improved. The code includes a complete data structure, time alignment algorithm, asynchrony rate calculation, weighted averaging, and other core logic, enabling direct integration into high-precision time synchronization systems.

[0409] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, systems, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a part for a module, program segment or instruction, and the part for the module, program segment or instruction comprises one or more executable instructions for realizing the logical function of the specification. In some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous boxes can actually be performed substantially in parallel, and they can sometimes also be performed in the opposite order, depending on the function involved.

[0410] It should also be noted that each box in the block diagram and / or flowchart, and combinations of boxes in the block diagram and / or flowchart, can be implemented by hardware that performs the corresponding function or action, such as a circuit or ASIC (Application Specific Integrated Circuit), or can be implemented by a combination of hardware and software, such as firmware.

[0411] Although the present invention has been described herein in conjunction with various embodiments, in the process of implementing the claimed invention, those skilled in the art may understand and implement other variations of the disclosed embodiments by examining the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude multiple situations. A single processor or other unit may implement several functions listed in the claims. The fact that certain measures are recorded in different dependent claims does not mean that these measures cannot be combined to produce good results.

[0412] The embodiments of the present application have been described above. The above description is illustrative and not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope of the described embodiments. The terminology used herein is selected to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons skilled in the art to understand the embodiments disclosed herein.< / timeperiod> < / timeperiod> < / double> < / timeperiod> < / timeperiod> < / timeperiod> < / timeperiod> < / localmoment> < / utility> < / limits> < / cmath> < / numeric> < / algorithm> < / vector> < / iostream> < / syncdata> < / syncdata> < / syncdata> < / double> < / double> < / periodstats> < / double> < / periodstats> < / double> < / double> < / periodstats> < / double> < / syncdata> < / periodstats> < / syncdata> < / syncdata> < / syncdata> < / syncdata> < / utility> < / limits> < / cmath> < / numeric> < / algorithm> < / vector> < / iostream>

Claims

1. A UWB clock synchronization method based on Beidou timing, characterized in that: include, Add calendar extension based on the clock counter output, continuously count the clock counter pulse updates to obtain the local time, and simultaneously obtain Beidou timing; The difference between the local time and Beidou time obtained at the same time is calculated as the pre-synchronization time difference of each local time; Divide the multiple local time points into multiple local unit time periods in equal proportion according to the temporal order; Select a trusted local unit period based on the pre-synchronization time difference of each local moment within each local unit period; The average of the pre-synchronization time differences of each local moment in the trusted local unit period is used as the synchronization calibration time difference of the trusted local unit period; Obtaining a plurality of target trusted local unit time periods by matching the pre-synchronization time difference of each local time in the previous local unit time period adjacent to the current local time with all trusted local unit time periods; The synchronization calibration time difference of the current local time is obtained according to the synchronization calibration time difference of all target trusted local unit time periods, and the clock of the current local time is synchronized.

2. The method according to claim 1, characterized in that The step of selecting a trusted local unit period according to the pre-synchronization time difference of each local moment in each local unit period includes: Calculate and obtain the mean and standard deviation of the pre-synchronization time difference of each local time contained in each local unit period; The timing quality difference between any two local unit periods is obtained by accumulating the difference between the mean and standard deviation of the pre-synchronization time difference of each local time contained in any two local unit periods; Select two local unit periods from among all local unit periods as marked local unit periods; Classifying all local unit periods into two local unit period sets according to the timing quality difference between each marked local unit period and each other local unit period; The local unit period in the local unit period set having the smaller average value of the pre-synchronization time differences of all local time moments included in the two local unit period sets is taken as the trusted local unit period.

3. The method according to claim 2, characterized in that The step of classifying all local unit periods into two local unit period sets according to the timing quality difference between each marked local unit period and each other local unit period, include, Classifying the other local unit time periods other than each marked local unit time period and the marked local unit time period with the smallest difference in timing quality into the same local unit time period set; Determine whether the timing quality between the local unit time periods included in each local unit time period set is consistent; If so, two local unit time period sets with internal timing quality consistency are obtained; If not, the local unit period is reselected and marked, and the local unit period set is re-divided until two local unit period sets with internal timing quality consistency are obtained.

4. The method according to claim 3, characterized in that The step of judging whether the timing qualities between the local unit time periods included in each local unit time period set are consistent includes: For each local unit time period set, calculate and obtain the mean value and the mean value of the pre-synchronization time difference of each local time instant included in all local unit time periods in the local unit time period set as the representative pre-synchronization time difference and representative standard deviation of the local unit time period set; Determine, for each local unit time period set, whether the local unit time period having the smallest timing quality difference between the representative pre-synchronization time difference and the representative standard deviation is a marked local unit time period; If yes, it is determined that the timing quality between the local unit time periods included in each local unit time period set is consistent; If not, the timing qualities between the local unit time periods included in each local unit time period set are not consistent.

5. The method according to claim 3, characterized in that The step of reselecting the marking local unit time period, include, In each local unit period set, the local unit period with the smallest difference in timing quality between the representative pre-synchronization time difference and the representative standard deviation is used as the reselected marked local unit period.

6. The method according to claim 1, characterized in that The step of matching the pre-synchronization time difference of each local time in the previous local unit time period adjacent to the current local time with all the trusted local unit time periods to obtain a plurality of target trusted local unit time periods, include, The previous local unit time period adjacent to the current local time is used as the reference local unit time; Calculate and obtain the difference between the reference local unit time and each trusted local unit time period as the time asynchrony rate; Get the maximum value of the time asynchronous rate; A number of trusted local unit time periods whose time asynchrony rate with the reference local unit time is less than a set maximum value are used as target trusted local unit time periods.

7. The method according to claim 6, characterized in that The step of calculating and obtaining the difference between the reference local unit time and each trusted local unit time period as the time asynchrony rate includes: The accumulated value of the pre-synchronization time difference of each pair of local times with the same time sequence within two local unit periods is used as the time asynchrony rate of the two local unit periods, and the time asynchrony rate between the reference local unit time and each trusted local unit period is calculated.

8. The method according to claim 6, characterized in that The step of obtaining the synchronization calibration time difference of the current local time according to the synchronization calibration time difference of all target trusted local unit time periods, include, The time asynchrony rate between each target trusted local unit time period and the reference local unit time period is used as the weight coefficient of the target trusted local unit time period; The weighted mean of the synchronization calibration time differences of all target trusted local unit time periods is calculated and obtained as the synchronization calibration time difference of the current local time.

9. A UWB clock synchronization method based on Beidou timing, characterized in that: include, Determine whether Beidou timing can be obtained; If so, performing satellite timing clock synchronization according to a UWB clock synchronization method based on Beidou timing according to any one of claims 1 to 8; If not, request clock synchronization from the adjacent base station and obtain the local time of the adjacent base station including the calendar extension.

10. A UWB clock synchronization system based on Beidou timing, characterized in that: include, The main base station is used to add calendar extensions based on the clock counter output, continuously count the clock counter pulse updates to obtain the local time, and simultaneously obtain Beidou timing; The difference between the local time and Beidou time obtained at the same time is calculated as the pre-synchronization time difference of each local time; Divide the multiple local time points into multiple local unit time periods in equal proportion according to the temporal order; Select a trusted local unit period based on the pre-synchronization time difference of each local moment within each local unit period; The average of the pre-synchronization time differences of each local moment in the trusted local unit period is used as the synchronization calibration time difference of the trusted local unit period; Obtaining a plurality of target trusted local unit time periods by matching the pre-synchronization time difference of each local time in the previous local unit time period adjacent to the current local time with all trusted local unit time periods; Obtain the synchronization calibration time difference of the current local time according to the synchronization calibration time difference of all target trusted local unit periods; Synchronize the local time clock based on the Beidou time service obtained simultaneously with the current local time; The slave base station requests clock synchronization from the master base station and obtains the local time including the calendar extension of the neighboring base station.

Citation Information

Patent Citations

  • Time calibration method and device

    CN116419386A

  • Time service method, device and system for electric power Beidou time-frequency synchronization

    CN117215173A