Next Article in Journal
Performance Evaluation of Coupled Thermal Enhancement through Novel Wire-Wound Fins Design and Graphene Nano-Platelets in Shell-and-Tube Latent Heat Storage System
Next Article in Special Issue
The Estimation Life Cycle of Lithium-Ion Battery Based on Deep Learning Network and Genetic Algorithm
Previous Article in Journal
Review of State of the Art Recycling Methods in the Context of Dye Sensitized Solar Cells
Previous Article in Special Issue
Inhomogeneities and Cell-to-Cell Variations in Lithium-Ion Batteries, a Review
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Implementing an Extended Kalman Filter for SoC Estimation of a Li-Ion Battery with Hysteresis: A Step-by-Step Guide

Institute for Data Processing and Electronics (IPE), Karlsruhe Institute of Technology (KIT), 76344 Eggenstein-Leopoldshafen, Germany
*
Authors to whom correspondence should be addressed.
Energies 2021, 14(13), 3733; https://doi.org/10.3390/en14133733
Submission received: 22 May 2021 / Revised: 14 June 2021 / Accepted: 18 June 2021 / Published: 22 June 2021

Abstract

:
The growing share of renewable energies in power production and the rise of the market share of battery electric vehicles increase the demand for battery technologies. In both fields, a predictable operation requires knowledge of the internal battery state, especially its state of charge (SoC). Since a direct measurement of the SoC is not possible, Kalman filter-based estimation methods are widely used. In this work, a step-by-step guide for the implementation and tuning of an extended Kalman filter (EKF) is presented. The structured approach of this paper reduces efforts compared with empirical filter tuning and can be adapted to various battery models, systems, and cell types. This work can act as a tutorial describing all steps to get a working SoC estimator based on an extended Kalman filter.

Graphical Abstract

1. Introduction

Lithium-ion batteries (LIB) have shown great potential as an energy storage technology for electrified transportation, portable electronics, and grid stabilization. In contrast to a fuel tank, the remaining energy in a battery cannot be measured directly. Therefore, the internal state of a battery has to be derived from accessible measurement values using mathematical models. These include physical models, data-driven models using machine learning, and equivalent circuit models (ECM). Physical models use differential equations to describe the electrochemical processes inside the cell. These are complex and require detailed information about the cells’ composition for accurate parameterization, but provide a detailed description of the processes inside a cell during a wide range of operating conditions [1]. In data-driven models, machine learning algorithms are used to derive the model directly from measured data without prior knowledge of the cell. However, machine learning algorithms require large data sets to properly train the model [2]. Equivalent circuit models (ECM) describe the batteries’ behaviour using voltage sources and passive electrical components, typically resistors and capacitors. The model parameters are determined by fitting the model prediction to measured responses. Compared with physical models, they do not provide detailed insight in internal processes, but are less complex and therefore easier to parameterize. ECMs provide a good compromise between accuracy and complexity, and are therefore used in many applications [1,3,4,5,6,7,8,9,10,11,12,13,14,15]. Models are always a simplification of reality. Model parameters are imprecise, and sensor measurements are noisy. As a result, the prediction of the model diverges from the true system response. To reduce the prediction error, several mathematical filtering techniques have been introduced [16]. A common approach used in LIB applications is the extended Kalman Filter (EKF) [3,9]. It is widely used to estimate the state of charge [17,18], state of health [1], and cell capacity [6,19]. It can also be used for online parameter estimation [20]. A major challenge is the adjustment of the EKF to the specific application. An improperly tuned filter can lead to unstable and unpredictable behavior [21]. In contrast to other publications [7,10,11,12] which tune the filter empirically, this paper systematically determines the required settings. In this process, a novel extension for handling current sensor noise is proposed. As an additional improvement, this work extends the common battery model by a hysteresis element, which is often omitted in the literature [7,10,11,12,13,14,15,21]. Battery systems often consist of many cells. The SoC estimation on a system level is always based on estimating the SoC of single cells [22]. Therefore, this paper focuses on single-cell SoC estimation only.

Structure of the Paper

Section 2 describes the theory of the battery model and the extended Kalman filter (EKF). In Section 3, EKF extensions for determining the process noise matrix, handling current sensor noise, and filter initialization are introduced. In Section 4, methods for cell characterization are introduced. Section 5 provides a step-by-step guide for setting up the EKF for application. Finally, Section 6 shows an experimental validation.

2. Theory

The principle of the extended Kalman filter for SoC estimation is shown in Figure 1. The EKF compares the measured cell voltage and the cell voltage predicted by a battery model. The model also predicts internal, immeasurable states. One of these states is the SoC of the battery cell. In a second step, the EKF corrects the internal states under consideration of the estimated accuracies of the measurement and the model prediction. Thus, it provides a corrected estimation of the SoC.

2.1. Battery Model

The proposed Kalman filter is based on an equivalent circuit model (ECM) to describe the cells’ behavior. Compared to other models, such as physical models, ECMs offer low computational complexity, require a small amount of parameters, and still provide good approximation [1,9]. Therefore, they are widely used in battery modeling applications [1,3,4,5,6,7,8,9,10,11,12,13,14,15]. Figure 2 shows the ECM proposed here. The associated equations are (1) to (6). A detailed explanation of the model is given by [1].
(1) η [ k 1 ] = 1 i [ k 1 ] 0 ( discharging ) η ˜ i [ k 1 ] < 0 ( charging ) (2) q [ k ] = q [ k 1 ] η [ k 1 ] · i [ k 1 ] · Δ t (3) v R j [ k ] = e Δ t τ j v R j [ k 1 ] + R j · 1 e Δ t τ j · i [ k 1 ] ( j = 1 , 2 ) (4) v h [ k ] = e η [ k 1 ] i [ k 1 ] γ Q cell Δ t v h [ k 1 ] M · 1 e η [ k 1 ] i [ k 1 ] γ Q cell Δ t · sgn ( i [ k 1 ] ) (5) v R 0 [ k ] = R 0 i [ k ] (6) v [ k ] = v oc ( q [ k ] ) v R 0 [ k ] v R 1 [ k ] v R 2 [ k ] + v h [ k ]
The sign of the current is positive for discharging and negative for charging processes.
Note that unlike [1], this paper uses the charge q instead of the state of charge z = q / Q cell , which makes Equation (2) independent of the cell capacity Q cell .
In contrast to many other approaches [7,10,11,12,13,14,15], the used model includes a hysteresis element, as proposed in [1]. The importance of this additional element is supported by the measurement of charging and discharging OCV curves, as described later. The effect of an instantaneous hysteresis as mentioned in [1] is not considered here.

