A Software Time Synchronization Implementation Method for a Sensor

By applying the software time synchronization method of the Kalman filtering model in a multi-sensor system, the problem of difficult sensor time synchronization is solved, and the system's time correction accuracy and overall performance are improved.

CN119311079BActive Publication Date: 2025-06-24SIMETRIC SEMICON SOLUTIONS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411848719.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-16
Publication Date
2025-06-24
Estimated Expiration
2044-12-16

AI Technical Summary

Technical Problem

In multi-sensor systems, time synchronization between sensors is difficult to achieve, resulting in a lack of data time correlation, affecting the accuracy and reliability of the system.

Method used

A software time synchronization method based on the Kalman filtering model is adopted to calculate the estimated value of the accumulated error by recording the time data during the sensor request and response process, and use it to correct the sensor measurement time to achieve time synchronization.

Benefits of technology

This method can improve the accuracy of time correction, reduce the impact of errors on system performance, ensure stable synchronization of sensor time with actual time, and improve the overall accuracy and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119311079B_ABST
    Figure CN119311079B_ABST
Patent Text Reader

Abstract

The present invention provides a method for implementing software time synchronization of sensors, which is applied to the scenario where sensors communicate with the SOC side through requests and responses. When the SOC side sends a request signal to the sensor, the SOC records this moment as the sensor request sending moment. After the request signal reaches the sensor, when the sensor obtains the recorded data in the data packet, the on-chip moment generated is obtained, and this moment includes the cumulative error caused by the instability of the crystal oscillator. At the same time, the response arrival moment when the sensor sends the data packet to the SOC is recorded; the Kalman filter model is used to obtain the estimated value of the nth cumulative error; according to the estimated value of the cumulative error and the on-chip moment at the nth moment, the corrected sensor measurement moment is calculated; the present invention projects the time lines of multiple sensors onto the real time line of the SOC respectively, and can correct the time of multiple sensors to the same time reference, realizing the time synchronization of the multi-sensor system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of industrial communication, and particularly relates to a method for realizing software time synchronization of sensors. Background Art

[0002] In the application scenario of multi-sensor integration, ensuring the time synchronization of each sensor is crucial. Time synchronization means that the internal clocks of all sensors must be kept consistent so that they can collect data at the same time point. This synchronism can ensure the temporal consistency of data among sensors, enabling the multi-sensor system to correctly fuse the measurement results of each sensor. If the sensors cannot maintain time synchronization, the system will face the problem of lack of temporal correlation between data, which may lead to distorted measurement results or difficulty in integration, ultimately affecting the accuracy and reliability of the entire system.

[0003] For a single sensor, time accuracy cannot be ignored either. Accurate timestamps not only help record the specific moment of sensor measurement but also improve the accuracy of measurement results. The accuracy of timestamps is directly related to the validity of data, especially in applications that require long-term monitoring or have high timing requirements. Whether it is a single sensor or a multi-sensor system, the accuracy of time management is a key factor in ensuring data quality and system performance. Therefore, when designing and implementing a sensor system, time synchronization and time management should be given priority, and effective technical means should be adopted to achieve this goal.

[0004] As Figure 1 shown, the transmission between the sensor and the SOC is carried out through a request and response communication method. When the SOC needs sensor data, it sends a request signal to the sensor. The request signal includes the id of the corresponding sensor, the content of the request, etc. After receiving the request signal from the SOC, the sensor checks if it is a request for its own data and then sends a response signal. The response signal includes the physical quantity measured by the sensor. On a chip with an on-chip time sensor, it will also include time information, but this time information is affected by the accuracy of the on-chip crystal oscillator and may have errors. When there are errors, the error from the normal time will gradually accumulate to form an accumulated error.

[0005] In the scenario of using sensors, sensors with crystal oscillators have the function of on-chip time. A crystal oscillator is a device that controls the increase of on-chip time through a certain frequency on a semiconductor device. After the initialization time, the crystal oscillator updates the on-chip time according to the frequency to keep it synchronized with the real time. Sensors with crystal oscillators can return the time on the sensor, but they often encounter the problem of insufficient accuracy of the crystal oscillator of the sensor, which leads to errors in time updates. The errors can accumulate, causing the on-chip time to deviate from the real time, and eventually causing the timestamp on the sensor to become unreliable, making it impossible for multi-sensor systems to achieve time synchronization. This situation poses a serious threat to the overall performance of the system and the accuracy of the data, especially in applications that rely on precise timing, which may cause deviations or errors in the system.

