# Tuning of Kalman Filter Parameters via Genetic Algorithm for State-of-Charge Estimation in Battery Management System

Authors: T. O. Ting; Ka Lok Man; Eng Gee Lim; Mark Leach
Journal: The Scientific World Journal
 (2014)

---

## Abstract

In this work, a state-space battery model is derived mathematically to estimate the state-of-charge (SoC) of a battery system. Subsequently, Kalman filter (KF) is applied to predict the dynamical behavior of the battery model. Results show an accurate prediction as the accumulated error, in terms of root-mean-square (RMS), is a very small value. From this work, it is found that different sets ofQ and R values (KF’s parameters) can be applied for better performance and hence lower RMS error. This is the motivation for the application of a metaheuristic algorithm. Hence, the result is further improved by applying a genetic algorithm (GA) to tune Q and R parameters of the KF. In an online application, a GA can be applied to obtain the optimal parameters of the KF before its application to a real plant (system). This simply means that the instantaneous response of the KF is not affected by the time consuming GA as this approach is applied only once to obtain the optimal parameters. The relevant workable MATLAB source codes are given in the appendix to ease future work and analysis in this area.


---

## Body

## 1. Introduction

Battery Management System (BMS) [1–3] comprises of mechanism that monitors and controls the normal operation of a battery system so as to ensure its safety while maintaining its State-of-Health (SoH). The BMS, in essence, measures the voltage, current, and temperature of each cell in a battery pack. These data are then analyzed by a management system that guarantees safe and reliable operations. A common example of an independent battery pack is portrayed in Figure 1. The battery is an essential component and should be accurately modeled in order to design an efficient management system [4]. Hence, a generic tool to describe the battery performance under a wide variety of conditions and applications is highly desirable [4]. As such, electrical modeling is necessary to provide such a tool that enables visualization of the processes occurring inside rechargeable batteries. These generic models are necessary for the development of battery management algorithms. These algorithms control the operation and maintain the performance of battery packs. In short, the ultimate aim of BMS is to prolong battery life, while ensuring reliable operation alongside many applications, especially in photovoltaic systems [5–7].Figure 1
Typical Lithium-ion battery packs for electric vehicle.Battery modeling is performed in many ways depending on the types of battery. In general, the resulting battery model is a mathematical model comprising numerous mathematical descriptions [8]. Ultimately, battery models aim to determine the state-of-charge (SoC) of the battery system. However, the complexity of the nonlinear electrochemical processes has been a great barrier to modeling this dynamic process accurately. The accurate determination of the SoC will enable utilization of the battery for optimal performance and long-life and prevent irreversible physical damage to the battery [9]. The solution to the SoC via neural networks [10] and fuzzy logic [11] has been difficult and costly for online implementation due to the large computation required, causing the battery pack controller to be heavily loaded. This may however be a good alternative in the near future as the computational power of processing chips increase alongside their declining cost.The state-estimation process usually leads to some state variables in a dynamical system. The SoC is a measure of a battery’s available power and thus it is important to calculate this value accurately from BMS by the cell voltage, temperature, and polarization effect caused by the electrolyte concentration gradient during high rate charging/discharging cycle [12]. Recently, the battery state-of-charge (SoC) is one of the significant elements attracting significant attention [13, 14]. By definition, SoC is the ratio of remaining capacity to the nominal capacity of the battery. Here, the remaining capacity is the number of ampere-hours (Ah) that can be extracted at normal operating temperature. The mathematical expression for the SoC is given in [13, 14], which is
(1)Z(t)=Z(0)+∫0t‍Ib(τ)Cndτ,
where t is time, z(t) is battery SoC, in amphere-hours (Ah), Ib is current flowing through the battery (passing through Cbk), illustrated in Figure 2, and Cn is nominal battery capacity. For charging, Ib>0 and for discharging, Ib<0.Figure 2
Schematic ofRC battery model.From this mathematical expression, it is noted that the SoC cannot be explicitly measured. In the literature, there is a myriad of methods dealing with predicting and estimating of SoC. The most popular of these methods are described in the following paragraphs.At present, Coulomb-counting [15], also known as charge counting, or current integration is the most commonly used technique; it requires dynamic measurement of battery current. This is an open-loop method; however, it suffers from a reliance on the mathematical integration, and errors (noise, resolution, and rounding) are cumulative, which can lead to large SoC errors at the end of the integration process in (1). On the positive side, if an accurate current sensor is incorporated, the implementation will be much easier.Another prominent SoC estimator is the well-known Kalman filter (KF), invented by Kalman in 1960. Although his popular work was published almost 54 years ago in [16], it remains as an important citation source in the literature. Readers who are new to this method can refer to an excellent KF tutorial by Faragher in [17]. The KF method is a well-known technique for dynamic state estimation of systems such as target tracking, navigation, and also battery systems [18, 19]. The state-of-the-art method provides recursive solution to linear filtering for state observation and prediction problems. The key advantage of the KF is that it accurately estimates states affected by external disturbances such as noises governed by Gaussian distribution. On the contrary, the disadvantage of KF is that it requires highly complex mathematical calculations. This can be realized by a state-space model, as shown in previous work by the author in [20, 21]. The modeling is a heavy duty task and is also presented in this work to ease the understanding of readers. As such, there exist some possibilities of divergence due to an inaccurate model and complex calculation. In the case of a slow processor, the calculation results may be delayed and exceed the sampling interval, thereby result in an inaccurate tracking.Various artificial intelligence (AI) methods, mainly the neural networks and fuzzy logic, are being applied in the estimation of battery’s SoC [10, 22]. Neural networks are computationally expensive, which can overload the BMS and thus this approach, though theoretically feasible, may not be suitable for online implementation that requires instantaneous feedback and action. Also, neural networks require huge datasets in the time-consuming training process. Other techniques for SoC, include the sliding mode observer, are reported in [12].In this work, a mathematical derivation leading to a state-space model is presented. The basic schematic model is adopted from [18, 20]. A thorough analysis in the form of state variables with the application of the Kalman filter is presented. The rest of the paper is organized as follows. The mathematical model is derived in Section 2, resulting in a state-space model. Further, in Section 3, the KF is applied to estimate the SoC of a battery system. This is followed by the tuning of KF’s parameter by adopting a metaheuristic approach, namely, a genetic algorithm in Section 4. Relevant results are presented in Section 5, and finally the conclusions are derived in Section 6.