2.2. Extended Kalman Filter for Battery SoC Estimation

The proposed model is nonlinear. In particular, the hysteresis voltage does not depend linearly on the current i. v o c ( q ) is also non-linear. This is why the original Kalman filter [23] cannot be used here. The extended Kalman filter (EKF) can handle these nonlinear dependencies [9]. The standard algorithm of the EKF is shown in Table 1. Here, predicted quantities are labeled with a hat ( z ^ ), and corrected variables with a tilde ( z ˜ ). u and y are input and output values, and therefore are not labeled.
For applying the EKF to SoC estimation, the general system description of the EKF is compared with the battery model and equivalents are identified. The comparison in Table 2 demonstrates this process.
After the identification of these equivalents, the matrices needed for the EKF algorithm can be derived. For a shorter notation, the following expressions are defined:
e 1 = e Δ t τ 1 e 2 = e Δ t τ 2 e h = e η [ k 1 ] i [ k 1 ] γ Q cell Δ t
Then the EKF matrices A , B and C are obtained, as stated by Equations (8)–(10).
A [ k ] = f z z [ k 1 ] , u [ k ] = diag 1 , e 1 , e 2 , e h , 0
(9) B [ k ] = f u z [ k 1 ] , u [ k ] = η [ k 1 ] · Δ t 0 0 R 1 1 e 1 0 0 R 2 1 e 2 0 0 η γ Δ t Q sgn ( i [ k 1 ] ) · v h [ k 1 ] + M · e h M 1 e h 0 0 0 R 0 (10) C [ k ] = g z z [ k ] , u [ k ] 1 = v oc q 1 1 1 1
The measurement noise matrix R is found as the precision of the voltage measurement:
R [ k ] = Cov ( y [ k ] ) = σ v 2 .
The determination of the process noise matrix Q [ k ] , which is defined as Q [ k ] = Cov ( z [ k ] ) is a harder task. A possible approach is presented in Section 3.1.

3. Useful Extensions to the EKF Algorithm

For a well-performing EKF, the tuning and initialization of the filter is critical [21,24]. The relevant matrices for tuning are the measurement noise R [ k ] and the process noise Q [ k ] . For the initialization, the initial state x ˜ [ 0 ] and its error P ˜ [ 0 ] have to be set [21].
The determination of R [ k ] is already presented in Equation (11). However, the standard EKF algorithm presents no method for the derivation of the remaining variables Q [ k ] and P ˜ [ 0 ] and x ˜ [ 0 ] .
The following extensions give methodic approaches for the tuning and initialization of the EKF. In Section 3.1 and Section 3.2, the Q matrix is derived from the errors of the model parameters and the noise of the current measurement. The setting of P ˜ [ 0 ] and x ˜ [ 0 ] is described in Section 3.3 in detail.

3.1. Determination of the Process Noise from Parameter Errors

No model fits reality perfectly. The process noise matrix Q quantizes the inaccuracies in the state equation of the given model. The origins of these inaccuracies are improper parameter values or the structure of the model [24].
In other words, the Q matrix indicates how precisely the state z [ k ] can be predicted when the state z [ k 1 ] is known. Hence, Q is added to the system state error P at each time step (see Table 1). Q significantly impacts the strength of the EKF’s correction of the state prediction.
An appropriate choice of the process noise matrix Q is a difficult but important task [24]. The authors of [24] remark that Q is often not systematically determined in EKF designs. In many implementations of an EKF for SoC estimation [7,10,11,12], this matrix is established experimentally.
However, an empirical choice of the design matrices cannot guarantee a working filter and cannot be generalized for other models. Therefore, this paper describes how to systematically derive Q based on the method described in [24].
According to [24], the Q matrix can be derived from the covariance of the parameters in the model. For the mathematical description, the parameters are summarized in a vector p which is
p = R 0 R 1 τ 1 R 2 τ 2 γ M η ˜ T
for the model used here. The associated covariance matrix is called Q p . Then, the process noise covariance is obtained as
Q [ k ] = J [ k ] · Q p [ k ] · J T [ k ] ,
where
J [ k ] = f p z [ k 1 ] , u [ k ] , p [ k ] .
Applying this definition of J to the model used here results in the matrix shown in Equation (15).
J [ k ] = 0 0 0 0 0 0 0 q [ k ] η ˜ 0 v R 1 [ k ] R 1 v R 1 [ k ] τ 1 0 0 0 0 0 0 0 0 v R 2 [ k ] R 2 v R 2 [ k ] τ 2 0 0 0 0 0 0 0 0 v h [ k ] γ v h [ k ] M v h [ k ] η ˜ i [ k ] 0 0 0 0 0 0 0
with
(16) q [ k ] η ˜ = 0 i [ k 1 ] 0 Δ t · i [ k 1 ] i [ k 1 ] < 0 (17) v R i [ k ] R i = ( 1 e i ) · i [ k 1 ] ( i = 1 , 2 ) (18) v R i [ k ] τ i = Δ t τ i 2 · e i · v R i [ k 1 ] R i i [ k 1 ] ) ( i = 1 , 2 ) (19) v h [ k ] γ = i [ k 1 ] η [ k 1 ] Q Δ t · e h · v h [ k 1 ] + M · sgn ( i [ k 1 ] ) (20) v h [ k ] M = ( 1 e h ) · sgn ( i [ k 1 ] ) (21) v h [ k ] η ˜ = 0 i [ k 1 ] 0 i [ k 1 ] γ Q Δ t · e h · v h [ k 1 ] + M · sgn ( i [ k 1 ] ) i [ k 1 ] < 0
Since J can change at every iteration, depending on the current and the system state, the Q matrix can also change. The notation [ k ] is therefore necessary.
A variable Q matrix is more sensible than a constant, as used in [7,10,11,12]. Now the Kalman filter knows that the state of the system is known more precisely in certain situations. For example, if i [ k 1 ] = 0 , most of the entries in J disappear. This is reasonable: If no current flows, v R 0 is exactly zero, without any uncertainty. The hysteresis voltage is unchanged v h [ k ] = v h [ k 1 ] . The model uncertainty of each RC voltage decreases in time as the voltage itself decreases. This behavior is only represented by an adaptive Q matrix.
Finally, for the calculation of the process noise matrix Q [ k ] , just the parameter covariances Q p are required. The parameters are assumed to be uncorrelated. The standard deviation or uncertainty of a parameter x is denoted by σ x , the variance σ x 2 . The parameters are assumed to be uncorrelated. Then the parameter covariance matrix Q p is obtained as
Q p = diag σ R 0 2 , σ R 1 2 , σ τ 1 2 , σ R 2 2 , σ τ 2 2 , σ γ 2 , σ M 2 , σ η ˜ 2 .

