Temperature Drift Compensation of a MEMS Accelerometer Based on DLSTM and ISSA

In order to improve the performance of a micro-electro-mechanical system (MEMS) accelerometer, three algorithms for compensating its temperature drift are proposed in this paper, including deep long short-term memory recurrent neural network (DLSTM-RNN, short DLSTM), DLSTM based on sparrow search algorithm (SSA), and DLSTM based on improved SSA (ISSA). Moreover, the piecewise linear approximation (PLA) method is employed in this paper as a comparison to evaluate the impact of the proposed algorithm. First, a temperature experiment is performed to obtain the MEMS accelerometer’s temperature drift output (TDO). Then, we propose a real-time compensation model and a linear approximation model for neural network methods compensation and PLA method compensation, respectively. The real-time compensation model is a recursive method based on the TDO at the last moment. The linear approximation model considers the MEMS accelerometer’s temperature and TDO as input and output, respectively. Next, the TDO is analyzed and optimized by the real-time compensation model and the three algorithms mentioned before. Moreover, the TDO is also compensated by the linear approximation model and PLA method as a comparison. The compensation results show that the three neural network methods and the PLA method effectively compensate for the temperature drift of the MEMS accelerometer, and the DLSTM + ISSA method achieves the best compensation effect. After compensation by DLSTM + ISSA, the three Allen variance coefficients of the MEMS accelerometer that bias instability, rate random walk, and rate ramp are improved from 5.43×10−4mg, 4.33×10−5mg/s12, 1.18×10−6mg/s to 2.77×10−5mg, 1.14×10−6mg/s12, 2.63×10−8mg/s, respectively, with an increase of 96.68% on average.


Introduction
The MEMS accelerometer is one of the essential measurement elements of an Inertial Measurement Unit (IMU), which inherits the advantages of MEMS technology, such as small size, light weight, low cost, low power consumption, etc. MEMS accelerometers can be used in various fields, such as aerospace, healthcare, gait analysis, sport science, activity recognition, and portable devices [1][2][3][4][5][6][7][8][9]. However, existing manufacturing defects, such as manufacturing tolerances, always degrade its performance. In addition, MEMS accelerometers are extremely sensitive to ambient temperature, causing their performance to degrade dramatically with temperature, which limits their application in high-precision fields. In recent years, researchers have proposed many different approaches to address the effects of temperature on MEMS accelerometers. In general, they are mainly divided into two methods: hardware method and software method.
The hardware method improves the temperature characteristics of MEMS accelerometers mainly through circuit control and structural optimization, which always require additional time and economic costs. Wang proposed a temperature compensation method for a high-performance resonant MEMS accelerometer based on a control circuit and structural design [10]. Liu used parasitic resistance to compensate for the temperature drift of dynamic resonant frequency. After compensation, the first-order temperature coefficient of the accelerometer's bias offset improved by 98.59%, and the long-term drift was suppressed by 93.14% [27]. Han analyzed the temperature effect and proposed the temperature compensation of a MOEMS accelerometer. The author used a finite-element method to complete the quantitative analysis and set up the temperature model by simulating the deformation of the sensor chip. The model was used to describe the accelerometer's temperature characteristics, and the temperature compensation was put forward based on the model. The results show that the temperature compensation can improve the stability of the MOEMS accelerometer [28]. Considering some specific applications, Yang considered a simple mathematical model to compensate for low-cost quartz accelerometers' temperature drifts at high temperatures. His model considers both temperature and rolling sensitivity and has been successfully applied to the temperature compensation of two low-cost quartz accelerometers. The result shows that the temperature drift was suppressed by 90% [29]. Pan focused on the compensation of bias drift and scale factor for a quartz flexible accelerometer between a quick turn-on and the thermal balance inside the system based on a three-layer depth wavelet neural network. Moreover, a variable rate learning algorithm was also employed in this method. Results show that the compensation algorithm increases efficiency and improves precision [30]. Li proposed an improved BP NN based on GA for temperature drift compensation of a quartz flexible accelerometer in different temperatures. The accelerometer's temperature and temperature drift output are used as the input and output of the model, respectively. The GA operation(selection, crossover, and mutation) improves the BP NN's optimization capability. The results show that this method achieved a good effect and had fewer training steps and better fitting accuracy precision than the standard BP NN [31]. Yu employed the artificial fish swarm (AFS) algorithm to carry out temperature drift compensation for a quartz flexible accelerometer. The accelerometer's temperature and output voltages are the input and output of the compensation model. The results show that the accelerometer's drift instability is reduced by 88.76% after compensation by the AFS algorithm [32]. Wu studied a quartz flexible accelerometer's temperature characteristics and proposed a method for its temperature drift compensation in the cold start condition. The author established the temperature drift compensation models based on temperature, temperature gradient, and time-related drift. Then, the PSO algorithm was employed to find the best model parameters. The results show that the proposed method greatly reduces the output signal's standard deviation [33].
Unlike the previous studies, this paper proposes a real-time compensation model and introduces a deep-learning approach. Moreover, a swarm intelligence optimization, SSA, is used to tune the parameters of DLSTM for finding the optimal global parameters, and an improved method is proposed to enhance the optimization ability of SSA. For evaluating the proposed methods' influence, the linear approximation model and the PLA method are introduced in this paper as a comparison. This paper proposes three methods for temperature drift compensation of a MEMS accelerometer: DLSTM, DLSTM + SSA, and DLSTM + ISSA. First, the experimental product, named guidance navigation and control (GNC) module, and the temperature experimental process are briefly introduced. Second, a real-time model is described to study the characteristics of the temperature drift of the MEMS accelerometer, which is a recursive method whose input and output are the output of the temperature drift at the last moment and the current moment, respectively. We then aim to improve the accuracy of the previously proposed model with DLSTM, a kind of RNN variant, since the temperature drift of MEMS accelerometers is a random time series, and RNNs are good at this signal. Afterwards, the parameters of DLSTM are optimized by SSA and ISSA, respectively. More accurate compensation results are obtained, further improving the generalization ability and robustness of the real-time model and DLSTM. Moreover, the linear approximation model and PLA method are also employed as a comparison with the proposed methods in this paper. Finally, Allan variance analysis is used to quantify the compensation results of the four methods. The results verify that the DLSTM + ISSA method shows the best compensation performance.

