3.state of Charge Estimation
3.state of Charge Estimation
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 1 of 4
Preparatory definitions, math concepts loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 2 of 4
Implement simple voltage- and current- loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 3 of 4
3.1.1: Welcome to the course!
Prerequisites:
loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 4 of 4
3.1.2: What is the importance of a good SOC estimator?
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 1 of 6
battery-model state, we first focus on estimating SOC only loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 2 of 6
Performance: Without good SOC estimator, one must be overly conservative when
using battery pack to avoid over/undercharge due to trusting poor estimate
With a good estimate, especially one with known error bounds, one can
aggressively use the entire pack capacity
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 3 of 6
3.1.2: What is the importance of a good SOC estimator?
A good SOC estimator is consistent and dependable for any driving profile,
enhancing overall power-system reliability
Density: Accurate battery state estimates allow battery pack to be used aggressively
within design limits, so pack doesn’t need to be over-engineered
This allows smaller, lighter battery packs
Economy: Smaller battery systems cost less. Warranty service on reliable systems
costs less
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 4 of 6
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 5 of 6
Credits
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 6 of 6
3.1.3: How do we define SOC carefully?
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 1 of 9
“Fully charged”
How can we know true SOC for any other purpose? loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 2 of 9
“Fully discharged”
DEFINITION :
balance
current state of state of power
temperature charge (SOC) health (SOH) cells limits
a manufacturer specified voltage (may be function of T ) loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 3 of 9
3.1.3: How do we define SOC carefully?
“Total capacity”
DEFINITION :
balance
current state of state of power
temperature charge (SOC) health (SOH) cells limits
removed as cell is brought from fully charged state loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 4 of 9
“Discharge capacity”
DEFINITION :
current state of state of power
temperature charge (SOC) health (SOH) cells limits
4C rate
resistance, and so also rate and temperature
3.8 8C rate
3.4
total capacity
3.2
Likewise, cell SOC is nonzero when terminal
3
voltage reaches vl .T / when i.t/ > 0 0 1 2 3 4
Discharge capacity (Ah)
5 6
The discharge capacity of a cell at a particular rate and temperature is not a fixed
quantity: it also generally decays slowly over time as the cell degrades
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 5 of 9
“Nominal capacity”
DEFINITION :
balance
current state of state of power
temperature charge (SOC) health (SOH) cells limits
specified quantity intended to be representative of 1C-rate loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 6 of 9
3.1.3: How do we define SOC carefully?
would be removed from cell if it were brought from its loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 7 of 9
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 8 of 9
Credits
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 9 of 9
3.1.4: What are some approaches to estimating battery cell SOC?
20
voltages, and hysteresis on v.t/
0
Wide flat areas of OCV curve dilute accuracy of 0 100 200
Time (min)
300 400 500
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 1 of 7
Even though its estimates are noisy, we’ll find an application for this modified
method in the next course
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 2 of 7
Z
loop once each measurement interval while pack is active
1 t
Ó .t/ D Ó .0/ b ./imeas./ d
Q 0
imeas .t/ D itrue .t/ C inoise .t/ C ibias .t/ C inonlin .t/ C isd .t/ C ileakage .t/
Okay for short periods of operation when initial conditions are known or can be
frequently “reset”
Subject to drift due to current sensor’s fluctuations, current-sensor bias, incorrect
capacity estimate, other losses
Uncertainty/error bounds grow (without limit) over time until estimate is “reset”
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 3 of 7
3.1.4: What are some approaches to estimating battery cell SOC?
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 4 of 7
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 5 of 7
measurements Yk D fy0 ; y1 ; ; yk g
②✝✞✟ ✠✡☛☞ ✌✍
❖❜s❡r✈✦❞ ❢❨❥❳ ✳✎✏ ✑ ✒ ✓ ✴
❯♥♦✧★✩✪✫✬✭
①❦ ✷ ✁ ✂✄✶ ☎✆
✔ ✕✖✗ ✘✙ ✚ ✛✜ ✢✣✤ ✥
The observations allow us to “peek” at what is happening in true system
Based on observations and model, we estimate state
Process- and sensor-noise randomness always cause imperfect estimates
So, to understand SPI solution, must study vector random processes
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 6 of 7
3.1.4: What are some approaches to estimating battery cell SOC?
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 7 of 7
3.1.5: Understanding uncertainty via mean and covariance
Review of probability
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 1 of 6
2 3 2 3
loop once each measurement interval while pack is active
X1 x1
6
X2 7 6
x2 7
where X1 through Xn are themselves
XD 6
6 ::
7
7, x0 D 6
6 ::
7
7,
scalar RVs, and x1 through xn are scalar
4 : 5 4 : 5
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 2 of 6
fZX .x/ 0 Z8 x
current state of state of power
cells
1.
temperature charge (SOC) health (SOH) limits
Z 1 1 1
loop once each measurement interval while pack is active
X D E.X x/.X
e N N D
x/ .x x/.x
N N T fX .x/ dx1 dx2 dxn
x/
T
1 1 1
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 3 of 6
3.1.5: Understanding uncertainty via mean and covariance
e
current state of state of power
Xy 0 8 y
y eT
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 4 of 6
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 5 of 6
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 6 of 6
3.1.6: Understanding joint uncertainty of two unknown quantities
Means that joint pdf factors into product of marginal pdfs (not generally true)
“The particular value of the random variable X1 has no impact on what value we
would obtain for the random variable X2 ”. . . no nonlinear or linear relationship
UNCORRELATED : Two jointly-distributed RVs X1 and X2 are uncorrelated iff
cov.X1 ; X2 / D E.X1 xN 1 /.X2 xN 2 /T D 0
Can show that this implies that EX1 X2T D EX1 EX2T : Means that expectation
of a product factors into product of expectations (not generally true)
Implies 12 D 0; uncorrelated means there is no linear relationship between RVs
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 1 of 7
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 2 of 7
Conditional probability
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 3 of 7
3.1.6: Understanding joint uncertainty of two unknown quantities
Bayes’ rule
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 4 of 7
Conditional expectation
1
EX D x jY D y D EX jY D xfX jY .x jY / dx
1
Conditional expectation is critical
KF is an algorithm to compute Exk j Yk . . . expected value of model state vector
given complete set of measurements made
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 5 of 7
If Y
current state of state of power
temperature charge (SOC) health (SOH) cells limits
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 6 of 7
3.1.6: Understanding joint uncertainty of two unknown quantities
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 7 of 7
3.1.7: Understanding time-varying uncertain quantities
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 1 of 7
D
current state of state of power
cells
EXk1 XkT2 .
temperature charge (SOC) health (SOH) limits
1. Autocorrelation: RX .k1 ; k2 / If stationary, loop once each measurement interval while pack is active
RX . / D EXk XkTC
Provides a measure of correlation between elements of the process having
time displacement
RX .0/ D X2 for zero-mean X
RX .0/ is always the maximum value of RX . /
2. Autocovariance: CX .k1 ; k2 / D E.Xk1 EXk1 /.Xk2 EXk2 /T . If stationary,
CX . / D E.Xk x/.X
N kC x/ N T
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 2 of 7
White noise
1. Zero mean
2. RX . / D EXk XkTC D SX . / where . / is the Dirac delta. . / D 0 8 ¤ 0
Therefore, the process is uncorrelated in time
Clearly an abstraction, but proves to be a very useful one
White noise Correlated noise
4 0.2
0.15
2
0.1
0.05
Value
Value
0
0
−0.05
−2
−0.1
−4 −0.15
0 200 400 600 800 1000 0 200 400 600 800 1000
Time Time
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 3 of 7
3.1.7: Understanding time-varying uncertain quantities
❲❤✐t❡ ❙✂❛♣✄❞
✢ ✣✤ ✥ ✙✚ ● ✳③ ✴ ✛✜
♥♦ s✁ ✇❦ ☎✆✝✞✟ ✠✶❀✡
✭✮✯✰
☛☞✌✍✎
❍ ✪✫ ✬ ✦ ✧★ ✩ ②✘
✏✑✒✓✔ ✕✷✖✗
✱✲✵✸✹✺
Can drive our linear system with noise that has desired characteristics by
introducing shaping filter H.´/ that itself is driven by white noise
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 4 of 7
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 5 of 7
Gaussian processes
NOTATION : Until now, we have always used capital letters for random variables
State of system driven by random process is an RV, so we could call it Xk
More common to retain standard notation xk and understand from context that we
are discussing an RV
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 6 of 7
3.1.7: Understanding time-varying uncertain quantities
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 7 of 7
3.1.8: Where from here?
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 1 of 3
4/23/18, 3)08 PM
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 2 of 3
file:///Users/glp/OneDrive%20-%20University%20of%20Colorado%20C…ING/MOOC-BMS/COURSE3/FIGURES/FIGURES-3-1-8/ancient-1300292.svg Page 1 of 1
Credits
loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | The importance of a good SOC estimator j 3 of 3
3.2.1: Predict/correct mechanism of sequential probabilistic inference
Vector notation
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 1 of 8
Matrix notation
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 2 of 8
loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 3 of 8
3.2.1: Predict/correct mechanism of sequential probabilistic inference
d T d T d T
dX
Y X D Y; dX
X Y D Y; and
dX
X AX D .A C AT /X
Then,
d T T C
0 D CE xk xk 2xk xk O C .xO kC/T xO kC j Yk
dxO k
D E 2.xk xO kC/ j Yk D 2xO kC
0 2E xk j Yk
O kC D E xk j Yk
x
Desire to find algorithm for computing for Exk j Yk
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 4 of 8
Define prediction
current state of state of power
error where
cells
x
temperature charge (SOC) health (SOH) limits
O D E xk j Yk
loop once each measurement interval while pack is active
xk 1
Error is always “truth minus prediction” or “truth minus estimate”
We can’t compute error in practice, since truth value is not known
But, we can prove statistical results using this definition that give an algorithm for
estimating the truth using measurable values
Also, define the measurement innovation (what is new or unexpected
in the
measurement) as yQk D yk O
yk where yOk D E yk j Yk 1
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 5 of 8
method of iterated expectation: EY EX jY X j Y D EX X
loop once each measurement interval while pack is active
Q D E xk E E xk j Yk 1 D E xk E xk D 0
E xk
E yQk D E yk E E yk j Yk 1 D E yk E yk D 0
Note also that xQ k is uncorrelated with past measurements as they have already
been incorporated into xO k
E xQ k j Yk 1 D E xk E xk j Yk 1 j Yk 1 D 0 D E xQ k
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 6 of 8
3.2.1: Predict/correct mechanism of sequential probabilistic inference
Predict/correct solution
loop once each measurement interval while pack is active
E Q j Yk D E xkj Yk
xk E xO k j Yk
xO kC xO k
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 7 of 8
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 8 of 8
3.2.2: The Kalman-filter gain factor
state estimate
cells
x
temperature charge (SOC) health (SOH) limits
k k k k
But, what is E xQ k j yk ?
loop once each measurement interval while pack is active
We will then apply this generic result for f .x j y/ to our specific problem of
determining f .xQ k j yk / by setting x D xQ k and y D yk
We can then use this conditional pdf to find E xQ k j yk
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 1 of 9
f .x; y/
2 y yN e
X y N
y
/ ,
f .y/ exp 1
2 .y N T
y/ yQ 1 .y y/N
where the constant of proportionality is not important to subsequent operations
Recall that exp.A/= exp.B / D exp.A B /. . . which we take advantage of next
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 2 of 9
T
1 x xN 1 x x N C 21 .y y/
N T yQ 1 .y y/
N
2 y yN
e
X y y N
To condense notation somewhat, define xQ D x xN and yQ D y yN
Then, the terms in the exponent become,
T
1 xQ 1 xQ C 1 yQ T 1yQ
yQ yQ yQ
2 e
X 2
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 3 of 9
3.2.2: The Kalman-filter gain factor
Then,
1 1 1 1
xQ xQ yQ xQ xQ yQ yQ 1 yQ xQ xQ yQ yQ 1
yQ xQ yQ
D I
1
yQ yQ xQ
0
I 0
0
yQ
I
0 I
.xQ xQ yQ yQ 1 yQ xQ / 1 0 xQ yQ yQ 1
D I
yQ 1 yQ xQ
0
I 0 yQ 1
I
0 I
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 4 of 9
1
exponent D 2
Q T 1
x M x Q xQ T M 1xQ yQ yQ 1yQ yQ T yQ 1yQxQ M 1xQ
C yQ T yQ 1yQxQ M 1xQ yQ yQ 1yQ C yQ T yQ 1yQ yQ T yQ 1yQ
Last two terms cancel; remaining terms can be grouped as
1
exponent D 2
Q
x
1 T
xQ yQ yQ y M
1
x Q Q 1
xQ yQ yQ y Q
In terms of only the original variables, exponent is
T 1
1
2
x N C xQ yQ yQ
x
1
.y N
y/ xQ xQ yQ yQ yQ xQ
1
x x N C xQ yQ yQ 1
.y N
y/
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 5 of 9
T 1
1
2
x N C xQ yQ yQ 1.y y/
x N xQ
1
xQ yQ yQ yQ xQ x x N C xQ yQ yQ 1.y y/
N
Infer that mean of f .x j y/ must be xN C xQ yQ yQ 1 .y y/
N
Infer that covariance of f .x j y/ must be xQ xQ yQ yQ 1 yQ xQ
So, we conclude that
f .xj y/ N .xN C xQ yQ yQ 1.y y/;
N xQ 1
xQ yQ yQ yQ xQ /
E x j y D E x C xQ yQ yQ y E y
1
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 6 of 9
3.2.2: The Kalman-filter gain factor
loop once each measurement interval while pack is active
E Q j yk D Q C
xk E xk xQ y;k
Q Q
1
y;k yk E yk
D Q C E xk xQ y;k
Q y;k
1
Q yk Q C yOk E yQk C yOk
D C 0 xQ y;k
Q y;k
1
Q yk yk Q C O .0 C yOk / D xQ y;k Q yQk
1
Q y;k
Lk
Putting all of the pieces together, we get the general update equation:
xO C D xO C L yQ k k k k
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 7 of 9
xQ ;k is
temperature charge (SOC) health (SOH) cells limits
C T
xQ ;k D E .xk xO kC/.xk xO kC/T D E .xk xO k / Lk yQk .xk xO k / Lk yk Q
D E xQ k Lk yQk xQ k Lk yQk T
T
D xQ ;k Lk E yQk
.x k yQk Lk C Lk y;k
Q k /T E xQ T
Q Lk
T
y;k
Q LT
k
Lk y;k
Q
D xQ ;k Q Lk
Lk y;k
T
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 8 of 9
Summary
loop once each measurement interval while pack is active
O kC D xO k C Lk yk yOk D xO k C Lk yQk
x
C
xQ ;k D xQ ;k
T
Q Lk
Lk y;k
where
O D E xk j Yk 1
xk xQ ;k D E .xk xO k /.xk xO k /T D E .xQ k /.xQ k /T
O kC D E xk j Yk
x
C
xQ ;k D E .xk O kC/.xk xO kC/T D E .xQ kC/.xQ kC/T
x
Ó k D E ´k j Yk 1 Q D E .yk yOk /.yk yOk / D E .yQk /.yQk /
y;k
T T
Lk D E .xk O k /.yk yOk / y;k Q D xQ y;k
T 1 1
x Q y;k
Q
Note that this is a linear recursion, even if the system is nonlinear(!)
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 9 of 9
3.2.3: Summarizing the six steps of generic sequential probabilistic inference
Steps 1a–1b
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 1 of 5
Step 1c
O D E yk j Yk
yk 1 D E h.xk ; uk ; vk / j Yk 1
Summarizing general step 1
Step 1a: State prediction time update
Prediction
Step 1b: Error covariance time update
Q y;kQ
General step 2b: State estimate measurement update
Compute the posterior state estimate by updating the prediction using the Lk and
the innovation yk O
yk
O C D xO k C Lk .yk
xk O
yk /
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 3 of 5
Step 1a: State prediction time update
Prediction
Step 1b: Error covariance time update
3.2.3: Summarizing the six steps of generic sequential probabilistic inference
Summarizing step 2
Correction
Step 2b: State estimate measurement update
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 4 of 5
Summary
✂ ✝ ✠ ✚
①❖❦ ❉ ❊ ✁ ✄ ❥ ❨☎✆✶ ✞ ✟ ❢ ✳✡ ☛☞✌ ❀ ✉ ✍✎✏ ✑ ✇✒✓✔ ✴ ✕ ✖✗✘✙ ✛
loop once each measurement interval while pack is active
Prediction
Step 1b: Error covariance time update
✧ ✷ ✺
✻✢✜◗✣✤ ✥ ✦ ★✪✩✬✫ ✭✮✰✯✲✱ ✵❚ ✸ ✹ ✼✽ ✾ ✿ ❂❁❄❃ ❅❆❇ ❈ ❋ ❍●❏■ ❑▲ ❪▼
Step 1c: Predict system output
❯ ❴ ❜ ③
②◆P ❘ ❙ ❱❲ ❳ ❩❬❭❫ ❵ ❛ ❤❝❞ ❡ ❣ ✐ ❧ ♠ ✈ ♥ ♦ ♣ qrst ④
Step 2a: Estimator gain matrix
⑤ ⑥ ⑦ ⑧❶⑨⑩❸❷ ❹❺ ❻ ❼❽
❿❾ ➀➁ ➂
Correction
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 5 of 5
3.2.4: Deriving the three Kalman-filter prediction steps
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 1 of 7
Assumptions on noises
Ewn wkT D
e
w; n D kI Evn vkT D
vQ ; n D kI
0; n ¤ k: 0; n ¤ k,
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 2 of 7
O D E f .xk 1; uk 1; wk 1/ j Yk 1
xk
D E Ak 1xk 1 C Bk 1uk 1 C wk 1 j Yk 1
D E Ak 1xk 1 j Yk 1 C E Bk 1uk 1 j Yk 1 C E wk 1 j Yk 1
D Ak 1xO kC 1 C Bk 1uk 1,
by the linearity of expectation, noting that wk 1 is zero-mean
INTUITION: When predicting the present state given only past measurements, the
best we can do is to use the most recent state estimate and system model,
propagating the mean forward in time
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 3 of 7
3.2.4: Deriving the three Kalman-filter prediction steps
Q D xk xO k D Ak 1xk 1 C Bk
xk 1 uk 1 C wk 1 O kC 1
Ak 1 x Bk 1 uk 1
D Ak 1xQ kC 1 C wk 1
Therefore, the covariance of the prediction error is
xQ D E .x
k
Q k /.xQ k /T D E .Ak 1xQ kC 1 C wk 1/.Ak 1xQ kC 1 C wk 1/T
D E Ak 1xQ kC 1.xQ kC 1/T ATk 1 C wk 1.xQ kC 1/T ATk 1 C Ak 1xQ kC 1wkT 1 C wk 1wkT 1
D Ak 1CxQ ;k 1ATk 1 C ew
Therefore cross terms drop out of the final result since the white process noise
wk 1 is not correlated with the state at time k 1 and is zero mean
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 4 of 7
current state of state of power
INTUITION : When estimating state-prediction error covariance temperature charge (SOC) health (SOH) cells limits
xQ D Ak C T
C ew
k 1 xQ ;k 1 Ak 1
Best to use most recent covariance estimate and propagate forward in time
For stable systems, Ak 1 C T
xQ ;k 1 Ak 1 is contractive: covariance gets “smaller”
State of stable systems always decays toward zero in absence of input, or
toward a known trajectory if uk ¤0
Term tells us that we tend to get increasingly certain of state estimate over time
On the other hand, e
w adds to the covariance
Unmeasured inputs add uncertainty to our estimate because they perturb the
trajectory away from the known trajectory based only on uk
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 5 of 7
O D E h.xk ; uk ; vk / j Yk 1 D E Ck xk C Dk uk C vk j Yk
yk 1
D E Ck xk j Yk 1 C E Dk uk j Yk 1 C E vk j Yk 1
D Ck xO k C Dk uk ,
since vk is zero-mean
O is best guess of system output, given only past measurements.
INTUITION : yk
The best we can do is to predict the output given the output equation of the
system model, and our best guess of the system state at the present time
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 6 of 7
3.2.4: Deriving the three Kalman-filter prediction steps
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 7 of 7
3.2.5: Deriving the three Kalman-filter correction steps
1
current state of state of power
cells
Q y;k
Q
temperature charge (SOC) health (SOH) limits
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 1 of 8
Q :
temperature charge (SOC) health (SOH) cells limits
ExQ k yQkT D E Q
xk .Ck xk Q C vk /T D E xQ k .xQ k /T CkT C xQ k vkT
D T
xQ ;k Ck
Combining y;k
Q and xQ y;k
Q in Lk D xQ y;k 1
Q ,
Q y;k
Lk D xQ ;k CkT Ck xQ ;k CkT C vQ 1
INTUITION : Note that the computation of Lk is the most critical aspect of Kalman
filtering that distinguishes it from a number of other estimation methods
The whole reason for calculating covariance matrices is to be able to update Lk
Lk is time-varying: It adapts to give the best update to the state estimate based
on present conditions
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 2 of 8
current state of state of power
O C D xO k C Lk .yk O
loop once each measurement interval while pack is active
xk yk /
xQ ;k tells us about state uncertainty at the present time, which we hope to reduce
as much as possible
A large entry in xQ ;k means that the corresponding state is very uncertain and
therefore would benefit from a large update
A small entry in xQ ;k means that the corresponding state is very well known
already and does not need as large an update
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 3 of 8
3.2.5: Deriving the three Kalman-filter correction steps
xQ ;k CkT
current state of state of power
The CkT term gives the coupling between state and output
Entries that are zero indicate that a particular state has no direct influence on a
particular output and therefore an output prediction error should not directly
update that state
Entries that are large indicate that a particular state is highly coupled to an
output so has a large contribution to any measured output prediction error;
therefore, that state would benefit from a large update
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 4 of 8
1
current state of state of power
Q ,
cells
INTUITION Q y;k
temperature charge (SOC) health (SOH) limits
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 5 of 8
INTUITION : yk O
is predicted measurement, based on present state prediction
Therefore, yk yOk is what is unexpected or new in the measurement
We call this term the innovation. The innovation can be due to a bad system
model, state error, or sensor noise
So, we want to use this new information to update the state, but must be careful
to weight it according to the value of the information it contains
Lk is the optimal blending factor, as we have already discussed
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 6 of 8
3.2.5: Deriving the three Kalman-filter correction steps
C T
xQ ;k D xQ ;k Q Lk D xQ ;k Lk y;k
T T
Lk y;k Q y;k
Q xQ y;k
Q
D xQ ;k Lk Ck xQ ;k
D .I Lk Ck /xQ ;k
INTUITION :
A covariance matrix is positive semi-definite, and Lk y;kQ LTk is also a
positive-semi-definite form, and we are subtracting this from the predicted-state
covariance matrix; therefore, the resulting covariance is “lower” than the
pre-measurement covariance
Measurement update has decreased our uncertainty in state estimate
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 7 of 8
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 8 of 8
3.2.6: Where from here?
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 1 of 3
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 2 of 3
Credits
loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Introducing the linear Kalman filter as a state estimator j 3 of 3
3.3.1: Visualizing the Kalman filter with a linearized cell model
Initialization
①❖✵❈ ✱ ✻✁◗ ❀✂ ➎➏➐➑ ➒➓➔→ ➣↔↕➙➛➜➝ ➞➟➠➡➢➤➥➦➧ ➨
1a 2c “Simple” to implement on
☎✄❦✆ ❉ ❆✝✞✶ ✠✟☛☞✌
✡ ✍ ❇✎✏✑ ✉ ✒✓✔ ⑩❸❶❷❹❺ ❻ ❼❽ ❾ ❿ ➀ ➁➂ ➃➄➇➅➆➈➉ a digital computer
1b 2b However, note that our
✕✘✖✗✙✚ ✛ ✜✢✣✤ ✥★✦✧✩✪✫✬ ✭✮✯✰
❚ ✲✳✇❡
Meas. ❤❣❥✐ ❧ ♥♠♣♦ q r s t③④ ⑤ ⑦⑥⑧ ⑨ cell models are nonlinear,
Meas.
1c
➌➍
2a ➊➋ so we cannot apply
②✴✷ ✸ ✹✺ ✽✼✿✾ ❁ ❂❃ ❄ ❅ ▲ ❊ ❋●❏❍■❑▼ ◆❘P ❬❙❯ ❱❨❲❳❩❭ ❪❴❫ ❵❛✈❜ ❝❞❢ (linear) Kalman filter to
them directly
Prediction Correction
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 1 of 8
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 2 of 8
D 1 ´k 36001 Q ik
OCV versus SOC for four cells at 25°C
´ k C1
4
Open-circuit voltage (V)
yk D 0:7 ´k R0 ik
Define state xk ´k and input uk ik
3.5
B D
1 10 4 , C D 0:7, and D D 0:01 0 20 40 60 80 100
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 3 of 8
3.3.1: Visualizing the Kalman filter with a linearized cell model
Iteration 1
i0
①❖❦ ❉ ❆✁✂✶ ☎✄✆✝✞❈ ✟ ❇✠✡☛ ✉ ☞✌✍ ✏✎✒✑ ✓ ✔ ✕ ✵✿✺ ✖ ✗✘✙✹ ✚ ✛ ✜ ✢✣✤✾✥✦
✻★✧◗❀✩ ✪ ✫✬✭✮ ✯✲✰✱✳✴✷✸ ✼✽❁❂ ❚ ❃ ❄✇❡ ❅●❊❋❍■ ❏ ❑ ▲ ▼ ◆ P ❘ ❙❯❱❲ ❳ ❨❩❬❭
②❪❫ ❴ ❵❛ ❝❜❢❞ ❣ ❤✐ ❥ ❧ ♥♠♦ ♣ qrs t ✈③④⑤⑥⑦ ⑧ ⑨⑩❶❷ ❸ ❹❺❻ ❼ ❽❾❿➀➁➂➃
➄ ➅ ➆ ➇➊➈➉➋➌ ➍➏➎ ➐➑➒ ➓➣➔→↔↕ ➙➜➛ ➝➞➠➟ ➡➢➤ ➥ ➦ ➧ ➨➩➫➭ ➯ ➲➳➵➸➺➻➼➽ ➾ ➚➪➶➹ ➘ ➴➷➬➮➱✃
❐ ❒❮❰ÏÐÑÒÓÔÕÖ×
ÙØÛÚ Ü ÞÝàß á â ã äåæ ç éèê ë ÿþ✶❈ ❉ ✵✿✹✾ ✁ ✂ ✻✄☎✆✝✞✟✠✡☛☞✺ ✳✌✍✸✎ ✏ ✑✒✓✔✕✖✗✴
ìíîïðñ òó ô õö÷ø ù úûüý ✘ ✙✚✛✜✢✣✤✥✦
✧ ①★ ✱
◗ ❀❦ ✩ ✪■ ✫ ▲ ✬ ✭ ✮ ✯✰✷✼✽
✲ ❁ ❄❂ ❯❱
❃ ❅❆ ❇ ❊❋ ● ❍❏❑▼◆❖P❘❙❚ ❲ ❳❨❩❬ ❭ ❪❫
❴❵
❧♠
p ❛ ❜❝❞❡❢❣❤✐❥
Iteration 2
i1
❈ ✟ ❇✠✡☛ ✉ ☞✌✍
①❖❦ ❉ ❆✁✂✶ ☎✄✆✝✞ ✏✎✒✑ ✓ ✵✿✹✾✔✕✖✗✘ ✙ ✚✛✜✢ ✣ ✤✥✺ ✦ ✧★✩✪✫✽✬
✻✮✭◗❀✯ ✰ ✱✲✳✴ ✷❁✸✼❂❃❄❅ ❊❋●❍
❚ ■ ❏✇❡ ❑ ▲ ❙ ❯❱❲❳❨❩❬❭❪❫❴ ❵ ❛❜❝❞ ❢ ❣❤✐❥❧♠♥♦♣qrs
◆▼ P❘
⑧
②t✈ ③ ④⑤ ⑦⑥⑨ ⑩ ❶❷ ❸ ❹ ❻❺❼ ❽ ❾❿➀➁➂➃➄➅➆➇➈ ➉ ➊➋➌➍ ➎ ➏➐➑➒ ➓ ➔→➣↔↕➙➛➜
➡ ➨ ➳
➝ ➞ ➟ ➠➤➢ ➥➦ ➧➩ ➫➭➯ ➲➸➵ ➺➻ ➼➾ ➚➪➹➶ ➘ ➬ ➮ ➱ ✃❐❒❮❰ÏÐÑÒÓÔÕ Ö ×ØÙÚÛÜÝÞßàáâãäåæ ç èéêë ì íîïðñò
➽ ➴➷
ó ôõö÷øùúûüý
ÿþ❦❈ ❉ ①❖✁ ✂ ▲ ✄ ✳②☎ ✆ ✞✝✟ ✴ ✑✏✷✒ ✓ ✵✔✕✾✖✗✘ ✙ ✚✛✜✢✣✶✤✥✦✧★✩✪✫✬ ✯ ✰✱✲✻✼❀❁❂❃
✭✇❤❡r✠ ✡☛ ☞ ✸✿✽✹ ✌ ✍✎✺✮ ❄ ❅❆❇❊❋●❍■
❏▼❑◗◆P ❘ ❙❚ ❯ ❱ ❲ ❳❨ ❩❬❫❭❪❴❵ ❛❞❜❝❢❣ ✐ ❥❧ ♠ ♥♦♣qst✉✈③④ ⑤ ⑥⑦⑧⑨ ⑩ ❶❷❸❹❺❻❼❽❾❿➀➁
➂ ➃➄➅➆➇➈➉➊➋➌➍➎
p
Output: Ó D 0:4998 3 1:99976 10 5 D 0:4998 0:013416
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 5 of 8
Covariance
✻①◗ ❀✶ ❉ ✁✂✄✵☎✺
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 6 of 8
3.3.1: Visualizing the Kalman filter with a linearized cell model
Results
×
❀✿ ✚✛✜ ❚❁❂❃ ✷✵
✴✷ ❊❄❅❆❇❈❉❋ ✴
❙ ✗✘✙ ●❍❏❑▲ ✲✳✱
✰✯ ✕✖✗✘
✔✕✖ ✮
❈ ❘❯❙
❚
✵
❱❨❲
❳
✲✑✒✓ ✑✒✓✔
✸ ✁ ✹✂✄ ✺☎✆ ✻✝✞ ✼✟✠ ✽✡☛ ✾☞✌ ✶✍✎✏ ✸ ✁ ✹✂✄ ✺☎✆ ✻✝✞ ✼✟✠ ✽✡☛ ✾☞✌ ✶✍✎✏
■✫✬✭✮✯✰✱✳ ■✦✧★✩✪✫✬✭
Note that Kalman filter does not perform especially well since vQ is quite large
However, these are best-possible results, since KF is the optimum MMSE estimator
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 7 of 8
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 8 of 8
3.3.2: Introducing Octave code to generate correlated random vectors
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 1 of 5
A needed transformation
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 2 of 5
Y , we can generate
temperature charge (SOC) health (SOH) cells limits
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 3 of 5
3.3.2: Introducing Octave code to generate correlated random vectors
y coordinate
3
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 4 of 5
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 5 of 5
3.3.3: Introducing Octave code to implement KF for linearized cell model
Introduction to lesson
w D vQ D 1 and
Code will be demonstrated for simulated system where e
xk D xk 1 C uk 1 C wk 1
yk D xk C vk
Can be modified in straightforward ways to simulate other systems having other
noise sources
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 1 of 7
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 2 of 7
KF step 1
for k = 1: maxIter ,
% KF Step 1 a : State estimate time update
xhat = A * xhat + B * u ; % use prior value of " u "
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 3 of 7
3.3.3: Introducing Octave code to implement KF for linearized cell model
KF step 2
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 4 of 7
Plot results
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 5 of 7
Sample results
w D vQ D 1, and
meas. voltage estimate estimate balance compute
D xk 1Cuk 1Cwk
loop once each measurement interval while pack is active
D xk C vk
❑✯❧♠✰✱ ✳✴✻✼✽ ✾✿ ❀❝❁❂❃❄
✒✓ ❭
yk ✏✑
t✔✕✖
❡✗✘✙✚✛✜✢
❜✣✤✥✦✧
❾
❽ ❬
❼
❻
❺ ❩
expected)
■★✩r❛✪✐♦♥ qs✉✈✇①②③④
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 6 of 7
3.3.3: Introducing Octave code to implement KF for linearized cell model
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 7 of 7
3.3.5: Can we automatically detect bad measurements with a Kalman filter?
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 1 of 7
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 2 of 7
NEES is chi-squared
Also, ´k N .0; I / since Q́ D M M M M D M M M M D I ;k k
T
k k
1 T
k k k
1
k
T T
k
NEES e D ´ ´ D yQ Q yQ is the sum of squares of independent N .0; 1/ RVs
2
k
T
k k
T
k
1
y;k k
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 3 of 7
3.3.5: Can we automatically detect bad measurements with a Kalman filter?
2 m=2
.m=2/ ✓✔✕✖
✏✑✒
❋
❉ ✠✡☛
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 4 of 7
Computer calculation of U
2
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 5 of 7
Manual table-lookup of U
2
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 6 of 7
3.3.5: Can we automatically detect bad measurements with a Kalman filter?
Summary
voltage-sensor errors
Once only, off-line, precompute 2U . ; m/ for yk 2 Rm and desired
As KF executes, every time sample, compute ek2 D yQkT y;k
Q yQk
1
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 7 of 7
3.3.6: How do I initialize and tune a Kalman filter?
If battery load is “off” for a “long” time, just assume that cell
current state of state of power
temperature charge (SOC) health (SOH) cells limits
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 1 of 7
w , vQ
current state of state of power
temperature charge (SOC) health (SOH) cells limits
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 2 of 7
w is covariance matrix of
temperature charge (SOC) health (SOH) cells limits
C D Axk C B uk C wk
xk 1
Process noise is any unmeasured (zero-mean, white) input that affects state vector
If wk chosen to model current-sensor noise, then e
w can be determined
statistically via experimentation
But, as no model is perfect, w also attempts to capture—in some way—state-
e
equation inaccuracies, so should have larger uncertainty than simply representing
current-sensor noise alone
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 3 of 7
3.3.6: How do I initialize and tune a Kalman filter?
of “measurement noise” vk
yk D C xk C Duk C vk
Measurement noise is any unmeasured (zero-mean, white) input that doesn’t affect
state vector, but which does corrupt measurements
If vk chosen to model voltage-sensor noise, then vQ can be determined statistically
via experimentation (or data sheet)
But, as no model is perfect, vQ also attempts to capture—in some way—output-
equation inaccuracies, so should have larger uncertainty than simply representing
voltage-sensor noise alone
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 4 of 7
Rate of convergence
w and vQ
temperature charge (SOC) health (SOH) cells limits
Large e
loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 5 of 7
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 6 of 7
3.3.6: How do I initialize and tune a Kalman filter?
Credits
loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 7 of 7
3.3.7: Where from here?
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 1 of 3
systems
loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 2 of 3
Credits
loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Coming to understand the linear Kalman filter j 3 of 3
3.4.1: Introducing nonlinear variations to Kalman filters
xk D Ak 1 xk 1 C Bk 1 uk 1 C wk 1
yk D Ck x k C Dk uk C vk
But, cell models are nonlinear, so the standard KF recursion doesn’t apply directly
We now generalize to the nonlinear case, with system dynamics described as
xk D f .xk 1 ; uk 1 ; wk 1 /
yk D h.xk ; uk ; vk /
Functions f ./ and h./ may be time-varying, but we generally omit the time
dependency from the notation for ease of understanding
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 1 of 5
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 2 of 5
expectation
Stepoperations (because
2b: State estimate of different system
measurement update model)
Prediction
Step 1b: Error covariance time update
Update steps of nonlinear Kalman filters
EKF andStep
current state of state of power
SPKF
1c: both follow same set of general steps as KF temperature charge (SOC) health (SOH) cells limits
Predict system output loop once each measurement interval while pack is active
Correction
Step 2b: State estimate measurement update
Again, EKF and SPKF simply have different expressions from KF for evaluating the
expectation operations implied in Step 2a (because of different system model)
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 4 of 5
Summary
1
cf. http://www.ieeeghn.org/wiki/index.php/First-Hand:The_Unscented_Transform
re. name “unscented”
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 5 of 5
3.4.2: Deriving the three extended-Kalman-filter prediction steps
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 1 of 6
O D Ef .x ; u ; w
xk k 1 k 1 k 1/ jY k 1
f .xO C ; u ; wN
k 1 k 1 k 1/ ,
where wN k 1 D Ewk 1 k 1 N D 0.)
. (Often, w
That is, we approximate the expected value of the new state by assuming that it is
reasonable to simply propagate xO kC 1 and wN k 1 through the state equation.
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 2 of 6
Q Dx O D f .x OC N
loop once each measurement interval while pack is active
xk k xk k 1; uk 1; wk 1/ f .xk 1
; uk 1; wk 1/
Approx. first term via Taylor series around prior operating point fxO kC 1 ; uk 1; wkN 1 g
xk f .xO C k 1
; uk 1; N
wk 1/ C df .x k 1;
dxk
uk 1; wk 1/
C
.xk 1 OC
xk 1
/
1 xk 1 DxO k 1
Defined as AOk 1
C df .x k 1;
dwk
uk 1; wk 1/
.wk 1 N
wk 1/
1
wk 1 DwN k 1
Defined as BO k 1
This gives xQ k AO k 1 xk Q C C BO
1 k 1w
ek 1
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 3 of 6
3.4.2: Deriving the three extended-Kalman-filter prediction steps
1
Note, by the chain rule of total differentials,
df .xk 1; uk 1; wk 1/ D @f .x k 1;
@xk
uk 1; wk 1/
dxk 1 C @f .x k 1;
@uk
uk 1; wk 1/
duk 1
1 1
C @f .x k 1; uk
@wk
1; wk 1/
dwk 1
1 0
df .xk 1; uk 1; wk 1/ @f .xk 1; uk 1; wk 1/ @f .xk 1; uk 1; wk 1/ duk
dxk
D @xk
C @uk dxk
1
1 1 1 1
@f .xk 1; uk 1; wk 1/ dwk @f .xk 1; uk 1; wk 1/
+
@wk dxk
1
D @xk
1 1 1
0
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 4 of 6
h.xO ; u ; vN /,
k k k
where vN k D Ev k
That is, it is assumed that propagating xO k and the mean sensor noise is the best
approximation to estimating the output
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 5 of 6
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 6 of 6
3.4.3: Deriving the three extended-Kalman-filter correction steps
Q y;k
Q
temperature charge (SOC) health (SOH) cells limits
Q D yk
yk O D h.xk ; uk ; vk /
yk O
h.xk ; uk ; vk / N
using Taylor-series expansion on first term
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 1 of 4
Q CO k xQ ;k CO k C DO k vQ DO k ;
loop once each measurement interval while pack is active
T T
y;k
Q E.xQ k /.CO k xQ k C DO k vQ k /
T
xQ y;k
D xQ ;k COkT
These terms may be combined to get the Kalman gain
D xQ ;k COkT COk xQ ;k COkT C DO k vQ DO kT
1
Lk
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 2 of 4
Computes posterior state estimate by updating prediction loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 3 of 4
3.4.3: Deriving the three extended-Kalman-filter correction steps
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 4 of 4
3.4.4: Introducing a simple EKF example, with Octave code
An EKF example
with e
w D 1 and vQ D 2
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 1 of 9
p5 C x C w
temperature charge (SOC) health (SOH) limits
AOk D D D
@f .xk ; uk ; wk / @ k k 1
q
xk DxO kC 2 5CxO kC
@xk @xk
xk DxO kC
p5 C x C w
BOk D @f .xk ; uk ; wk /
D @ k k
D1
@w k @w wk DwN k k
wk DwN k
O D @h.xk ; uk ; vk /
Ck D @ xk3 vk C
D 3.xO k /2
@x k xk DxO k @xk
xk DxO k
Dk O D @h.xk ; uk ; vk / D @ xk3 C
vk
D1
@v k vk DNvk @vk
vk DNvk
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 2 of 9
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 3 of 9
3.4.4: Introducing a simple EKF example, with Octave code
for k = 1: maxIter ,
% EKF Step 1 a : State estimate time update
% ( First compute Ahat , Bhat : Specifics depend on model !)
% Note : For this example , x ( k +1) = sqrt (5+ x ( k ) ) + w ( k )
% Note : You need to insert your system ' s f (...) equation here
Ahat = 0.5/ sqrt (5+ xhat ) ; Bhat = 1;
xhat = sqrt (5+ xhat ) ;
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 4 of 9
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 5 of 9
EKF step 2c
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 6 of 9
3.4.4: Introducing a simple EKF example, with Octave code
subplot (1 ,2 ,2) ;
plot (t , xstore (1: maxIter ) - xhatstore , 'b - ' ,t , ...
3* sqrt ( SigmaXstore ) , 'm - - ' ,t , -3* sqrt ( SigmaXstore ) , 'm - - ') ;
grid ; legend ( ' Error ' , ' bounds ' ,0) ;
title ( ' EKF Error with bounds ') ;
xlabel ( ' Iteration ') ; ylabel ( ' Estimation error ') ;
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 7 of 9
Representative results
EKF works well for small states, when system is fairly linear
loop once each measurement interval while pack is active
4 −0.5
State
3
−1
2
−1.5
1 EKF error
EKF bounds
0 −2
0 10 20 30 40 0 10 20 30 40
Iteration Iteration
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 8 of 9
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 9 of 9
3.4.5: Preparing to implement EKF on an ECM
current state of state of power
temperature charge (SOC) health (SOH) cells limits
Model true cell current as ik C wk , but measure ik only (wk is current-sensor error)
Assume k D 1, leverage adaptivity of EKF overcome this inaccuracy
Then, state-of-charge equation can be written
t
Q
.ik C wk / ´ k C1 D ´k
The two derivatives that we need for this term are (with Q having units [A s]):
@´k C1 @´k C1 t
@´k C
D 1, and
@wk
D Q
´k DÓ k wk DwN
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 1 of 8
If j
current state of state of power
t=.Rj Cj //, then resistor-currents state temperature charge (SOC) health (SOH) cells limits
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 2 of 8
.ik Cwk / t
D exp
meas. voltage estimate estimate balance compute
If AH;k
current state of state of power
, then hysteresis state temperature charge (SOC) health (SOH) cells limits
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 3 of 8
3.4.5: Preparing to implement EKF on an ECM
@hk C1 t t
@wk
D Q
exp
Q
j.ik C wk /j .1 C hk /
If we assume that ik C wk < 0,
@hk C1 t t
@wk
D Q
exp
Q
j.ik C wk /j .1 hk /
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 4 of 8
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 5 of 8
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 6 of 8
3.4.5: Preparing to implement EKF on an ECM
@yk @OCV.´k /
@´k
D @´k
5
Empirical OCV derivative for six cells
´k DÓ k ´k DÓ k 4
zero-phase filter!) 0
0 10 20 30 40 50 60 70 80 90 100
Filtering not really necessary State of charge (%)
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 7 of 8
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 8 of 8
3.4.6: Introducing Octave code to initialize and control EKF for SOC estimation
time = DYNData . script1 . time (:) ; deltat = time (2) - time (1) ;
time = time - time (1) ; % start time at 0
current = DYNData . script1 . current (:) ; % discharge > 0; charge < 0.
voltage = DYNData . script1 . voltage (:) ;
soc = DYNData . script1 . soc (:) ;
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 1 of 6
3.4.6: Introducing Octave code to initialize and control EKF for SOC estimation
% Covariance values
SigmaX0 = diag ([1 e -3 1e -3 1e -2]) ; % uncertainty of initial state
SigmaV = 2e -1; % uncertainty of voltage sensor , output equation
SigmaW = 1 e1 ; % uncertainty of current sensor , state equation
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 2 of 6
3.4.6: Introducing Octave code to initialize and control EKF for SOC estimation
% Now , enter loop for remainder of time , where we update the EKF
% once per sample interval
hwait = waitbar (0 , ' Computing ... ') ;
for k = 1: length ( voltage ) ,
vk = voltage ( k ) ; % " measure " voltage
ik = current ( k ) ; % " measure " current
Tk = T ; % " measure " temperature
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 3 of 6
3.4.6: Introducing Octave code to initialize and control EKF for SOC estimation
figure ; plot ( time /60 ,100* sochat , time /60 ,100* soc ) ; hold on
plot ([ time /60; NaN ; time /60] ,...
[100*( sochat + socbound ) ; NaN ; 100*( sochat - socbound ) ]) ;
title ( ' SOC estimation using EKF ') ; xlabel ( ' Time ( min ) ') ; ylabel ( ' SOC (%) ') ;
legend ( ' Estimate ' , ' Truth ' , ' Bounds ') ; grid on
fprintf ( ' RMS SOC estimation error = % g %%\ n ' , sqrt ( mean ((100*( soc - sochat ) ) .^2) ) ) ;
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 4 of 6
3.4.6: Introducing Octave code to initialize and control EKF for SOC estimation
% Covariance values
ekfData . SigmaX = SigmaX0 ; ekfData . SigmaV = SigmaV ;
ekfData . SigmaW = SigmaW ; ekfData . Qbump = 5;
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 5 of 6
3.4.6: Introducing Octave code to initialize and control EKF for SOC estimation
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 6 of 6
3.4.7: Introducing Octave code to update EKF for SOC estimation
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 1 of 8
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 2 of 8
Compute b bk 1, and implement steps 1a and 1b loop once each measurement interval while pack is active
Ak 1 , B
% Step 1 a : Compute Ahat [k -1] , Bhat [k -1]; Then , state estimate time update
nx = length ( xhat ) ; Ahat = zeros ( nx , nx ) ; Bhat = zeros ( nx ,1) ;
Ahat ( zkInd , zkInd ) = 1; Bhat ( zkInd ) = - deltat /(3600* Q ) ;
Ahat ( irInd , irInd ) = diag ( RC ) ; Bhat ( irInd ) = 1 - RC (:) ;
Ah = exp ( - abs ( I * G * deltat /(3600* Q ) ) ) ; % hysteresis factor
Ahat ( hkInd , hkInd ) = Ah ;
B = [ Bhat , 0* Bhat ];
Bhat ( hkInd ) = - abs ( G * deltat /(3600* Q ) ) * Ah *(1+ sign ( I ) * xhat ( hkInd ) ) ;
B ( hkInd ,2) = Ah -1;
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 3 of 8
3.4.7: Introducing Octave code to update EKF for SOC estimation
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 4 of 8
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 5 of 8
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 6 of 8
3.4.7: Introducing Octave code to update EKF for SOC estimation
60 0
40
−2
20
0 −4
0 100 200 300 400 500 600 0 100 200 300 400 500 600
Time (min) Time (min)
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 7 of 8
Summary
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 8 of 8
3.4.8: Where from here?
nonlinear systems
How to apply two assumptions to derive the extended Kalman filter from the
generic Gaussian sequential-probabilistic-inference solution
How to write Octave/MATLAB code to implement EKF for a simple example and
for the battery-cell state-estimation problem
See some examples of applying EKF to estimate cell SOC using lab-test data
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 1 of 3
Sigma-point approach to approximating statistics of a RV loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 2 of 3
Credits
loop once each measurement interval while pack is active
Dr. Gregory L. Plett j University of Colorado Colorado Springs Battery State-of-Charge (SOC) Estimation | Cell SOC estimation using an extended Kalman filter j 3 of 3