3.2. Current Error Contribution to the Process Noise

Another source of error in the prediction of z [ k ] from z [ k 1 ] is the current. In the real battery system, the current is gained by a noisy measurement. The error of this measurement is one of the reasons why simple Coulomb-counting SoC estimators have poor long-term accuracy [9].
There exists no covariance matrix for the input variable in the theoretical description of the EKF like the R matrix for the measurement variable. Instead, the Q matrix is meant to contain all uncertainties of the system equation, including input errors implicitly.
For the systematical derivation of the Q matrix, the current error has to be included computationally. For this purpose, [25] propose a method for linear Kalman filtering with noisy input variables. A similar derivation can be performed for the extended Kalman filter. Its idea is analogue to the considerations of [24] regarding the derivation of the Q matrix from parameter errors, and is presented in the following.
Let ζ [ k ] be the noise of u [ k ] and S [ k ] = Cov ( ζ [ k ] ) the associated covariance matrix. Then, the state equation is denoted as
z [ k ] = f ( z [ k 1 ] , u [ k ] + ζ [ k ] ) + δ [ k ] .
By Taylor series expansion and omission of higher-order terms, the state equation can be rewritten as
z [ k ] = f ( z [ k 1 ] , u [ k ] ) + f u ζ [ k ] + δ [ k ]
= f ( z [ k 1 ] , u [ k ] ) + B [ k ] ζ [ k ] + δ [ k ] δ [ k ] .
This results in the following calculation of the Q matrix:
Q [ k ] = Cov ( z [ k ] ) = Cov ( δ [ k ] )
= Cov ( B [ k ] ζ [ k ] + δ [ k ] )
(28) ζ , δ uncorrelated Q [ k ] = Cov ( B [ k ] ζ [ k ] ) + Cov ( δ [ k ] ) (29) = B [ k ] · Cov ( ζ [ k ] ) · B T [ k ] + Cov ( δ [ k ] ) (30) = B [ k ] · S [ k ] · B T [ k ] + Q s t d [ k ] ,
where Q s t d [ k ] is the process noise without input (or current) error consideration. Using a current sensor with precision σ i ( i ) (the precision can depend on the current in general), the matrix S [ k ] is
S [ k ] = ( σ i ( i [ k 1 ] ) ) 2 0 0 0 0 0 0 0 ( σ i ( i [ k ] ) ) 2
for the proposed battery model and the definition of the input variable vector u . The process noise is finally calculated as
Q [ k ] = J [ k ] · Q p [ k ] · J T [ k ] + B [ k ] · S [ k ] · B T [ k ] .
For a better understanding, the entry Q 00 is regarded, which gives the uncertainty of the prediction of the charge q:
Q 00 [ k ] = ( σ i ( i [ k 1 ] ) ) 2 · ( Δ t ) 2 i [ k 1 ] 0 σ η ˜ 2 · ( Δ t · i [ k 1 ] ) 2 + ( σ i ( i [ k 1 ] ) ) 2 · ( η ˜ · Δ t ) 2 i [ k 1 ] < 0 .
For Q 00 = 0 , the Kalman filter could not significantly correct the charge q predicted by Equation (2) and hence produce almost the same result as a Coulomb counter. By the proposed Q matrix, the current error determines how freely the Kalman filter can deviate from the Coulomb-counting prediction.
In [21] the authors propose a similar derivation of Q from the current error. In contrast to this work, they assume perfect models with no parameter errors, and therefore do not regard the first part of the Q matrix calculation according to Section 3.1.

3.3. Initialisation

