**1. Introduction**

The LiFePO4 battery has advantages such as good safety, long service life, and high power density, and so on [1,2], which is widely used in electric vehicles and energy storage systems. To prevent battery failures such as overcharging and over-discharging, it is necessary to monitor the battery operating status in real time, especially its state of charge (SOC).

The methods of accurate SOC estimation can generally be categorized into the following types: open-circuit voltage, ampere-hour integral-based estimation method, datadriven-based estimation method, and filtering algorithms based on equivalent circuit models [3–5]. There is a monotonic one-to-one correspondence between the open-circuit voltage and the SOC value of the battery. The corresponding table of open-circuit voltage and SOC can be established, and the SOC value can be determined by looking up the table [6]. However, this method requires a long time after the battery is charged and discharged before measuring the open-circuit voltage. Reference [7] proposed a fast opencircuit voltage prediction method. The battery only needs to be placed within 15 min to accurately predict the open-circuit voltage. However, the calculation process is complex, and the requirements for the processor are high. The ampere-hour integral method tracks the SOC by the change in the current integral value. The measurement error will accumulate in the integral, resulting in a large error of SOC. Reference [8] analyzed the error sources

**Citation:** Xia, Y.; Ye, Z.; Huang, L.; Sun, L.; Jiang, Y. Research on a High-Precision State-of-Charge Estimation Method Based on Forgetting Factor Recursive Least Squares and Adaptive Extended Kalman Filter Applied to LiFePO4 Battery. *Electronics* **2023**, *12*, 3670. https://doi.org/10.3390/electronics 12173670

Academic Editors: Luis Hernández-Callejo, Jesús Armando Aguilar Jiménez and Carlos Meza Benavides

Received: 2 July 2023 Revised: 3 August 2023 Accepted: 4 August 2023 Published: 31 August 2023

**Copyright:** © 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

of the ampere-hour analysis method and proposed a method to reduce the cumulative error of time and the proportional error of the SOC. However, it is more dependent on the current accuracy, and the accuracy of the current sensor is higher.

If the data-driven algorithm is trained properly, it can predict the SOC of any type of battery without knowing its inherent characteristics in advance. Reference [9] proposed a method of predicting SOC via artificial neural network machine learning. The root-meansquared error (RMSE) of the LiFePO4 battery used in this paper is 0.33% during the test cycle. The author of Reference [10] proposed a recurrent neural network (RNN) with long short-term memory (LSTM) to accurately estimate the SOC of lithium-ion batteries, and it can achieve high accuracy at temperatures from 10 ◦C to 25 ◦C. Reference [11] used the support vector machine (SVM) method to estimate the SOC of the battery from the experimental data set, which has high accuracy. In the method of machine learning or deep learning, a data-driven algorithm collects terminal voltage, working current, temperature, and other data in the work of the battery, and it uses neural network and machine learning to train a large amount of data to obtain the current SOC value. This method needs to collect a large amount of data for calculation, which requires a powerful processor and is sensitive to the type of battery. If the internal parameters of the battery change, the data-driven model cannot follow the internal changes well, resulting in a larger SOC estimation error.

The filtering algorithms based on equivalent circuit models mainly use derivative algorithms of Kalman filtering (KF) and particle filtering algorithms for SOC estimation [12–17]. As the most popular model-based method, the KF-based algorithm has enhanced robustness to measurement and process noise and has a high estimation accuracy [18]. Based on the extended Kalman filter (EKF) algorithm, an adaptive dual EKF algorithm is proposed in Ref. [12]; the EKF algorithm is used to improve the nonlinear battery model for SOC estimation in Refs. [17,19] for the LiFePO4 battery. A strong tracking volume EKF algorithm (STEKF) is proposed in Ref. [20] to provide accurate SOC prediction and a faster computing time. A multi-rate strong tracking EKF algorithm (MRSTEKF) is proposed by introducing multi-rate control strategy and enhancement technology in Ref. [21], and the SOC tracking stability and estimation accuracy is improved from 55.34% and 49.51% with STEKF to 52.66% and 33.88% with MRSTEKF, respectively. An online adaptive EKF algorithm based on the Davidson model is used to estimate SOC [22], and the SOC estimation error can be reduced to 2%. The sigma points Kalman filter (SPKF) is another nonlinear system filtering algorithm that can be used to estimate SOC, which uses numerical approximations instead of analytical approximations of EKF. A joint battery model and SOC estimation algorithm based on SPKF is proposed in Ref. [23], which has the same computational complexity as EKF but has higher accuracy. In Ref. [24], a combination of the volumetric Kalman filtering algorithm and the forgetting factor recursive least squares (FFRLS) algorithm is used to estimate SOC, and the maximum estimation error of SOC under high-rate pulses is reduced to be less than 1%. On the other hand, the method of approximating a probability density function based on a particle filter is used to estimate the SOC. In Ref. [25], a volumetric particle filter for accurate SOC estimation is proposed. In Ref. [26], dual-scale, dual-particle, and dual-scale adaptive particle filters for SOC estimation are proposed. However, compared with SOC estimation algorithms based on the Kalman filter, the SOC estimation algorithms based on the particle filter have a larger computational burden [27]. In Ref. [28], an analytical mathematical formulation of storage and its SOC is presented. In Ref. [29], a power allocation strategy based on cluster switching to relieve the stated problem in two levels is proposed, which is used to eliminate the imbalanced SOC and decrease battery energy loss. To address the power allocation challenges, a novel optimized state-of-charge (SOC) feedback-based energy management strategy in Ref. [30] is proposed for HESS in IPS to restrain the DC bus voltage fluctuation in this paper.

In this paper, a FFRLS-AEKF joint estimation algorithm based on time-varying parameter model is proposed, which considers the characteristics that the FFRLS algorithm can update the battery parameters in real time and the AEKF algorithm can correct the initial value error of SOC and follows the parameters of the battery. Firstly, the working principle

of FFRLS for battery parameter identification is analyzed. Secondly, the second-order equivalent circuit state discretization equation based on the AEKF algorithm is established, and the steps of the battery SOC estimation method based on AEKF are discussed. Thirdly, a joint SOC estimation method based on FFRLS-AEKF is proposed. Fourthly, the SOC estimation performance of three methods as EKF, AEKF, and FFRLS-AEKF is compared by experiments. The experimental results show that the FFRLS-AEKF algorithm can have a higher SOC estimation and faster accuracy convergence speed. Finally, the thesis is summarized.

#### **2. The Basic Principle of Parameter Identification Based on the FFRLS**

#### *2.1. Mathematical Modeling of a Second-Order RC Circuit*

The second-order RC equivalent circuit model of the LiFePO4 battery is shown in Figure 1. The two RC circuits, respectively, describe the electrochemical polarization process with a small time constant and the concentration polarization process with a large time constant. Among them, *UOC* is the open-circuit voltage of the battery, *R*<sup>0</sup> is the internal resistance, and *Rp*<sup>1</sup> and *Cp*<sup>1</sup> are the electrochemical polarization internal resistance and electrochemical polarization capacitance, respectively. *Rp*<sup>2</sup> and *Cp*<sup>2</sup> are the concentration difference polarization internal resistance and concentration difference polarization capacitance, respectively. *U*<sup>L</sup> and *I*<sup>L</sup> are load voltage and load current, respectively.

**Figure 1.** Second-order RC model.

According to Figure 1, the state space equation expression of the second-order RC model circuit can be listed as follows:

$$
\begin{pmatrix}
\frac{d\boldsymbol{l}\_{p1}}{dt} \\
\frac{d\boldsymbol{l}\_{p2}}{dt}
\end{pmatrix} = \begin{pmatrix}
0 & -\frac{1}{\mathbb{R}\_{p2}\mathbb{C}\_{p2}}
\end{pmatrix} \begin{pmatrix}
\boldsymbol{U}\_{p1} \\
\boldsymbol{U}\_{p2}
\end{pmatrix} + \begin{pmatrix}
\frac{1}{\mathbb{C}\_{p1}} \\
\frac{1}{\mathbb{C}\_{p2}}
\end{pmatrix} \boldsymbol{I}\_{L} \\
\boldsymbol{U}\_{OC} = \boldsymbol{U}\_{p1} + \boldsymbol{U}\_{p2} + \boldsymbol{R}\_{0}\boldsymbol{I}\_{L} + \boldsymbol{U}\_{L}
\end{pmatrix} \tag{1}
$$

where *dUp*<sup>1</sup> *dt* and *dUp*<sup>2</sup> *dt* represent the electrochemical polarization voltage and the concentration difference polarization voltage, respectively.

#### *2.2. The Basic Principle of the FFRLS*

The traditional recursive least squares (RLS) method is widely used in the field of system identification. For linear systems, its mathematical description can be expressed as follows:

$$\begin{array}{l} \mathcal{Y}(k) = \boldsymbol{\varrho}(k)\boldsymbol{\theta}(k)^{T} + \boldsymbol{e}(k) \\ \boldsymbol{\varrho}(k) = [-\boldsymbol{\Upsilon}(k-1)\cdots - \boldsymbol{\Upsilon}(k-n)\,\boldsymbol{u}(k)\cdots\boldsymbol{u}(k-n)] \end{array} \tag{2}$$

where *Y*(*k*) is the output signal of the system at *k* time, *u*(*k*) is the input signal of the system at *k* time, *θ*(*k*) represents the parameter vector to be estimated, *ϕ*(*k*) is the input matrix of the system at time *k*, *n* is the parameter to be estimated, and *e*(*k*) is the noise of the system. The recursive formula of the FFRLS method is as follows:

$$\begin{array}{l} \hat{\theta}(k+1) = \hat{\theta}(k) + K(k+1)[Y(k+1) - \boldsymbol{\varrho}^T(k+1)\boldsymbol{\theta}(k)]\\ K(k+1) = P(k+1)\boldsymbol{\varrho}(k+1) \\ P(k+1) = P(k) - \frac{P(k)\boldsymbol{\varrho}(k+1)\boldsymbol{\varrho}^T(k+1)}{1 + \boldsymbol{\varrho}^T(k+1)P(k)\boldsymbol{\varrho}(k+1)} \end{array} \tag{3}$$

In Equation (3), *P*(*k*) is the covariance matrix, and *K*(*k*) is the gain matrix. During the recursive process, RLS uses the difference between the estimated value and the measured value of the system output, as well as the gain matrix *K*(*k*), to make adjustments to the parameter vector ˆ *θ*(*k*). During initialization, the initial value of ˆ *θ*(*k*) and *K*(*k*) can be any value, *P*(0) = *αI*, *α* is as large as possible a constant, and *I* is the identity matrix.

To reduce the influence of past data and give greater weight to new data, a forgetting factor is introduced by setting it to *λ*(0 < *λ* < 1), leading to the development of FFRLS [31,32]. Equation (3) is modified as follows:

$$\begin{array}{l} \hat{\theta}(k+1) = \hat{\theta}(k) + K(k+1)[y(k+1) - q^T(k+1)\hat{\theta}(k)]\\ K(k+1) = \frac{P(k)q(k+1)}{\lambda + q^T(k+1)P(k)q(k+1)}\\ P(k+1) = \frac{1}{\lambda}[1 - K(k+1)q^T(k+1)]P(k) \end{array} \tag{4}$$

Equation (4) is a recursive formula based on the forgetting factor recursive least squares method, where the forgetting factor *λ* is generally taken between 0.95 and 1. The larger the value of *λ*, the smaller the weight of new data. When *λ* = 1, it degenerates into the ordinary RLS method.
