State of Charge (SOC) Estimation Based on Extended Exponential Weighted Moving Average H ∞ Filtering

: When the classical H ∞ algorithm (HIF) is applied to estimate the state of charge (SOC) of a lithium battery, the inﬂuence of historical data is usually ignored, resulting in an increase in the estimation error. In order to improve the accuracy of SOC estimation, this paper proposes an extended exponential weighted moving average H ∞ algorithm (EE-HIF) in view of the inﬂuence of historical data. By designing the Gaussian function, the weighted distribution of the data at different times can effectively reduce the estimation error caused by the inaccuracy of the lithium battery model. In addition, when the system contains Gaussian white noise and alternating current input, the proposed method can achieve a faster convergence speed and better robustness. Simulation results show the advantages of the proposed algorithm, as compared to an HIF ﬁltering algorithm and an exponentially weighted moving average H ∞ algorithm (EWMA).


Introduction
Lithium batteries are widely used in electric vehicles and energy storage capacity configurations due to their high energy density, low self-discharge rate, long service life, and low pollution. The Battery Management System (BMS) is one of the core technologies in electric vehicles (EV) and energy storage systems [1]. State of charge (SOC) estimation is a significant factor of BMS performance, which is the basis of battery thermal management and safety management [2,3]. Accurately estimating the SOC can avoid over-discharged or over-charged situations to protect the battery from explosions or fire, which can improve the performance and prolong the lifetime of the battery.
At present, a variety of SOC estimation methods have been proposed. Each estimation method has its own advantages and disadvantages. The ampere-hour integral method [4,5] only needs to measure the battery current, so it is easy to implement on-board. However, this method needs an accurate initial SOC and a high current sampling rate to avoid cumulative errors. The open circuit voltage method [6] is another common method of SOC estimation. This method is based on the relationship between open circuit voltage (OCV) and SOC, and the disadvantage of this method is that the battery needs to be left for a period of time, which is not suitable for real-time estimation of the SOC of a lithium battery. The neural network [7,8] method is also one of the commonly used methods of SOC estimation in engineering. The calculation step of this method depends on the training data. In order to ensure estimation accuracy, a large amount of data needs to be trained. The complexity of this algorithm is relatively high and it is not suitable for practical application.
As a common state estimation algorithm, the Kalman filter (KF) algorithm [9] is applied to the estimation of SOC. The disadvantage of KF is that when the model is not accurate, the estimation accuracy and robustness of the Kalman filter algorithm cannot meet the requirements. The extended Kalman filter (EKF) uses the minimum mean square error as the best criterion [10,11], and it can estimate SOC with an inaccurate initial value of SOC. However, due to the highly nonlinear state space of the battery, the SOC obtained by using this method cannot meet the requirements of high-precision estimation. The unscented Kalman filter [12] uses statistical linearization to reduce errors in the differential and computational quantities. However, the SOC estimation accuracy is still subject to the battery mode and the influence of type accuracy. The H ∞ algorithm [13][14][15][16] designs the cost function from the perspective of game theory to minimize the error norm. The advantage of the use of the H ∞ algorithm for SOC estimation is that this method is suitable for cases where the model is unknown. However, it ignores the influence of historical data. Due to the neglect of historical data, the estimation error of this method will increase. When the model accuracy is not high, the estimation error and convergence speed are unsatisfactory.
The above methods have been widely used in SOC estimation, but there are still some problems. For example, the negligence of historical information will increase the estimation error of SOC. A model with low accuracy will result in unsatisfactory estimation accuracy and convergence speed. The current SOC estimation algorithm is difficult to balance in terms of the estimation accuracy and robustness, as well as the complexity of the algorithm. In response to the above problems, this paper establishes the first-order Thevenin circuit model of the lithium battery, uses current pulse experiment to identify the parameters of the first-order Thevenin model, draws on the idea of exponential weighting, and proposes an extended exponential weighted algorithm.
The core idea of the exponential weighted moving average (EWMA) theory [17,18] is that the degree of influence of historical data on estimation results decreases with time and distance. In other words, the recent data have a greater impact on estimation than do the long-term data. Therefore, the weight of each historical datum is allocated by the principle of considering the time priority, and the weighting process is performed in chronological order. The historical data can be used to estimate the SOC of a lithium battery more accurately. On this basis, the extended exponential weighted moving average H ∞ (EE-HIF) algorithm realizes adjustment by changing the standard deviation of the Gaussian function, which effectively overcomes the shortcomings of the exponentially weighted moving average H ∞ algorithm with a slower convergence speed when the weighting coefficients differ greatly. Compared with the H ∞ (HIF) algorithm and the EWMA algorithm, the EE-HIF algorithm is expected to improve the accuracy of SOC estimation and the robustness of the algorithm. At the same time, the complexity of the algorithm is within an acceptable range [19]. In the case of increased system model errors and alternating current input, the advantage of the EE-HIF algorithm is more obvious than the advantages of EWMA and HIF.