For the initialisation of the EKF algorithm, the system state z ˜ [ 0 ] and its error P ˜ [ 0 ] have to be estimated. The initial state might be well-known under certain conditions, whereas the error of the initial state is quite hard to guess.
It is useful to start the EKF in a defined state, for example after a long resting time. Then the best estimation for the initial state is
z ˜ [ 0 ] = q [ 0 ] v R 1 [ 0 ] v R 2 [ 0 ] v h [ 0 ] v R 0 [ 0 ] = q 0 0 0 0 0 ,
where q 0 is chosen such that v o c ( q 0 ) = v [ 0 ] .
For an estimation of the initial state error P ˜ [ 0 ] , a method described in [24] can be applied. This method is also used in [21]. The Ref. [24] supposes to estimate an upper limit z u and a lower limit z l for the initial system state and calculate the initial state error as
P ˜ [ 0 ] = diag 0.5 · z u z l T · 0.5 · z u z l .
The limits z u , and z l will be established in the following equations. Hereby, it is assumed that i [ 0 ] = 0 and the system was in rest for Δ t rest before the initialization.
The only state that can be determined precisely is v R 0 [ 0 ] = 0 due to i [ 0 ] = 0 . That means the upper and lower limits for this state are 0.
In general, the RC elements are not completely discharged at initialization, resulting in an error on the estimation v R j [ 0 ] = 0 . Let i max be the maximum allowed absolute value for currents in the system. Then the limits for the initial RC voltages are
v R j , min [ 0 ] = R j · i max · e Δ t rest / τ j v R j , max [ 0 ] = R j · i max · e Δ t rest / τ j .
Independent of the current, the hysteresis voltage varies between M and M , so that the limits can be estimated as
v h , min [ 0 ] = M v h , max [ 0 ] = M .
The most difficult state is q, since it is obtained from the assumption that the measured voltage at initialization is OCV, as the other voltages v R 0 , v R j and v h are all estimated to be 0. The error of q [ 0 ] is a consequence of the errors of the other states. For the derivation of the limits q min [ 0 ] and q max [ 0 ] , Equation (6) is regarded:
(38) v o c [ 0 ] = v [ 0 ] + v R 0 [ 0 ] + v R 1 [ 0 ] + v R 2 [ 0 ] v h [ 0 ] (39) v o c , min [ 0 ] = v [ 0 ] R 1 · i max · e Δ t rest / τ 1 R 2 · i max · e Δ t rest / τ 2 M (40) v o c , max [ 0 ] = v [ 0 ] + R 1 · i max · e Δ t rest / τ 1 + R 2 · i max · e Δ t rest / τ 2 + M .
The limits for q can then be estimated as:
q min [ 0 ] = q min where v o c ( q min ) = v o c , min
q max [ 0 ] = q max where v o c ( q max ) = v o c , max .
Finally, the limits z l and z u are obtained as
z l = q min R 1 · i max · e Δ t rest / τ 1 R 2 · i max · e Δ t rest / τ 2 M 0 z u = q max R 1 · i max · e Δ t rest / τ 1 R 2 · i max · e Δ t rest / τ 2 M 0
and can be used in Equation (35) for the calculation of the initial state error P ˜ [ 0 ] .

4. Cell Characterization

4.1. OCV Measurement

Before the Kalman filter can work with the model, the relationship v o c ( q ) must be known. This relationship is called the OCV curve, and will be implemented as a lookup table (LUT). A common method for OCV measurement is pulsed charging and discharging [26]. Starting from SoC = 100%, the battery is discharged in small steps. After each current pulse, the battery cell is allowed to rest for a long time. During this phase, the RC voltages decrease to zero. The procedure is repeated until the battery is empty. The voltages at the end of each resting phase yield the OCV discharge curve. Afterwards, charging pulses and resting phases are executed until the battery is full again. The resting voltages yield the charge OCV curve.
The alignment of the two OCV curves is reached by a correct setting of the coulombic efficiency η ˜ . Thus, the OCV measurement can already give an estimation of this parameter if the current was measured precisely.
Figure 3 shows the results of an exemplary OCV measurement. In each step, a charge of 1 Ah is charged or discharged. The resting time after each pulse is 1 h.
The maximum polarization voltage M of the hysteresis element is defined as half the difference of charge and discharge OCV curves and can be extracted directly from the OCV measurement. It can then be implemented as LUT M ( q ) .

4.2. Model Parameter Identification

The second necessary characterization step is the estimation of the parameter values. For this purpose, measurement data of the cell need to be collected. Figure 4 shows a possible experiment.
The experiment consists of two phases. First, one or multiple chirp signals bring the battery to a defined state [1]. The effect of these frequency sweeps is that the RC voltages v R j [ 0 ] and the hysteresis voltage v h [ 0 ] are almost 0. Then, the measured voltage v [ 0 ] is approximately equal to the open-circuit voltage v o c ( q [ 0 ] ) , and q [ 0 ] can be determined.
In the second phase, a rectangular current profile is run. Then the model is fit to the measured voltage. This is done by minimizing the residual sum of squares (RSS) between the predicted cell voltage v ^ (according to the model Equation (6)) and the measured voltage v:
min R 0 , R 1 , τ 1 , R 2 , τ 2 , γ k ( v ^ [ k ] v [ k ] ) 2 .
For the minimization, common direct search methods may be used. A popular option is the Nelder–Mead algorithm. MATLABs fminsearch is a standard implementation [27].
Since the parameters may vary with SoC, temperature or aging the parametrization experiment should be repeated under different conditions and with multiple cells. The parameters may then be implemented as LUTs. The precision of the parameters is obtained as the standard deviation of the parameter values of identical cells at equal conditions. When the parameters are not implemented as LUTs, the standard deviation calculations should consider the system’s complete operating range.

5. Step-by-Step Guide to Implementation

This chapter gives an overview of the necessary steps to get a working EKF implementation for SoC estimation. It summarizes the tasks that have to be performed before and during operation of the battery system. Figure 5 shows this as a step-by-step guide.

6. Experimental Validation

6.1. Experimental Setup