[0006] In order to solve the problem of sensor time synchronization, a group policy-based method can be used. This is equivalent to giving up the on-chip time function on the sensor. Under this policy, the data read request is distributed according to the predetermined group, and the sensors in each group will ensure that the data read request is received within a time period and the data is collected within the same time period. Subsequently, the system will read the data returned by the sensor according to the group and stamp the data of each group with the same timestamp to indicate that the data is collected within the same time period. This method reduces the impact of individual sensor time errors on the overall system by simplifying the time synchronization problem to intra-group synchronization. However, the time obtained by this group policy-based method is approximate and can only ensure that a group of sensors occurs in a certain time period. Since the timestamp is based on the group, rather than accurate to each sensor, there may still be slight time differences between the sensors in the group. In addition, this method cannot fundamentally solve the problem of single sensor time accuracy, especially when the crystal oscillator deviation is large, the time error of a single sensor will still affect the accuracy of the data. Therefore, although the group policy can alleviate the problem of multi-sensor time synchronization to a certain extent, in applications with high precision requirements, more advanced synchronization technology or more rigorous calibration of the sensor time base is still needed. Summary of the invention

[0007] In view of the above problems, the present invention provides a method for realizing software time synchronization of a sensor, which is applied to a scenario in which a sensor and an SOC terminal communicate in a request and response manner. When the SOC terminal sends a request signal to the sensor, the SOC records the time as the time when the sensor request is sent. After the request signal reaches the sensor, the sensor returns a data packet to the SOC, which contains the on-chip time when the data was generated. , which contains the accumulated error due to the instability of the crystal oscillator; then, after the sensor sends the data packet to the SOC, the SOC records the response arrival time ; n represents the nth request and response to the sensor; the Kalman filter model is used to obtain the estimated value of the cumulative error at the nth time, and the process includes the following:

[0008] S1. According to the historical experimental data, obtain the initial value parameters required for the Kalman filter model;

[0009] S2. According to the time data obtained during the sensor request and response process, obtain the observed value of the cumulative error;

[0010] S3. According to the observed value of the cumulative error, input it into the Kalman filter model to obtain the estimated value of the cumulative error;

[0011] S4. According to the estimated value of the cumulative error and the on-chip time at the nth moment, calculate the corrected sensor measurement time .

[0012] Preferably, obtaining the initial value parameters required for the Kalman filter model in S1 specifically includes:

[0013] According to the time data obtained from multiple request returns in the experimental data, obtain the growth rate of the cumulative error , which is always equal to the initial value;

[0014] According to multiple experimental data, obtain the data of multiple cumulative error observed values, and obtain the covariance of the cumulative error observed values based on these data ;

[0015] According to multiple experimental data, obtain the data of multiple cumulative error predicted values, and obtain the initial covariance value of the cumulative error prediction based on these data ;

[0016] The initial value of the cumulative error is set to 0, that is = 0.

[0017] Preferably, in S2, obtaining the observed value of the cumulative error , is calculated through the following formula:

[0018]

[0019] where is the on-chip time at the nth time; is the sensor response arrival time; is the sensor request sending time.

[0020] Preferably, the specific process of S3 is:

[0021] S31. Based on the obtained speed Build a physical model, that is, build a state transition equation for prediction. The formula of the state transition equation is as follows:

[0022]

[0023] Among them, is the predicted value of the cumulative error at the nth time based on the estimated value of the cumulative error at the (n - 1)th time; is the estimated value of the cumulative error at the (n - 1)th time; is the difference between the on-chip time at the nth time and the on-chip time at the (n - 1)th time, that is:

[0024]

[0025] Among them, is the on-chip time at the nth time;

[0026] Among them, the state transition equation of the prediction covariance:

[0027]

[0028] Among them, is the extrapolation of the prediction covariance at the nth time based on the estimated value of the prediction covariance at the (n - 1)th time; is the estimated value of the prediction covariance at the (n - 1)th time;

[0029] S32, through the estimated value of the cumulative error of the Kalman filter when requesting the sensor at the (n - 1)th time , and the obtained state transition equation, obtain the predicted value of the cumulative error at the nth moment :

[0030]

[0031] Among them, is the predicted value at the nth time based on the estimated value of the cumulative error at the (n - 1)th time; is the estimated value of the cumulative error at the (n - 1)th time; is the difference between the on-chip time at the nth time and the on-chip time at the (n - 1)th time;

[0032] S33, according to the prediction covariance transfer matrix:

[0033]

[0034] Among them, is the extrapolation of the prediction covariance at the nth time based on the estimated value of the prediction covariance at the (n - 1)th time;

[0035] S34, according to, calculated and Calculate the Kalman gain at the nth time :

[0036]

[0037] wherein represents the Kalman gain at the nth time, is the extrapolation of the predicted covariance at the nth time based on the estimated value of the predicted covariance at the (n - 1)th time, is the observation covariance of the cumulative error observation value;

[0038] S35. According to the obtained Kalman gain and the predicted value of the cumulative error at the nth time of the cumulative error, obtain the estimated value of the cumulative error at the nth time :

[0039]

[0040] wherein, is the predicted value of the cumulative error at the nth time through the estimated value of the cumulative error at the (n - 1)th time; is the cumulative error observation value; represents the Kalman gain at the nth time;

[0041] S36. According to the obtained Kalman gain and the estimated value of the predicted covariance at the (n - 1)th time, extrapolate the predicted covariance at the nth time to obtain the estimated value of the predicted covariance at the nth time :

[0042]

[0043] wherein is the extrapolation of the predicted covariance at the nth time through the estimated value of the predicted covariance at the (n - 1)th time, represents the Kalman gain at the nth time.

[0044] Preferably, the specific process in S4 is as follows:

[0045] According to the estimated value of the cumulative error at the nth time calculated in S3 , and the on-chip time at the nth time, obtain the corrected sensor measurement time :

[0046]

[0047] wherein is the on-chip time at the nth time; is the estimated value of the cumulative error at the nth time.

[0048] Compared with the prior art, the present invention has the following beneficial effects:

[0049] A method for implementing software time synchronization of a sensor provided by the present invention. As time goes by, by continuously updating the covariance matrix in the Kalman filter, the algorithm will gradually converge, making the error estimate value closer to the true difference between the sensor time and the NTP network time. This convergence effect not only improves the accuracy of time correction but also reduces the impact of errors on the overall performance of the system, ensuring that the sensor time can stably reflect the actual time.

[0050] During the calibration process of a single sensor, the Kalman filter can effectively correct the time deviation caused by sensor errors. However, in a multi-sensor system, due to the possible differences in time errors of each sensor, the time synchronization problem is more complex. To solve this problem, through the method of the present invention, the time lines of multiple sensors are respectively projected onto the true time line of the SOC. Through this projection, the times of multiple sensors can be corrected to the same time reference, realizing the time synchronization of the multi-sensor system. This synchronization not only helps to improve the overall accuracy and reliability of the system but also ensures that data from different sensors can be effectively integrated and analyzed on the same time reference in complex application scenarios. Brief Description of the Drawings

[0051] Figure 1 It is a schematic diagram of the transmission mode between the sensor and the SOC.

[0052] Figure 2 It is a schematic diagram of time when the sensor communicates with the SOC.

[0053] Figure 3 It is a schematic diagram of the overall framework of the present invention.

[0054] Figure 4 It is a schematic diagram of the specific implementation process of the Kalman filter algorithm. Detailed Embodiment

[0055] Combined with Figure 2 , the principle of the present invention is explained as follows:

[0056] Ts: The moment when the sensor requests to send;

[0057] T2: The moment when the request signal arrives at the sensor;

[0058] T3: The moment when the response signal returns from the sensor;