## 2. Battery Modeling

Many model-based state-estimations have been proposed in [18, 20, 21, 23]. In [18, 21], the well-known Kalman filter [16] had been applied successfully for both state observation and prediction of the SoC. Work in [24] utilized manufacturers’ data in modeling the dynamic behavior of the battery. Several battery models exist from many works over the past few years. Each of these models varies in terms of its complexity and applications. In this work, a dynamical battery model is adopted, consisting of state variable equations, from [20, 21]. The schematic representation of this model is shown in Figure 2. In this model, there exists a bulk capacitor Cbk that acts as an energy storage component in the form of the charge, a capacitor that models the surface capacitance and diffusion effects within the cell Csurface, a terminal resistance Rt, a surface resistance Rs, and an end resistance Re. The voltages across both capacitors are denoted as VCb and VCs, respectively.


### 2.1.  Mathematical Derivations of Battery Model

In this derivation, we aim to form a state-space model consisting of the state variablesVCb, VCs, and V0. State variables are mathematical descriptions of the “state” of a dynamic system. In practice, the state of a system is used to determine its future behavior. Models that consist of a paired first-order differential equations are in the state-variable form.Following the voltages and currents illustrated in Figure2, the terminal voltage V0 can be expressed as
(2)V0=IRt+IbRe+VCb,
which is similar to
(3)V0=IRt+IsRs+VCs.
By (2) and (3), and following straightforward algebraic manipulation, V0 can be written as
(4)IbRe=IsRs+VCs-VCb.
From Kirchoff’s current law, I=Ib+Is,
(5)Is=I-Ib.
Thus, substituting (5) into (4) yields
(6)Ib(Re+Rs)=IRs+VCs-VCb.
By assuming a slow varying Cbk, that is, Ib=CbkV˙Cb (from basic formula of i=C(∂V/∂t)), and then substituting it into (6), and after rearranging results in
(7)V˙Cb=IRsCbk(Re+Rs)+VCsCbk(Re+Rs)-VCbCbk(Re+Rs).
By applying a similar derivation, the rate of change of the surface capacitor voltage V˙Cs, derived also from (2) and (3), gives
(8)V˙Cs=IReCsurface(Re+Rs)-VCsCsurface(Re+Rs)+VCbCsurface(Re+Rs).
Further, by assuming A=1/Cbk(Re+Rs) and B=1/Csurface(Re+Rs), (7) and (8) can be written as
(9)V˙Cb=A·I·Rs+A·VCs-A·VCb,V˙Cs=B·I·Re-B·VCs+B·VCb,
respectively. Further, (9) and (10) can be combined to form a state variable relating voltages VCs and VCb and current flow I, which is
(10)[V˙CbV˙Cs]=[-AAB-B][VCbVCs]+[A·RsB·Re]I.
Next, the output voltage is derived from (2) and (3). By adding both equations, we obtain
(11)2V0=2IRt+IbRe+IsRs+VCb+VCs.
Then by substituting Ib=Rs/(Rs+Re)·I and Is=Re/(Rs+Re)·I into (11), it is further simplified as
(12)V0=VCb+VCs2+(Rt+ReRsRe+Rs)I.
Taking the time derivative of the output voltage and assuming dI/dt≈0 (this simply means that the change rate of terminal current can be ignored when implemented digitally), we obtain
(13)V˙0=V˙Cb+V˙Cs2.
Substituting the formulae obtained in (9) and (10) into (13) results in
(14)2V˙0=(-A+B)VCb+(A-B)VCs+(ARs+BRe)I.
Then, solving for VCs from (12) we obtain
(15)VCs=2V0-2(Rt+ReRsRe+Rs)I-VCb,
and after substituting it into (14), it yields
(16)V˙0=(-A+B)VCb+(A-B)V0+[A(0.5Rs+Rt+D)+B(0.5Re-Rt-D)]I.
Finally, the complete state variable network is obtained by substituting (16) into (10), represented in matrix form as
(17)[V˙CbV˙CsV˙0]=[-AA0B-B0(-A+B)0(A-B)]·[VCbVCsV0]+[A·RsB·ReA(0.5Rs-Rt-D)+B(0.5Re+Rt+D)]I,
whereby constants A, B, and D were derived previously but are hereby restated as
(18)[ABD]=[1Cbk(Re+Rs)1Csurface(Re+Rs)ReRsRe+Rs].
This completes the initial derivation of the battery model.