The battery cell which will be evaluated as an example in the following is part of a battery system. The system consists of 96 cells that are connected in series and partitioned into four modules. These modules are organized in a master–slave principle. Each module contains an Infineon AURIX Tricore microcontroller that executes the battery management system (BMS) software, including the proposed EKF algorithm. To connect the battery to the grid, a Delta Elektronika SM 500-CP-90 inverter is used. The setup is shown in Figure 6.
The BMS measures the cell voltage by an LTC6811 battery monitoring chip that provides a precision of σ v = 0.1   mV . It measures the cell current by a VAC T60404 fluxgate current sensor with a precision of σ i = 100   mA . The offset of the current sensor is compensated roughly at startup.

6.2. Evaluated Cell

The cell under test is a NMC pouch cell. Its OCV curve is presented in Figure 3. The following cell parameters and standard deviations have been experimentally determined during the preparation of the EKF (see Figure 5):
R 0 = 1.31   m Ω ± 0.20   m Ω R 1 = 0.72   m Ω ± 0.10   m Ω τ 1 = 36   s ± 8   s R 2 = 0.69   m Ω ± 0.35   m Ω τ 2 = 642   s ± 200   s γ = 17 ± 10 η ˜ = 0.98 ± 0.02
In the tested version, v oc and M are implemented as LUTs. The standard deviation of M is set to σ M ( q ) = 0.2 · M ( q ) . Due to their comparatively small variation in the examined operating range, the remaining parameters are implemented as constant values with constant standard deviations.
With the safety limits v min = 3.058 V and the v max = 4.092 V , the usable capacity Q cell is found from the OCV curve as
Q cell = 38.16   Ah .

6.3. Experiment Procedure

The procedure of the experiment is shown in Figure 7. It mainly consists of a rectangular charge and discharge current profile. After every four repetitions of this profile, the battery is discharged for a longer period and then held in rest for the same time. As a result, the voltage captured at the end of the resting phase can be assumed to be discharged OCV, which yields a reference point for the SoC.

6.4. Comparative Analysis

The results of the proposed EKF SoC estimator (E1) will be compared to three other estimators:
(E2)
an EKF with a roughly tuned process noise matrix Q
(E3)
a Coulomb counter with the internal current sensor and the assumed capacity of Q cell = 38.16   Ah .
(E4)
a Coulomb counter with the precise current sensor of the inverter and cell capacity correction.
E4 is assumed to be the best estimation, and therefore works as the reference SoC. The capacity correction is performed after the experiment based on the measured data. Note that E4 is therefore not applicable for real-time estimation. In contrast, the other three estimators are run in real-time.
For E2, the following Q matrix is used:
Q = Cov ( z ( k ) ) = diag ( σ q 2 , σ v R 1 2 , σ v R 2 2 , σ v h 2 , σ v R 0 2 )
= diag ( 4 , 2 · 10 5 , 2 · 10 5 , 1 · 10 4 , 2 · 10 8 )
Note that in our implementation, q is in Ah , whereas the voltages are in mV , which leads to a comparatively large value in the first entry. The order of magnitude for this entry is adapted from [10,12], which proposes a value of 0.01 that is a squared SoC value (variance of the state). This means 10% standard deviation in SoC. However, the Ref. [7] chooses a SoC standard deviation of 0.32%. For comparison, an averaged value of 2 Ah ( 5 % SoC) is selected and squared to get 4 ( Ah ) 2 as the first entry in Q . The magnitudes of the voltages v R j strongly depend on the cell-specific resistances, and therefore cannot be adapted from the literature directly. They are roughly estimated from the resistance values and an average current ( R j · i avg ). The hysteresis voltage is not mentioned in any of the referenced papers, but it is in the order of 10 mV. The estimation of v R 0 is quite exact, so the corresponding entry in Q is calculated from the inaccuracy of the current sensor ( R 0 · σ i ).

6.5. Results

The cell voltage and current measured by the BMS are shown in Figure 8. At t 15   h , one of the cells in the battery system is fully discharged. Therefore, the tested cell cannot be discharged lower than 3.2 V. Furthermore, the last 15 A discharge interval (according to Figure 7) cannot be fully executed. Therefore, only four OCV capture points are recorded.
Figure 9 presents the SoCs estimated by the above-mentioned estimators, E1–E4. Additionally, it shows the SoCs calculated via the OCV discharge curve (see Figure 3) evaluated at the OCV capture points. The error bars result from the possibility that the hysteresis element is not fully polarized after a 30 min discharge. The points show the case of full polarization.
The high-accuracy current sensor measured a charge difference of 35.83 Ah between t = 0   h and the fourth OCV capture point at t = 13   h . The charge difference between these two points in the OCV curve (Figure 3) is only 34.11 Ah. Therefore, for the gauging of the reference E4, we assume a cell capacity of 40.09 Ah instead of 38.16 Ah, as used by E1 to E3.
For better visibility of the results, the errors of E1–E3 compared to the reference E4 are depicted in Figure 10.

6.6. Discussion

6.6.1. Validity of the Reference

In the literature, the reference, often called true SoC or real SoC, is gained by Coulomb-counting [10,11,13,21]. This may work for a high-precision current sensor and a perfectly known cell capacity. Capacity and SoC estimation experiments have to be conducted under equal conditions. This is done by monitoring the cell in a controlled temperature chamber (in [21]). In the present system, the cell is in a different condition during the experiment than during the recording of the OCV-SoC dependency described in Section 4.1.
The correction is performed with the fourth OCV point that is captured during the experiment. The fourth OCV point has a small error bar due to the steep region in the OCV curve. Therefore, the reference has a small uncertainty. E4 also hits the three other OCV capture points, which confirms the gauging. The capacity difference of nearly 2 Ah can be explained by the higher temperature in the cell compared to the OCV measurement, which is 29 C during the experiment. A possible error of the current sensor also accumulates into the corrected cell capacity.

6.6.2. SoC Estimation Algorithms

Figure 9 shows that the proposed algorithm E1 has the highest accuracy. It only diverges a little from the reference, and hits all OCV capture points at least within each error range. Besides this, Figure 10 confirms the quality of this estimator. The error of the proposed EKF is roughly in a range of ±1% and clearly outperforms the two compared estimators, E2 and E3.
E2 shows an acceptable performance, with an error of a range of ±4%. However, significant fluctuations occur, especially after the resting phases. The performance of E2 might be improved, when the constant Q matrix is determined more elaborately, such as by trial and error.
The estimation of the Coulomb counter with the internal current sensor (E3) shows the lowest error in the beginning. However, the error grows until the end of the experiment. This is the expected behaviour of a Coulomb-counting estimator. The errors have two origins: the accumulated error in the current measurement and the error of the assumed cell capacity.

7. Conclusions

This work shows the implementation process of a state of charge (SoC) estimator for lithium-ion batteries based on an extended Kalman filter (EKF) using an equivalent circuit model (ECM). The used model includes a hysteresis element to represent the difference between charge and discharge behavior.
For the adjustment of the EKF, methodic approaches are presented. The EKF tuning can be directly derived from sensor and model accuracy. This accelerates development by omitting effortful empirical determination of the process noise matrix Q . All required steps are presented in a step-by-step guide.
The proposed EKF is experimentally compared to a roughly tuned EKF. It achieves a maximum error of ± 1 % and good stability. It outperforms the roughly tuned EKF, which shows a maximum error of ± 4 % and significant fluctuations. The difference in the performance demonstrates how sensitive the EKF reacts to the process noise matrix. Therefore, careful EKF tuning is vital.

8. Outlook

The presented method has been designed to be applicable to other cell chemistries, ECMs, and sensors. This should be experimentally validated in a wide range of operational conditions. This could include increased currents, a wide temperature range, and extended runtimes to facilitate aging processes. We expect that the accuracy of the SoC estimator could be further increased by implementing LUTs for more model parameters instead of using averaged values.

Author Contributions

Conceptualization, B.R., S.B. and T.B.; methodology, B.R.; software, B.R.; validation, B.R. and S.B.; resources, T.B.; data curation, B.R. and S.B.; writing—original draft preparation, B.R. and S.B.; writing—review and editing, B.R., S.B. and T.B.; supervision, T.B.; funding acquisition, T.B. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Conflicts of Interest

The authors declare no conflict of interest.

Abbreviations

The following abbreviations are used in this manuscript:
BMSBattery mangement system
EKFExtended Kalman filter
LIBLithium ion battery
LUTLookup table
NMCNickel manganese cobalt
OCVOpen-circuit voltage
RCresistor-capacitor
SoCState of charge
Notation
Δ t sampling time z system state
ktimestep number: x [ k ] : = x ( k Δ t ) u input variable
icell current ( > 0 for discharge) y measurement variable
vcell voltage δ process noise
η ˜ coulombic efficiency ε measurement noise
R 0 internal resistance p model parameters
R j resistance of the j-th RC element ζ input noise
C j capacitance of the j-th RC element P system state error
τ j time constant of the j-th RC element K Kalman gain
Mmax. hysteresis polarization voltage A linearization state/state
γ hysteresis rate (unitless) B linearization state/input
Q cell cell capacity C linearization measurement/state
qcharge in the cell R measurement noise covariance
zstate of charge (SoC): z = q / Q cell Q process noise covariance
v o c open-circuit voltage (OCV) Q p parameter covariance
v R 0 voltage at internal resistance J linearization state/parameters
v R j voltage at the j-th RC element S input noise covariance
v h hysteresis voltage σ x standard deviation of x
e j exp Δ t / τ j x ^ x is a predicted value
e h exp η [ k 1 ] i [ k 1 ] γ / Q cell Δ t x ˜ x is a corrected value
Δ t rest resting time before initialization