[0059] Tr: The moment when the sensor response arrives;

[0060] t1: Request transmission time;

[0061] t2: The time period during which sensor data may occur;

[0062] t3: Response transmission time;

[0063] Solid line box of pn: Represents the nth request packet;

[0064] Dashed line box of pn: Represents the nth response packet.

[0065] Two times obtained from the time axis TL1 regarded as accurate on the data acquisition unit SOC: The transmission time of sending the request , The reception time of receiving the return , Take The time as the time when sampling actually occurs on the sensor;

[0066] The time axis TL2 with error measured by the sensor will record the sampling time during sampling ;

[0067] And The obtained difference Is the difference between the returned sampling time and the actual sampling time, that is, the error between the time axis TL1 and the time axis TL2;

[0068] The focus of the present invention lies in how to use Kalman filtering to dynamically predict the time when sampling actually occurs.

[0069] The core idea of Kalman filtering is: Predict the next state based on the current state, and correct the prediction result through the measured value to obtain the best state estimate. It assumes that the system and the measurement process satisfy linear Gaussian distribution, that is, both the system noise and the measurement noise follow normal distribution.

[0070] The Kalman filter is a recursive algorithm that does not require storing a large amount of historical data, so it is suitable for real-time systems. It can effectively combine prediction and measurement information and provide a better state estimate in the presence of noise. Under the assumption of linear and Gaussian noise, the Kalman filter is the optimal state estimation algorithm. Therefore, Kalman filtering is a method for processing noise errors in real-time systems and is the optimal estimation in linear systems.

[0071] Kalman filtering can have good results in linear systems. However, from the previous data, the experimental results show that the measured time increases linearly, and the time difference between the measured time and the time of the SOC used for calibration Also increases linearly. For the convenience of processing and to reduce the complexity of calculation and theory. So we decide to use the time deviation As the processing variable of Kalman filtering instead of directly processing time.

[0072] To make the data processed by Kalman filtering more accurate, three points need to be noted:

[0073] The system is linear;

[0074] The noise distribution satisfies the Gaussian distribution;

[0075] The preset system model is as accurate as possible;

[0076] In order to make the predicted value obtained by the Kalman filter more accurate, it is necessary to determine the initial conditions of the Kalman filter and verify the accuracy of the model through experiments.

[0077] In addition, there is also a very important initial condition in the application of the Kalman filter, which is the initial state and the initial covariance matrix. There are multiple methods to evaluate the initial state and the initial covariance matrix:

[0078] 1. Set according to prior knowledge;

[0079] 2. Initialize through system observation;

[0080] 3. Estimate through the average value in the stationary phase;

[0081] 4. Estimate using training data;

[0082] 5. Initialize using the Bayesian method;

[0083] 6. Gradual convergence method (Warm-up Phase);

[0084] By the above methods, all the prerequisites for using the Kalman filter are completed, and the system is transformed into a linear system. The system model and the initial state are determined through experiments or other methods.

[0085] The following further illustrates the method of the present invention in conjunction with specific embodiments.

[0086] Embodiment 1:

[0087] As Figure 3 shown, the implementation manner of the present invention is: when the SOC sends a request signal to the sensor, the SOC records this moment as the sensor request sending moment , after the request signal reaches the sensor, the on-chip moment generated when the recorded data is obtained in the data packet obtained by the sensor , this moment includes the cumulative error caused by the instability of the crystal oscillator; at the same time, record the response arrival moment when the sensor sends the data packet to the SOC ; n represents the nth request and response to the sensor; use the Kalman filter model to obtain the estimated value of the cumulative error of the nth time, and the process includes:

[0088] S1. Obtain the initial value parameters required for the Kalman filter model according to historical experimental data;

[0089] S2. Obtain the observed value of the cumulative error according to the time data obtained during the sensor request and response process;

[0090] S3. Input the observed value of the cumulative error into the Kalman filter model to obtain the estimated value of the cumulative error;

[0091] S4. Calculate the corrected sensor measurement time according to the estimated value of the cumulative error and the on-chip time at the nth moment .

[0092] The specific implementation method is as Figure 4 shown:

[0093] In this embodiment, the initial value of the cumulative error speed is obtained according to the time data obtained from multiple request returns in the experimental data . In this example, no adjustment is made to in the Kalman filter, and the cumulative error speed is always equal to the initial value ;

[0094] According to multiple experimental data, obtain the data of multiple observed values of the cumulative error, and obtain the covariance of the observed values of the cumulative error according to these data ;

[0095] According to multiple experimental data, obtain the data of multiple predicted values of the cumulative error, and obtain the initial value of the predicted covariance of the cumulative error according to these data ;

[0096] The initial value of the cumulative error is positioned as 0, that is = 0.

[0097] The specific method of S1 is:

[0098] First, conduct experiments on the sensor for multiple trial runs to obtain multiple sets of returned time data( , , );

[0099] Obtain the initial value of the cumulative delay speed by dividing the difference between two data by the difference in network time ;

[0100] Calculate the variance in multiple experiments , and the initial value of the predicted covariance .

[0101] The specific method of S2 is as follows:

[0102] At the nth time when the SOC sends a request to the sensor, record this moment as . When receiving the data responded by the sensor, record this moment as . Meanwhile, according to the information of the data packet returned by the sensor, according to the formula:

[0103]

[0104] obtain value;

[0105] The specific method of S3 is as follows:

[0106] According to the output of the algorithm at the (n - 1)th time, and , and the time interval between the nth and the (n - 1)th times, according to the formula:

[0107] obtain the predicted value of the cumulative error at the nth time.

[0108] The predicted covariance matrix extrapolation remains unchanged and is equal to the estimated value of the predicted covariance matrix at the (n - 1)th time:

[0109]

[0110] According to the predicted covariance matrix extrapolation and the observation covariance matrix, calculate the Kalman gain:

[0111]

[0112] According to the obtained Kalman gain and the predicted value of the cumulative error at the nth time obtain the estimated value of the cumulative error at the nth time :

[0113]

[0114] According to the obtained Kalman gain , and the estimated value of the observation covariance at the (n - 1)th time, extrapolate the observation covariance at the nth time obtain the estimated value of the predicted covariance at the nth time :

[0115]

[0116] In this example, the specific method of S4 is as follows:

[0117] According to the on-chip time of the sensor data at the nth measurement, obtain the corrected sensor measurement moment .

[0118]

[0119] in is the on-chip time when the nth sensor data is generated; is the estimated value of the cumulative error at the nth time.

[0120] Embodiment 2:

[0121] In this embodiment, the other processes are the same as those in Embodiment 1, except that in Embodiment 1, the speed is in an absolutely constant state, but there are cases where the initial speed measurement is inaccurate or the running speed changes in the experiment. Adding the cumulative error speed variable to the Kalman filter and relying on the Kalman filter to converge the cumulative error speed can capture a more accurate cumulative delay speed. In form, the variables become multivariables, i.e., vectors, and the operation method becomes a matrix operation.

[0122] Return the obtained time data according to multiple requests in the experimental data, and obtain the initial value of the cumulative error speed , cumulative error speed The Kalman filter will be continuously updated iteratively;

[0123] Based on multiple experimental data, multiple cumulative error observation data are obtained, and the observation covariance matrix is ​​calculated based on these data. ;

[0124]

[0125] in is the variance of the accumulated error observations, is the on-chip moment at the nth and n-1th times The difference.

[0126] Based on multiple experimental data, multiple cumulative error prediction values ​​are obtained, and the initial value of the prediction covariance matrix of the cumulative error is obtained based on these data. ;

[0127]

[0128] in is the cumulative error forecast variance, is the on-chip moment at the nth and n-1th times The difference.

[0129] In this embodiment, in S2, the cumulative error observation value is obtained , calculated by the following formula:

[0130]

[0131] in It is the nth on-film moment; is the sensor response arrival time; is the time when the sensor request is sent;

[0132] Observed value of cumulative error velocity :

[0133]

[0134] is the n-1th cumulative error estimate; is the on-chip moment at the nth and n-1th times The difference. is the cumulative error observation.

[0135] State Vector From the above two , Consists of.

