Time Synchronization Method, Site Device and Time Synchronization System
By generating interrupt signals, collecting temperatures and using the Kalman model and controller for frequency and time compensation, the accuracy of time synchronization between access point equipment and site equipment is solved, and high-precision time synchronization and cost reduction are achieved.
Patent Information
- Application Number
- CN202510605612.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-05-12
AI Technical Summary
In wireless networks, it is difficult to accurately synchronize time between access point equipment and site equipment, which is affected by factors such as temperature and equipment aging.
The interrupt signal is generated by the site equipment, the equipment temperature is collected, the frequency offset coefficient is determined using the Kalman state model and observation model, and the frequency and time compensation is performed in combination with the fuzzy controller and the proportional integral controller to achieve time synchronization.
Ensure the stability and accuracy of time synchronization and reduce synchronization costs.
Smart Images

Figure CN120129046B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a time synchronization method, site equipment, and a time synchronization system. Background Art
[0002] With the development of wireless networking technology, wireless networks have become increasingly integrated into every aspect of life, playing an indispensable role. In wireless networks, communication and collaboration between access point devices (such as routers) and station devices (such as trackers, smartphones, and sensors) are becoming increasingly frequent and complex. To ensure efficient wireless network operation and accurate data transmission, maintaining time synchronization between access point devices and station devices is crucial.
[0003] However, in related wireless network time synchronization solutions, it is often difficult to accurately synchronize the time of access point devices and site devices due to the influence of various factors (such as temperature and device aging). Summary of the Invention
[0004] In view of the above, it is necessary to provide a time synchronization method, a site device, and a time synchronization system that can solve the technical problem of difficulty in accurately synchronizing the time of an access point device and a site device.
[0005] On the one hand, the present application provides a time synchronization method, applied to a site device, wherein the site device is communicatively connected to an access point device via a wireless network, the method comprising: generating an interrupt signal in response to a beacon signal sent by the access point device, wherein the beacon signal corresponds to the access point time, collecting the device temperature of the site device, determining a frequency offset coefficient of the site device based on the interrupt signal and the device temperature, compensating the frequency of the site device according to the frequency offset coefficient, and compensating the site time of the frequency-compensated site device based on the frequency offset coefficient and the access point time, thereby completing time synchronization between the site device and the access point device.
[0006] In some embodiments of the present application, before determining the frequency offset coefficient of the site device, the method further includes: determining a first state vector corresponding to the first time based on a vector related to the predicted frequency offset coefficient, the first coefficient, and the second coefficient at the first time, wherein the first coefficient and the second coefficient are both related to the standard clock beat number of the interrupt signal; determining a state transfer matrix corresponding to the first time based on a matrix related to a first temperature difference and a second temperature difference corresponding to the first time, wherein the first temperature difference corresponding to the first time is related to the device temperature corresponding to the first time, the device temperature corresponding to the second time, and the inflection point temperature of an oscillator in the site device; the second temperature difference corresponding to the first time is related to the device temperature corresponding to the first time and the device temperature corresponding to the second time, wherein the second time is before the first time; determining a second state vector corresponding to the second time based on a vector related to the predicted frequency offset coefficient, the first coefficient, and the second coefficient at the second time; determining a noise vector corresponding to the first time based on a vector related to a systematic error deviation at the first time, wherein the systematic error deviation at the first time is related to the systematic error of the site device at the first time and the systematic error at the second time; and constructing a Kalman state model based on a first objective equation, wherein the first objective equation is used to determine the first state vector based on the state transfer matrix, the second state vector, and the noise vector.
[0007] In some embodiments of the present application, before determining the frequency offset coefficient of the site device, the method also includes: determining an observation matrix based on a first preset variable corresponding to a target value, wherein the target value is determined by the packet loss situation of the beacon signal, and constructing a Kalman observation model based on a second target equation and a third target equation, wherein the second target equation is used to determine a third preset variable corresponding to the observation vector of the site device at the first time based on the observation matrix, the first state vector and the second preset variable corresponding to the observation noise of the site device at the first time, wherein the observation noise at the first time satisfies a preset probability distribution, and the third target equation is used to determine the actual frequency offset coefficient of the first time based on the standard interrupt period of the interrupt signal, the standard clock beat number and the clock beat number corresponding to the interrupt signal at the first time.
[0008] In some embodiments of the present application, determining the frequency offset coefficient of the site device based on the interrupt signal and the device temperature includes: based on the standard clock beat number, the device temperature, the inflection point temperature, the system error, the clock beat number, the standard interrupt period, the target value and the observation noise, using the Kalman state model and the Kalman observation model to perform state prediction and state update on the site device until both the first coefficient and the second coefficient meet the first preset condition to obtain the frequency offset coefficient.
[0009] In some embodiments of the present application, the use of the Kalman state model and the Kalman observation model to predict and update the state of the site device includes: predicting the state of the site device and updating the state based on an adaptive factor and an information weighting factor.
[0010] In some embodiments of the present application, before compensating the site time of the site equipment after frequency compensation, the method also includes: constructing a time model based on a fourth target equation, wherein the fourth target equation is used to determine the standard time corresponding to the first time based on the standard clock beat number and the frequency offset coefficient.
[0011] In some embodiments of the present application, compensating the site time of the frequency-compensated site device based on the frequency offset coefficient and the access point time to complete time synchronization between the site device and the access point device includes: compensating the site time using a fuzzy controller and a proportional-integral controller based on the frequency offset coefficient, the standard clock beat number, and the time model, until the proportional-integral parameters of the proportional-integral controller all meet a second preset condition, thereby completing time synchronization between the site device and the access point device, wherein the proportional-integral parameters include a proportional gain and an integral gain.
[0012] In some embodiments of the present application, the step of compensating the site time includes: after obtaining the Mth frequency offset coefficient, calculating the Mth standard time of the site device based on the standard clock beat number and the Mth frequency offset coefficient using the time model, where M is an integer greater than or equal to 1, determining a first time deviation according to the Mth standard time and the access point time corresponding to the Mth frequency offset coefficient, determining a second time deviation according to the first time deviation and the site time of the site device after the M-1th compensation, determining an Mth proportional integral parameter of the proportional integral controller based on the second time deviation and the time deviation rate of the second time deviation using the fuzzy controller, determining the Mth time offset coefficient of the site device according to the Mth proportional integral parameter, and compensating the site time after the M-1th compensation according to the Mth time offset coefficient.
[0013] On the other hand, the present application provides a site device, which is communicatively connected to an access point device via a wireless network. The site device includes a communication module, a temperature sensor, and a programmable logic device. In response to receiving a beacon signal sent from the access point device, the communication module generates an interrupt signal, wherein the beacon signal has a corresponding access point time. The communication module sends the interrupt signal and the access point time to the programmable logic device. The temperature sensor collects a device temperature of the site device and sends the device temperature to the programmable logic device. The programmable logic device determines a frequency offset coefficient of the site device based on the interrupt signal and the device temperature. The programmable logic device compensates the frequency of the site device according to the frequency offset coefficient. The programmable logic device compensates the site time of the frequency-compensated site device based on the frequency offset coefficient and the access point time, thereby completing time synchronization between the site device and the access point device.
[0014] On the other hand, the present application provides a time synchronization system, which includes the site device and the access point device.
[0015] The above-described embodiment determines a frequency offset coefficient based on the interrupt signal and device temperature, enabling tracking of the impact of factors such as changes in site device temperature on the oscillator frequency. Since site time can vary due to changes in the oscillator frequency, compensating the site device frequency based on the frequency offset coefficient allows for preliminary adjustment of the site time. Compensating the frequency-compensated site time based on the frequency offset coefficient and the access point time corrects for accumulated asynchronous errors between site devices, suppresses clock divergence caused by temperature drift and hardware aging, and enables site devices to achieve high-precision (e.g., 10μs) time synchronization using the access point time as a unified benchmark. This multi-dimensional compensation, including frequency and time compensation, ensures the stability and accuracy of time synchronization. Furthermore, by eliminating the need for additional hardware and software configuration, such as Bluetooth, during the synchronization process, the cost of time synchronization can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 2 is a schematic diagram of a time synchronization system provided in an embodiment of the present application.
[0017] Figure 2 This is a flowchart of a time synchronization method provided by an embodiment of the present application.
[0018] Figure 3 This is a timing diagram of a clock signal, an ideal interrupt signal, a collected interrupt signal, an access point time, and a site time provided in an embodiment of the present application.
[0019] Figure 4 It is a schematic diagram of a time synchronization method provided in an embodiment of the present application.
[0020] Figure 5 This is a flowchart of a time compensation method provided in one embodiment of the present application.
[0021] Figure 6 is the membership function of the second time deviation e provided in an embodiment of the present application.
[0022] Figure 7 It is the membership function of the time deviation rate ec provided in an embodiment of the present application.
[0023] Figure 8 This is a working diagram of a fuzzy controller and a proportional-integral controller provided in one embodiment of the present application.
[0024] Figure 9 It is a structural diagram of a site device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0025] It should be noted that, in this application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A alone, A and B together, and B alone, where A and B can be singular or plural. The terms "first," "second," "third," "fourth," and so on (if any) in the specification, claims, and drawings of this application are used to distinguish similar objects, not to describe a specific order or precedence.
[0026] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete manner. The following embodiments and features in the embodiments may be combined with each other unless there is a conflict.
[0027] With the development of wireless networking technology, wireless networks have become increasingly integrated into every aspect of life, playing an indispensable role. In wireless networks, communication and collaboration between access point devices (such as routers) and station devices (such as trackers, smartphones, and sensors) are becoming increasingly frequent and complex. To ensure efficient wireless network operation and accurate data transmission, maintaining time synchronization between access point devices and station devices is crucial.
[0028] However, in related wireless network time synchronization solutions, it is often difficult to accurately synchronize the time of access point devices and site devices due to the influence of various factors (such as temperature and device aging).
[0029] To solve this technical problem, an embodiment of the present application provides a time synchronization method that can ensure the stability and accuracy of time synchronization and reduce the cost of time synchronization.
[0030] The time synchronization method provided in the embodiments of the present application can be applied to one or more station (STA) devices. The station device can form a time synchronization system with a communication-connected access point (AP) device, wherein the station device can be a tracker, a tracking scanner, or other device. The present application does not limit the type of station device, and the access point device can be a router or other device.
[0031] like Figure 1 FIG. 1 is a schematic diagram of a time synchronization system provided by an embodiment of the present application. Figure 1In the present invention, a time synchronization system includes multiple access point devices AP10, wherein any two access point devices AP10 can achieve time synchronization via the Time-Sync Protocol for Sensor Network (TPSN) time synchronization protocol. Each access point device AP10 can be connected to multiple station devices STA20 via a wireless network. Each access point device AP10 can send a beacon signal (e.g., a beacon message) to the station device STA20 that is connected to each access point device STA20, so that the station device STA20 can achieve time synchronization based on the received beacon signal. The wireless network can be Wireless Fidelity (Wi-Fi). The following describes in detail the method by which the station device can achieve time synchronization based on the received beacon signal.
[0032] It is understandable that Figure 1 The two AP10 shown are only examples, and more access point devices may be included in actual applications. Figure 1 In other embodiments of the present application, Figure 1 Each device in the embodiment may include more or less components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0033] like Figure 2 The figure is a flow chart of a time synchronization method provided by an embodiment of the present application. According to different requirements, the order of each step in the flow chart can be adjusted according to actual requirements, and some steps can be omitted. The time synchronization method is applied to a site device, such as Figure 1 and Figure 9 The site equipment 20 is shown.
[0034] S11 , generating an interrupt signal in response to a beacon signal sent by an access point device, wherein the beacon signal corresponds to access point time.
[0035] In some embodiments of the present application, an access point device is in communication connection with a site device. Due to factors such as network delay jitter, signal delay, and differences in communication protocols, the access point time of the access point device is not synchronized with the site time of the site device. Therefore, it is necessary to synchronize the time of the access point device and the site device.
[0036] The beacon signal can be used to trigger or control a station device to generate an interrupt signal for time synchronization. For example, the beacon signal can be a beacon message. The interrupt signal can be used to notify, trigger, or control a station device to perform time synchronization operations. The access point time can be used to identify the generation or transmission time of the beacon signal.
[0037] In some embodiments, the site device may include structural components such as a communication module, a programmable logic device, and an oscillator. For example, the communication module may be a Wi-Fi module, the programmable logic device may be a field programmable gate array (FPGA) chip, and the oscillator may be a crystal oscillator, also known as a crystal oscillator. The communication module is used to receive beacon signals sent by the access point device and generate corresponding interrupt signals. The oscillator is used to generate a clock signal (Clock, CLK) as a time reference for the site device. The programmable logic device is used to perform time synchronization based on the clock signal generated by the oscillator and the interrupt signal generated by the communication module. To clearly illustrate the time synchronization method provided in the embodiments of the present application, the following description will use a Wi-Fi module as an example of the communication module and an FPGA chip as an example of the programmable logic device.
[0038] For example, in response to a beacon message sent from an access point device, the Wi-Fi module can trigger the generation of a corresponding interrupt signal and send the interrupt signal and the access point time corresponding to the beacon signal to the FPGA chip for sampling. By sampling the interrupt signal, the FPGA chip can determine information such as the interrupt signal's interrupt period and the number of clock ticks between two rising edges.
[0039] In some embodiments, the signal delay mentioned above can be the delay between the collected interrupt signal and the ideal interrupt signal. This delay may include the delay of the access point device sending the beacon signal, the propagation delay of the beacon signal, the delay of the Wi-Fi module processing the beacon signal to generate the interrupt signal, and the delay of the FPGA chip sampling the interrupt signal, etc.
[0040] For example, if the beacon signal is a beacon message, the interrupt signal can be called a beacon interrupt, such as Figure 3 As shown in FIG, it is a timing diagram of a clock signal, an ideal interrupt signal, a collected interrupt signal, an access point time and a station time provided by an embodiment of the present application. Figure 3 The FPGA chip uses the sampling clock to calculate the number of clock beats between two sampling beacon pulses. If the number of clock beats between the two rising edges of the beacon interrupt signal is recorded as , the beacon interruption period can be recorded as , θ Indicates the delay between the interrupt signal sampled by the FPGA chip and the ideal interrupt signal, Indicates the access point time, Indicates the site time.
[0041] S12, collecting the device temperature of the site device.
[0042] In some embodiments of the present application, the FPGA chip can collect the device temperature of the site device using a variety of methods, and this application does not limit the method of collecting device temperature. For example, in addition to the programmable logic device, communication module, and oscillator, the site device may also include a temperature sensor. The FPGA chip can communicate with the temperature sensor within the site device to obtain the device temperature collected by the temperature sensor for the site device.
[0043] S13, determining a frequency offset coefficient of the site device based on the interrupt signal and the device temperature.
[0044] In some embodiments of the present application, before determining the frequency offset coefficient of the site device, the FPGA chip can determine the first state vector corresponding to the first time based on the vector related to the predicted frequency offset coefficient, the first coefficient and the second coefficient at the first time, wherein the first coefficient and the second coefficient are both related to the standard clock beat number of the interrupt signal, and determine the state transfer matrix corresponding to the first time based on the matrix related to the first temperature difference and the second temperature difference corresponding to the first time, the first temperature difference corresponding to the first time is related to the device temperature corresponding to the first time, the device temperature corresponding to the second time and the inflection point temperature of the oscillator in the site device, the second temperature difference corresponding to the first time is related to the device temperature corresponding to the first time and the device temperature corresponding to the second time, and the second time is located before the first time, and determine the second state vector corresponding to the second time based on the vector related to the predicted frequency offset coefficient, the first coefficient and the second coefficient at the second time, and determine the noise vector corresponding to the first time based on the vector related to the system error deviation at the first time, wherein the system error deviation at the first time is related to the system error of the site device at the first time and the system error at the second time, and construct a Kalman state model based on the first target equation, wherein the first target equation is used to determine the first state vector based on the state transfer matrix, the second state vector and the noise vector.
[0045] The predicted frequency deviation coefficient may represent the number of time deviation beats caused by the frequency deviation of the oscillator within a unit time (eg, 1 second) predicted by the Kalman state model.
[0046] For example, the Kalman state model can refer to the first objective equation shown in the following formula (1):
[0047] ; (1)
[0048] in, represents the first state vector, , in , Indicates the first time, represents the predicted frequency offset coefficient, represents the first coefficient, represents the second coefficient, = × , = × , and Indicates the preset coefficient, Indicates the device temperature corresponding to the first time, Indicates the inflection point temperature of the oscillator in the site equipment, = × , , It can be determined by the coefficient of stress relaxation effect and mass loading effect of oscillator aging. f 0 Indicates the frequency of the oscillator in the site device when the device temperature is T0. Indicates the number of standard clock beats in the site equipment at a standard temperature (e.g. 25°C) and nominal frequency per unit time (e.g. 1 second). Indicates the systematic error at the first time.
[0049] represents the state transition matrix, , represents the first temperature difference, , represents the second temperature difference, , Indicates the second time, Indicates the device temperature corresponding to the second time.
[0050] represents the second state vector, and the second state vector can refer to the description of the first state vector.
[0051] represents the noise vector, , Indicates the system error deviation at the first time, , .
[0052] In this embodiment, by constructing a Kalman state model, the state at a subsequent and adjacent time can be predicted based on the state at a previous time.
[0053] In some embodiments, before determining the frequency offset coefficient of the site device, the FPGA chip can determine the observation matrix based on the first preset variable corresponding to the target value, wherein the target value is determined by the packet loss situation of the beacon signal, and construct a Kalman observation model based on the second target equation and the third target equation, wherein the second target equation is used to determine the third preset variable corresponding to the observation vector of the site device at the first time based on the observation matrix, the first state vector and the second preset variable corresponding to the observation noise of the site device at the first time, wherein the observation noise at the first time satisfies the preset probability distribution, and the third target equation is used to determine the actual frequency deviation coefficient at the first time based on the standard interrupt period of the interrupt signal, the standard number of clock beats and the number of clock beats corresponding to the interrupt signal at the first time.
[0054] The second objective equation is used to convert the state predicted by the Kalman state model into an observed value, and the third objective equation is used to determine the actual frequency offset coefficient at the first time. This is then used to determine the actual measured value. This allows for the calculation of a residual between the measured and observed values, and for state updates based on this residual. The actual frequency offset coefficient represents the number of time offset ticks per unit time (e.g., 1 second) caused by the oscillator's frequency offset, calculated from actual observed data.
[0055] For example, the Kalman observation model can refer to the second objective equation shown in the following formula (2) and the third objective equation shown in the following formula (3):
[0056] ; (2)
[0057] in, represents the observation vector, represents the observation matrix, , is the first preset variable, indicating the target value, represents the first state vector, is the second preset variable, representing the observation noise, .
[0058] ; (3)
[0059] in, Indicates the first time, the formula (3) represents the actual frequency deviation coefficient, Indicates the number of clock beats corresponding to the first time, which is the number of clock beats between the two rising edges of the interrupt signal. Indicates the standard interrupt cycle, Indicates the number of standard clock ticks in the site equipment per unit time (for example, 1 second) at a standard temperature (for example, 25°C) and nominal frequency.
[0060] In this embodiment, since the Kalman observation model includes the first state vector in the Kalman state model, the association relationship between the Kalman observation model and the Kalman state model can be constructed through the first state vector, so that the state predicted by the Kalman state model can be converted into an observation value.
[0061] In some embodiments of the present application, after detecting an interrupt signal, the FPGA chip determines the frequency offset coefficient of the site device based on the interrupt signal and the device temperature, including: based on the standard clock beat number, device temperature, inflection point temperature, system error, clock beat number, standard interrupt period, target value and observation noise, using the Kalman state model and the Kalman observation model to predict and update the state of the site device until the first coefficient and the second coefficient both meet the first preset condition to obtain the frequency offset coefficient.
[0062] The inflection point temperature can refer to the factory parameters of the oscillator, for example, it can be 25°C. The observation noise is also called measurement noise, which can be determined by the measurement error of the temperature sensor. For example, if the measurement error of the temperature sensor is ±0.5°C, the covariance matrix R of the observation noise is set to Systematic errors can be systematic errors in processes such as temperature sampling and can be determined experimentally. When beacon signal packets are lost, the target value can be 1; when beacon signal packets are not lost, the target value can be zero. The standard clock tick count and standard interrupt period can be predefined. The frequency offset coefficient can represent the number of time offset ticks caused by factors such as oscillator frequency offset and beacon signal packet loss per unit time (e.g., 1 second), as predicted by the Kalman filter algorithm.
[0063] Based on the number of clock ticks between two consecutive rising edges, the standard number of clock ticks, the device temperature, the inflection point temperature, the system error, the standard interruption period, the target value, and the observation noise, the FPGA chip can predict and update the state of the site device according to the Kalman state model in formula (1) and the Kalman observation model in formulas (2) to (3) until the first coefficient and the second coefficient that meet the first preset condition are obtained. Reference can be made to the method of using the Kalman filter or the Kalman filter algorithm in the related art for state prediction and state update.
[0064] The first preset condition can be customized. For example, the first preset condition can be that both the first coefficient and the second coefficient tend to be stable. For example, the first coefficient tends to be stable when the variation between consecutively obtained first coefficients is within a third numerical range, and the second coefficient tends to be stable when the variation between consecutively obtained second coefficients is within a fourth numerical range. The third numerical range and the fourth numerical range can be customized, and this application does not impose any restrictions on this. The above examples of the first preset condition are merely examples and are not limited to these in actual applications.
[0065] In this embodiment, since the state transfer matrix in the Kalman state model is related to the device temperature, the first state vector is related to the predicted frequency deviation coefficient, and the Kalman observation model is associated with the Kalman state model, the Kalman state model and the observation model can track the impact of factors such as changes in the device temperature of the site device and the packet loss of the beacon signal on the frequency of the oscillator. The state predicted by the Kalman state model can be corrected through the actual frequency deviation coefficient, thereby improving the accuracy of the frequency offset coefficient.
[0066] In some embodiments, the FPGA chip uses the Kalman state model and the Kalman observation model to predict and update the state of the site device, including: predicting the state of the site device and updating the state of the site device based on the adaptive factor and the information weighting factor.
[0067] For example, an FPGA chip can implement state prediction and state update through the following formulas (4) to (8).
[0068] Status prediction:
[0069] ; (4)
[0070] Prediction minimum mean squared error (MSE) matrix:
[0071] ; (5)
[0072] Calculate the Kalman gain matrix using the adaptive factor:
[0073] ; (6)
[0074] Update the status by the innovation weighting factor:
[0075] ; (7)
[0076] Update the minimum MSE matrix by the adaptive factor:
[0077] ; (8)
[0078] in, represents the MSE matrix, represents the Kalman gain matrix, represents the adaptive factor, Indicates the updated status. represents the innovation weighting factor, represents the updated MSE matrix, and the Can represent actual measured values, can represent the observation value of the Kalman observation model, Can represent residual 。
[0079] In this embodiment, the state update and state prediction are performed by using the adaptive factor and the innovation weighting factor, so that the precision and accuracy of the frequency offset coefficient can be improved.
[0080] S14: Compensate the frequency of the site equipment according to the frequency offset coefficient.
[0081] In some embodiments of the present application, the FPGA chip can use a frequency offset coefficient to adjust the external capacitance value, voltage control voltage, and temperature sensor temperature of the oscillator in the site equipment so that the oscillator frequency reaches the nominal frequency. If the oscillator is a crystal oscillator, the oscillator frequency can be referred to as the crystal oscillator frequency.
[0082] In this embodiment, since the frequency offset coefficient represents the number of time offset beats caused by factors such as the frequency offset of the oscillator and the packet loss of the beacon signal, and the site time will change due to the change of the oscillator frequency, the frequency of the oscillator in the site equipment is compensated according to the frequency offset coefficient, which can reduce the errors caused by factors such as the frequency offset of the oscillator and the packet loss of the beacon signal, thereby improving the time synchronization accuracy.
[0083] S15 , based on the frequency offset coefficient and the access point time, compensating the site time of the frequency-compensated site device to complete time synchronization between the site device and the access point device.
[0084] In some embodiments of the present application, before compensating the site time of the frequency-compensated site device, the FPGA chip can construct a time model based on the fourth target equation, where the fourth target equation is used to determine the standard time corresponding to the first time based on the standard clock beat number and the frequency offset coefficient.
[0085] For example, the time model can refer to the fourth objective equation shown in the following formula (9):
[0086] ; (9)
[0087] in, Indicates standard time. Indicates the number of clock beats between the two rising edges of the interrupt signal. Indicates the number of standard clock beats, represents the frequency shift coefficient, It can represent the delay between the interrupt signal and the standard beacon signal. It can represent the delay difference between two consecutive interrupt signals. , when calculating standard time, you can Items are considered zero.
[0088] In some embodiments of the present application, the FPGA chip compensates the site time of the frequency-compensated site device based on the frequency offset coefficient and the access point time, including: based on the frequency offset coefficient, the standard clock beat number and the time model, using a fuzzy controller and a proportional integral (PI) controller to compensate the site time until the proportional integral parameters of the proportional integral controller all meet the second preset condition, thereby completing the time synchronization between the site device and the access point device, wherein the proportional integral parameters include proportional gain and integral gain.
[0089] Among them, the combined control strategy of the fuzzy controller and the proportional-integral controller can be called a fuzzy control (Fuzzy-PI) algorithm. The proportional-integral parameters include the proportional gain and the integral gain. The second preset condition can be that both the proportional gain and the integral gain tend to be stable. For example, the proportional gain tends to be stable when the change between the continuously obtained proportional gains is within a first numerical range, and the integral gain tends to be stable when the change between the continuously obtained integral gains is within a second numerical range. The first numerical range and the second numerical range can be customized, and this application does not impose any restrictions on this. The above examples of the second preset condition are only examples and are not limited to this in actual applications.
[0090] like Figure 4 FIG. 1 is a schematic diagram of a time synchronization method provided by an embodiment of the present application. Figure 4In the system, the crystal oscillator (abbreviated as "crystal oscillator") is used to generate a clock signal and send the clock signal CLK to the FPGA chip. The temperature sensor is used to collect the device temperature of the site device and send the device temperature to the FPGA chip. The Wi-Fi module is used to respond to the beacon signal sent from the access point device, generate an interrupt signal, and send the access point time (which can be a timestamp) corresponding to the interrupt signal and the beacon signal to the FPGA chip. The FPGA chip calculates the actual frequency of the site device based on the received interrupt signal, tracks the frequency offset coefficient (abbreviated as "frequency offset") caused by temperature based on the actual frequency of the device thermometer, and compensates the frequency of the site device based on the frequency offset coefficient, so that the site time is adjusted. According to the access point time and the frequency offset coefficient, a fuzzy controller and a proportional-integral controller are used to determine the time offset coefficient (abbreviated as "time offset"), and according to the time offset coefficient, the adjusted site time is served or compensated to complete time synchronization.
[0091] In this embodiment, the frequency offset coefficient is used to accurately calculate the preliminary standard time using the time model. The time offset coefficient is calculated using the access point time, the standard time, and the site time compensated by the frequency offset coefficient using the fuzzy controller and the proportional integral controller. The access point time delay and the node interruption delay difference ( ) and the nonlinear error of the oscillator drift are mapped into fuzzy rules, so that the time offset coefficient can reflect the difference in interruption delay between the station equipment and the access point ( ), oscillator time-varying drift, and packet packet delay. Using the time offset coefficient to compensate for site time corrects the accumulated asynchronous errors between site devices and suppresses clock divergence caused by temperature drift and hardware aging. This allows site devices to achieve high-precision time synchronization (for example, 10μs) using the access point time as a unified benchmark.
[0092] The above-described embodiment uses a Kalman filter algorithm to determine a frequency offset coefficient based on interrupt signals and device temperature, thereby tracking the impact of factors such as changes in site device temperature on the oscillator frequency. Since site time can vary due to changes in the oscillator frequency, compensating the site device frequency based on the frequency offset coefficient allows for preliminary adjustment of the site time. Compensating the frequency-compensated site time based on the frequency offset coefficient and access point time corrects for accumulated asynchronous errors between site devices, suppresses clock divergence caused by temperature drift and hardware aging, and enables site devices to achieve high-precision (e.g., 10μs) time synchronization using the access point time as a unified benchmark. This multi-dimensional compensation, including frequency and time compensation, ensures the stability and accuracy of time synchronization. Furthermore, by eliminating the need for additional hardware and software configuration, such as Bluetooth, during the synchronization process, the cost of time synchronization can be reduced.
[0093] In some embodiments of the present application, Figure 5 FIG. 1 is a flow chart of a time compensation method provided by an embodiment of the present application, comprising the following steps:
[0094] S121 , after obtaining the Mth frequency offset coefficient, calculate the Mth standard time of the site device using a time model based on the standard clock beat number and the Mth frequency offset coefficient.
[0095] In some embodiments of the present application, M is an integer greater than or equal to 1. The calculation method of the Mth standard time can refer to the above formula (8), and will not be repeated in this application.
[0096] S122: Determine a first time offset according to the access point time corresponding to the Mth standard time and the Mth frequency offset coefficient.
[0097] In some embodiments of the present application, the first time deviation It can be the access point time corresponding to the Mth frequency offset coefficient With the Mth standard time The difference.
[0098] S123: Determine a second time offset according to the first time offset and the site time of the site equipment after the M-1th compensation.
[0099] In some embodiments of the present application, when M is 1, the time after the M-1th compensation may represent the station time that is not compensated by the time offset coefficient, and the second time deviation e may be the difference between the station time after the M-1th compensation and the first time deviation. The difference between .
[0100] After obtaining each frequency offset coefficient, the FPGA chip will compensate the frequency of the oscillator in the site device according to the frequency offset coefficient, so that the site time of the site device is adjusted, and calculate the corresponding time offset coefficient based on the frequency offset coefficient, and adjust the adjusted site time. Therefore, the site time after the M-1th compensation in this application can be the time after the oscillator is frequency compensated using the corresponding frequency offset coefficient.
[0101] S124 , based on the second time deviation and the time deviation rate of the second time deviation, using a fuzzy controller, determining an Mth proportional-integral parameter of a proportional-integral controller.
[0102] In some embodiments of the present application, the second time deviation e and the time deviation rate ec are input parameters of the fuzzy controller, and the input parameters of the fuzzy controller can be divided into seven fuzzy subsets, namely {NB, NM, NS, ZO, PS, PM, PB}. Figure 5 The following are examples of fuzzy subsets provided by this application.
[0103] The output parameters of the fuzzy controller include the correction and correction amount , correction amount Used to adjust the proportional gain in the proportional integral parameter , correction amount Used to adjust the integral gain in the proportional integral parameter .
[0104] In some embodiments, the FPGA chip can control the correction amount corresponding to the fuzzy controller output based on the preset fuzzy rules, the center of the membership function of each fuzzy subset of the input parameters of the fuzzy controller and the output membership of the membership function. and correction amount .
[0105] Exemplarily, the fuzzy rules may include the following: (1) If the second time deviation e is greater than the first preset value and the time deviation rate ec is greater than the second preset value, it can be determined that the system is currently in the initial state, or the system is no longer in a steady state due to abnormal input, working mode or environmental changes. At this time, the fuzzy controller can be controlled to output the second time deviation e with a larger sign. |Quickly correct the time deviation value and control the fuzzy controller to output the second time deviation e with the larger sign| |To avoid integral saturation and achieve fast and stable control. (2) If the second time deviation e is within the first preset numerical range and the time deviation rate ec is within the second preset numerical range, the fuzzy controller can be controlled to output a value within the first preset numerical range. | and in the second preset value range | |, where the sign rule is the same as in step (1) above, and | | is smaller than the larger one in step (1) above | |, in the second preset value range | | is smaller than the larger one in step (1) above | |, each value in the first preset numerical interval is less than the first preset value, and each value in the second preset numerical interval is less than the second preset value. (3) If the second time deviation e is less than the third preset value and the time deviation rate ec is less than the fourth preset value, determine the proportional gain and integral gain The adjustment is completed, and the fuzzy controller can be controlled to output a smaller and To ensure the stability of the system, the third preset value may be smaller than each value in the first preset numerical range, and the fourth preset value may be smaller than each value in the second preset numerical range.
[0106] Among them, the correction amount is determined by the center of the membership function and the output membership of the membership function and correction amount The method can refer to the relevant technology. Figure 6 As shown in FIG, it is the membership function of the second time deviation e provided by an embodiment of the present application. Figure 7 As shown in FIG, it is the membership function of the time deviation rate ec provided by an embodiment of the present application. Figure 6 In the figure, the horizontal axis represents the second time deviation e, where The unit can be expressed as microseconds, and the vertical axis represents the degree of membership. Figure 7 In the figure, the horizontal axis represents the time deviation rate ec, where The unit can be expressed in microseconds, and the vertical axis represents the degree of membership.
[0107] In some embodiments, the FPGA chip can set the second time deviation e, the time deviation rate ec, the correction amount and correction amount The quantization range of the second time deviation e and the time deviation rate ec can be set to [-5µs, 5µs], so as to improve the accuracy of the proportional gain and the integral gain, thereby accelerating the synchronization speed and synchronization accuracy. and The quantization range of can be [-1,1].
[0108] In some embodiments, the proportional gain and the integral gain may be calculated using the following formulas (10) and (11):
[0109] ; (10)
[0110] ; (11)
[0111] in, represents the proportional gain, Indicates the initial value of the proportional gain in the proportional-integral controller or the proportional gain calculated in advance, Indicates the correction amount for the proportional gain, represents the integral gain, Indicates the initial value of the integral gain in the proportional-integral controller or the integral gain calculated in advance, Indicates the correction amount for the integral gain.
[0112] S125 , determining an Mth time offset coefficient of the site device according to the Mth proportional integral parameter, and compensating the site time after the M-1th compensation according to the Mth time offset coefficient.
[0113] In some embodiments of the present application, the calculation method of the time offset coefficient can refer to the following formula (12):
[0114] ; (12)
[0115] in, represents the time offset coefficient, represents the proportional gain, Please refer to the explanation of formula (1) above. Indicates the integral gain.
[0116] In some embodiments, the FPGA chip can utilize a time offset coefficient to compensate for station time using various methods. For example, the FPGA chip can determine a target time based on the time offset coefficient and station time, and adjust the station time to the target time. For example, the target time can be the sum or difference of the time offset coefficient and the station time.
[0117] like Figure 8 The figure shows the working diagram of the fuzzy controller and the proportional integral controller provided by an embodiment of the present application. Figure 8 In the Kalman filter algorithm, the frequency offset coefficient is calculated Input into the time model to obtain standard time , the access point time provided by the Wi-Fi module With standard time Subtracting them, we can get the first time deviation , the deviation between the first updated site time and the first time By subtracting, the second time deviation e can be obtained. By taking the time derivative of the second time deviation e, the time deviation rate ec can be obtained. The second time deviation e and the time deviation rate ec are input to the fuzzy controller. The correction value output by the second time deviation e, the time deviation rate ec and the fuzzy controller is obtained. and correction amount The proportional gain and integral gain corresponding to the output of the proportional-integral controller are controlled to update the previously updated site time, and this cycle is repeated. After a period of time, the time synchronization between the site device and the access point device can be achieved.
[0118] like Figure 9 The figure is a schematic diagram of the structure of the site equipment provided by an embodiment of the present application. Figure 9In the embodiment, the site device 20 includes a crystal oscillator 201 , a temperature sensor 202 , a Wi-Fi module 203 and an FPGA chip 204 .
[0119] The crystal oscillator 201 is used to generate a clock (CLK) signal and send the clock signal to the FPGA chip 204 .
[0120] The temperature sensor 202 is used to collect the device temperature of the site device and send the device temperature to the FPGA chip 204.
[0121] The Wi-Fi module 203 is configured to generate an interrupt signal in response to a beacon signal sent from an access point device, and send the interrupt signal and the access point time (which may be a timestamp) corresponding to the beacon signal to the FPGA chip 204 .
[0122] The FPGA chip 204 determines the frequency offset coefficient of the site device based on the interrupt signal and the device temperature, compensates the frequency of the site device according to the frequency offset coefficient, and uses a fuzzy controller and a proportional-integral controller based on the frequency offset coefficient and the access point time to compensate the site time of the site device, thereby completing the time synchronization between the site device and the access point device, so as to realize the time synchronization method described above.
[0123] In other embodiments of the present application, in addition to the crystal oscillator 201, the temperature sensor 202, the Wi-Fi module 203 and the FPGA chip 204, the site device may also include other structural components, such as a processor, a memory, etc., to facilitate the implementation of the time synchronization method described above.
[0124] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. The computer program includes program instructions. The method implemented when the program instructions are executed can refer to the methods in the above-mentioned embodiments of the present application.
[0125] The computer-readable storage medium may be the internal memory of the site device described in the above embodiment, such as the hard disk or memory of the site device. The computer-readable storage medium may also be an external storage device of the site device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the site device.
[0126] In some embodiments, the computer-readable storage medium may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the site device, etc.
[0127] It is understood that the structures illustrated in the embodiments of the present application do not constitute specific limitations on any device. In other embodiments of the present application, each device may include more or fewer components than shown, or combine or separate certain components, or arrange the components differently. The components shown in the diagrams may be implemented in hardware, software, or a combination of software and hardware.
[0128] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the module division is merely a logical function division, and other division methods may be used in actual implementation.
[0129] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected to achieve the purpose of the solution of this embodiment according to actual needs.
[0130] In addition, the functional modules in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0131] Therefore, the embodiments should be considered in all respects as illustrative and non-restrictive, and the scope of the present application is defined by the appended claims rather than the foregoing description, and all changes that come within the meaning and range of equivalents of the claims are intended to be embraced therein. Any reference to a figure in a claim should not be construed as limiting the claim to which it relates.
[0132] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in this application may also be implemented by a single unit or device through software or hardware. Terms such as first and second are used to indicate names and do not imply any particular order.
[0133] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit the present application. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present application.
Claims
1. A time synchronization method, applied to a site device, wherein the site device is connected to an access point device via a wireless network, characterized in that: The method comprises: generating an interrupt signal in response to a beacon signal sent by the access point device, wherein the beacon signal corresponds to access point time; Collecting the device temperature of the site device; determining a frequency offset coefficient of the site device based on the interrupt signal and the device temperature; Compensating the frequency of the site equipment according to the frequency offset coefficient; Constructing a time model based on a fourth target equation, wherein the fourth target equation is used to determine a standard time corresponding to the first time according to the standard clock beat number of the interrupt signal and the frequency offset coefficient; Based on the frequency offset coefficient and the access point time, compensating the site time of the frequency-compensated site device to complete time synchronization between the site device and the access point device includes: based on the frequency offset coefficient, the standard clock tick number, and the time model, using a fuzzy controller and a proportional-integral controller to compensate the site time until proportional-integral parameters of the proportional-integral controller all meet a second preset condition, thereby completing time synchronization between the site device and the access point device, wherein the proportional-integral parameters include a proportional gain and an integral gain.
2. The time synchronization method according to claim 1, wherein: Before determining the frequency offset coefficient of the site device, the method further includes: determining a first state vector corresponding to the first time according to a vector associated with a predicted frequency deviation coefficient at the first time, a first coefficient, and a second coefficient, wherein the first coefficient and the second coefficient are both associated with a standard clock tick number of the interrupt signal; determining a state transition matrix corresponding to the first time based on a matrix associated with a first temperature difference and a second temperature difference corresponding to the first time, wherein the first temperature difference corresponding to the first time is associated with a device temperature corresponding to the first time, a device temperature corresponding to the second time, and an inflection point temperature of an oscillator in the site device, and the second temperature difference corresponding to the first time is associated with the device temperature corresponding to the first time and the device temperature corresponding to the second time, and the second time is before the first time; determining a second state vector corresponding to the second time according to a vector related to the predicted frequency offset coefficient at the second time, the first coefficient, and the second coefficient; determining a noise vector corresponding to the first time according to a vector associated with a systematic error deviation at the first time, wherein the systematic error deviation at the first time is associated with a systematic error of the site device at the first time and a systematic error at the second time; A Kalman state model is constructed according to a first objective equation, wherein the first objective equation is used to determine the first state vector based on the state transfer matrix, the second state vector and the noise vector.
3. The time synchronization method according to claim 2, wherein: Before determining the frequency offset coefficient of the site device, the method further includes: Determining an observation matrix according to a first preset variable corresponding to a target value, wherein the target value is determined by packet loss of the beacon signal; A Kalman observation model is constructed based on the second target equation and the third target equation, wherein the second target equation is used to determine the third preset variable corresponding to the observation vector of the site device at the first time based on the observation matrix, the first state vector and the second preset variable corresponding to the observation noise of the site device at the first time, wherein the observation noise at the first time satisfies the preset probability distribution, and the third target equation is used to determine the actual frequency deviation coefficient of the first time based on the standard interrupt period of the interrupt signal, the standard clock beat number and the clock beat number corresponding to the interrupt signal at the first time.
4. The time synchronization method according to claim 3, wherein: Determining the frequency offset coefficient of the site device based on the interrupt signal and the device temperature includes: Based on the standard clock beat number, the equipment temperature, the inflection point temperature, the system error, the clock beat number, the standard interruption period, the target value and the observation noise, the Kalman state model and the Kalman observation model are used to perform state prediction and state update on the site equipment until the first coefficient and the second coefficient both meet the first preset condition to obtain the frequency offset coefficient.
5. The time synchronization method according to claim 4, wherein: The using the Kalman state model and the Kalman observation model to predict and update the state of the site equipment includes: Based on the adaptive factor and the information weighting factor, the status of the site equipment is predicted and updated.
6. The time synchronization method according to claim 1, wherein: The steps of compensating the site time include: After obtaining the Mth frequency offset coefficient, calculating the Mth standard time of the site device using the time model based on the standard clock beat number and the Mth frequency offset coefficient, where M is an integer greater than or equal to 1; Determining a first time offset according to the Mth standard time and the access point time corresponding to the Mth frequency offset coefficient; Determine a second time offset according to the first time offset and the site time of the site device after the M-1th compensation; determining an Mth proportional-integral parameter of the proportional-integral controller using the fuzzy controller based on the second time deviation and the time deviation rate of the second time deviation; An Mth time offset coefficient of the site device is determined according to the Mth proportional integral parameter, and the site time after the M-1th compensation is compensated according to the Mth time offset coefficient.
7. A site device, characterized in that: The site device is connected to the access point device through a wireless network, and the site device includes a communication module, a temperature sensor and a programmable logic device. the communication module generating an interrupt signal in response to receiving a transmitted beacon signal from the access point device, wherein the beacon signal has a corresponding access point time; The communication module sends the interrupt signal and the access point time to the programmable logic device; The temperature sensor collects the device temperature of the site device and sends the device temperature to the programmable logic device; The programmable logic device determines a frequency offset coefficient of the site device based on the interrupt signal and the device temperature; The programmable logic device compensates the frequency of the site equipment according to the frequency offset coefficient; The programmable logic device constructs a time model based on a fourth target equation, wherein the fourth target equation is used to determine a standard time corresponding to the first time according to the standard clock beat number of the interrupt signal and the frequency offset coefficient; The programmable logic device compensates the site time of the frequency-compensated site device based on the frequency offset coefficient and the access point time to complete time synchronization between the site device and the access point device, including: compensating the site time using a fuzzy controller and a proportional-integral controller based on the frequency offset coefficient, the standard clock tick number, and the time model, until proportional-integral parameters of the proportional-integral controller all meet a second preset condition, thereby completing time synchronization between the site device and the access point device, wherein the proportional-integral parameters include a proportional gain and an integral gain.
8. A time synchronization system, characterized in that: The time synchronization system includes the site device and the access point device according to claim 7.
Citation Information
Patent Citations
Time and frequency deviation compensation method and user terminal
CN106028436A