References

  1. Plett, G.L. Battery Management Systems, Volume I: Battery Modeling; Artech House: Norwood, MA, USA, 2015. [Google Scholar]
  2. Meng, J.; Luo, G.; Ricco, M.; Swierczynski, M.; Stroe, D.I.; Teodorescu, R. Overview of Lithium-Ion Battery Modeling Methods for State-of-Charge Estimation in Electrical Vehicles. Appl. Sci. 2018, 8, 659. [Google Scholar] [CrossRef] [Green Version]
  3. Shrivastava, P.; Soon, T.K.; Idris, M.Y.I.B.; Mekhilef, S. Overview of model-based online state-of-charge estimation using Kalman filter family for lithium-ion batteries. Renew. Sustain. Energy Rev. 2019, 113, 109233. [Google Scholar] [CrossRef]
  4. Ahmed, R.; Gazzarri, J.; Onori, S.; Habibi, S.; Jackey, R.; Rzemien, K.; Tjong, J.; LeSage, J. Model-based parameter identification of healthy and aged li-ion batteries for electric vehicle applications. SAE Int. J. Altern. Powertrains 2015, 4, 233–247. [Google Scholar] [CrossRef] [Green Version]
  5. Xing, Y.; He, W.; Pecht, M.; Tsui, K.L. State of charge estimation of lithium-ion batteries using the open-circuit voltage at various ambient temperatures. Appl. Energy 2014, 113, 106–115. [Google Scholar] [CrossRef]
  6. Hu, C.; Youn, B.D.; Chung, J. A multiscale framework with extended Kalman filter for lithium-ion battery SOC and capacity estimation. Appl. Energy 2012, 92, 694–704. [Google Scholar] [CrossRef]
  7. Ciortea, F.; Rusu, C.; Nemes, M.; Gatea, C. Extended kalman filter for state-of-charge estimation in electric vehicles battery packs. In Proceedings of the 2017 International Conference on Optimization of Electrical and Electronic Equipment (OPTIM) & 2017 Intl Aegean Conference on Electrical Machines and Power Electronics (ACEMP), Brasov, Romania, 25–27 May 2017; pp. 611–616. [Google Scholar]
  8. Wang, L.; Wang, L.; Liao, C. Research on improved EKF algorithm applied on estimate EV battery SOC. In Proceedings of the 2010 Asia-Pacific Power and Energy Engineering Conference, Chengdu, China, 28–31 March 2010; pp. 1–4. [Google Scholar]
  9. Hannan, M.A.; Lipu, M.H.; Hussain, A.; Mohamed, A. A review of lithium-ion battery state of charge estimation and management system in electric vehicle applications: Challenges and recommendations. Renew. Sustain. Energy Rev. 2017, 78, 834–854. [Google Scholar] [CrossRef]
  10. Chen, Z.; Fu, Y.; Mi, C.C. State of charge estimation of lithium-ion batteries in electric drive vehicles using extended Kalman filtering. IEEE Trans. Veh. Technol. 2012, 62, 1020–1030. [Google Scholar] [CrossRef]
  11. Zhang, F.; Liu, G.; Fang, L. A battery State of Charge estimation method with extended Kalman filter. In Proceedings of the 2008 IEEE/ASME International Conference on Advanced Intelligent Mechatronics, Xi’an, China, 2–5 July 2008; pp. 1008–1013. [Google Scholar]
  12. Jokić, I.; Zečević, Ž.; Krstajić, B. State-of-charge estimation of lithium-ion batteries using extended Kalman filter and unscented Kalman filter. In Proceedings of the 2018 23rd International Scientific-Professional Conference on Information Technology (IT), Zabljak, Montenegro, 19–24 February 2018; pp. 1–4. [Google Scholar]
  13. Lee, J.; Nam, O.; Cho, B. Li-ion battery SOC estimation method based on the reduced order extended Kalman filtering. J. Power Sources 2007, 174, 9–15. [Google Scholar] [CrossRef]
  14. He, H.; Xiong, R.; Zhang, X.; Sun, F.; Fan, J. State-of-charge estimation of the lithium-ion battery using an adaptive extended Kalman filter based on an improved Thevenin model. IEEE Trans. Veh. Technol. 2011, 60, 1461–1469. [Google Scholar]
  15. Sepasi, S.; Ghorbani, R.; Liaw, B.Y. Improved extended Kalman filter for state of charge estimation of battery pack. J. Power Sources 2014, 255, 368–376. [Google Scholar] [CrossRef]
  16. Hariharan, K.S.; Tagade, P.; Ramachandran, S. Mathematical Modeling of Lithium Batteries: From Electrochemical Models to State Estimator Algorithms; Springer International Publishing: Cham, Switzerland, 2017. [Google Scholar]
  17. Wei, Z.; He, H.; Pou, J.; Tsui, K.L.; Quan, Z.; Li, Y. Signal-Disturbance Interfacing Elimination for Unbiased Model Parameter Identification of Lithium-Ion Battery. IEEE Trans. Ind. Inform. 2020, 1. [Google Scholar] [CrossRef]
  18. Hu, J.; He, H.; Wei, Z.; Li, Y. Disturbance-Immune and Aging-Robust Internal Short Circuit Diagnostic for Lithium-Ion Battery. IEEE Trans. Ind. Electron. 2021, 1. [Google Scholar] [CrossRef]
  19. Zhou, D.; Yin, H.; Xie, W.; Fu, P.; Lu, W. Research on online capacity estimation of power battery based on ekf-gpr model. J. Chem. 2019, 2019, 5327319. [Google Scholar] [CrossRef] [Green Version]
  20. Diab, Y.; Auger, F.; Schaeffer, E.; Wahbeh, M. Estimating lithium-ion battery state of charge and parameters using a continuous-discrete extended kalman filter. Energies 2017, 10, 1075. [Google Scholar] [CrossRef] [Green Version]
  21. Bian, X.; Wei, Z.; He, J.; Yan, F.; Liu, L. A two-step parameter optimization method for low-order model-based state of charge estimation. IEEE Trans. Transp. Electrif. 2020, 7, 399–409. [Google Scholar] [CrossRef]
  22. Plett, G.L. Battery Management Systems, Volume II: Equivalent-Circuit Methods; Artech House: Norwood, MA, USA, 2015. [Google Scholar]
  23. Kalman, R.E. A New Approach to Linear Filtering and Prediction Problems. Trans. ASME J. Basic Eng. 1960, 82, 35–45. [Google Scholar] [CrossRef] [Green Version]
  24. Schneider, R.; Georgakis, C. How to not make the extended Kalman filter fail. Ind. Eng. Chem. Res. 2013, 52, 3354–3362. [Google Scholar] [CrossRef]
  25. Ma, W.; Qiu, J.; Liang, J.; Chen, B. Linear kalman filtering algorithm with noisy control input variable. IEEE Trans. Circuits Syst. II Express Briefs 2018, 66, 1282–1286. [Google Scholar] [CrossRef]
  26. Soto, A.; Berrueta, A.; Sanchis, P.; Ursúa, A. Analysis of the main battery characterization techniques and experimental comparison of commercial 18650 Li-ion cells. In Proceedings of the 2019 IEEE International Conference on Environment and Electrical Engineering and 2019 IEEE Industrial and Commercial Power Systems Europe (EEEIC/I&CPS Europe), Genova, Italy, 11–14 June 2019; pp. 1–6. [Google Scholar]
  27. Optimizing Nonlinear Functions. Available online: https://de.mathworks.com/help/matlab/math/optimizing-nonlinear-functions.html (accessed on 2 May 2021).
