A Battery SOC Estimation Method Based on AFFRLS-EKF

The lithium-ion battery is the key power source of a hybrid vehicle. Accurate real-time state of charge (SOC) acquisition is the basis of the safe operation of vehicles. In actual conditions, the lithium-ion battery is a complex dynamic system, and it is tough to model it accurately, which leads to the estimation deviation of the battery SOC. Recursive least squares (RLS) algorithm with fixed forgetting factor is widely used in parameter identification, but it lacks sufficient robustness and accuracy when battery charge and discharge conditions change suddenly. In this paper, we proposed an adaptive forgetting factor regression least-squares–extended Kalman filter (AFFRLS–EKF) SOC estimation strategy by designing the forgetting factor of least squares algorithm to improve the accuracy of SOC estimation under the change of battery charge and discharge conditions. The simulation results show that the SOC estimation strategy of the AFFRLS–EKF based on accurate modeling can effectively improve the estimation accuracy of SOC.


Introduction
The main purpose of the battery management system (BMS) is to ensure the safe operation of the batteries [1]. State evaluation of a battery, including state of charge, state of health, and state of life, is a critical task for a BMS. As the power source and energy storage equipment in the actual operation of electric vehicles, the battery will carry out continuous charging and discharging operations, and the battery state remains changing. It is very important to predict the battery status in advance to adjust the battery management system in time and ensure the safe operation of the battery. As a key power source for hybrid electric vehicles, accurate acquisition of SOC is very important to improve the dynamic performance of the battery and optimize the energy management strategy [2,3]. Model-based SOC estimation is an important research direction. However, battery SOC is affected by many factors such as actual working conditions, ambient temperature, battery aging, and self-discharge rate [4], accurate modeling is difficult, which leads to the difficult problem of high-precision SOC estimation.
There is much research literature on battery SOC estimation methods. Ampere-hour measurement method is one of the traditional SOC estimation algorithms. Due to the unknown initial value of SOC and the existence of an integral part, the estimation error will gradually accumulate with the increase of the battery running time, so the ampere-hour measurement method is usually combined with other estimation algorithms [5,6]. The open-circuit voltage method [7] and the internal resistance characteristic method [8] have a good performance, however, it requires the battery to stand for a period, which is not conducive to online calculation. The estimation accuracy of battery SOC is also affected by actual battery working conditions. The extended Kalman filter (EKF) has been successfully applied for the estimation of SOC in HEV BMSs. The traditional Kalman filter (KF) is used for linear problems, while EKF linearizes the prediction by using partial derivatives and Taylor series expansion [9]. The influence of acquisition accuracy of voltage, current, and other signals on SOC estimation is discussed in the view of the hardware [10]. To reduce the initial error of the Coulomb counting method (CCM), the SOC can be calculated accurately by applying the battery efficiency to the open-circuit voltage (OCV) [11]. The application of machine learning (ML) in the BMS of LIB has long been adopted for efficient, reliable, accurate prediction of several important states of LIB such as state of charge, state of health, and remaining useful life [12]. Electromagnetic interference (EMI) of battery management systems (BMSs) will cause measurement errors of current and voltage signals, which will affect the performance of BSM [13][14][15][16][17][18][19]. For the situation that battery working conditions change rapidly, a recursive calculation method based on the Kalman filter is adopted [20][21][22]. The algorithm considers the battery as a dynamic system, and the filter performs state recursion according to the input (current, voltage, temperature, etc.) to obtain the estimated value of SOC. The method has a strong suppression effect on noise and is suitable for the condition of rapid current variation. However, the algorithm involves complex matrix inversion operation, and the calculation accuracy depends on the precise battery model. As the temperature changes and the battery ages, the internal and external characteristics of the battery will change. To improve the accuracy of the battery dynamic model, it is necessary to identify the battery parameters online [23]. The recursive least squares (RLS) algorithm is an easy algorithm to implement. However, with the increase of data, phenomena such as data saturation will occur, and it cannot be used for parameter identification well. Moreover, due to its fixed forgetting factor, the robustness of the system is poor when disturbed [24]. The least-square algorithm with a forgetting factor (FFRLS) adds a forgetting factor on the basis of RLS algorithm to solve the problem of data saturation [25,26]. Battery parameter identification based on RLS and SOC estimation algorithm based on EKF is widely used [27][28][29][30]. In Literature [27], the model parameter identification deviation caused by current and voltage measurement noise was compensated to improve the parameter identification accuracy to improve the SOC estimation accuracy. In literature [28], decoupled double estimators were used to estimate SOC and battery capacity, and different time scales were used to improve the accuracy and stability of the model. A SOC estimation algorithm combining variable factor RLS and CKF was proposed in the literature [29] to effectively improve the accuracy of estimation. Considering SOC constraints and estimation errors, the literature [30] introduced gain factors based on EKF algorithm, and the proposed algorithm has good effects in terms of accuracy, convergence speed, and robustness.
However, none of the above methods focuses on the SOC estimation under the condition of battery charging and discharging state changes. When the current charging and discharging state changes, the battery system is disturbed, resulting in inaccurate parameter estimation which affects the accuracy of the modeling of the equivalent circuit of the battery, thus affecting the accuracy of battery SOC estimation. In order to improve the estimation accuracy of battery SOC, a precise modeling method based on parameter identification was proposed under the condition of battery charging and discharging state changes. An adaptive forgetting factor regression least-squares algorithm (AFF-RLS) was designed to improve the model parameter identification accuracy, and then the battery SOC is estimated by the extended Kalman filter algorithm.
The main contributions of this paper are as follows: 1.
The paper proposed an AFFRLS-EKF SOC estimation strategy based on parameter identification modeling aiming at the uncertainty of battery model parameters under the condition of abrupt change of battery charge and discharge.

2.
The second-order Thevenin equivalent circuit model (2-order ECM) of the battery was established, and the SOC-OCV relationship was obtained. According to the charging and discharging conditions, a segment-adaptive recursive least square algorithm was designed to identify the parameters to improve the model accuracy.

3.
The proposed estimation strategy is applied to numerical simulation experiments, and RLS-EKF and AFFRLS-EKF are compared. The latter one has better performance in accuracy and robustness.

Equivalent Circuit Model
The battery is a complex electrochemical system. An accurate description of battery internal and external characteristics is one of the solutions to improve the accuracy of battery SOC estimation. In order to accurately describe the battery characteristics, the electrochemical model [31][32][33], equivalent circuit model [34][35][36], electrochemical impedance model [10], and other model-based methods were proposed to solve the SOC estimation problem. The more accurate the battery model is to simulate the electrochemical processes that occur during the battery operation, the more accurate the model will be. The equivalent circuit model has been widely used due to its better model accuracy and higher computational efficiency [37]. Combined with the model accuracy, calculation amount, and feasibility analysis, the equivalent circuit model second-order Thevenin model is adopted. The second-order RC model can simulate the electrochemical polarization and concentration polarization of the battery, which is one of the most common models of lithium batteries in the actual operation of vehicles. Compared with the first-order Thevenin model, it can more accurately describe the actual characteristics of the battery. Figure 1 shows a second-order Thevenin equivalent circuit model. gorithm was designed to identify the parameters to improve the mod 3. The proposed estimation strategy is applied to numerical simulatio and RLS-EKF and AFFRLS-EKF are compared. The latter one ha mance in accuracy and robustness.

Equivalent Circuit Model
The battery is a complex electrochemical system. An accurate descri internal and external characteristics is one of the solutions to improve battery SOC estimation. In order to accurately describe the battery cha electrochemical model [31][32][33], equivalent circuit model [34][35][36], elect pedance model [10], and other model-based methods were proposed to estimation problem. The more accurate the battery model is to simul chemical processes that occur during the battery operation, the more accu will be. The equivalent circuit model has been widely used due to its bet racy and higher computational efficiency [37]. Combined with the mode culation amount, and feasibility analysis, the equivalent circuit mode Thevenin model is adopted. The second-order RC model can simulate th cal polarization and concentration polarization of the battery, which is o common models of lithium batteries in the actual operation of vehicles. C the first-order Thevenin model, it can more accurately describe the actua of the battery. Figure 1 shows a second-order Thevenin equivalent circuit  As shown in Figure 1, when current I flows out of the positive electrode, the battery is in a state of discharge; otherwise, the battery is in a state of charge. V oc is the battery's open-circuit voltage (OCV) which represents the nonlinear relation with the SOC of the battery. R s is the ohmic resistance of the battery that represents the contact resistance between the electrode material and the electrolyte. The first RC network describes the polarization characteristics with R 1 , C 1 standing for polarization resistance and polarization capacitance, respectively. The second RC circuit illustrates the dynamic behavior of the battery along with concentration polarization, in which R 2 , C 2 represents the concentration polarization resistance and capacitance, respectively. V T is the terminal voltage that can be measured directly.
We can fit the OCV-SOC relationship by using the OCV-SOC test, and the test results are shown in Table 1 [38]. Literature [39] studied the influence degree and computational complexity of temperature, data points, and aging degree on the lithium battery open-loop voltage model. The 11th-order polynomial fitting was selected, and the functional relationship between VOC and SOC was obtained as follows: The curve-fitted SOC-OCV correlation are shown in Figure 2.
The curve-fitted SOC-OCV correlation are shown in Figure 2. According to Kirchhoff's voltage law, the circuit terminal voltage T V is expressed as follows:

VOC(V)
where 1 V represents the battery electrochemical polarization voltage, which is described as Equation (3). 2 V represents the battery concentration polarization voltage, which is described as Equation (4).
After modeling the Li-battery with Equations (2)-(4), the Li-battery model can be expressed in state-space equation form as follows: According to Kirchhoff's voltage law, the circuit terminal voltage V T is expressed as follows: where V 1 represents the battery electrochemical polarization voltage, which is described as Equation (3). V 2 represents the battery concentration polarization voltage, which is described as Equation (4).
After modeling the Li-battery with Equations (2)-(4), the Li-battery model can be expressed in state-space equation form as follows: where C represents the capacity of the Li-battery (Ah). The battery model parameters are greatly affected by the system model and external disturbance. The RLS algorithm can accurately capture the real-time characteristics of the system by regularly correcting and updating the system parameters. Therefore, Equation (5) can be expressed in the s-domain as follows: where s is for the frequency operator.
To ensure the consistency of system stability before and after transformation, the function was transformed from the s domain to the z domain by the bilinear transformation method.
Substitute Equation (7) into Equation (6) and simplify to obtain the discrete transfer function of the system. Matlab solves the change from the s domain to the z domain to obtain the transfer function of Z domain, as shown in Equation (8).
where {b i |i = 0, 1, 2 } , a j |j = 1, 2 are the parameters to be identified. The relationship between model parameters and parameters to be identified is as follows: 4(a 1 +a 2 −1) T is the sample time. Equation (8) can be rewritten in the difference equation form as: where Therefore, Equation (10) can be rewritten as follows in matrix form: with, Equations (10)-(13) will be used in the RLS algorithm to estimate model parameters. Then the battery model parameters can be obtained by Equation (9) after θ(k) is estimated.

Adaptive Forgetting Factor Regression Least Squares
RLS can reduce the influence of application environment uncertainty on the system model and model parameters by periodic parameter correction and updating, to achieve the accurate acquisition of real-time characteristics of the system. In the RLS algorithm, the forgetting factor is a very important parameter, whose value will affect the convergence rate and sensitivity to noise of the algorithm [24]. Therefore, in this paper, the forgetting factor adaptive recursive least square method is used to estimate the parameters. When the battery charge and discharge conditions change suddenly, the adaptive forgetting factor is introduced to adjust the confidence ratio of the recursive model to the old data and the new data, to realize the accurate estimation of the model parameters. For the system model to be identified as shown in Equation (11), the recursion formula of the recursive least squares algorithm with forgetting factor is described as Equation (14) [40]: where, k = 1, 2, 3, . . . ,θ(k) andθ(k+1) are the identifiable vectors of order k and order k + 1 respectively, I is the identity matrix, λ is a constant forgetting factor in the range of 0 to 1, K(k+1) is the correction gain vector, P(k+1) and P(k) are the covariance matrices of order k and order k + 1, respectively. When the battery charging and discharging conditions change suddenly, the system disturbance is large, and the instantaneous error of the parameters to be estimated is large, which affects the stability of the system. Therefore, the forgetting factor λ is designed to reduce the instantaneous error of the estimated parameters and increase the stability of the system. Since λ varies within the range of 0-1, the higher its value is, the stronger the anti-interference ability of the system will be. When the current change exceeds a certain value, it indicates that the current changes from charging state to discharging state or from discharging state to charging state. The rules for detecting current zero crossing are as follows: where, δ indicates whether the charging state of the battery has changed, δ= 1 represents the battery changing from charging state to discharging state or the battery changing from discharging state to charging state, δ= 0 indicates that the battery remains charged or always remains discharged, min(|I(k)|, |I(k − 1)|) is the smaller of |I(k)| and |I(k − 1)|. In order to increase the robustness of the system, an adaptive weighting factor λ(k) is introduced, which is adjusted according to the status of the current charge and discharge and the magnitude of identification error Extended Kalman filter (EKF) can make the optimal estimation of the target state under the minimum variance, which is often used in SOC estimation of lithium iron phosphate batteries. For the nonlinear system, the state equation of discrete space is as follows: where x k represents the state of the system at time k, x k ∈ R n , u k represents the control variable, z k represents the measurement vector, z k ∈ R n , ω k and υ k represent process noise and measurement noise, respectively, ω k and υ k are uncorrelated and subject to Gaussian distribution, Q k and R k are covariance, f (·) and h(·) are nonlinear functions. Firstly, the nonlinear functions f (·) and h(·) are linearized, The extended Kalman filter algorithm is shown in Table 2. 1 Parameter initialization: Where x 0 represents the initial state value, P 0 represents the initial covariance,x − k+1|k represents the k + 1 prior estimate, P k+1|k represents the k + 1 prior covariance, P k|k represents the k prior covariance, K k+1 represents the Kalman gain of k + 1,x k+1 represents the k + 1 posterior estimate, P k+1|k+1 represents the k + 1 covariance.
In combination with the forgetting factor adaptive least squares parameter identification and EKF algorithm, the battery SOC estimation strategy is shown in Figure 3. In combination with the forgetting factor adaptive least squares parameter identification and EKF algorithm, the battery SOC estimation strategy is shown in Figure 3.

Simulation Results and Analysis
The current curve is shown in Figure 4, and the terminal voltage curve is shown in Figure 5.

Simulation Results and Analysis
The current curve is shown in Figure 4, and the terminal voltage curve is shown in Figure 5. voltage remains unchanged, with slight changes due to the soft changes in the terminal voltage caused by the discharge phenomenon in the R 1 C 1 circuit and the R 2 C 2 circuit. charge state changes to the open-circuit state. When ti = 333 min, the battery changes from open-circuit state to charging state. The battery state changes at ti = 416 min, 500 min, 666 min, 833 min, 916 min, 1000 min, 1166 min, 1333 min, and 1416 min, respectively. The battery terminal voltage curve is shown in Figure 4, In the battery charging time interval, the measured value of the battery terminal voltage increases, while the voltage at the end of the discharge interval decreases. In the open circuit interval of the battery, the terminal voltage remains unchanged, with slight changes due to the soft changes in the terminal voltage caused by the discharge phenomenon in the R1C1 circuit and the R2C2 circuit.   As can be seen from Figure 6a, the error of terminal voltage is large at several t i moments when the battery state changes, indicating that when the battery state changes, the estimation of parameters by the general least square algorithm fluctuates greatly, with the maximum error reaching 9.3789 V. When the battery state remains unchanged, the performance of the least square algorithm is high, and the estimation error of terminal voltage is kept within 0.2 V, as shown in Figure 6b. Based on parameter estimation, EKF is used to carry out SOC estimation. The SOC estimation results are shown in Figure 6c,d. At several special t i moments when the battery state changes, the parameter estimation error is large and the SOC estimation error suddenly increases. In the time interval when the battery state remains unchanged, the parameter estimation effect is good, but the SOC estimation error is relatively weak.
The estimation results of the AFFRLS-EKF algorithm proposed in this paper are shown in Figure 7.
Set the initial value θ 0 = [0.4 0.26 0.22 − 0.065 − 2.0481], P 0 = 10 3 * E 5 , where E 5 is the fifth-order identity matrix. The simulation was carried out in Matlab, and the results were shown in Figures 6 and 7. Substitute the estimated results of parameters R S , R 1 , R 2 , C 1 , and C 2 into Equation (4) to calculate the estimated terminal voltage V T . By comparing the estimated V T with the actual measured V T , the estimation accuracy of terminal voltage can reflect the estimation accuracy of each parameter.
As can be seen from Figure 7a, the estimation result of terminal voltage is very good. Even at the moment of battery state suddenly change, the estimation error of terminal voltage is less than 0.1 V, which greatly reduces the transient error of terminal voltage Sensors 2021, 21, 5698 9 of 12 estimation at the moment of battery state sudden change. As can be seen from Figure 7b, the voltage estimation error is less than 0.0439 V in the battery state retention time interval. It is shown that the proposed AFFRLS-EKF algorithm can not only improve the dynamic performance but also improve the estimation accuracy in a steady state. It can be seen from Figure 7c that the estimation effect of SOC is very good, and the estimation error is kept within 2.3%.  As can be seen from Figure 6a, the error of terminal voltage is large at several ti moments when the battery state changes, indicating that when the battery state changes, the estimation of parameters by the general least square algorithm fluctuates greatly, with the maximum error reaching 9.3789 V. When the battery state remains unchanged,

Conclusions
Aiming at the inaccurate estimation of battery parameters caused by the change of current charging and discharging state, this paper proposes a forgetting factor adaptive least-square parameter identification algorithm. Based on the accurate identification of the second-order equivalent circuit model, the battery SOC is estimated by combining with EKF. Compared with the RLS-EKF algorithm, the algorithm proposed in this paper can better suppress the estimation error of terminal voltage when the battery state changes and improve the estimation accuracy of SOC during the steady-state.
The current flowing through series lithium-ion batteries must be strictly equal, but differences between series batteries can cause the battery to overcharge or discharge during the charge and discharge process [41,42]. This will make a significant impact on battery life, battery safety, and battery capacity utilization efficiency. In order to ensure the consistency of the voltage between the series battery cells, it is very important to balance the charge and discharge. In a BMS, a battery equalizer is used to achieve voltage consistency between series-connected battery cells. Therefore, the influence of voltage consistency between battery cells in series on the state estimation of the battery management system will be considered in the subsequent research.