[0136]

[0137] In this embodiment, the specific process of S3 is:

[0138] S31, based on the speed obtained Construct a state transfer matrix for prediction. The state transfer matrix F is:

[0139]

[0140] The state transfer equation is:

[0141]

[0142] in, is the predicted value of the nth state vector through the estimated value of the n-1th state vector; F is the state transfer matrix, is the estimated value of the state vector for the n-1th time; is the on-chip moment of the nth and n-1th times The difference, that is:

[0143]

[0144] in, It is the nth on-film moment;

[0145] Among them, the state transition equation of the prediction covariance is:

[0146]

[0147] in, The prediction covariance matrix at the nth time is extrapolated by using the estimated value of the prediction covariance matrix at the (n - 1)th time; is the estimated value of the prediction covariance matrix at the (n - 1)th time;

[0148] S32. The predicted value of the state vector at the nth time is obtained by using the estimated value of the state vector of the Kalman filter when requesting the sensor at the (n - 1)th time , and, the obtained state transition equation; :

[0149]

[0150] Wherein, is the predicted value of the state vector at the nth time extrapolated by using the estimated value of the state vector at the (n - 1)th time; F is the state transition matrix, is the estimated value of the state vector at the (n - 1)th time; is the difference between the on-chip time at the nth time and the on-chip time at the (n - 1)th time ;

[0151] S33. According to the covariance transfer matrix:

[0152]

[0153] Wherein, is the prediction covariance matrix at the nth time extrapolated by using the estimated value of the prediction covariance matrix at the (n - 1)th time;

[0154] S34. According to, the calculated and calculate the Kalman gain:

[0155]

[0156] Wherein represents the Kalman gain at the nth time, is the prediction covariance matrix at the nth time extrapolated by using the estimated value of the prediction covariance at the (n - 1)th time, is the observation covariance matrix;

[0157] S35. According to the obtained Kalman gain and the predicted value of the state vector at the nth time obtain the estimated value of the state vector at the nth time :

[0158]

[0159] Wherein, is the predicted value of the state vector at the nth time extrapolated by using the estimated value of the state vector at the (n - 1)th time; is the observed value of the state vector; represents the Kalman gain at the n-th time;

[0160] S36. According to the obtained Kalman gain and the estimated value of the prediction covariance at the (n - 1)-th time, extrapolate the prediction covariance at the n-th time to obtain the estimated value of the prediction covariance at the n-th time :

[0161]

[0162] where is to extrapolate the prediction covariance matrix at the n-th time through the estimated value of the prediction covariance matrix at the (n - 1)-th time, represents the Kalman gain at the n-th time; E is the identity matrix.

[0163] In this example, the specific method of S4 is as follows:

[0164] According to the on-chip time of the sensor data at the n-th measurement, obtain the corrected sensor measurement time .

[0165]

[0166] where is the on-chip time at the n-th time; is the estimated value of the state vector at the n-th time, which exists in the state vector .

[0167] Embodiment 3:

[0168] In this embodiment, other processes are the same as those in Embodiment 2. The difference is that in Embodiment 2, the speed is in a uniform state, and the speed of the cumulative error will not always increase or always decrease. This example proposes a solution for the case where the speed of the cumulative error changes according to a certain trend, and this situation is called an acceleration model. In form, the variables become multi-variables, i.e., vectors, and the operation method also becomes matrix operation.

[0169] According to the time data obtained from multiple requests in the experimental data, obtain the cumulative error speed , and the initial value of the cumulative error acceleration , the cumulative error speed and the cumulative error acceleration will be continuously iteratively updated in the Kalman filter;

[0170] According to multiple sets of experimental data, obtain the data of multiple cumulative error observed values, and calculate the cumulative error observation covariance matrix ;

[0171]

[0172] wherein is the variance of the cumulative error observation value, is the on-chip time at the nth and (n - 1)th times difference.

[0173] Based on multiple sets of experimental data, multiple data of cumulative error prediction values are obtained, and based on these data, the initial value of the cumulative error prediction covariance ;

[0174]

[0175] wherein is the variance of the cumulative error prediction value, is the on-chip time at the nth and (n - 1)th times difference.