Model Establishment
There are many commonly used lithium battery models [20][21][22][23]. Among them, the Thevenin model not only has the characteristics of simple operation, but also reflects the dynamic and static characteristics of lithium batteries. Figure 1 shows the first-order Thevenin model selected in this article. In Figure 1, U is the terminal voltage of the lithium battery, U oc is the open circuit voltage of the lithium battery, I is the operating current of the lithium battery, R 1 is the ohmic internal resistance of the lithium battery, R 2 is the polarization internal resistance of the lithium battery, C is the lithium battery's internal resistance Polarized capacitance, and U c,k is the voltage across capacitor C at time step k. The state-space equation of the first-order resistor-capacitor (RC) model is: where T is the sampling period, SOC k represents the SOC of the lithium battery at time step k, and Q 0 represents the rated capacity. x k = SOC k , U c,k T is the state variable of the system, u k = I k represents the control input of the system, and y k = U k represents the output of the system. w k is the system noise and its covariance is q k , v k is the observation noise of the system and its covariance is r k , and the statistical characteristics of the system noise and the observation noise are unknown. The system matrix, input matrix, output matrix and direct transfer matrix in the state space model of lithium battery are, respectively, Therefore, the first-order model of lithium battery can be expressed as:

Acquisition of SOC-OCV Curve
This experiment takes a ternary lithium-ion battery with a rated voltage of 3.6 V and a rated capacity of 36 Ah as the test object. There is a nonlinear relationship between the open circuit voltage U oc of the battery and the SOC of the battery [24], which plays a very important role in the battery energy management system [25][26][27]. In order to obtain the function relationship between open circuit voltage and SOC (SOC-OCV), we conducted experiments on the charge and discharge characteristics of the battery at a rate of 0.5 C [28] under an experimental environment of 25 • C [29]. By utilizing SOC-OCV experimental data, the constant current discharge of nine equidistant pulses was selected. The stable battery terminal voltage was regarded as the open circuit voltage. Due to the hysteresis of the SOC-OCV of the lithium battery, the open circuit voltage in the charged state will be slightly higher than the open circuit voltage in the discharged state. In order to reduce the experimental error, high-level fitting was performed on the SOC-OCV curve during discharging of the lithium-ion battery, and the average value of the open circuit voltage was selected as the fitting data, as shown in Figure 2. Through the use of curve fitting, an eighth-order polynomial equation for the open circuit voltage with respect to SOC is derived as follows:

Model Parameters Identification
During the experiment, the rated voltage and rated capacity of the battery can be obtained directly, while other parameters cannot be measured directly and need to be obtained through current pulse experiment. The aim of this method in this experiment is to reduce the discharge current to zero when the battery gets to a constant current discharge and to determine the value of the parameter by the change of the voltage of the battery's terminal voltage. The experimental current and voltage diagram as shown in    Figure 3 shows the voltage and current variation curves through the test. Figure 4 shows the curve of voltage parameter while SOC = 0.9. After 40 min of resting, when the battery is almost stable internally, the voltage U 0 is the open circuit voltage U oc . Figure 4 shows that at the moment of t 1 and t 2 , it is the voltage mutation at the end of the lithium-ion battery that is caused by the ohmic resistance R 1 , which is calculated as shown in Equation (4).
where ∆U = U 0 − U 1 is the change of voltage across R 1 at the instant when the discharge current I disappears. ∆U = U 1 − U 2 illustrates the potential change at both ends of RC loop power off, which can be used to obtain R 2 via Equation (5).
In the period from t 1 to t 2 , the terminal voltage of the lithium-ion battery slowly decreases from U 1 to U 2 . This is the process by which the discharge current charges the polarized capacitor, which is the zero-state response phase of the dual RC circuit. The terminal voltage equation is shown by the Equation (6).
τ is the time constant of RC network,τ = R 2 C. τ can be calculated via Equation (6). C can be calculated via Equation (7).
The corresponding parameters of the experiment can be acquired by using the MAT-LAB CFTool according to the above equations.
According to the results of parameter identification, the Thevenin model of the battery was established by using the MATLAB toolbox Simscape. The difference between the real terminal voltage and the simulated terminal voltage with the input current is defined as the terminal voltage error, which is used to reflect the accuracy of the model. The terminal voltage error curve obtained through simulation is shown in Figure 5.
It can be seen from Figure 5 that the terminal voltage error is only 0.01, while the average error and maximum error of the first-order model are 0.0054 and 0.0517, respectively. In general, the parameter identification results of the Thevenin model have high accuracy under the stage discharge test conditions, indicating that the identification method is feasible and effective.

HIF Algorithm
The recursive formula of the classic H ∞ algorithm is shown in Equation (8): In Formula (8), δ is the set performance boundary, K k is the filter gain vector, P k is the second-order prediction covariance matrix, S k is a symmetric positive definite matrix that can be customized, x − k is the prior value of x k , and x + k is the posterior value of x k . The HIF algorithm is to minimize the cost function to obtain the best estimate. The core idea is to find the balance between the target and the estimation. The goal is to select the appropriate process noise and measurement noise to the maximum. The HIF algorithm can effectively estimate the SOC of a lithium battery system with uncertain noise and is not affected by the initial value. However, because the HIF algorithm only takes the state at the current moment to estimate the state at the next moment, and ignores all previous data, the accuracy of the SOC estimation is not high.

EE-HIF Algorithm
In order to process current data and historical data reasonably, we first must introduce the exponential weighted moving average theory. According to the idea of the EWMA algorithm, it achieves the effect of making full use of historical data for accurate estimation and for the purpose of effectively controlling the mean drift in the estimation process [30].
In the EWMA algorithm, the weighting coefficient of each number decreases exponentially with time. The advantage is that there is no need to save the past data. The formula of the EWMA algorithm is: Transform Equation (9) to get Equation (10): In the lithium battery SOC state estimation, as shown in Equations (9) and (10), µ represents the constant weighting coefficient, where 0 < µ < 1. x k represents the exponential weighted estimation value at time k. The role of x k is to replace x + k for estimation. Equations (9) and (10) are the theoretical basis for lithium battery SOC state estimation. This model is suitable for data with no obvious fluctuations in the overall trend.
Analyzing Equation (9), we can see that the EWMA algorithm model is a recursive model, and expanding it results in Equation (11).
In Formula (11), n represents a certain historical moment. Analyzing Equation (11), we can see that x k is the exponential weighted estimation value obtained by the weighted average of historical data, and the weighting coefficients are, respectively, µ, µ(1 − µ), µ(1 − µ) 2 , · · · , µ(1 − µ) j , · · · , and µ(1 − µ) n from near to far in time, since (1 − µ) is for a constant in the range of 0 to 1, and it is easy to find from the nature of the exponential function that is larger than the historical moment n as the weighting coefficient value becomes smaller. In other words, the longer the historical moment, the smaller the weighting coefficient.
For the limit of the weighting coefficient expressed by Equation (11), we can get: When estimating the SOC of the lithium battery, the sum of the weights shall satisfy The EWMA method calculates the average of the data in the past period of time with different weights; the closer to the time k, the greater the weight. It can be seen from Equation (9) that the magnitude of constant weighting coefficient µ determines the influence proportion of x k−1 and x + k on the exponentially weighted estimation value x k . Equation (10) shows that x k is an estimated value obtained by correction on the basis of x k−1 . The constant weighting coefficient µ can be regarded as a correction coefficient for the estimation error, which can be reasonably controlled. Although the EWMA algorithm effectively reduces the influence of historical information on the estimation of lithium battery SOC, the convergence speed of the algorithm is relatively slow when the difference between µ and (1 − µ) is relatively large because the filter cannot allocate the weight reasonably at this time. In order to deal with the shortage of constant weighting coefficient µ more effectively, this paper proposes the use of the EE-HIF algorithm. The selection of the exponential weighting coefficient µ k is a variable that obeys Gaussian distribution, and the distribution characteristics of the Gaussian function [31,32] are used to allocate the weight reasonably and improve the algorithm convergence speed. At the same time, Equations (9) and (10) correspond to Equations (14) and (15).
The expression of µ k is shown in Equation (16).
According to Equation (16), σ represents the standard deviation of the Gaussian function. The size of σ determines the shape of the Gaussian function; the smaller the σ, the narrower the graph of the Gaussian function, and the larger the σ, the wider the graph of the Gaussian function. Selecting an appropriate value of σ can make the EE-HIF algorithm not only have better smoothing characteristics but also effectively maintain the edge structure of the original curve, making the SOC estimation result fluctuate around the true value in a small range. On the one hand, it can reduce the lag deviation caused by the EWMA algorithm estimation when the data fluctuates in this way, and on the other hand, it can improve the convergence speed of the algorithm. The exponential weighting coefficient µ k is a variable whose size depends on the difference between x k and x + k . The image of the Gaussian function is normally distributed. The nature of the normal distribution shows that if the difference between x k and x + k is larger, the value of µ k is smaller and the exponential weighted estimation value is closer to x k−1 ; if the difference between x k and x + k is smaller and the value of µ k is larger, the exponential weighted estimation value is closer to x + k . When this information is combined with Equations (8) and (14)- (16), one can obtain the EE-HIF algorithm, as shown in Equation (17): According to Equation (17), x 0 , P 0 is the initial value set.

Comparative Analysis of the EWMA and HIF Algorithms
In order to improve the accuracy of battery SOC estimation, this paper conducted follow-up experiments at a discharge rate of 0.5 C at 25 • C through the previous discussion. Through the battery charging and discharging experiments under the set working conditions, the advantages of estimating the SOC of lithium batteries based on the extended exponential weighted H∞ algorithm were verified. The initial value of SOC is set to 0.8, S(k) is the unit matrix, and δ is 10 4 . In EWMA, when there is a significant difference between the constant weighting coefficient µ and (1 − µ), the convergence speed of the algorithm will be relatively slow, so µ should not be too small or too large. Moreover, in order to reflect the effect of exponential weighting, we hope that the estimation results are more inclined to x k−1 , so we take µ = 0.4 for simulation. In the HIF algorithm, we found that, after many experiments, the best satisfactory estimation result could be obtained when setting δ = 10 4 . Figures 6 and 7 show the estimated state curve and estimated error curve of the HIF and EWMA algorithms, respectively.  It can be seen from Figures 6 and 7 that the estimation accuracy and the convergence rate of the EMWA algorithm can be more obvious than that of the HIF algorithm by proper selection of the constant weighting coefficient. However, since µ and (1 − µ) are constants, the estimation accuracy and convergence rate of the algorithm cannot be controlled more accurately. In order to deal with constant weighting coefficient µ more flexibly, we set µ k as a variable that obeys Gaussian distribution.

