SOC Estimation of Lithium-Ion Battery Based on Kalman Filter Algorithm for Energy Storage System in Microgrids

State-of-charge (SOC) is one of the vital factors for the energy storage system (ESS) in the microgrid power systems to guarantee that a battery system is operating in a safe and reliable manner for the system. Many uncertainties and noises, such as nonlinearities in the internal states of a battery, sensor measurement accuracy and bias, temperature effects, calibration errors, and sensor failures, pose a challenge to the accurate estimation of SOC in most applications. This study makes two contributions to the existing literatures. First, a more accurate extended Kalman filter (EKF) algorithm is proposed to estimate the battery nonlinear dynamics. Due to its discrete form and ease of implementation, this straightforward approach could be more suitable for real applications on the ESS. Second, its order selection principle and parameter identification method are illustrated in detail. It can accurately demonstrate the characteristics of the lithium-ion battery to show the feasibility and effectiveness of the algorithm for the ESS.


Introduction
One of the most remarkable differences between traditional energy production and distribution systems and present ones is that most of the power generation is decentralized to smaller plants located near the end-use points called microgrids. A microgrid is a localized physical space that consists of distributed power generation, storage, and consumption. The need for achieving a balance between the electric power generation and the demand of consumers has added to the emergence of smaller power generation and demand environments, in which the adaptation of production to load can be performed much more dynamically due to their distributed smaller elements and the geographical proximity of all elements in the microgrids.
The most important techniques is the energy storage components for using energy later, and the energy storage system (ESS) on the grid for various purposes, such as grid stability, peak shaving, and renewable energy time shifting. The batteries play a significant role in the microgrids. Due to the volatility, flammability and entropy changes, batteries have a potential to ignite or even explode when overcharged. The solutions to all these problems lie not only in battery technologies, but also the management systems for the batteries. The battery management system (BMS), which integrates the battery system with the rest of the power train, plays a vital role in improving the battery performance, safety, and reliability. Meanwhile, the accurate estimation of state-of-charge (SOC) is one of the main tasks of the BMS, which will help improve the system performance, reliability, and safety, and will also lengthen the lifetime of the battery. In fact, the precise SOC estimation of the battery can avoid unpredicted system interruptions and prevent the batteries from being over charged and over discharged, which may cause permanent damage to the internal structure of the batteries [1].
The SOC means the proportion of released or stored energy from all the battery energy storage. Only when the SOC is estimated precisely, the energy balance can be achieved without damaging the batteries. However, due to a battery's complex internal chemical and physical reactions, the SOC cannot be measured directly and multiple factors should be considered. Thus, it is difficult to estimate the SOC when the battery is working.
The general approach for measuring the SOC is to indirectly estimate both the coulombs and current flowing in and out of the cell stack under all operating conditions and the individual cell voltages of each cell in the stack accurately [2]. The coulomb counting (CC) method, which measures the current flowing into and out of the cell, is the most commonly used estimation method [3], [4]. However, the integral calculation of the current flow has an accumulation error; with the increase in the operating time, the accumulation error will result in a larger SOC estimation error. The other normally used SOC estimation method includes the open-circuit voltage (OCV) method, neural network method, and so on. The OCV method is often used in the battery overhaul rather than the SOC estimation; neural network models are too complicated to train the physical model and to need a plenty of operating data [5].
The method presented in this study is the extended algorithm based on the Kalman filter, which is used to estimate the inner states of any dynamic system. The core of the extended Kalman filter (EKF) algorithm is to propose a precise state describe model, according to the , measurement data, to calculate the values of the objects with the recursive algorithm. Comparing to other algorithms, the EKF algorithm has its own advantages: even if there were errors in the system, self-correction can be down to a certain range and the optimal estimation value can be obtained. The EKF algorithm needs accurate state describe model and accurate measurement values.

Modeling of lithium-ion battery
The purpose of building a battery model is to establish the battery's internal state variables and external quantitative relation electrical characteristics, and to set up the mathematical model. Further, based on the external variables, such as battery voltage, current, and temperature, a battery model helps to calculate the internal state variables, such as SOC, internal resistance, and electromotive force. Many types of battery models were proposed to guarantee the precision in the previous literatures [2,4]. An equivalent circuit model [5] of them to represent schematically a chemical reaction inside a lithium-ion battery pack is shown in Fig. 1. The bulk capacitance (C b ) represents the battery pack storage capacity, and the surface capacitance (C d ) represents the battery diffusion effects to describe the cell's electrochemical polarization and concentration polarization, which reflects the battery transient response of charge or discharge. The resistances R i and R d represent the internal resistance and the polarization resistance, respectively. The voltages across the bulk capacitor and the surface capacitor are denoted by V b and V d , respectively. The battery pack terminal voltage and the terminal current are denoted by V o and I, respectively. The parameters required for the battery model can be determined from the experimental data, where the OCV tests are performed upon the successive discharge of a battery by injecting the current pulses as described in section Ⅳ. This kind of model has a good dynamic performance and can simulate the dynamic characteristics of the lithium-ion battery accurately [6].
According to the Kirchhoff's voltage and current laws, the capacitance voltage variation, and its current relationship, the characteristics of the model in Fig. 1 [4] can be expressed as follows: (3) Since the relationship of OCV and SOC for the lithium-ion battery is only piecewise linear in practice, the voltages across the bulk capacitor can be expressed as where the k and d coefficients are not constant and vary with the battery SOC and ambient temperature. Thus, they can be expressed as These two equations (5) and (6) are indicated as a model of the state and observation equations for the lithium-ion battery pack.
The curve graph of OCV based on the nonlinearity of the SOC can be obtained in Fig. 2.

SOC estimation principle of EKF
In case that the system's state equation is nonlinear, the Kalman filtering method cannot be used directly, i.e., the linearization system equation by using the Taylor series expansion is required; this type of linear equation for the nonlinear model of the Kalman filtering method is called the EKF method [4].
According to (5) and (6) If the system input of a model is defined as u(t) = I and the output is defined as y(t) = V o , then the battery model can be written as In these formulas, w and v represent the system noise and measurement noise, respectively. For (9) and (10) of the nonlinear model, the model after linearization by using the Taylor series expansion is obtained. where For the digital computation of the linearized model of (13) and (14), the system equations for the continuous time equation should be expressed by the discretized time model, as represented in (19) and (20).
where the parameters in both the equations are, where I is the unit matrix and T s is the sampling period, respectively.
As per the above equations, the Kalman filter is an optimal observer whose principle is illustrated in Fig. 3. The principle is to minimize the errors between the estimated and the measured outputs in real time, using a feedback that adjusts the uncertain variables of the used model [7]. By such a model, it is possible to observe the physical parameters of the model that are not accessible to measurements. The correction is weighted by a gain vector K that allows the correction of the dynamics and the performance of the filter. The gain is calculated at each iteration from the error predictions and uncertainties (noise) on the states and measurements. The filter dynamic control is then based on the initialization of the noise matrices of states Q and measurements R, as well as through the initialization of the matrix of error covariance P. To realize the optimal observer as indicated in Fig. 3, the Kalman filter algorithm can be divided into two parts [7] as follows: • Predict system status, system output, and error • Correct the current state estimate value based on the system output value This takes place in two phases: the first phase has the initialization of the matrices P, Q, and R; and the second phase includes observation, which is composed of two steps at each sampling interval [8], as shown in Fig. 4. First, the algorithm predicts the value of the present state, output, and error covariance. Second, by using a measurement of the physical system output, it corrects the state estimation and error covariance. The core of EKF was to compare the predicted value and the measurement value, adjusting the Kalman gain. According to the size of the error, the gain will be used to calculate the next predicted value. The bigger the error, the greater the gain, and the bigger the estimated value will be corrected. Similarly, the lesser the error, the smaller the gain, the lesser the estimated value will be corrected. So, the EKF algorithm is applied to the SOC estimation for a lithium-ion battery pack. However, this technique cannot be utilized in practical applications, where the operation is much more dynamic and unpredictable. Another much simpler theory [9] behind the parameter extraction involves Ohm's law, which relates the proportionality between the instantaneous voltage and current. However, this technique works well only if the time step used is smaller than the time constant of the associated reaction, so that the change in the state can be considered minimal. A much more advanced technique includes the application of the curve fitting tools [10] in MATLAB to identify the values of R i , R d , C d , and C b . The value of R i is determined using the instantaneous change in the value of the voltage at the end of a discharge pulse. The technique proposed in this study is similar to the one as presented in [11]. The difference lies in the fact that the model in [11] does not consider the effect of the varying levels of the discharge currents. However, the proposed model in this study includes this effect.