[0176] In this embodiment, in S2, the cumulative error observation value is obtained through the following formula:

[0177]

[0178] wherein is the on-chip time at the nth time; is the sensor response arrival time; is the sensor request sending time;

[0179] Observation value of the cumulative error speed :

[0180]

[0181] is the algorithm estimation value at the (n - 1)th time; is the on-chip time at the nth and (n - 1)th times difference. is the cumulative error observation value.

[0182] Observation value of the cumulative error acceleration :

[0183]

[0184] is the cumulative delay speed algorithm estimation value at the (n - 1)th time; is the on-chip time at the nth and (n - 1)th times difference. is the cumulative delay speed observation value at the nth time.

[0185] State vector By the above three 、 、 Composed of.

[0186]

[0187] In this embodiment, the specific process of S3 is as follows:

[0188] S31. Based on the obtained cumulative error velocity And the cumulative error acceleration Construct a state transition matrix for prediction. The state transition matrix F is:

[0189]

[0190] The state transition equation is:

[0191]

[0192] Among them, Is the predicted value of the state vector at the nth time through the estimated value of the (n - 1)th time; F is the state transition matrix, Is the estimated value of the state vector at the (n - 1)th time; Is the difference between the nth time and the on-chip time at the (n - 1)th time That is:

[0193]

[0194] Among them, Is the on-chip time at the nth time;

[0195] Among them, the state transition equation of the prediction covariance:

[0196]

[0197] Among them, Is the extrapolation of the prediction covariance matrix at the nth time through the estimated value of the prediction covariance matrix at the (n - 1)th time; Is the estimated value of the prediction covariance matrix at the (n - 1)th time;

[0198] S32. Through the estimated value of the state vector of the Kalman filter when requesting the sensor at the (n - 1)th time , and, the obtained state transition equation, obtain the predicted value of the state vector at the nth time :

[0199]

[0200] Among them, is the predicted value of the nth state vector based on the estimated values of the state vectors in the previous n - 1 times; F is the state transition matrix, is the estimated value of the (n - 1)th state vector; is the difference in on-chip time between the nth and the (n - 1)th times ;

[0201] S33, obtain the covariance transition matrix according to the physical model:

[0202]

[0203] where is the extrapolation of the predicted covariance matrix of the nth time based on the estimated value of the predicted covariance matrix of the (n - 1)th time;

[0204] S34, calculate the calculated based on, and the observation covariance matrix to calculate the Kalman gain:

[0205]

[0206] where represents the Kalman gain of the nth time, is the extrapolation of the predicted covariance matrix of the nth time based on the estimated value of the predicted covariance of the (n - 1)th time, is the covariance matrix of the cumulative error observation value;

[0207] S35, based on the obtained Kalman gain and the predicted value of the cumulative error of the nth time obtain the estimated value of the cumulative error of the nth time :

[0208]

[0209] where is the predicted value of the nth state vector based on the estimated values of the state vectors in the previous n - 1 times; is the cumulative error observation value; represents the Kalman gain of the nth time;

[0210] S36, based on the obtained Kalman gain and the extrapolation of the predicted covariance of the nth time based on the estimated value of the predicted covariance of the (n - 1)th time obtain the estimated value of the predicted covariance of the nth time :

[0211]

[0212] where The prediction covariance matrix of the nth time is extrapolated through the estimation of the prediction covariance matrix of the (n - 1)th time. represents the Kalman gain of the nth time; E is the identity matrix.

[0213] In this embodiment, the specific method of S4 is as follows:

[0214] Based on the on-chip time of the sensor data at the nth measurement, the corrected sensor measurement time is obtained. .

[0215]

[0216] Where is the on-chip time generated by the sensor data of the nth time; is the estimated value of the cumulative error of the nth time, which exists in the state vector .

[0217] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

[0218] Although the specific implementation manners of the present invention are described above, they are not limitations on the protection scope of the present invention. Those skilled in the art should understand that various modifications or deformations that can be made without creative efforts on the basis of the technical solutions of the present invention are still within the protection scope of the present invention.

Claims

1. A method for realizing software time synchronization of a sensor, characterized in that: Applicable to scenarios where sensors and SOCs communicate through requests and responses. When the SOC sends a request signal to the sensor, the SOC records this as the time when the sensor request was sent. After the request signal reaches the sensor, the sensor returns a data packet to the SOC, which contains the on-chip time when the data was generated. , which contains the accumulated error due to the instability of the crystal oscillator. Then, after the sensor sends the data packet to the SOC, the SOC records the arrival time of the response. ; n represents the nth request and response to the sensor; the Kalman filter model is used to obtain the estimated value of the nth cumulative error, and the following process is included: S1, based on historical experimental data, obtain the initial value parameters required by the Kalman filter model; S2, obtain the accumulated error observation value based on the moment data obtained during the sensor request and response process; S3, according to the cumulative error observation value, input the Kalman filter model to obtain the cumulative error estimate; the specific process is: S31, obtain the initial value of the cumulative error speed , cumulative error speed Always equal to the initial value ; Based on the accumulated error speed obtained Construct a physical model, that is, construct a state transfer equation, which is used to predict the cumulative error. The state transfer equation formula is: in, It is the predicted value of the nth cumulative error based on the estimated value of the n-1th cumulative error; is the n-1th cumulative error estimate; It is the difference between the on-chip time at the nth time and the time at the n-1th time, that is: in, is the nth on-chip moment; S32, based on the cumulative error estimate of the Kalman filter when the sensor is requested for the n-1th time , and the obtained state transfer equation, obtain the nth cumulative error prediction value : in, It is the prediction of the nth cumulative error based on the n-1th cumulative error estimate; is the n-1th cumulative error estimate; is the difference between the on-chip time at the nth time and the n-1th time, is the cumulative error velocity; S33, obtaining the nth prediction covariance matrix extrapolation value according to the prediction covariance transfer matrix: in, It is the extrapolation of the n-th prediction covariance based on the n-1-th prediction covariance estimate; Represents the estimated value of the prediction covariance matrix at n-1 times; S34, according to the calculated as well as Calculate the Kalman gain: in represents the nth Kalman gain, It is the extrapolation of the n-th prediction covariance by the n-1 prediction covariance estimate. is the observation covariance; S35, according to the obtained Kalman gain And the predicted value of the cumulative error at time n of the cumulative error Get the n-th cumulative error estimate : in, It is the predicted value of the nth cumulative error through the n-1th cumulative error estimate; is the nth cumulative error observation; represents the nth Kalman gain; S36, according to the obtained Kalman gain And the n-1 prediction covariance estimate is used to extrapolate the n-th prediction covariance Get the nth prediction covariance estimate : in It is the extrapolation of the n-th prediction covariance by the n-1 prediction covariance estimate. represents the nth Kalman gain; S4, calculate the corrected sensor measurement time based on the estimated value of the cumulative error and the on-chip time at the nth time .

2. A method for implementing software time synchronization of a sensor as claimed in claim 1, characterized in that: The initial value parameters required for the Kalman filter model are obtained in S1, specifically including: Return the obtained time data according to multiple requests in the experimental data, and obtain the initial value of the cumulative error speed , cumulative error speed Always equal to the initial value ; Based on multiple experimental data, multiple cumulative error observation data are obtained, and the observed covariance of the cumulative error is obtained based on these data. ; Based on multiple experimental data, multiple cumulative error prediction values ​​are obtained, and the initial value of the predicted covariance of the cumulative error is obtained based on these data. ; The initial value of the accumulated error is set to 0, that is, =0.

3. The method for implementing software time synchronization of a sensor according to claim 1, characterized in that: In S2, the cumulative error observation value is obtained , calculated by the following formula: in It is the nth on-film moment; is the sensor response arrival time; is the time when the sensor requests to be sent.

4. The method for implementing software time synchronization of a sensor according to claim 1, characterized in that: The specific process in S4 is: According to the n-th cumulative error estimate calculated in S3 , and the nth on-chip moment , and the corrected sensor measurement time is obtained : in is the nth on-chip time; is the n-th cumulative error estimate.