### 2.2. Numerical Example

By substituting all capacitor and resistor values from Table1 into (18), the following values are obtained:
(19)[ABD]=[0.0015087593475661.6238379409734910.001875000000000].Table 1
Parameters for cell model [18, 20].
C
bk
C
surface
R
e
R
s
R
t
8
8372.83 F
82.11 F
0.00375 Ω
0.00375 Ω
0.002745 ΩBy defining matrixA,
(20)A=[-AA0B-B0(-A+B)0(A-B)],(21)B=[A·RsB·ReA(0.5Rs-Rt-D)+B(0.5Re+Rt+D)].
Again by substituting the values from Table 1 to calculate A, B, and D, we obtain the value of A as
(22)A=[-1.51×10-31.51×10-301.6238-1.623801.62230-1.6223]andB as
(23)B=[5.66×10-66.08×10-31.05×10-2].As such (17) can be rewritten as
(24)[V˙CbV˙CsV˙0]=A·[VCbVCsV0]+B·I,
or numerically as
(25)[V˙CbV˙CsV˙0]=[-0.00150.001501.6238-1.623801.62230-1.6223]·[VCbVCsV0]+[5.66×10-66.08×10-31.05×10-2]·I.


### 2.3. State-Space Modeling

Based on control theories, a lumped linear network can be written in the form(26)x˙(t)=Ax(t)+Bu(t),y(t)=Cx(t)+Du(t),
where in this work, the state variable x˙(t) is
(27)x˙(t)=[V˙CbV˙CsV˙0].
Obviously,
(28)x(t)=[VCbVCsV0],
with
(29)u(t)=I.
Therefore, by restating the previous calculation values in (21) and (23), we should note that the values of A, B, C, and D are as follows:
(30)A=[-1.51×10-31.51×10-301.6238-1.623801.62230-1.6223],(31)B=[5.66×10-66.08×10-31.05×10-2],(32)C=[001],(33)D=[0],
respectively. As such, with (32), the output y(t) is in fact
(34)y(t)=V0.
This means that the output of the system is the open terminal voltage V0, as expected. Note that this is an important observation from this state-space modeling.Further, the above state-space variables are transformed to a transfer function,G(s). This is done by using ss2tf function in MATLAB, which after factorization yields
(35)G(s)=0.01054s2+0.0171s+2.981×10-5s3+3.248s2+2.637s-1.144×10-18.
The plot of the unit step response for the gain in (35) is given in Figure 3. Basically, it shows that the open circuit terminal voltage V0 in Figure 2 increases linearly during the charging operation in a very slow manner after transient behaviour for few seconds.Figure 3
Output response of RC model due to constant input.