Experimental Product
The experimental product used in this paper is an in-house-designed GNC Module developed entirely by us. The GNC Module includes a dual-core processor, AD, IMU, external interface, etc., which can provide a full range of inertial information. In addition, combined with information from other external sensors, such as GPS or geomagnetic field information, the GNC Module can realize a broader range of functions, such as integrated navigation, flight control, electronic control combination, steering gear control, etc. The dimensions of the GNC Module are 30 mm × 30 mm × 21.6 mm. Its picture is shown in Figure 1a.

Experimental Scheme
In order to study the temperature drift characteristics of the MEMS accelerometer in the GNC Module, we conducted a temperature test on it. Here, we ignore the influence of other factors and set the reference value of temperature drift equal to zero. The experimental scheme is set up as follows.

1.
As is shown in Figure 1b, the GNC Module is placed in a temperature-controlled oven with a static base The accelerometer chosen in this paper has axes perpendicular to the local gravity direction. The function of the static base is to ensure that the product on it is not disturbed by the vibration of the external environment; 2.
At the beginning of the experiment, the temperature of the temperature-controlled oven is set to −40°C and maintained for 1 h; 3.
The temperature of the temperature-controlled oven is raised to 80°C at a heating rate of 1°C/min. At the beginning of this step, a computer outside the temperaturecontrolled oven synchronously collected the MEMS accelerometer's output with a frequency of 200 Hz until the end of the heating process; 4.
The temperature of the temperature-controlled oven is maintained at 80°C for 1 h; 5.
Then the temperature of the temperature-controlled oven is brought down to room temperature. The temperature experiment is over.

Real-Time Compensatiom Model
Many authors typically use temperature and other temperature-related quantities as inputs to temperature compensation models. In this way, the collected temperature must be accurate enough. Otherwise, the temperature error will be directly introduced into the compensation model, thus reducing the compensation accuracy. In addition, the temperature is usually output synchronously with temperature drift, so real-time compensation is impossible. We propose a one-step ahead predictor to perform real-time compensation, a recursive method based on the TDO from the last moment. This method uses the TDO at time t − 1 (U(t − 1)) and t (U(t)) as the model input and output, respectively. That is, the TDO of the MEMS accelerometer from 1 to ) are represented as the input and output data for the proposed model, respectively. M is the total number of the MEMS accelerometer's TDO. The model can be described as follows: where X(t) and Y(t) are the input and output of the model at time t, respectively. U(t − 1) and U(t) are the TDO of the MEMS accelerometer at time t − 1 and t, respectively. F[·] is the target function to be trained. The framework of the proposed real-time compensation model is shown in Figure 2.