Pulse discharge test
The pulse discharge test (PDT) includes the discharging of the battery pack by providing the current in the form of constant pulses. There is a rest time included between the application of two subsequent pulses as shown in Fig.  5. The rest time is decided based on the settling of the OCV to steady state. The discharge pulses are supplied to the pack to reduce the SOC by 15% with each pulse. The duration of each pulse is calculated using the SOC dependency equation on the discharge current. The main aim of these tests is to extract the model parameters, R i , R d , C d , and C b . The PDTs are performed at varying pulse current levels to identify the effect of the discharge current on the model parameters. These tests are also used to determine the OCV-SOC curves. The discharge current values are decided based on the maximum current rating of the cell specified in the data sheet.

Continuous discharge test
The continuous discharge test (CDT) involves the discharging of a battery pack at constant continuous current levels as shown in Fig. 6. The current levels remain the same as for the PDTs. These tests are used to identify the effect of the different discharge currents on the capacity of the battery pack and of each cell.

Experimental results
To simulate lithium-ion battery charge and discharge state in a normal use, and verify the effectiveness of the SOC estimation procedure, the following charging experiments have been conducted. Under a normal temperature, the battery is charged from OCV = 3 V reference state (namely, SOC 0% status) under a constant current until OCV = 4.2 V (namely, SOC 100% status). The state change, the error of the voltage, and the SOC waveform diagram are observed. The SOC estimation results and the expected integral values are basically the same, which explains that the EKF algorithm can achieve the accurate SOC estimation values. We evaluated the accuracy of the SOC estimation. The current load applied to the target lithium-ion battery is shown in Fig. 7. Charge and discharge produces the current load pattern shown in Fig. 8. This charging method is the constant current-constant voltage (CC-CV) charging topology. The experiments are discharged on the above current patterns until the battery SOC reaches 0.0%. The experiments are evaluated by comparing the estimated SOC by EKF that implements the MCU microcomputer and SOC calculated by the charging and discharging machine. The SOC estimation accurately evaluates the absolute value by subtracting the true SOC from the estimated SOC in percentage. The true SOC is given by the SOC value, which is given by the highly accurate experimental equipment. The time transition of the estimated SOC and reference SOC is shown in Fig. 10. The average error for the SOC estimation experiment is 0.15%. The experimental results show that the proposed EKF-based SOC estimation method is effective and can estimate the battery SOC accurately.

Conclusion
In this study, a new method for the SOC estimation based on the EKF algorithm has been presented for the ESS in the microgrids, after obtaining the relationship of the lithium-ion battery SOC and OCV. First, the parameters of the lithium-ion battery model are confirmed, and then these parameters are plugged into the state and observation equations. The measured current and voltage are used in equations. Further, through the iterative calculation of the EKF equations and constant updating of the system status, an accurate estimation value can be obtained ultimately. This type of EKF calculation algorithm has been validated through the simulation and experiments. Thus, the SOC estimation based on the EKF algorithm is effective and accurate. If the difference between the noise value in equations and the actual noise value is substantial, the estimated value is difficult to converge to a reasonable range. Estimation of the influence of noise in the algorithm is the next step in the research direction.
This method may be applied for an accurate estimation of SOC to improve the ESS performance, reliability, and safety, and to lengthen the lifetime of the battery on ESS in the microgrid.