### 2.4. Observability of the RC Battery Model

In control theory, observability is the degree to which the internal states of a system can be predicted via its external outputs. As such, for an observable system, the behavior of the entire system can be predicted via the system’s outputs. On the other hand, if a system is not observable, the current values of some of its states cannot be estimated through the output signal. This means the controller does not know the states’ values. In theory, the observability of a system can be determined by constructing an observability matrixOb.                               (36)Ob=[CCACA2⋮CAn-1],
and a system is observable if the row rank of Ob is equal to n (this is also known as a full rank matrix). The ultimate rationale of such a test is that if n rows are linearly independent, then each of the n states is viewable through linear combinations of the output y(t).Further, substitutingA and C values from (30) and (32) into (36) yields
(37)Ob=[0011.62230-1.6223-2.63440.00242.6320].
Clearly, in this case Ob is a full rank matrix, which concludes that this system is observable.


## 2.1.  Mathematical Derivations of Battery Model

In this derivation, we aim to form a state-space model consisting of the state variablesVCb, VCs, and V0. State variables are mathematical descriptions of the “state” of a dynamic system. In practice, the state of a system is used to determine its future behavior. Models that consist of a paired first-order differential equations are in the state-variable form.Following the voltages and currents illustrated in Figure2, the terminal voltage V0 can be expressed as
(2)V0=IRt+IbRe+VCb,
which is similar to
(3)V0=IRt+IsRs+VCs.
By (2) and (3), and following straightforward algebraic manipulation, V0 can be written as
(4)IbRe=IsRs+VCs-VCb.
From Kirchoff’s current law, I=Ib+Is,
(5)Is=I-Ib.
Thus, substituting (5) into (4) yields
(6)Ib(Re+Rs)=IRs+VCs-VCb.
By assuming a slow varying Cbk, that is, Ib=CbkV˙Cb (from basic formula of i=C(∂V/∂t)), and then substituting it into (6), and after rearranging results in
(7)V˙Cb=IRsCbk(Re+Rs)+VCsCbk(Re+Rs)-VCbCbk(Re+Rs).
By applying a similar derivation, the rate of change of the surface capacitor voltage V˙Cs, derived also from (2) and (3), gives
(8)V˙Cs=IReCsurface(Re+Rs)-VCsCsurface(Re+Rs)+VCbCsurface(Re+Rs).
Further, by assuming A=1/Cbk(Re+Rs) and B=1/Csurface(Re+Rs), (7) and (8) can be written as
(9)V˙Cb=A·I·Rs+A·VCs-A·VCb,V˙Cs=B·I·Re-B·VCs+B·VCb,
respectively. Further, (9) and (10) can be combined to form a state variable relating voltages VCs and VCb and current flow I, which is
(10)[V˙CbV˙Cs]=[-AAB-B][VCbVCs]+[A·RsB·Re]I.
Next, the output voltage is derived from (2) and (3). By adding both equations, we obtain
(11)2V0=2IRt+IbRe+IsRs+VCb+VCs.
Then by substituting Ib=Rs/(Rs+Re)·I and Is=Re/(Rs+Re)·I into (11), it is further simplified as
(12)V0=VCb+VCs2+(Rt+ReRsRe+Rs)I.
Taking the time derivative of the output voltage and assuming dI/dt≈0 (this simply means that the change rate of terminal current can be ignored when implemented digitally), we obtain
(13)V˙0=V˙Cb+V˙Cs2.
Substituting the formulae obtained in (9) and (10) into (13) results in
(14)2V˙0=(-A+B)VCb+(A-B)VCs+(ARs+BRe)I.
Then, solving for VCs from (12) we obtain
(15)VCs=2V0-2(Rt+ReRsRe+Rs)I-VCb,
and after substituting it into (14), it yields
(16)V˙0=(-A+B)VCb+(A-B)V0+[A(0.5Rs+Rt+D)+B(0.5Re-Rt-D)]I.
Finally, the complete state variable network is obtained by substituting (16) into (10), represented in matrix form as
(17)[V˙CbV˙CsV˙0]=[-AA0B-B0(-A+B)0(A-B)]·[VCbVCsV0]+[A·RsB·ReA(0.5Rs-Rt-D)+B(0.5Re+Rt+D)]I,
whereby constants A, B, and D were derived previously but are hereby restated as
(18)[ABD]=[1Cbk(Re+Rs)1Csurface(Re+Rs)ReRsRe+Rs].
This completes the initial derivation of the battery model.