Figure 1. Principle of an EKF for battery SoC estimation.
Figure 1. Principle of an EKF for battery SoC estimation.
Energies 14 03733 g001
Figure 2. Equivalent circuit model with two RC elements and hysteresis similar to [1].
Figure 2. Equivalent circuit model with two RC elements and hysteresis similar to [1].
Energies 14 03733 g002
Figure 3. Exemplary measurement results for the OCV curve of NMC pouch cells recorded at a cell temperature of 22 C .
Figure 3. Exemplary measurement results for the OCV curve of NMC pouch cells recorded at a cell temperature of 22 C .
Energies 14 03733 g003
Figure 4. Schematic view of a model parameterization experiment.
Figure 4. Schematic view of a model parameterization experiment.
Energies 14 03733 g004
Figure 5. Steps before (blue) and during operation (green) of the proposed EKF for SoC estimation of a lithium-ion battery cell.
Figure 5. Steps before (blue) and during operation (green) of the proposed EKF for SoC estimation of a lithium-ion battery cell.
Energies 14 03733 g005
Figure 6. Experimental setup. (a) Battery system consisting of four battery modules, the SM 500-CP-90 inverter and LabVIEW program for data extraction. (b) Inside view of a battery module.
Figure 6. Experimental setup. (a) Battery system consisting of four battery modules, the SM 500-CP-90 inverter and LabVIEW program for data extraction. (b) Inside view of a battery module.
Energies 14 03733 g006
Figure 7. Procedure of the experiment.
Figure 7. Procedure of the experiment.
Energies 14 03733 g007
Figure 8. Measured cell voltage and current during the experiment. In the voltage diagram, the OCV capture points are marked. The current is the signal as measured by the imprecise internal current sensor, which is the same signal used in the EKF algorithm.
Figure 8. Measured cell voltage and current during the experiment. In the voltage diagram, the OCV capture points are marked. The current is the signal as measured by the imprecise internal current sensor, which is the same signal used in the EKF algorithm.
Energies 14 03733 g008
Figure 9. Estimated SoC for the proposed algorithm (E1) compared to the Coulomb counter based on the internal current sensor (E3), the empirically tuned EKF (E2) and the capacity corrected Coulomb counter based on a more precise current sensor (E4).
Figure 9. Estimated SoC for the proposed algorithm (E1) compared to the Coulomb counter based on the internal current sensor (E3), the empirically tuned EKF (E2) and the capacity corrected Coulomb counter based on a more precise current sensor (E4).
Energies 14 03733 g009
Figure 10. SoC estimation errors for the estimators E1, E2 and E3 referring to the SoC estimation of E4. The values are plotted in % and due to the unit of the SoC, they are not relative errors.
Figure 10. SoC estimation errors for the estimators E1, E2 and E3 referring to the SoC estimation of E4. The values are plotted in % and due to the unit of the SoC, they are not relative errors.
Energies 14 03733 g010
Table 1. Standard system and algorithm description of the extended Kalman filter.
Table 1. Standard system and algorithm description of the extended Kalman filter.
Model Equations
State equation: z [ k ] = f ( z [ k 1 ] , u [ k ] ) + δ [ k ]
Measurement equation: y [ k ] = g ( z [ k ] , u [ k ] ) + ε [ k ]
  
0. Initilization
Initilization of the system state: z ˜ [ 0 ] = (see Section 3.3)
Initilization of the system state error: P ˜ [ 0 ] = (see Section 3.3)
  
1. Prediction
Prediction of the system state: z ^ [ k ] = f ( z ˜ [ k 1 ] , u [ k ] )
Prediction of the system state error: P ^ [ k ] = A [ k ] · P ˜ [ k 1 ] · A T [ k ] + Q [ k ]
Prediction of the measured value: y ^ [ k ] = g ( z ^ [ k ] , u [ k ] )
Kalman gain: K [ k ] = P ^ [ k ] · C T [ k ] C [ k ] · P ^ [ k ] · C T [ k ] + R [ k ]
  
2. Correction
Correction of the system state: z ˜ [ k ] = z ^ [ k ] + K [ k ] · y [ k ] y ^ [ k ]
Correction of the system state error: P ˜ [ k ] = 𝟙 K [ k ] · C [ k ] · P ^ [ k ]
  
Repeat 1. and 2. once per sampling interval
Table 2. Comparison of the general description of the EKF and the used equivalent circuit model of a battery cell.
Table 2. Comparison of the general description of the EKF and the used equivalent circuit model of a battery cell.
General DescriptionUse Case: ECM
State eq. z [ k ] = f ( z [ k 1 ] , u [ k ] ) + δ [ k ] Equations (2)–(5)
Measurement eq. y [ k ] = g ( z [ k ] , u [ k ] ) + ε [ k ] Equation (6)
System state z [ k ] q [ k ] v R 1 [ k ] v R 2 [ k ] v h [ k ] v R 0 [ k ]
Input/controller u [ k ] i [ k 1 ] sgn ( i [ k 1 ] ) i [ k ]
Measured variable y [ k ] v
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Rzepka, B.; Bischof, S.; Blank, T. Implementing an Extended Kalman Filter for SoC Estimation of a Li-Ion Battery with Hysteresis: A Step-by-Step Guide. Energies 2021, 14, 3733. https://doi.org/10.3390/en14133733

AMA Style

Rzepka B, Bischof S, Blank T. Implementing an Extended Kalman Filter for SoC Estimation of a Li-Ion Battery with Hysteresis: A Step-by-Step Guide. Energies. 2021; 14(13):3733. https://doi.org/10.3390/en14133733

Chicago/Turabian Style

Rzepka, Benedikt, Simon Bischof, and Thomas Blank. 2021. "Implementing an Extended Kalman Filter for SoC Estimation of a Li-Ion Battery with Hysteresis: A Step-by-Step Guide" Energies 14, no. 13: 3733. https://doi.org/10.3390/en14133733

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop