A time synchronization method and system for wireless communication
By using one-way UDP broadcasting from the master node and linear regression processing, the limitations of wireless synchronization schemes in terms of deployment and robustness are solved, achieving high-precision time synchronization between multiple devices. This is applicable to scenarios such as industrial internet, power distribution network, and robot learning and training.
Patent Information
- Application Number
- CN202611710118.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-11-02
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies suffer from limitations in wired synchronization deployment, poor adaptability to satellite timing environments, reliance on two-way message exchange for traditional wireless synchronization, uncertain jitter in timestamps, and insufficient robustness in synchronization under harsh conditions. Consequently, it is difficult to provide stable microsecond-level time synchronization output for multiple slave nodes under conditions without wiring or satellite line-of-sight.
By adopting unidirectional UDP broadcasting by the master node, the slave node does not need to send uplink service messages. By obtaining the time base information and reference count information of the master and slave nodes, the slave node time offset information is calculated, linear regression processing and frequency offset compensation are performed, and synchronized slave node time base information is generated, thus achieving high-precision time synchronization of the wireless link.
It achieves high-precision time synchronization for dozens of slave nodes, reduces the risk of wireless channel collisions and congestion, adapts to complex wireless electromagnetic environments, and improves the robustness of time synchronization results. It is suitable for wireless time synchronization business scenarios such as industrial internet, power distribution network, and robot learning and training.
Smart Images

Figure CN123184779A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of wireless communication technology, and in particular relates to time synchronization methods and systems for wireless communication. Background Technology
[0002] Time synchronization is a core foundational technology supporting fields such as the Industrial Internet, power automation, mobile communications, and autonomous driving. With the increasing wireless and mobile development of industrial equipment, a large number of mobile AGVs, distributed robots, and vehicle-mounted collaborative terminals are being deployed. Traditional wired deployment models are difficult to adapt to mobile and temporary deployment scenarios, leading to a continuously increasing industry demand for wireless time synchronization technology with microsecond-level accuracy. Current mainstream high-precision time synchronization technologies include wired PTP protocol, satellite time synchronization, NTP network time protocol, and WiFi Fine Time Measurement (FTM) to provide timestamps and RTT information based on frame round-trip measurements. If used for node clock synchronization, corresponding offset estimation and correction processing are also required. Different technologies have different trade-offs in deployment methods, synchronization accuracy, and environmental adaptability, and various solutions still have many technical shortcomings that need to be addressed.
[0003] The existing technologies are the IEEE 1588 wired PTP precise time protocol and the WiFi FTM (802.11mc) wireless fine time measurement scheme. IEEE 1588 PTP relies on a wired Ethernet link and utilizes boundary clocks and transparent clock switches to calculate master-slave node clock deviation and propagation delay through bidirectional message exchange and hardware timestamping, achieving sub-microsecond time synchronization. FTM is based on the WiFi wireless frame round-trip measurement mechanism, obtaining timestamps at the MAC layer to complete time calibration between wireless nodes.
[0004] However, IEEE 1588PTP relies on dedicated wired network infrastructure, making it unsuitable for mobile nodes and temporary deployment scenarios. While FTM provides timestamps and RTT information based on frame round-trip measurements, it requires corresponding offset estimation and correction processing for node clock synchronization. PTP relies on dedicated wired networks and is unsuitable for mobile scenarios; NTP deployments are generally affected by network latency asymmetry and implementation limitations, making it difficult to guarantee the stable edge synchronization required for this application. Summary of the Invention
[0005] In view of this, embodiments of this application provide a time synchronization method and system for wireless communication, aiming to solve the problems existing in the prior art, such as limited deployment of wired synchronization schemes, poor adaptability to satellite timing environments, reliance on bidirectional message interaction for traditional wireless synchronization, uncertain jitter in timestamps, insufficient synchronization robustness under harsh working conditions, and difficulty in providing stable microsecond-level time synchronization output for multiple slave nodes under conditions of no wiring and no satellite line of sight.
[0006] A first aspect of this application provides a time synchronization method for wireless communication, comprising: Obtain the master node time base information, the slave node time base information to be synchronized, and the node time reference count information; Based on the master node time base information, the slave node time base information to be synchronized, and the node time reference count information, multiple slave node time offset information are calculated. Based on the multiple slave node time offset information, the slave node time reference information to be synchronized is analyzed and processed to generate processed slave node time reference information; Linear regression processing is performed based on the slave node time reference information to be synchronized and the processed slave node time reference information to generate a slave node time information regression curve. Based on the regression curve of the slave node time information, the slave node offset time prediction calculation is performed to obtain the slave node offset time prediction information; Based on the processed slave node time base information and the slave node offset time prediction information, the slave node time base information to be synchronized is synchronized to generate synchronized slave node time base information.
[0007] A second aspect of this application provides a time synchronization system for wireless communication, comprising: The information acquisition module is used to acquire the time base information of the master node, the time base information of the slave nodes to be synchronized, and the node time reference count information. The slave node time offset information calculation module is used to calculate multiple slave node time offset information based on the master node time base information, the slave node time base information to be synchronized, and the node time reference count information. The processed slave node time reference information generation module is used to analyze and process the slave node time reference information to be synchronized based on the multiple slave node time offset information, and generate processed slave node time reference information. The slave node time information regression curve generation module is used to perform linear regression processing based on the slave node time reference information to be synchronized and the processed slave node time reference information to generate a slave node time information regression curve. The slave node offset time prediction information generation module is used to perform slave node offset time prediction calculation based on the slave node time information regression curve to obtain slave node offset time prediction information. The synchronized slave node time reference information generation module is used to perform synchronization processing on the slave node time reference information to be synchronized based on the processed slave node time reference information and the slave node offset time prediction information, and generate synchronized slave node time reference information.
[0008] A third aspect of this application provides a terminal device, the terminal device including a memory and a processor, the memory storing a computer program executable on the processor, the processor executing the computer program to implement the steps of the time synchronization method for wireless communication as described in the first aspect above.
[0009] A fourth aspect of this application provides a computer-readable storage medium, comprising: storing a computer program, which, when executed by a processor, implements the steps of the time synchronization method for wireless communication described in the first aspect above.
[0010] Compared with the prior art, the beneficial effects of this application are as follows: This application uses unidirectional UDP broadcasting by the master node, eliminating the need for slave nodes to send uplink service messages. This reduces the risks of wireless channel collisions, backoff, and congestion in a master-slave scenario, supports simultaneous synchronization of dozens of slave nodes, and achieves high-precision time synchronization based on wireless links in a master-slave topology. It does not rely on dedicated synchronization cables or satellite line-of-sight conditions, can robustly handle sampling jitter caused by the wireless link, and simultaneously completes phase correction and progressive frequency offset compensation. It allows multiple slave clock nodes to be synchronized to output hardware synchronization edges according to a unified absolute counting slot, thereby controlling the error range of wireless time synchronization between multiple devices within 50 microseconds. This improves the robustness of time synchronization results in complex radio electromagnetic environments and can adapt to various wireless time synchronization service scenarios such as industrial internet, power distribution network, and robot learning and training. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram illustrating the implementation process of the time synchronization method for wireless communication provided in Embodiment 1 of this application; Figure 2 This is a schematic diagram illustrating the implementation process of the time synchronization method for wireless communication provided in Embodiment 2 of this application; Figure 3 This is a schematic diagram illustrating the implementation process of the time synchronization method for wireless communication provided in Embodiment 3 of this application; Figure 4 This is a schematic diagram illustrating the implementation process of the time synchronization method for wireless communication provided in Embodiment 4 of this application; Figure 5This is a schematic diagram illustrating the implementation process of the time synchronization method for wireless communication provided in Embodiment 5 of this application; Figure 6 This is a schematic diagram illustrating the implementation process of the time synchronization method for wireless communication provided in Embodiment Six of this application; Figure 7 This is a schematic diagram illustrating the implementation process of the time synchronization method for wireless communication provided in Embodiment 7 of this application; Figure 8 This is a schematic diagram of the structure of a time synchronization system for wireless communication provided in an embodiment of this application; Figure 9 This is a schematic diagram of the terminal device provided in the embodiments of this application. Detailed Implementation
[0013] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0014] To illustrate the technical solution described in this application, specific embodiments are provided below.
[0015] Figure 1 A flowchart illustrating the implementation of the time synchronization method for wireless communication provided in Embodiment 1 of this application is shown below in detail: Step S101: Obtain the master node time base information, the slave node time base information to be synchronized, and the node time reference count information.
[0016] In this embodiment, the master node time base information can refer to the counting data corresponding to the hardware timer inside the master clock node and the Unix time base data. Specifically, it can be a set of multiple binary reference points composed of the wireless TSF count value collected by the master clock node during the software timed callback and the master node's 1MHz GPTimer count value, which can be generated by the master clock node according to a fixed period. The slave node time base information to be synchronized can refer to the original counting data of the slave clock node's local hardware timer, specifically, it can be the slave node's 1MHz GPTimer count value read by the slave clock node in the Beacon reception callback. The node time reference count information can be the complete set of reference counts obtained by the master node and the slave node to be synchronized based on the same public wireless TSF time domain, which can be used to establish the mapping relationship between the master node's hardware timer and the slave node's hardware timer. It can be understood that the master node time base information can be encapsulated in a UDP synchronization batch and broadcast through the wireless link. The slave node time base information and the node time reference count information to be synchronized can be collected by the slave clock node to be synchronized within the complete time range of the Beacon reception callback after filtering the Beacon management frame with a specified BSSID.
[0017] In this embodiment, a complete UDP synchronization batch can carry all master node time base information. If the slave clock node to be synchronized does not receive the complete UDP synchronization batch, it will not perform subsequent time synchronization calculations.
[0018] In this embodiment, the Master reads the current TSF of the AP, and the Slave reads the current TSF of the STA following the AP in the Beacon callback of the target BSSID. Both ends first read GPTimer(before), then TSF, then GPTimer(after), and the local reference count is before + (after - before) / 2. Validity checks include successful read, TSF > 0, count not rolled back, not crossing the GPTimer ISR of this project, and sampling span ≤ 100μs. The Master attempts a maximum of three times per callback, and the Slave attempts once per Beacon. 100μs is a sampling quality threshold, not a guarantee of physical synchronization accuracy; midpoint pairing does not equate to simultaneous hardware latching.
[0019] In this embodiment, 50 primary reference points constitute one slice, and 100 primary reference points constitute two slices; each slice in the same batch and repeated transmissions share the batch ID, Unix baseline, and future output target; the slave verifies the source, fields, and reassembles the slices.
[0020] In this embodiment, a one-way broadcast mechanism is adopted, and the slave node does not need to send any reply message to the master node, which reduces wireless uplink traffic and is suitable for a master-slave cluster scenario. If packet loss occurs in the UDP synchronization batch, the batch is determined to be incomplete, and all reference point data in this batch is directly discarded without interpolation calculation of the incomplete data.
[0021] Step S102: Based on the master node time reference information, the slave node time reference information to be synchronized, and the node time reference count information, calculate multiple slave node time offset information.
[0022] In this embodiment, the expected count value of the master node's hardware timer corresponding to the wireless TSF count value carried by the Beacon can be calculated first using the node time reference count information. Then, combined with the slave node time reference information to be synchronized, the slave node time offset information corresponding to each set of reference points is calculated one by one. It is understood that the slave node time offset information represents the count deviation of the slave clock node's hardware timer relative to the master clock node's hardware timer. If the number of valid reference points is less than a preset reference point number threshold, the current calculation is deemed invalid, and no more slave node time offset information is generated; the preset reference point number threshold can be manually set. Multiple slave node time offset information can be generated by summarizing the deviation results corresponding to all valid reference points. It is understood that the reference point number threshold can be configured according to actual business needs; for example, it can be set to 8-16 reference points. If the number of valid reference points is less than the threshold, the current synchronization is skipped to avoid regression fitting distortion caused by insufficient samples. It is understood that the current firmware does not pair the transmitted TSF in the Beacon payload with the GPTimer during callback, but instead uses the current STATSF.
[0023] Step S103: Based on the multiple slave node time offset information, analyze and process the slave node time reference information to be synchronized to generate processed slave node time reference information.
[0024] In this embodiment, the median of the sequence of time offset information from multiple slave nodes is first calculated, followed by the median absolute deviation. Then, anomaly detection is performed on the time offset information of multiple slave nodes using a pre-set effective deviation range threshold. This pre-set threshold can be manually configured. When anomaly slave node time offset information exceeding the effective deviation range threshold is identified, the abnormal sample is not directly removed. Instead, the median of the sequence is used to replace the abnormal slave node time offset information, ensuring that the total number of sample sequences remains unchanged and guaranteeing the sample input size for subsequent linear regression. Then, the slave node time offset information after anomaly replacement is paired and integrated with the corresponding slave node time reference information to be synchronized, thereby generating processed slave node time reference information. This step is understood to be used to suppress the adverse effects of abnormal samples caused by wireless reception callback jitter on subsequent calculations.
[0025] Step S104: Perform linear regression processing based on the slave node time reference information to be synchronized and the processed slave node time reference information to generate a slave node time information regression curve.
[0026] In this embodiment, the time obtained by converting the local hardware timer count difference in the time base information of the slave node to be synchronized can be used as the independent variable, and the corresponding slave node time offset information in the processed slave node time base information can be used as the dependent variable. Then, a linear regression operation is performed using ordinary least squares. It is understood that the linear regression operation will output a slope parameter representing the clock frequency offset and a fitting intercept parameter. The validity of the regression result needs to be verified. When the regression result verification conditions are met, the regression result is retained; these preset verification conditions can be manually set. After successful verification, a slave node time information regression curve is generated. This curve reflects the trend of the time offset of the slave clock node relative to the master clock node as the local running time changes.
[0027] Step S105: Perform slave node offset time prediction calculation based on the slave node time information regression curve to obtain slave node offset time prediction information.
[0028] In this embodiment, the real-time count value of the hardware timer of the slave clock node to be synchronized at the current moment can be read. Then, the time reference information of the slave node to be synchronized corresponding to the reference point in the middle of this batch is selected as the extrapolation anchor point. Then, the frequency offset compensation amount accumulated from the anchor point moment to the current moment is calculated by using the frequency offset slope of the slave node time information regression curve. It can be understood that this calculation process can avoid the time lag problem caused by directly using the offset data of the sampling moment to correct the current timer. Then, the representative value of the phase deviation output by the processed slave node time reference information is summarized and calculated to obtain the slave node offset time prediction information.
[0029] Step S106: Based on the processed slave node time reference information and the slave node offset time prediction information, perform synchronization processing on the slave node time reference information to be synchronized to generate synchronized slave node time reference information.
[0030] In this embodiment, a 64-bit count overflow and underflow check is first performed on the count correction result of the time base information of the slave node to be synchronized. After the check passes, a one-time phase correction of the time base information of the slave node to be synchronized is performed. Then, the frequency offset slope output from the slave node time information regression curve is converted into a 16.16 fixed-point format compensation amount, and fixed-point margin accumulation processing is performed at the maintenance point per second. The preset maintenance point per second trigger condition can be manually preset. When the fixed-point accumulation margin reaches an integer microsecond, a small-step count correction is performed on the time base information of the slave node to be synchronized, with the fractional part remaining in the accumulator. Then, combined with the common future output target count issued by the master node, the global absolute count slot is aligned, thereby generating the synchronized slave node time base information. It is understood that the synchronized slave node time base information is used to drive the hardware register to generate the GPIO hardware synchronization edge. The time metadata output by the UART is only used for log printing debugging and will not be used as the basis for synchronization events, preventing software transmission delay from introducing synchronization errors. Understandably, the actual edge is generated by the GPTimer alarm ISR directly writing to W1TS / W1TC, and there is still an ISR response delay; it is not a direct, software-delay-free pin flip by the hardware comparator. The UART transmits the nominal time of the target edge, without synchronizing it with its arrival time.
[0031] The time synchronization method for wireless communication provided in this application uses unidirectional UDP broadcasting by the master node, eliminating the need for slave nodes to send uplink service messages. This reduces the risks of wireless channel collisions, backoff, and congestion in a master-slave scenario, supports simultaneous synchronization of dozens of slave nodes, and achieves high-precision time synchronization based on wireless links in a master-slave topology. It does not rely on dedicated synchronization cables or satellite line-of-sight conditions, and can robustly handle sampling jitter caused by the wireless link. It also performs phase correction and progressive frequency offset compensation, enabling multiple slave clock nodes to output hardware synchronization edges according to a unified absolute counting slot. This allows the error range of wireless time synchronization between multiple devices to be controlled within 50 microseconds, thereby improving the robustness of time synchronization results in complex radio electromagnetic environments. It can be adapted to various wireless time synchronization service scenarios such as industrial internet, power distribution network, and robot learning and training.
[0032] Figure 2 The flowchart illustrating the implementation of the time synchronization method for wireless communication provided in Embodiment 2 of this application is shown. The difference between this method and Embodiment 1 is that step S103 specifically includes: Step S201: Calculate the median time offset information of the slave nodes based on the multiple slave node time offset information.
[0033] In this embodiment, the median time offset information of a slave node can refer to the middle value of a numerical sequence composed of multiple slave node time offset information. It can be used to characterize the phase deviation level of the overall sample. It can be generated by sorting all slave node time offset information according to their numerical values, and then selecting the offset value corresponding to the middle position of the sorted sequence. Understandably, using median statistics can reduce the interference of a few abnormal offset samples on the overall phase characterization result, providing a benchmark reference for subsequent anomaly detection operations. For example, multiple slave node time offset information can be 50 data points, or 100 data points are also supported, all even numbers. Understandably, the code sorts the offset array copy, averages the two middle offsets, and performs integer division; it doesn't just arbitrarily select a middle element, and the original sampling time and its corresponding order remain unchanged.
[0034] Step S202: Based on the multiple slave node time offset information and the median slave node time offset information, multiple slave node time absolute deviation information is calculated.
[0035] In this embodiment, the absolute time deviation information of a slave node refers to the absolute value of the difference between each slave node time offset and the median slave node time offset. This value characterizes the degree of deviation of a single offset sample from the overall median level. It can be generated by calculating the difference between each set of slave node time offsets and the median slave node time offset, taking the absolute value of the difference, and then summing the results for all samples. This generates multiple absolute time deviation information sets for slave nodes. Understandably, multiple absolute time deviation information sets provide a computational basis for subsequently identifying abnormal offset samples caused by jitter.
[0036] Step S203: Based on the median time offset information of the slave nodes, the absolute time deviation information of multiple slave nodes, and the preset absolute time deviation threshold information of the slave nodes, the time reference information of the slave nodes to be synchronized is filtered and replaced to generate processed slave node time reference information.
[0037] In this embodiment, the preset absolute time deviation threshold information for slave nodes can be manually preset and used to define the legal value range of slave node time offset information. Each slave node's absolute time deviation information can be compared with the preset threshold information to distinguish between normal and abnormal samples. For the identified abnormal samples, the median of the slave node time offset is used to replace them, rather than directly deleting them. This maintains the sample array length, ensuring the number of input samples for subsequent linear regression. Normal samples retain their original values. The filtered and replaced offset samples are then paired and integrated with their corresponding slave node time reference information to generate the processed slave node time reference information. This sub-step refines the identification and replacement process for abnormal samples, suppressing erroneous samples introduced by random jitter in Beacon reception callbacks and reducing the negative impact of abnormal data on subsequent linear regression calculations.
[0038] The time synchronization method for wireless communication provided in this application embodiment realizes robust preprocessing of offset samples, reduces the adverse effects of random jitter in the wireless channel, thereby ensuring the reliability of subsequent frequency offset estimation and time base correction operations, and improving the stability of multi-node time synchronization output results in a wireless environment.
[0039] Figure 3 The flowchart illustrating the implementation of the time synchronization method for wireless communication provided in Embodiment 3 of this application is shown. The difference between this method and Embodiment 2 is that step S203 specifically includes: Step S301: Determine whether the absolute time deviation information of the slave node is greater than the preset absolute time deviation threshold information of the slave node; if yes, proceed to step S302; if no, proceed to step S303.
[0040] In this embodiment, the preset absolute time deviation threshold for slave nodes can be manually set and used as a criterion for determining whether a single slave node time offset belongs to an abnormal sample. Each set of slave node time absolute deviation information can be iterated through, and then the value of each slave node time absolute deviation information can be compared with the preset absolute time deviation threshold information to complete the legality judgment of a single set of samples. It can be understood that when the absolute time deviation information of a slave node is greater than the preset absolute time deviation threshold information, it means that the corresponding slave node time offset information belongs to an abnormal sample; when the absolute time deviation information of a slave node is less than or equal to the preset absolute time deviation threshold information, it means that the corresponding slave node time offset information belongs to a normal and usable sample.
[0041] Step S302: Based on the median time offset information of the slave node, the time reference information of the slave node to be synchronized is replaced to generate processed slave node time reference information.
[0042] In this embodiment, a scenario where the absolute time deviation of a slave node is greater than a preset absolute time deviation threshold indicates that the current sample is an abnormally offset sample. The abnormal slave node time offset information can be replaced with the median slave node time offset information. Then, the replaced offset value is paired and bound with the corresponding slave node time reference information to be synchronized, thereby generating processed slave node time reference information. It is understood that this step does not directly discard abnormal samples, but only performs numerical replacement, maintaining the total number of samples in the sample sequence and ensuring the sample input scale for subsequent linear regression operations.
[0043] Step S303: Generate processed slave node time reference information based on the slave node time reference information to be synchronized.
[0044] In this embodiment, if the determination result is that the absolute time deviation information of the slave node is less than or equal to the preset absolute time deviation threshold information of the slave node, it means that the current sample is a normally usable offset sample. The original slave node time offset information can be retained without modification, and then the original slave node time offset information and the corresponding slave node time reference information to be synchronized are directly paired and bound to generate the processed slave node time reference information. It can be understood that this branch directly uses the valid samples obtained from the acquisition and calculation, which can retain the true clock offset change characteristics and provide reliable input data for subsequent frequency offset fitting.
[0045] The time synchronization method for wireless communication provided in this application embodiment enables the individual identification of time offset information of each slave node, making the robust processing logic clearer and more controllable, avoiding sample distortion problems caused by random jitter in wireless reception, improving the reliability of subsequent frequency offset estimation and time base correction results, and ensuring the operation effect of one master and multiple slave wireless time synchronization under complex electromagnetic conditions.
[0046] Figure 4 The following is a flowchart illustrating the implementation of the time synchronization method for wireless communication provided in Embodiment 4 of this application. The difference between this method and Embodiment 1 is that step S104 specifically includes: Step S401: Using the time reference information of the slave node to be synchronized as the horizontal axis and the processed time reference information of the slave node as the vertical axis, generate multiple slave node time information regression curve coordinate points.
[0047] In this embodiment, the time reference information of the slave node to be synchronized can correspond to the horizontal axis value of each sample point, and the processed slave node time reference information can correspond to the vertical axis value of the same sample point. Each pair of paired samples after the anomaly replacement processing can be mapped to a two-dimensional coordinate system. Then, all valid paired samples are traversed, and coordinate mapping processing is performed on each pair of samples, thereby generating multiple slave node time information regression curve coordinate points. It can be understood that multiple slave node time information regression curve coordinate points can completely represent the distribution of time offset following the changes in the local hardware timing of the slave node after robust processing, providing original coordinate samples for subsequent regression calculations.
[0048] Step S402: Generate a regression curve for the time information of the slave nodes based on the coordinate points of the regression curve for the time information of the multiple slave nodes.
[0049] In this embodiment, multiple regression curve coordinate points of slave node time information can be used as input for calculation. Then, ordinary least squares method is used to perform fitting calculations on all coordinate samples. Compliance verification needs to be performed on the fitting output results. The fitting output results are retained when they meet the pre-set regression fitting validity judgment conditions; these pre-set conditions can be manually defined. Then, based on the parameters output by the fitting calculation, a fitting line reflecting the offset change with timing is plotted, thereby generating the slave node time information regression curve. It can be understood that the slave node time information regression curve can reflect the overall frequency offset change trend of the slave clock node to be synchronized relative to the master clock node, filtering out interference caused by single-sample random jitter.
[0050] The time synchronization method for wireless communication provided in this application converts paired time reference samples into coordinate samples that can be used for fitting calculations. This facilitates the verification and debugging of the regression calculation process, reduces the interference of random wireless jitter on the frequency offset fitting results, ensures the accuracy of frequency offset trend extraction, and improves the reliability of subsequent time offset prediction and time reference correction.
[0051] Figure 5 The flowchart illustrating the implementation of the time synchronization method for wireless communication provided in Embodiment 5 of this application is shown. The difference between this method and Embodiment 1 above is that step S105 specifically includes: Step S501: Based on the regression curve of the slave node time information, calculate the slope information of the slave node time curve and the intercept information of the slave node time curve.
[0052] In this embodiment, the slope information of the slave node time curve can characterize the change in time offset of the slave clock node relative to the master clock node per unit time, and the intercept information of the slave node time curve can characterize the basic offset value corresponding to the time origin position. The fitting parameters stored within the slave node time information regression curve can be parsed, and then the slope information of the slave node time curve representing the rate of change of frequency offset and the intercept information of the slave node time curve representing the basic offset can be extracted from them, thus obtaining the slope information and intercept information of the slave node time curve. It is understood that these two types of parameters together define a complete fitting straight line, providing basic parameter input for subsequent offset prediction calculations.
[0053] Step S502: Generate a time fitting straight line for the slave node based on the slope information of the slave node time curve and the intercept information of the slave node time curve.
[0054] In this embodiment, the slope information of the slave node time curve can be used as the rate of change parameter, and the intercept information of the slave node time curve can be used as the initial offset parameter. These two types of parameters are then combined to establish a corresponding mapping relationship between time and time offset, thereby generating a slave node time fitting line. It can be understood that the slave node time fitting line can be used to calculate the corresponding theoretical time offset based on any local hardware timing value, supporting offset extrapolation prediction at any given time.
[0055] Step S503: Perform slave node offset time prediction calculation based on the slave node time fitting straight line to obtain slave node offset time prediction information.
[0056] In this embodiment, the real-time count value of the hardware timer of the slave clock node to be synchronized at the current moment can be read. Then, the time reference information of the slave node to be synchronized corresponding to the reference point in the middle of this batch is selected as the extrapolation anchor point. Choosing an intermediate anchor point avoids extreme jitter that is prone to occur at the beginning and end of the sample, reducing the extrapolation prediction error. Then, the time difference from the anchor point to the current moment is substituted into the slave node time fitting line to calculate the cumulative frequency offset compensation amount generated in this time period. Finally, the phase deviation representative value output by the slave node time reference information after the processing is superimposed for summarization calculation, thereby obtaining the slave node offset time prediction information. It can be understood that this calculation method avoids directly using the offset value of the historical sampling moment to correct the current timer, reducing the error caused by the frequency offset within the sampling to correction interval.
[0057] The time synchronization method for wireless communication provided in this application embodiment enables extrapolation prediction of the time offset at the current moment, avoids the time lag error introduced by the inconsistency between the sampling time and the correction time, improves the accuracy of the offset time prediction information from the node, and ensures the effect of subsequent time synchronization correction.
[0058] Figure 6The following is a flowchart illustrating the implementation of the time synchronization method for wireless communication provided in Embodiment Six of this application. The difference between this method and Embodiment One is that step S106 specifically includes: Step S601: Calculate the current slave node reference time difference information based on the slave node time reference information to be synchronized, the processed slave node time reference information, and the slave node offset time prediction information.
[0059] In this embodiment, the current slave node reference time difference information represents the total count difference that the hardware timer of the slave clock node to be synchronized needs to correct. The current slave node time reference information read by the hardware timer of the slave clock node to be synchronized can be obtained. Then, combined with the phase deviation representative value output from the processed slave node time reference information and the slave node offset time prediction information, the total count deviation that needs to be corrected is summarized and statistically analyzed. Simultaneously, a 64-bit count overflow and underflow pre-verification is performed; the preset count overflow and underflow judgment rules can be manually preset. After the verification shows no abnormalities, the current slave node reference time difference information is generated. It is understood that the current slave node reference time difference information provides specific correction values for subsequent one-time phase correction.
[0060] Step S602: Calculate the current slave node reference time compensation information based on the slave node time information regression curve.
[0061] In this embodiment, the current slave node reference time compensation information can represent the frequency offset compensation amount that needs to be continuously applied between batches. The frequency offset slope can be obtained by parsing the slave node time information regression curve, and then converted into a 16.16 fixed-point format compensation value. This value is used for the fixed-point margin accumulation calculation per second maintenance point, thereby generating the current slave node reference time compensation information. Using a 16.16 fixed-point fractional means that the fractional part below microseconds is retained, eliminating the need to modify the hardware crystal oscillator register. Progressive frequency offset compensation is completed through software counting and accumulation, resulting in good hardware platform compatibility. It is understood that the current slave node reference time compensation information is used to implement progressive frequency offset rate compensation without requiring modification of the hardware crystal oscillator parameters.
[0062] Step S603: Based on the current slave node reference time difference information and the current slave node reference time compensation information, perform synchronization processing on the slave node time reference information to be synchronized to generate synchronized slave node time reference information.
[0063] In this embodiment, a one-time phase correction of the time base information of the slave node to be synchronized can be completed using the current slave node reference time difference information. Then, the current slave node reference time compensation information is loaded into the fixed-point margin accumulation module. Fixed-point margin accumulation processing is performed at the maintenance point every second. When the accumulated fixed-point margin reaches an integer microsecond, a small-step counting correction is performed on the time base information of the slave node to be synchronized, with the fractional part remaining in the accumulator. Then, combined with the common future output target count issued by the master node, the global absolute count slot is aligned, thereby generating the synchronized slave node time base information. It is understood that the synchronized slave node time base information can directly drive the hardware register to generate GPIO hardware synchronization edges. The time metadata output by the UART is only used as a debug log and does not participate in synchronization event triggering, avoiding software link latency interference with synchronization accuracy.
[0064] In this embodiment, after a successful time synchronization transaction, the Slave sends a ready report. Upon receiving the first valid report, the Master starts its own GPIO2 / GPIO3 from the future global 5-second slot. Subsequent Slave additions or removals do not reset its phase. GPIO2 is an integer ranging from 1 to 500Hz, with a default of 30Hz and a nominal 50% duty cycle, using the quotient remainder for half-cycle accumulation. Each device is configured independently and does not automatically broadcast its frequency. GPIO3 is a 5-second period with a 100ms high level. Both routes in the global 5-second slot are simultaneously written high using W1TS; the UART only corresponds to GPIO3.
[0065] The time synchronization method for wireless communication provided in this application embodiment facilitates the verification of phase correction and frequency offset compensation, ensuring the time reference accuracy of the master-slave wireless time synchronization during calibration and long-term operation.
[0066] Figure 7 The flowchart illustrating the implementation of the time synchronization method for wireless communication provided in Embodiment Seven of this application is shown. The difference between this method and Embodiment Six is that step S601 specifically includes: Step S701: Perform time count value statistical processing based on the time reference information of the slave node to be synchronized to obtain the number of time count values of the slave node to be synchronized.
[0067] In this embodiment, the number of time count values of the slave nodes to be synchronized can represent the total number of valid reference samples in this round. All time reference information of the slave nodes to be synchronized participating in this round of calculation can be traversed, and then the total number of valid sample entries can be counted. Sample entries marked as invalid are filtered out, thereby generating the number of time count values of the slave nodes to be synchronized. It can be understood that the number of time count values of the slave nodes to be synchronized is used to determine the intermediate position of the sample sequence, providing a counting basis for subsequent selection of intermediate values.
[0068] Step S702: Based on the number of slave node time counts to be synchronized, the intermediate position values of the processed slave node time base information and the slave node offset time prediction information are selected to obtain the intermediate value information of the processed slave node time base and the intermediate value information of the slave node offset time prediction.
[0069] In this embodiment, the intermediate index position of the sample sequence can be obtained based on the number of time counts of the slave nodes to be synchronized. Then, according to the intermediate index position, the sample at the corresponding position is read from the processed slave node time base information to obtain the intermediate value information of the processed slave node time base. At the same time, the offset prediction related data corresponding to that position is read to obtain the intermediate value information of the slave node offset time prediction, thereby generating the intermediate value information of the processed slave node time base and the intermediate value information of the slave node offset time prediction. It is understandable that selecting the sample at the middle position of the batch as the anchor point can reduce the interference of the extreme samples at the beginning and end of the sampling sequence on the correction calculation and avoid the jitter of the beginning and end samples directly affecting the total correction difference.
[0070] Step S703: Calculate the current slave node reference time difference information based on the processed slave node time reference intermediate value information and the slave node offset time prediction intermediate value information.
[0071] In this embodiment, the hardware timer count value of the slave clock node to be synchronized at the current moment can be read. Then, using the processed intermediate value information of the slave node's time reference as the extrapolation anchor point, the cumulative frequency offset from the anchor point time to the current moment is calculated by combining the intermediate value information of the slave node's offset time prediction. The total correction difference is obtained by superimposing the phase deviation representative value. Then, 64-bit count overflow and underflow pre-checks are performed. The preset count out-of-bounds judgment condition can be preset manually. After the check passes, the current slave node reference time difference information is generated. It can be understood that performing extrapolation calculations using batch intermediate samples can reduce the adverse effects of abnormal sampling points at the beginning and end on the total correction difference and improve the reliability of the phase correction value.
[0072] The time synchronization method for wireless communication provided in this application uses samples in the middle of the batch as anchor points for extrapolation calculation, avoids interference from individual samples at the beginning and end of the sampling sequence on the time difference calculation, improves the operational robustness of one-time phase correction, and enables the wireless time synchronization method to maintain a stable and reliable synchronization effect even in complex electromagnetic environments with strong wireless jitter.
[0073] Corresponding to the method in the above embodiments, Figure 8 A structural block diagram of a time synchronization system for wireless communication provided in an embodiment of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown. Figure 8The example time synchronization system for wireless communication can be the execution entity of the time synchronization method for wireless communication provided in the aforementioned embodiment 1.
[0074] Reference Figure 8 The time synchronization system for wireless communication includes: The information acquisition module 810 is used to acquire the master node time base information, the slave node time base information to be synchronized, and the node time reference count information. The slave node time offset information calculation module 820 is used to calculate multiple slave node time offset information based on the master node time base information, the slave node time base information to be synchronized, and the node time reference count information. The processed slave node time reference information generation module 830 is used to analyze and process the slave node time reference information to be synchronized based on the multiple slave node time offset information, and generate processed slave node time reference information. The slave node time information regression curve generation module 840 is used to perform linear regression processing based on the slave node time reference information to be synchronized and the processed slave node time reference information to generate a slave node time information regression curve. The slave node offset time prediction information generation module 850 is used to perform slave node offset time prediction calculation based on the slave node time information regression curve to obtain slave node offset time prediction information. The synchronized slave node time reference information generation module 860 is used to perform synchronization processing on the slave node time reference information to be synchronized based on the processed slave node time reference information and the slave node offset time prediction information, and generate synchronized slave node time reference information.
[0075] The process by which each module in the time synchronization system for wireless communication implements its respective function, as provided in the embodiments of this application, can be found in the foregoing. Figure 1 The description of Embodiment 1 shown will not be repeated here.
[0076] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0077] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0078] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0079] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0080] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0081] The time synchronization method for wireless communication provided in this application can be applied to terminal devices that can access the public wireless time domain and read and calibrate local hardware counts. If the synchronization edge output is covered, a corresponding real-time output interface is also required for mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality / virtual reality devices, laptops, super mobile personal computers, netbooks, personal digital assistants, and other terminal devices. This application does not impose any restrictions on the specific type of terminal device.
[0082] For example, the terminal device may be a station in a WLAN, a cellular phone, a cordless phone, a session initiation protocol phone, a wireless local loop station, a personal digital processing device, a handheld device with wireless communication capabilities, a computing device or other processing device connected to a wireless modem, an in-vehicle device, a vehicle networking terminal, a computer, a laptop computer, a handheld communication device, a handheld computing device, a satellite wireless device, a wireless modem card, a set-top box, a user premises equipment, and / or other devices for communication over a wireless system, as well as next-generation communication systems, such as mobile terminals in 5G networks or mobile terminals in future evolved public terrestrial mobile networks, etc.
[0083] As an example and not a limitation, when the terminal device is a wearable device, the term "wearable device" can also refer to any device that utilizes wearable technology to intelligently design and develop everyday wearables, such as glasses, gloves, watches, clothing, and shoes. Wearable devices are portable devices worn directly on the body or integrated into a user's clothing or accessories. Wearable devices are not merely hardware devices; they achieve powerful functions through software support, data interaction, and cloud interaction. Broadly defined, wearable smart devices include those with comprehensive functions, large sizes, and the ability to perform complete or partial functions without relying on a smartphone, such as smartwatches or smart glasses, as well as those focused on a specific application function that require interaction with other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.
[0084] Figure 9 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. For example... Figure 9 As shown, the terminal device 9 of this embodiment includes: at least one processor 90 ( Figure 9 (Only one is shown in the image) a memory 91, which stores a computer program 92 that can run on the processor 90. When the processor 90 executes the computer program 92, it implements the steps in the various time synchronization method embodiments for wireless communication described above, for example... Figure 1 Steps S101 to S106 are shown. Alternatively, when the processor 90 executes the computer program 92, it implements the functions of each module / unit in the above system embodiments, for example... Figure 8 The functions of modules 810 to 860 are shown.
[0085] The terminal device 9 can be a desktop computer, laptop, handheld computer, or cloud server, etc. The terminal device may include, but is not limited to, a processor 90 and a memory 91. Those skilled in the art will understand that... Figure 9 This is merely an example of terminal device 9 and does not constitute a limitation on terminal device 9. It may include more or fewer components than shown, or combine certain components, or different components. For example, the terminal device may also include input transmission devices, network access devices, buses, etc.
[0086] The processor 90 may be a central processing unit, or it may be other general-purpose processors, digital signal processors, application-specific integrated circuits, off-the-shelf programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0087] In some embodiments, the memory 91 may be an internal storage unit of the terminal device 9, such as a hard disk or memory of the terminal device 9. The memory 91 may also be an external storage device of the terminal device 9, such as a plug-in hard disk, smart memory card, secure digital card, flash memory card, etc., equipped on the terminal device 9. Furthermore, the memory 91 may include both internal and external storage units of the terminal device 9. The memory 91 is used to store operating systems, applications, bootloaders, data, and other programs, such as the program code of computer programs. The memory 91 can also be used to temporarily store data that has been sent or will be sent.
[0088] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0089] This application also provides a terminal device, which includes at least one memory, at least one processor, and a computer program stored in the at least one memory and executable on the at least one processor. When the processor executes the computer program, it causes the terminal device to implement the steps in any of the above method embodiments.
[0090] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the various method embodiments above.
[0091] This application provides a computer program product that, when run on a terminal device, enables the terminal device to implement the steps described in the various method embodiments above.
[0092] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, RAM, ROM, Flash, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory, random access memory, electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0093] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0094] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0095] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0096] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A time synchronization method for wireless communication, characterized in that, include: Obtain the master node time base information, the slave node time base information to be synchronized, and the node time reference count information; Based on the master node time base information, the slave node time base information to be synchronized, and the node time reference count information, multiple slave node time offset information are calculated. Based on the multiple slave node time offset information, the slave node time reference information to be synchronized is analyzed and processed to generate processed slave node time reference information; Linear regression processing is performed based on the slave node time reference information to be synchronized and the processed slave node time reference information to generate a slave node time information regression curve. Based on the regression curve of the slave node time information, the slave node offset time prediction calculation is performed to obtain the slave node offset time prediction information; Based on the processed slave node time base information and the slave node offset time prediction information, the slave node time base information to be synchronized is synchronized to generate synchronized slave node time base information.
2. The time synchronization method for wireless communication as described in claim 1, characterized in that, The step of analyzing and processing the time reference information of the slave nodes to be synchronized based on the multiple slave node time offset information to generate processed slave node time reference information specifically includes: Based on the multiple slave node time offset information, the median slave node time offset information is calculated; Based on the multiple slave node time offset information and the median slave node time offset information, multiple slave node time absolute deviation information is calculated; Based on the median time offset information of the slave nodes, the absolute time deviation information of multiple slave nodes, and the preset absolute time deviation threshold information of the slave nodes, the time reference information of the slave nodes to be synchronized is filtered and replaced to generate the processed slave node time reference information.
3. The time synchronization method for wireless communication as described in claim 2, characterized in that, The step of filtering and replacing the slave node time reference information to be synchronized based on the median slave node time offset information, multiple slave node time absolute deviation information, and a preset slave node time absolute deviation threshold information to generate processed slave node time reference information specifically includes: Determine whether the absolute time deviation information of the slave node is greater than the preset absolute time deviation threshold information of the slave node; If so, the time reference information of the slave node to be synchronized is replaced according to the median time offset information of the slave node to generate the processed slave node time reference information. If not, then based on the time reference information of the slave node to be synchronized, the processed slave node time reference information is generated.
4. The time synchronization method for wireless communication as described in claim 1, characterized in that, The step of generating a regression curve for slave node time information by performing linear regression processing based on the slave node time reference information to be synchronized and the processed slave node time reference information specifically includes: Using the time reference information of the slave node to be synchronized as the horizontal axis and the processed time reference information of the slave node as the vertical axis, multiple slave node time information regression curve coordinate points are generated. Based on the coordinate points of the regression curve of the multiple slave node time information, a slave node time information regression curve is generated.
5. The time synchronization method for wireless communication as described in claim 1, characterized in that, The step of performing slave node offset time prediction calculation based on the slave node time information regression curve to obtain slave node offset time prediction information specifically includes: Based on the regression curve of the slave node time information, the slope information of the slave node time curve and the intercept information of the slave node time curve are calculated. Based on the slope information and intercept information of the slave node time curve, a slave node time fitting straight line is generated; The slave node offset time prediction information is obtained by performing slave node offset time prediction calculation based on the slave node time fitting straight line.
6. The time synchronization method for wireless communication as described in claim 1, characterized in that, The step of synchronizing the time reference information of the slave node to be synchronized based on the processed slave node time reference information and the slave node offset time prediction information to generate synchronized slave node time reference information specifically includes: Based on the slave node time reference information to be synchronized, the processed slave node time reference information, and the slave node offset time prediction information, the current slave node reference time difference information is calculated. Based on the regression curve of the slave node time information, the current slave node reference time compensation information is calculated; Based on the current slave node reference time difference information and the current slave node reference time compensation information, the slave node time reference information to be synchronized is synchronized to generate synchronized slave node time reference information.
7. The time synchronization method for wireless communication as described in claim 6, characterized in that, The step of calculating the current slave node reference time difference information based on the slave node time reference information to be synchronized, the processed slave node time reference information, and the slave node offset time prediction information specifically includes: Based on the time base information of the slave node to be synchronized, the time count value is statistically processed to obtain the number of time count values of the slave node to be synchronized. Based on the number of slave node time counts to be synchronized, the intermediate position values of the processed slave node time base information and the slave node offset time prediction information are selected by the intermediate position value to obtain the intermediate value information of the processed slave node time base and the intermediate value information of the slave node offset time prediction. Based on the intermediate value information of the slave node time base after processing and the intermediate value information of the slave node offset time prediction, the current slave node base time difference information is calculated.
8. A time synchronization system for wireless communication, characterized in that, include: The information acquisition module is used to acquire the time base information of the master node, the time base information of the slave nodes to be synchronized, and the node time reference count information. The slave node time offset information calculation module is used to calculate multiple slave node time offset information based on the master node time base information, the slave node time base information to be synchronized, and the node time reference count information. The processed slave node time reference information generation module is used to analyze and process the slave node time reference information to be synchronized based on the multiple slave node time offset information, and generate processed slave node time reference information. The slave node time information regression curve generation module is used to perform linear regression processing based on the slave node time reference information to be synchronized and the processed slave node time reference information to generate a slave node time information regression curve. The slave node offset time prediction information generation module is used to perform slave node offset time prediction calculation based on the slave node time information regression curve to obtain slave node offset time prediction information. The synchronized slave node time reference information generation module is used to perform synchronization processing on the slave node time reference information to be synchronized based on the processed slave node time reference information and the slave node offset time prediction information, and generate synchronized slave node time reference information.
9. A terminal device, characterized in that, The terminal device includes a memory and a processor. The memory stores a computer program that can run on the processor. When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7.