## 2.2. Numerical Example

By substituting all capacitor and resistor values from Table1 into (18), the following values are obtained:
(19)[ABD]=[0.0015087593475661.6238379409734910.001875000000000].Table 1
Parameters for cell model [18, 20].
C
bk
C
surface
R
e
R
s
R
t
8
8372.83 F
82.11 F
0.00375 Ω
0.00375 Ω
0.002745 ΩBy defining matrixA,
(20)A=[-AA0B-B0(-A+B)0(A-B)],(21)B=[A·RsB·ReA(0.5Rs-Rt-D)+B(0.5Re+Rt+D)].
Again by substituting the values from Table 1 to calculate A, B, and D, we obtain the value of A as
(22)A=[-1.51×10-31.51×10-301.6238-1.623801.62230-1.6223]andB as
(23)B=[5.66×10-66.08×10-31.05×10-2].As such (17) can be rewritten as
(24)[V˙CbV˙CsV˙0]=A·[VCbVCsV0]+B·I,
or numerically as
(25)[V˙CbV˙CsV˙0]=[-0.00150.001501.6238-1.623801.62230-1.6223]·[VCbVCsV0]+[5.66×10-66.08×10-31.05×10-2]·I.


## 2.3. State-Space Modeling

Based on control theories, a lumped linear network can be written in the form(26)x˙(t)=Ax(t)+Bu(t),y(t)=Cx(t)+Du(t),
where in this work, the state variable x˙(t) is
(27)x˙(t)=[V˙CbV˙CsV˙0].
Obviously,
(28)x(t)=[VCbVCsV0],
with
(29)u(t)=I.
Therefore, by restating the previous calculation values in (21) and (23), we should note that the values of A, B, C, and D are as follows:
(30)A=[-1.51×10-31.51×10-301.6238-1.623801.62230-1.6223],(31)B=[5.66×10-66.08×10-31.05×10-2],(32)C=[001],(33)D=[0],
respectively. As such, with (32), the output y(t) is in fact
(34)y(t)=V0.
This means that the output of the system is the open terminal voltage V0, as expected. Note that this is an important observation from this state-space modeling.Further, the above state-space variables are transformed to a transfer function,G(s). This is done by using ss2tf function in MATLAB, which after factorization yields
(35)G(s)=0.01054s2+0.0171s+2.981×10-5s3+3.248s2+2.637s-1.144×10-18.
The plot of the unit step response for the gain in (35) is given in Figure 3. Basically, it shows that the open circuit terminal voltage V0 in Figure 2 increases linearly during the charging operation in a very slow manner after transient behaviour for few seconds.Figure 3
Output response of RC model due to constant input.