LSTM and DLSTM
• LSTM LSTM was proposed by Hochreiter and Schmidhuber in 1997 and is a popular variant of RNN [34]. The framework of LSTM is shown in Figure 3. LSTM is built with a "gate" structure and a cell unit. Three gate units in LSTM adjust the information flow within the unit adaptively, called forget gate, input gate, and output gate. The cell can remember values over arbitrary time intervals [34][35][36].
The equations of the LSTM are described below. The sigmoid function implements the forget gate, which determines the information to be discarded from the cell state. The output of the forget gate ranges from zero to one, representing the forgetting degree of each input in the cell state. The smaller the forget gate output, the more information is forgotten. Its equation can be described as Formula (2).
where x t and h t−1 are the input of the forget gate, W f x and W f h are the coefficients of x t and h t−1 , respectively, b f is the threshold of forget gate, σ(·) is the sigmoid function, f t is the output of forget at time t, and h t−1 is the output of LSTM at time t. The second part is the input gate, which determines the new information to be stored in the current cell state. The input gate consists of two parts. The first is the sigmoid function that decides the value to update. Similar to the forget gate, the output of the sigmoid function represents the updating degree of each input. The second is the tanh function that creates a new candidate value g t . Both outputs are added to the cell state after a pointwise multiplication operation. Its equation can be described as Formulas (3) and (4).
where tan h(·) is the tanh funtion. The meanings of other parameters are similar to the previous ones. The last part is the output gate, which decides what information to output. The function of the sigmoid function is similar to the previous which decides the output degree of each input. The cell state is put through a tanh function and then pointwise multiplication with O t as the output of LSTM. Its equation can be described as Formulas (5)-(7).
where C(t) is the cell state at time t, and represents the point-wise multiplication operation. The meanings of other parameters are similar to the previous ones. The above analysis shows that x t and h t are the input and output of LSTM, respectively; f t , i t , g t , and O(t) are intermediate variables in the calculation process; , W oh , and b o are the weights determined in the training process; σ(·) and tanh(·) are activation functions; C(t) records the cell state at time t, which is initialized as 0.
• DLSTM Figure 3 and Formulas (2)-(7) describe a single-layer LSTM. Figure 4 describes a twolayer DLSTM. In the two-layer DLSTM, the first-layer LSTM's output is passed to the second-layer LSTM and used as input. The input vector goes through the two-layer DLSTM layer by layer to jointly determine the output of the two-layer DLSTM. In general, DLSTM is a sequence LSTM that decides the output together. Its structure is shown in Figure 5. SSA is a swarm intelligence optimization algorithm inspired by the foraging and anti-predation behaviors of sparrow populations, which Xue proposed in 2020 [37]. It has strong optimization capabilities and fast efficiency and was widely welcomed as soon as it was proposed. After simplifying and idealizing the biological characteristics of sparrow populations during foraging, the authors concluded the following rules.

1.
Sparrow populations typically divide during foraging into subpopulations called producers and scroungers. The criteria for classification are according to the fitness value of individual sparrows. Producers usually have better fitness values, while others are scroungers. Producers are primarily responsible for finding food and have larger search areas to provide foraging areas and directions for the entire sparrow population. Scroungers follow the producer's location to find food; 2.
Some individuals in the population have a strong anti-predation ability, called scouters. When scouters detect danger, they will act against predation; 3.
Producers and scroungers can dynamically switch in each generation according to their fitness values, but the number of individuals in these two subpopulations remains the same; 4.
Some scroungers may monitor producers and compete for food, while some starving scroungers may look elsewhere for food; 5.
When aware of the danger, the fittest sparrow will randomly approach others, and others will move toward the best sparrow.
Assume that there are a total of N sparrow individuals in the population, each with d dimensions/elements. This sparrow population can be represented as an expression (8). Each row of the matrix represents a sparrow individual.
The mathematical expression of SSA can be summarized as follows. Updating Producer Location where x t i,j is the j-th dimension of the i-th individual in the t-th iteration of the producers; j = 1, 2, . . . , d, where d is the dimension of the sparrows; iter max is largest number of iterations; α is a random value in the range of (0, 1]; Q is a random value from a normal distribution; R 2 ∈ [0, 1] is the alarm value; ST ∈ [0.5, 1] is the safety threshold; R 2 < ST means there is no danger around the producer, and they will continue their extensive search; and R 2 ≥ ST means there is danger around the producer and they will fly to other safe areas. Updating Scroungers Location where x t best,j and x t worst,j are the j-th dimension of the individual with the best and worst fitness in the t-th iteration, respectively; n is the total number of sparrows; A is a d dimensional vector, each element of which is randomly 1 or −1, and A + = A T (AA T ) −1 ; L is a d dimensional vector, each element of which is a 1; i > n 2 means that the fitness of i-th scrounger is poor, it will fly to other places for food; and i ≤ n 2 means that the i-th scrounger is likely to forage around the best individual. Updating Scouters Location where β is a random number that follows a normal distribution; K is a random number that obeys a uniform distribution and K ∈ [−1, 1]; is a very small constant to ensure the denominator is not 0; f i , f b , and f w are the i-th individual's fitness, the best fitness, and the worst fitness in the t-th iteration, respectively; and f i = f b and f i > f b denote whether the sparrow is the individual with best fitness or not in the t-th iteration, respectively. When they feel danger, they follow Rule 5 to perform the corresponding actions, respectively.
• ISSA Although the original SSA has strong optimization ability and fast efficiency, it easily falls into the local optimum [38][39][40]. The foraging area and direction of the entire sparrow population mainly depend on the producers, so we need to expand the explo-ration range of the producers to improve the foraging ability of the entire population. The improvement of ISSA mainly comes from the following three aspects.

1.
Introducing self-adaptive hyper-parameters to producers: In Formula (9), the update position of the producer is affected by exp(− i α·iter max ). When α is a random value, as i becomes larger, the value range of exp(− i α·iter max ) becomes (0, 0.4), where iter max = 1000. It is shown in Figure 6. We introduce the adaptive weight w shown by Formula (12) to improve the producer's search speed and global search ability.
where w 0 = 1 is initial weight; c is set to 0.9. After adding the adaptive weight w, the producers' formula is changed to Formula (13).

2.
We Introduce the Lévy flight (LF) mechanism, which is widely used to overcome the premature convergence problem [41,42]. In the LF algorithm, the random walk is used to tune local search capabilities. The formula of LF is shown in Formulas (14) and (15).
where M LF and N LF are random numbers that obey a Gaussian distribution; β = 1.5; and Γ(·) is Gamma function. After the introduction of the LF algorithm, Formulas (13) and (10) are changed to (16) and (17) 3.
The sparrow individuals with the best fitness are directly passed on to the next generation. Its purpose is to ensure that the population's overall quality does not decline.
The workflow of ISSA is similar to SSA. The difference is that producers and scroungers obey different formulas in SSA and ISSA, respectively. Moreover, the individual with the best fitness in the last generation replaces the individual with the worst fitness in the current generation in ISSA. Here, we present the workflow by the example of ISSA. The workflow of ISSA is shown in Figure 7.

Fusion Algorithm
It was introduced in the last section that ISSA is similar to SSA. In this section, we present the fusion algorithm by the example of DLSTM + ISSA. The fusion algorithm can improve the accuracy and generalization ability of the temperature drift model. The workflow of DLSTM + ISSA is shown in Figure 8, and its steps can be described as follows:

1.
We randomly generate N groups values as the initial parameters of DLSTM. Each group of parameters represents a solution of DLSTM. Each group of parameters contains d elements, where d is the total number of parameters. These N groups of parameters have the same form as expression (8) and are used to train the DLSTM.

2.
We train the DLSTM until the ending condition one is met; that is, the accuracy of the DLSTM meets requirements or reaches preset cycles of the DLSTM training. At this time, new N group parameters are obtained. If the accuracy meets the requirements, we finish training and export the optimal parameters. Otherwise, new N groups of parameters constitute the initial population of the ISSA.

3.
The ISSA is used to evaluate and improve the parameters in the population further until ending condition two is met. That is, the accuracy of the DLSTM meets the requirements or reaches preset cycles of the ISSA.

4.
We export the optimal results.

PLA Model
The PLA method uses the MEMS accelerometer's temperature and TDO as the input and output of the PLA model, respectively. The model can be described as follows: where X(t) and Y(t) are the input and output of the PLA model at time t, respectively. U(t) and T(t) are the TDO and temperature output of the MEMS accelerometer at time t, respectively. F L [·] is the target function to be trained. The framework of the PLA model is shown in Figure 9.