Comparative Analysis of Three Estimation Methods of the EE-HIF, EWMA, and HIF Algorithms
When using the EE-HIF algorithm to estimate the SOC of a lithium-ion battery, the selection of the standard deviation σ is very critical. If σ is selected to be too small, it is difficult for the filter to track the original curve of SOC; if σ is too large, the filter tends to diverge. In the EE-HIF algorithm, the width of the Gaussian function is determined by the standard deviation σ. Choosing an appropriate small value of σ obtains a narrower Gaussian function image. At the same time, the narrower the frequency band of the Gaussian filter, the less signal is allowed to pass. Therefore, the bandwidth of the filter can be controlled by adjusting the standard deviation of the Gaussian function, so that the estimated value of the EE-HIF algorithm fluctuates around the true value in a small range. So, the effect of effectively assigning the filter weight is achieved, and the impact of historical data is reduced. Through many experiments, the standard deviation σ = 0.1 is selected in the simulation, and the filter can estimate the SOC of the lithium battery more accurately. The simulation step size was set to 0.1 s, with a total time of 35,000 s. By appropriately selecting the standard deviation of the Gaussian function, the EE-HIF algorithm can not only improve the convergence speed of the filter but also improve the accuracy of the estimator. At the same time, the cyclic iterative method is used to estimate the SOC of the lithium battery and the internal resistance of the model, and the parameters are estimated and updated in real time, which effectively overcomes the problem of model drift caused by time-varying parameters.
In order to verify the superiority of the EE-HIF algorithm with high estimation accuracy and good robustness, Figures 8 and 9 show the SOC state estimation curve and the estimation error curve of three estimation methods, respectively. The maximum error, root mean square error (RMSE), convergence speed, and computational time are shown in Table 1. Among them, the standard deviation of the Gaussian function is σ = 0.1 in the EE-HIF algorithm, and µ = 0.4 in the EWMA algorithm. It can be clearly seen from Figures 8 and 9 that by adjusting the weighted descent speed, although the convergence speed of the EMWA algorithm has been improved, the convergence speed of the EE-HIF algorithm is faster. Moreover, compared to the HIF and EMWA algorithms, the EE-HIF algorithm has a higher estimation accuracy. It can be seen from Table 1 that, compared with the HIF and EWMA algorithms, the maximum error, RMSE, and convergence speed of the EE-HIF algorithm are more satisfying. According to the above analysis, it can be seen that the EE-HIF algorithm effectively reduces the impact of historical data. While ensuring the convergence speed of the algorithm, it effectively reduces the SOC estimation error and has better robustness.   By comparing the three estimation algorithms, it can be found that the EE-HIF algorithm has the highest estimation accuracy and the fastest convergence speed. The RMSE of the EE-HIF algorithm is 0.0065, which is 55% of that of the EMWA algorithm and 47% of that of the HIF algorithm. However, compared with the other two algorithms, the complexity of the EE-HIF algorithm is slightly increased. The computational time is measured by a computer simulation process. It can be seen from Table 1 that the computational time of EE-HIF is 5.08 s, which is 107% of that of the EWMA algorithm and 126% of that of the HIF algorithm. The complexity of the EE-HIF algorithm is within an acceptable range. Therefore, the EE-HIF algorithm represents a better trade-off between accuracy and computational time for online SOC estimation.
In the whole estimation process, the estimation result of the EE-HIF algorithm can effectively maintain the edge structure of the original curve, suppress the nonlinear characteristics of the lithium battery system and the influence of time-varying parameters, and improve the estimation accuracy of the lithium battery SOC. On the one hand, the EE-HIF algorithm considers the influence of historical data and solves the shortcoming of low estimation accuracy of the HIF algorithm. On the other hand, the Gaussian distribution is applied to overcome the shortcoming of slow convergence speed of the EMWA algorithm by setting the weighted descent rate more flexibly. The EE-HIF algorithm overcomes the shortcomings of the EMWA algorithm. It can be used as a promotion of the HIF algorithm, and can also be used to modify the EWMA algorithm.