## 2.4. Observability of the RC Battery Model

In control theory, observability is the degree to which the internal states of a system can be predicted via its external outputs. As such, for an observable system, the behavior of the entire system can be predicted via the system’s outputs. On the other hand, if a system is not observable, the current values of some of its states cannot be estimated through the output signal. This means the controller does not know the states’ values. In theory, the observability of a system can be determined by constructing an observability matrixOb.                               (36)Ob=[CCACA2⋮CAn-1],
and a system is observable if the row rank of Ob is equal to n (this is also known as a full rank matrix). The ultimate rationale of such a test is that if n rows are linearly independent, then each of the n states is viewable through linear combinations of the output y(t).Further, substitutingA and C values from (30) and (32) into (36) yields
(37)Ob=[0011.62230-1.6223-2.63440.00242.6320].
Clearly, in this case Ob is a full rank matrix, which concludes that this system is observable.


## 3.  Kalman Filter for SoC Estimation

A continuous time-invariant linear system can be described in the state variable form as(38)x˙(t)=Ax(t)+Bu(t),y(t)=Cx(t),
where u(t) is the input vector, x(t) is the state vector, y(t) is the output vector, A is the time invariant dynamic matrix, B is the time invariant input matrix, and C is the time invariant measurement matrix.If we assume that the applied inputu is constant during each sampling interval, a discrete-time equivalent model of the system will now be
(39)x(n+1)=Ad·x(n)+Bd·u(n),y(n+1)=Cd·x(n+1),
where
(40)Ad≈I+A·Tc,Bd=B·Tc,Cd=C,
whereby I is the identity matrix and Tc is the sampling period. As for this system, two independent process noises are present which are additive Gaussian noise, w vector representing system disturbances and model inaccuracies and V vector representing the effects of measurement noise.Bothw and v have a mean value of zero and the following covariance matrices:
(41)E[w·wT]=Q,E[v·vT]=R,
where E denotes the expectation (or mean) operator and superscript T means the transpose of the respective vectors. In usual case, Q and R are normally set to a constant before simulation; in our case both are set to one (see Section 5). Further, a genetic algorithm (GA) is applied in order to obtain a better set of Q and R values resulting in lower RMS error from the KF’s output.By inclusion of these noises, the resulting system can now be described by(42)x(n+1)=Ad·x(n)+Bd·u(n)+w,z(n+1)=Cd·x(n+1)+v,
which is illustrated in Figure 4,Figure 4
Discrete system model with noisesw and v.


### 3.1.  Property of Kalman Filter

An important property of the KF is that it minimizes the sum-of-squared errors between the actual valuex and estimated states x^, given as
(43)fmin⁡(x)=E([x-x^]·[x-x^]T).
To understand the operations of the KF, the meaning of the notation x^(m∣n) is crucial. Simply stated, it means that the estimate of x at event m takes into account all discrete events up to event n. As such, (43) can include such information, now expanded as
(44)fmin⁡(x)=E([x(n)-x^(n∣n)]·[x(n)-x^(n∣n)T]).
In recursive implementation of the KF, the current estimate x^(n∣n), together with the input u(n) and measurement signals z, is used for further estimating x^(n+1∣n+1). This means that in this discrete system, the input for each sample step will be u1, u2, u3,…,un+1 with respect to the output of y1, y2, y3,…,y(n+1). The recursive KF algorithm is obtained with the predictor and corrector stages.


### 3.2.  KF Online Implementation

For the case of a battery, it is well understood that only the terminal quantities can be measured (terminal voltageV0 and current I). Assuming that battery parameters are time-invariant quantities, the recursive KF algorithm is applied. By applying (40) into (30)–(32), we obtain the following values of updated matrices, with Tc=1:
(45)Ad=[0.99841.51×10-301.62380.623801.622300.6223],Bd=[5.66×10-66.08×10-31.05×10-2],Cd=[001].
Note that Bd and Cd remain similar to their previous values, as given in (31) and (32). By utilizing MATLAB’s control toolbox, the KF is placed in parallel to the state-space model, hereby represented by plant in Figure 5. The complete source code is given in the Appendix.Figure 5
Parallel connection of plant and Kalman filter.


## 3.1.  Property of Kalman Filter

An important property of the KF is that it minimizes the sum-of-squared errors between the actual valuex and estimated states x^, given as
(43)fmin⁡(x)=E([x-x^]·[x-x^]T).
To understand the operations of the KF, the meaning of the notation x^(m∣n) is crucial. Simply stated, it means that the estimate of x at event m takes into account all discrete events up to event n. As such, (43) can include such information, now expanded as
(44)fmin⁡(x)=E([x(n)-x^(n∣n)]·[x(n)-x^(n∣n)T]).
In recursive implementation of the KF, the current estimate x^(n∣n), together with the input u(n) and measurement signals z, is used for further estimating x^(n+1∣n+1). This means that in this discrete system, the input for each sample step will be u1, u2, u3,…,un+1 with respect to the output of y1, y2, y3,…,y(n+1). The recursive KF algorithm is obtained with the predictor and corrector stages.


## 3.2.  KF Online Implementation

For the case of a battery, it is well understood that only the terminal quantities can be measured (terminal voltageV0 and current I). Assuming that battery parameters are time-invariant quantities, the recursive KF algorithm is applied. By applying (40) into (30)–(32), we obtain the following values of updated matrices, with Tc=1:
(45)Ad=[0.99841.51×10-301.62380.623801.622300.6223],Bd=[5.66×10-66.08×10-31.05×10-2],Cd=[001].
Note that Bd and Cd remain similar to their previous values, as given in (31) and (32). By utilizing MATLAB’s control toolbox, the KF is placed in parallel to the state-space model, hereby represented by plant in Figure 5. The complete source code is given in the Appendix.Figure 5
Parallel connection of plant and Kalman filter.


## 4.  Genetic Algorithm

The genetic algorithm (GA), introduced by John Holland, is an approach based on biological evolution [25]. The algorithm is developed based on Charles Darwin’s theory of survival of the fittest. The GA has a very powerful encoding mechanism that enables the representation of a solution vector as either a real coded or binary string. Both encodings serve a different purpose in the context of different problem space. GAs are regarded as the global optimizer that often spot or locate the potential area or even accurately obtain the best solution, known as the global minimum [26–28]. Underneath this popular algorithm are the three operators that contribute to its success in performing optimization task.(i)
Selection. In selection, offsprings with higher fitness have better chance for survival to the following generation in the evolutionary process. This basically is based on the theory of “survival of the fittest.”(ii)
Crossover. The crossover increases and maintains the diversity of the entire population over the entire run. This is due to the fact that a population with higher diversity has the ability to explore a wider range of search space.(iii)
Mutation. This enables chromosomes (potential solutions) to jump to a wider range than crossover. Again, mutation also increases the diversity of the entire population.The pseudocode of the GA is presented in Algorithm1, and relevant figure depicting the algorithm flow is illustrated in Figure 6. To avoid extended discussions on GA, we include here a complete workable source code in the appendix. All parameter settings for the GA are available in the source code.Algorithm 1:Pseudocode of GA.
(1) BEGIN
(2) Initialize populationP(X)
(3)whileTerminate = Falsedo
(4) P(X)←f(x): Fitness evaluation,
(5) Selection,
(6) Crossover,
(7) Mutation,
(8)end while
(9) ENDFigure 6
GA flowchart.In the context of Kalman filter, GA is applied to tune theQ and R parameters, which was explained in detail in Section 3.


## 5. Results

The program, implemented in MATLAB, is given in the appendix to clarify the results obtained in this work. Take note that theQ and R mentioned in (41) are both set to a numerical value of one (Q = R = 1) in the first simulation. The results obtained are tabulated in Table 2. From these results, RMS of the estimated error, which is the error from KF, is far smaller in comparison to the measured error, with values of 1.0013 V and 1.92×10-4 V, respectively. This RMS error is further minimized by utilizing Q=0.012697316315642 and R=2.303940992875865, found using the GA approach. A graph depicting the convergence characteristic is shown in Figure 7.Table 2
RMS error recorded during charging operation.
Output
Q, R
RMS error [V]
Measurement,y-yv
1, 1
1.0013
Estimated (KF),y-ye
1, 1
1.9185
×
1
0
-
4
Estimated (KF),y-ye
0.012697316315642,
2.3282
×
1
0
-
6
(After GA tuning)
2.303940992875865Figure 7
The convergence characteristic of GA.The time plot of the estimated error from 0 s to 60000 s is shown in Figure8, depicting a very small amplitude, in blue color (≈±0.04 V) along the timeline. This is observed through the zoomed display of the MATLAB graph. On the contrary, the measurement error, portrayed by green color noise in Figure 8, has an absolute magnitude of ≈±2 V.Figure 8
The voltage error recorded and depicting measured (green color) and estimated (blue color) errors.


### 5.1.  Charging Behaviour

The charging characteristic is illustrated in Figure9 whereby the initial terminal voltage V0 starts from 0 V and rises up to approximately 0.5 V within 60000 seconds (which is 100 minutes). Charging impulses of 1.53 A are applied in this case as shown in Figure 9. As expected, this is a time consuming process as in general case it may take hours for a car battery (lead acid) to be completely charged.Response of RC battery model in terms ofV0 due to charging current I=1.53 A pulses.
(a)
(b)


### 5.2.  Discharging

For the discharging process, the initial value of terminal voltage,y0=V0, is set to 2.2 V in the MATLAB program. Again, in this case, impulses of 1.53 A are applied, but now in negative form. The dynamic behavior of the discharging characteristic is shown in Figure 10. From this figure, it is observed that the discharging process is similar to the charging process, but now with a linearly decreasing terminal voltage slope. The open terminal voltage V0 drops from 2.2 V to 1.7 V in 60000 seconds (100 minutes); this is similar to the charging process as it takes 100 minutes to reach V0=0.5 V from zero potential.Response of RC battery model in terms ofV0 due to discharge current I=-1.53 A pulses.
(a)
(b)


## 5.1.  Charging Behaviour

The charging characteristic is illustrated in Figure9 whereby the initial terminal voltage V0 starts from 0 V and rises up to approximately 0.5 V within 60000 seconds (which is 100 minutes). Charging impulses of 1.53 A are applied in this case as shown in Figure 9. As expected, this is a time consuming process as in general case it may take hours for a car battery (lead acid) to be completely charged.Response of RC battery model in terms ofV0 due to charging current I=1.53 A pulses.
(a)
(b)


## 5.2.  Discharging

For the discharging process, the initial value of terminal voltage,y0=V0, is set to 2.2 V in the MATLAB program. Again, in this case, impulses of 1.53 A are applied, but now in negative form. The dynamic behavior of the discharging characteristic is shown in Figure 10. From this figure, it is observed that the discharging process is similar to the charging process, but now with a linearly decreasing terminal voltage slope. The open terminal voltage V0 drops from 2.2 V to 1.7 V in 60000 seconds (100 minutes); this is similar to the charging process as it takes 100 minutes to reach V0=0.5 V from zero potential.Response of RC battery model in terms ofV0 due to discharge current I=-1.53 A pulses.
(a)
(b)


## 6. Conclusion

In this work, we successfully obtained the state variables of the RC model representing a battery in terms of mathematical derivations. The derivations lead to the conclusion that there exist three state variables relevant to a battery’s state-space model. With this state-estimation model, a prominent technique known as the Kalman filter is applied in the aim of estimating state-of-charge for a Battery Management System. From numerical results, the KF is shown to be accurate in predicting the dynamic behavior of the system. This is shown by a very small RMS error of the estimation in comparison to its measurement. The estimated error is further reduced after incorporating the optimized values ofQ and R through the offline GA approach. As such, the efficacy of such an approach is, thus, validated.



---

*Source: 176052-2014-08-05.xml*