PLA Algorithm
The MEMS accelerometer continuously outputs the TDO and the measured internal temperature value during the experiment. The measured internal temperature increases as the temperature rises in the temperature-controlled oven. Consider each temperature (T(t)) and its corresponding MEMS accelerometer's TDO (U(t)) as a whole ([T(t), U(t)]). Divide the data set ([T, U]) evenly into intervals over the entire temperature range according to the temperature. In this paper, we divide the data set into ten intervals, that is [T 1 (t), U 1 (t)], . . . , [T 10 (t), U 10 t)]. It is fitted separately according to Formula (19) in each interval.
where X(t) and Y(t) are the input and output of the formula at time t, respectively. U(t) and T(t) are the TDO and temperature output of the MEMS accelerometer at time t, respectively., and k and b, respectively, denote the slope and intercept of the linear function. Ten sets of k and b and nine temperature split points will be calculated using the PLA algorithm to fit the training data. The temperature values in the validation data set are first determined by which temperature range they belong to according to the temperature split points. The predictions are then calculated by combining the corresponding PLA parameters.

Results and Analysis
This paper used a calibrated GNC Module to experiment, during which the data collecting process lasted at least 2 hours, and more than 1,440,000 data were obtained. We collected two sets of TDO of a MEMS accelerometer under the same condition, one for training the model proposed in this paper, named training data, and the other for validating the performance of the previously obtained model, named validation data. In this way, we verified the compensation effect of the proposed methods in this paper at a heating rate of 1°C/min. Therefore, the two data sets have similar characteristics with at least half an hour between experiments. The experimental scheme is described in Section 2.2. The training and validation process on the proposed model are both based on a CPU. All the simulations and analyses in this paper were carried out in Matlab.
We performed 5 s smoothing on the training data in the training process to remove noise caused by data fluctuations. The hidden layers' node numbers were both ten. The DL-STM's maximum number of iterations was set to 500. The preset cycles of SSA and ISSA were both 200. The learning rate was 0.02. The initial population of DLSTM had ten individuals. Figure 10 shows the simulation results of the training data. From Figure 10, we can see that all four methods simulate the training data well, in which the bias of the DLSTM + SSA method is the largest. At this time, we obtained three set global optimal parameters of the DLSTM by the three methods and a set global optimal parameters of the PLA. Then, we apply the four models newly obtained from training data on validation data to verify their effectiveness. We perforedm 0.5 s smoothing on the validation data to ensure its diversity. Figure 11 shows the fitting results, and Figure 12 shows the compensation results. From Figures 11 and 12, all of the methods work well except for the bias of the DLSTM + SSA method.
Furthermore, we introduce Allan variance to analyze the compensation results quantitatively. Allan variance is a standard and popular method for analyzing the performance of inertial sensors [26,43,44]. Figure 13 shows the compensation results of Allan variance analysis by the four methods, and Table 1 shows the corresponding quantitative results. Here, we mainly focus on the three Allan coefficients: bias instability (B), rate random walk (K), and rate ramp (R).     Figure 13 shows that the DLSTM + ISSA method shows the best compensation performance, further confirmed by Table 1. Table 1 shows that after compensation by the four methods, the three Allen variance coefficients increased by an average of 89.36%, 90.85%, 96.68%, and 17.94%, respectively. The results also prove the effectiveness of the proposed method.

Conclusions
This paper investigates a MEMS accelerometer's temperature drift compensation methods based on DLSTM, DLSTM + SSA, and DLSTM + ISSA. First, we proposed a real-time compensation model, a recursive method. Then, DLSTM was established to improve the accuracy of the temperature drift compensation model. DLSTM + SSA and DLSTM + ISSA were used to optimize the parameters of DLSTM to improve its precision, where ISSA was an optimization algorithm for SSA. Moreover, the linear approximation model and PLA method were also used to compare with the proposed methods in this paper. Finally, Allan variance analysis was used to quantify the compensation results, showing that all three methods had excellent performance of which DLSTM + ISSA was the best. The PLA method has little compensation effect in this application. The results of Allan variance analysis showed B from 5.43 × 10 −4 to 2.77 × 10 −5 , K from 4.33 × 10 −5 to 1.14 × 10 −6 , and R from 1.18 × 10 −6 to 2.63 × 10 −8 after compensation by DLSTM + ISSA. These three coefficients have an average improvement of 96.68%.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript: