Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 12, No. 3, 2024 1 Study on Second‐order RC Model Charge State Estimation Method for Lithium Battery Based on EKF Algorithm Changchang Li1, a 1School of Shipping, Shandong Jiaotong University, Weihai 264200, China. a1430564954@qq.com Abstract: In order to improve the estimation accuracy of the state of charge (SOC) of lithium-ion batteries, this paper proposes a SOC estimation method based on the second-order RC equivalent circuit model and the extended Kalman filter (EKF) algorithm. Firstly, the second-order RC equivalent circuit model is selected as the research object in this paper, and the parameters of the second-order RC model are identified by combining the hybrid pulse charging and discharging test and the 1stopt software, and then the extended Kalman filtering algorithm is applied under the MATLAB environment to estimate the SOC based on the second-order RC equivalent circuit model. The simulation results show that the adopted estimation method can accurately track the SOC trend of the battery compared with the actual state-of-charge (SOC) reference value. Through experimental analysis, the estimation results of the EKF algorithm combined with the second-order RC equivalent circuit model have a small error with the actual value, and the estimation accuracy is high and ideal. Keywords: Lithium battery, state of charge, battery equivalent circuit model, extended Kalman filter algorithm. 1. Introduction Lithium-ion batteries are widely used in electric vehicles, portable electronic devices and energy storage systems due to their high energy density, long life and environmental friendliness. However, in order to ensure the safety and longevity of batteries, it is crucial to accurately estimate their state-of-charge (SOC), which reflects the amount of charge remaining in the battery and is one of the core parameters in a battery management system (BMS)[1]. Accurate SOC estimation not only prevents overcharging or overdischarging, but also improves energy utilization and extends battery life[2]. Currently, common SOC estimation methods include open circuit voltage method, ampere-time integration method, Kalman filtering method and so on. However, the complex electrochemical characteristics of Li-ion batteries make these methods have certain limitations in practical applications, such as the open-circuit voltage method requires a long time of resting, and the ampere-time integration method is susceptible to cumulative errors. The extended Kalman filter (EKF) algorithm has become one of the popular methods for SOC estimation in recent years because of its ability to deal with nonlinear systems and dynamic noise[3]. The EKF algorithm is able to utilize real-time measurements for state estimation according to the dynamic characteristics of the battery, and thus has a better performance in nonlinear and unsteady battery systems. In battery modeling, the equivalent circuit model has become one of the commonly used models for SOC estimation due to its low computational complexity and its ability to effectively capture the dynamic characteristics of the battery. In particular, the second-order RC equivalent circuit model can more accurately describe the voltage dynamic response of the battery and provides an effective state-space model for SOC estimation. However, it is a challenge to obtain accurate model parameters. In this paper, the internal parameters of the battery are accurately identified by using 1stopt software and combined with the EKF algorithm to build a simulation model for SOC estimation in MATLAB[4]. The aim of this paper is to propose an accurate and robust SOC estimation method for lithium batteries by combining the second-order RC equivalent circuit model with the EKF algorithm. Through experimental and simulation validation, we analyze the performance of the method under real working conditions and evaluate its potential application in battery management systems. 2. Lithium Battery Equivalent Model and Parameter Identification 2.1. Equivalent modeling of lithium battery Battery models can effectively simulate the operating characteristics of lithium-ion batteries during the charging and discharging process, which is crucial for the analysis, management and control of the battery state. An accurate battery model can not only better reflect the electrochemical processes inside the battery, but also provide a solid foundation for the accurate estimation of the battery state of charge (SOC)[5]. In this paper, the Thevenin equivalent model and the RC parallel network are chosen to characterize the polarization reaction of the battery, and this model can effectively describe the dynamic characteristics of the battery during charging and discharging, especially its nonlinear features. In order to better simulate the polarization process and dynamic response behavior of batteries, especially in the transition stage of battery charging and discharging, a model that can accurately reflect the polarization process is needed. Therefore, in this paper, the second-order RC equivalent model is selected based on balancing the model accuracy and computational resources. By introducing two RC parallel networks, the second-order RC model is able to more accurately describe the complex dynamic response behavior 2 of lithium-ion batteries during the polarization process, especially the performance of the characteristics under multiple time constants[6]. Compared with the first-order RC model, the second-order model is able to capture more information about the battery dynamics, thus better reflecting the battery characteristics under fast charging and discharging conditions and improving the overall accuracy of the model. As shown in Fig. 1, the open-circuit voltage of the battery is denoted as UOC, the resistor R0 represents the internal resistance of the battery, U0 is the voltage across the ohmic internal resistance, I is the load current of the battery, and Vb while is the terminal voltage of the battery. The two RC networks in the model consist of resistor R1R2, and capacitor C1C2, respectively, which are used to characterize the polarization process and dynamic properties of the battery at different time constants. The corresponding voltage sums represent the dynamic responses of the two RC networks. With these two RC parallel networks, the second-order RC model is able to capture the complex electrochemical processes inside the battery while maintaining a low computational complexity[7].   Figure 1. Second-order RC equivalent circuit model for lithium batteries It follows from Kirchhoff's law: b oc 1 2 0V U U U IR    (1) 1 1 1 1 d d U U C I t R   (2) 2 2 2 2 d d U U C I t R   (3) The SOC of a lithium battery is defined as the ratio of its residual capacity to its rated capacity, and is calculated by the following formula: 00SOC( ) SOC( ) dt t n I t t t Q     (4) Where:t-time;SOC(t)-t moment lithium battery SOC value;SOC(t0)-t0 moment lithium battery SOC value;η- Coulomb efficiency,η=1;Qn-rated capacity of lithium battery. 2.2. Parameter identification 2.2.1. Battery SOC-OCV relationship curve Before the SOC estimation of Li-ion battery, it is necessary to identify the parameters of its equivalent circuit model, and the Li-ion battery with a saturation voltage of 4.2V, a cut-off voltage of 2.5V, and a capacity of 2000mA-h is taken as the object of the study. First of all, we refer to the “FreedomCar Power-Assisted Battery Test Manual” to carry out the hybrid pulse power characterization (HPPC) experiments on the lithium battery at a constant temperature of 25℃, and the purpose of the experiments is to determine the relationship between the UOC and the SOC of the lithium battery and to identify the parameters of the lithium battery model. Firstly, the mixed pulse power characterization (HPPC) experiment is carried out for Li-ion batteries at a constant temperature of 25℃ with reference to “FreedomCar Power Assisted Battery Test Manual”, and the purpose of the experiment is to determine the relationship between UOC and SOC of Li-ion batteries and identify the parameters of Li-ion battery model[8]. The relationship equation of SOC-OCV is obtained through the HPPC experiment, and the curve is shown in Fig. 2.   Figure 2. SOC-OCV relationship graph 3 A 5th order polynomial was fitted to the SOC-UOC curve to characterize the functional relationship between UOC and SOC: 5 4 3 2 ( ) 5.947 19.12 23.14 12.25 3.207 3.249 OCV SOC SOC SOC SOC SOC SOC            (5) 2.2.2. Joint 1stopt software parameter identification Based on the experimental data obtained from the Hybrid Pulsed Power Characterization (HPPC) test experiments, we first selected the end voltage data for the segment of SOC from 100% to 90% and imported these experimental data in MATLAB. Next, variables with time as the horizontal coordinate and terminal voltage as the vertical coordinate were created and the data were simplified as necessary for fitting analysis[9]. Subsequently, the CurveFitting toolbox of MATLAB was utilized to select a custom fitting function for fitting analysis, which was in the form of an exponential function. In order to further improve the fitting accuracy, we can optimize the other four unknown parameters in the model with the help of 1stOpt software to determine the initial value of the optimization, and the obtained optimization parameters are then returned to MATLAB for initialization and final determination of the parameter values. The same steps can be used for other SOC intervals, and the corresponding resistance, capacitance and other parameters are solved sequentially to construct a complete battery equivalent circuit model. The parameters are identified using 1stopt software and the fitted relational equation in MATLAB, and the results of parameter identification are shown in Table 1. Table 1. Parameter identification results SOC /OCU V 0 /R  1 /R  1 /C F 2 /R  2 /C F 0.1 3.4677 0.341 0.013 10199 0.01341 171585 0.2 3.5555 0.238 0.00783 6583 0.00616 212834 0.3 3.599 0.231 0.02 5196 0.01297 98493 0.4 3.626 0.227 0.01466 11058 0.01345 135971 0.5 3.6649 0.228 0.008 7554 0.00066 71314 0.6 3.7536 0.2373 0.02883 3892 0.00245 739292 0.7 3.840 0.2445 0.02598 6249 0.01767 107143 0.8 3.940 0.231 0.02254 7501 0.03153 51096 0.9 4.05 0.228 0.017 11316 0.03436 33884 3. SOC Estimation Methods 3.1. The anharmonic integral method The ampere-time integration method is one of the basic methods for SOC estimation. The principle is to estimate the SOC change of the battery by measuring the charge and discharge currents of the battery and time integrating the currents. The method relies on current sensor measurements and is based on the initial SOC value and rated capacity of the battery. The method is simple, easy to implement, and suitable for real-time SOC estimation. However, it is susceptible to the accuracy of the current sensor and noise, and there is a cumulative error, especially when running for a long period of time, the estimation accuracy may decrease. It is suitable for applications requiring real-time current monitoring in battery management systems, and is usually used in systems where the initial SOC is calibrated periodically by other methods[10]. 3.2. Open-circuit voltage method The open-circuit voltage method is based on the relationship between the open-circuit voltage (OCV) of the battery and the SOC. By measuring the terminal voltage of the battery in the resting state, the SOC can be estimated based on the OCV-SOC curve.This method requires less battery modeling, but requires the battery to be in the resting state to avoid the effect of dynamic current. When the battery is at rest for a long time, the estimation accuracy is high and is not affected by the cumulative error. However, it requires the battery to be at rest, so it is not suitable for real-time SOC estimation in dynamic environments. The relationship between OCV and SOC may be flatter in some SOC intervals, which affects the estimation sensitivity. It is suitable for application scenarios such as energy storage systems and standby power supplies that are stationary for long periods of time, and is usually used in combination with other methods to improve the estimation accuracy under dynamic operating conditions[11]. 3.3. Kalman filter Kalman filtering is a dynamic method based on state estimation, which is capable of updating SOC estimates in real time by combining the current, voltage, and temperature information of the battery. The common Extended Kalman Filter (EKF) and Untraceable Kalman Filter (UKF) can handle the nonlinear behavior of the battery, and continuously update and optimize the SOC estimation through the fusion of the dynamic model and measurement data. It can estimate SOC with high accuracy under dynamic working conditions, has strong robustness, and is suitable for real-time applications. However, it requires an accurate battery model, more complex algorithms, and high computational resource requirements. Widely used in electric vehicles, UAVs and other real-time dynamic operation systems, especially in the battery operation environment complex and rapidly changing scenarios with excellent performance[12]. 4 4. SOC Estimation of Lithium Battery Based on Extended Kalman (EKF) Algorithm 4.1. Extended Kalman (EKF) Algorithm The KF algorithm is only applicable to linear systems, for nonlinear systems, it is necessary to linearize the nonlinear system, and then use the KF algorithm for state estimation, this filtering method is called the EKF algorithm.The EKF can deal with the nonlinear relationship between the voltage and the SOC in the estimation of the SOC of Li-ion batteries, and it can adapt to the complexity of the battery system by approximating the real value through the first-order linearization of the nonlinear equations[13]. Extended Kalman filtering (EKF) is a state estimation method for nonlinear systems. The relationship between SOC and voltage and current of Li-ion battery is usually nonlinear, and EKF can effectively estimate SOC by approximating the nonlinear system to be processed as a linear system.The working principle of EKF is divided into two main steps: 1. Prediction stage: The EKF first predicts the next moment value of SOC based on the state space model of the battery. The state-space model is usually based on an equivalent circuit model of the battery (e.g., a second-order RC model), where the input variable is current, the output variable is voltage, and the state variable is SOC. Predictive equations: | 1 1 1 1ˆ , )ˆ(k k k k kx f x u w     (6) where (.)f is the nonlinear equation of state of the battery, is | 1ˆk kx  the predicted SOC, ku is the input current, and kw is the system noise. 2. Update phase: In the update phase, EKF uses the actual measured voltage data, combined with the model's predicted values, to update the SOC estimate by minimizing the error between the predicted and measured values. Specifically, EKF calculates the covariance of the SOC estimation error, which in turn updates the SOC estimate to make it closer to the true value. Update the equations: | | 1 | 1 )ˆ (ˆ ˆ( , )k k k k k k k k kx x K y h x u    (7) where (.)h is the measurement equation, kK is the Kalman gain, ky is the actual measured voltage value, and |ˆk kx is the updated SOC.The EKF dynamically tracks the SOC value of the battery through an iterative prediction and update process. 4.2. EKF algorithm to estimate SOC The extended Kalman filter algorithm is used to estimate the SOC of lithium batteries. The iterative procedure of the extended Kalman filter is written directly in the m-file of MATLAB, and the initial value of SOC is defined as 0.5, which is used to verify the convergence of the EKF algorithm. Experimental discharge data of the battery, including current and voltage, are loaded and analyzed to introduce random noise to simulate the measurement error. The real value of SOC is calculated by the ampere-time integration method, which is used to compare with the SOC estimated by EKF. The simulation results are shown in Fig. 3, Fig. 4. Figure 3. Comparison of terminal voltage error under EKF algorithm 5 Figure 4. Comparison of SOC errors under EKF algorithm Figure represents the simulation results. Blue color indicates the true values of SOC and OCV, and pink color indicates the SOC and OCV values estimated by the extended Kalman filter. It can be seen that when the initial values are inaccurate, the extended Kalman filter still converges to the neighborhood of the true values very quickly. The end voltage error is about 0.1 V and the SOC error is about 5%. The error between the simulated estimated SOC and the actual measured SOC fluctuates within a certain range, verifying the accuracy of the touch-fit model. 5. Conclusion In this paper, an equivalent circuit model of the second- order RC equivalent circuit of a lithium battery is established, and the parameters in the model are identified using matlab joint 1stopt, and a simulation model of the lithium battery and the iterative process of the extended Kalman filter are established in Matlab. The measured currents and voltages were input into the model, and the SOC values obtained from the extended Kalman filter were compared with the actual values, which showed that the algorithm was able to estimate the SOC values effectively. References [1] Tan Zefu, Sun Rongli, Yang Rui, et al. A review of the development of battery management system [J]. Journal of Chongqing University of Technology (Natural Science), 2019, 33(9):40-45. [2] Genxing Liao, Yingying Zhao, Yanfeng Gao, et al. Model parameter identification and charge state estimation of lithium- ion batteries[J]. Power Supply Technology, 2021, 45(9):1136- 1139. [3] HONG Yu-Tong, HONG Han-Chi, LIN Yi-Hang. Modeling simulation for identifying charge state parameters of automotive lithium-ion batteries[J]. Journal of Xiamen Institute of Technology, 2020, 28(3): 9-14. [4] Li Xiaofeng. Identification of SOC-related parameters of lithium-ion battery based on MATLAB[J]. Electrotechnical Materials, 2021(5):25-28, 34. [5] Jiang Qin, Zhang Xuanxiong. Model parameter identification and charge state estimation of lithium-ion battery for electric vehicles[J]. Electronic Science and Technology, 2020, 33(2):32-36. [6] Wang Shifan, Luo Yang, Dong Liang, et al. Offline identification of the parameters of the second-order Thevenin lithium battery equivalent model [J]. Electronic Design Engineering, 2018, 26(9):46-49. . [7] Li Huan, Wang Shunli, Zou Chuanyun, et al. Research on SOC estimation based on Thevenin model and adaptive Kalman [J]. Automation Instrumentation, 2021, 42(1):46-51. [8] Fan Bin, Ren Shan, Luo Yunjun. SOC-OCV relationship of lithium-ion batteries under actual use conditions [J]. Power Supply Technology, 2018, 42(5):641-644. [9] Li Tianfeng, Yi Yingping. Research on model parameter identification of lithium-ion battery for electric vehicles[J]. Software Guide, 2021, 20(10):117-123. [10] SONG Lei,LU Chunguang,LIU Lin,et al. Estimation of lithium iron phosphate battery state of charge based on modified ampere-time integration method[J]. Journal of Zhengzhou University: Engineering Edition, 2023, 44(6):84-90. [11] ZHANG Yuanhui, LIU Peiqi, SI Fengmiao, et al. Estimation of the state of charge of lithium batteries for electric vehicles[J]. Technology and Markets, 2023, 30(7):56-58. [12] MONG Yonglong, AI Xuezhong, ZHENG Wei, et al. Prediction of lithium battery charge state based on adaptive traceless Kalman filtering algorithm[J]. Chemical Automation and Instrumentation, 2024, 51(2):294-300. [13] Fu Rong. Study on nonlinear factors for SOC estimation of lithium-ion battery based on EKF [D]. Changchun:Jilin University, 2019.