Comparative Analysis of the Three Estimation Methods (EE-HIF, EWMA, and HIF) When the Model Error Increases
In order to verify the advantages of the EE-HIF algorithm on the basis of experimental data, Gaussian white noise (current bias) with an average value of 50 mA was added. Figure 10 shows the terminal voltage curve when Gaussian white noise with an average value of 50 mA is added. Figures 11 and 12 show the estimated state curve and the estimated error curve of the three methods under Gaussian white noise with a mean value of 50 mA, respectively. It can be seen from Figure 10 that after adding 50 mA of Gaussian white noise, the model error increases significantly. In the simulation, the standard deviation σ = 0.1 is used in the EE-HIF algorithm. At this time, the image of the Gaussian function is relatively narrow, and the simulation results are more satisfactory. Next, we set µ = 0.4 in the EWMA algorithm. At this time, the weighting coefficients in the EWMA algorithm are not much different, and the filtering effect is better than it was before. The estimation accuracy of the EE-HIF algorithm can be clearly seen by comparing Figure 11. It is significantly higher than that of the other two methods. Although the estimation error tends to increase after adding 50 mA Gaussian white noise, the mean square error of the EE-HIF algorithm can be controlled within 0.3. It can be clearly seen from Figures 11 and 12 that the EE-HIF algorithm has a faster convergence rate than do the other two methods. Therefore, when the interference noise increases and the model accuracy is not high, compared with the HIF and the EWMA algorithm, the EE-HIF algorithm has a greater improvement in terms of estimation accuracy and robustness.

Estimation under Variable Current
In many practical application scenarios, the discharge of lithium-ion batteries is not constant. The following experiment simulates the acceleration and braking process of an electric vehicle during driving, and the current change process is shown in Figure 13. With the input current i(t) changing as shown in Figure 13, EE-HIF, EWMA, and HIF are used to estimate the SOC of the lithium battery. Figure 14 shows the relative error between the estimated curve and the ideal curve. It can be seen from Figures 13 and 14 that the input current changes cause obvious errors in the estimation process of the three methods. The working current does not change significantly in the first 10 min, and the estimation error of the EE-HIF algorithm does not exceed 4%. The working current changes significantly between 10 and 30 min, and the estimation error of the EE-HIF algorithm also increases at this moment. The working current gradually decreases and stabilizes between 30 and 80 min and the estimation error first increases and then decreases due to EE-HIF tracks the reference curve. In the entire estimation process, the estimation error of EE-HIF is within 7% while those of HIF and EWMA have a larger fluctuation. Therefore, the estimation effect of EE-HIF is better than that of the other two methods under an alternating current input for lithium battery systems.

Conclusions
This paper combines the first-order RC circuit model of a lithium-ion battery with the EE-HIF algorithm to propose a new SOC estimation method. On the one hand, this method uses the idea of exponential weighting to achieve the effect of the reasonable distribution of historical data weights. On the other hand, the Gaussian function is used to adjust the weighted descent rate for weight distribution and error correction for data at different times, which improves the estimation accuracy of the SOC and the convergence speed of the algorithm. The experimental analysis shows that the estimation accuracy of the EE-HIF algorithm is significantly higher than that of the HIF algorithm. In the estimation process of the EE-HIF algorithm, by appropriately selecting the variance of the Gaussian function, the convergence speed of the filter can be improved, and the limitation of the slow convergence speed of the EWMA algorithm when the weighted drop rate is distributed unevenly is improved. When the system model error increases, the EE-HIF algorithm can still maintain a high estimation accuracy and good robustness. The simulation results verify the effectiveness of the algorithm. This algorithm should make an important contribution to the field of electric vehicles and energy storage.

Data Availability Statement:
The authors confirm that the data supporting the findings of this study are available within the article.

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

Nomenclature
The abbreviations and variable symbols in the paper are as follows: the state variable of the system x k exponential weighted estimation value x − k the prior value of x k x + k the posterior value of x k y k the output of the lithium battery system u k control input of the battery system R resistance of lithium battery system C capacitance of lithium battery system T sampling period I operating current of the lithium battery Q 0 the rated capacity of the lithium battery