# Battery State of Charge Estimation Using Kalman Filter
[绠�浣撲腑鏂嘳(./README_zh_CN.md)
This small project comes from the simulation part of my college graduation design which aimed to estimate the state of charge(SoC) of lithium battery. I mainly finished the experiments, parameters identification and simulation of extended kalman filter(EKF). The completion unscented kalman filter(UKF) simulation needs to thank the contribution from my friend, Pengcheng Gu. And the BBDST working condition block is also benefit from the help of my senior, Cong Jiang. 馃槝馃攱thanks angain to my warm friends.馃攱鉂�
## General Content
Li-Battery model building, parameters identification and verification, SoC estimation using extended kalman filter(EKF) through two ways:
1. Simulinks(EKF only)
2. Scripts(EKF&UKF)
## First Try
The inputs of the model include current and voltage comes from battery data in HPPC(Hybrid PulsePower Characteristic) test.
Thevenin equivalent circuit model and extended kalman filter are included in the simulation file "EKFSim_R2016.slx", of which the structure is shown in the snapshot below.
![Simulink](./imgs/simulink.jpg)
The estimated curve has distinct divergences in the current pulse areas and it converges to the true value in the constant current discharge areas.
The estimated SoC and update Up(voltage of RC element in Thevenin ECM) change synchronously due to the same state vector that they are in, that can be seen in the function block 'EKF'.
Kalman filter update of states including SoC and Up, according to the difference between observed values and predicted values of UL(voltage on the load). The code format of this expression is as following.
```matlab
X_upd = X_pre + K*(UL_obs-UL_pre);
```
The output results of the simulation are shown in the figures belows.
![States Output](./imgs/SimOutput.jpg)
![UL curves](./imgs/UL.jpg)
## Improvement
After improvement, the I/O relationship between modules becomes more perspicuous, the corresponding Simulink file is named Improved_EKFSim.slx.
![Improvement](./imgs/ImprovedSim.jpg)
The BBDST(Beijing Bus Dynamic Street Test) working condition is used here as the input current.
![BBDST](./imgs/BBDST.jpg)
The output results are shown in the figures belows.
![Simulink_EKF_AH](./imgs/Simulink_EKF_AH.jpg)
![Err](./imgs/Error_EKF_AH.jpg)
## Scripts
MATLAB scripts simulate discharge process of lithium-ion battery under the BBDST working condition and constant current working condition with observation noise, and uses EKF/UKF method to estimate SoC of the battery.
```matlab
function main(Work_modes, SoC_est_init)
```
The main function requires two arguments:
- Work_mode: Choice of working condition with 1 representing BBDST working condition and 2 representing constant current.
- SoC_est_init: The initial value of estimated SoC, it's set to 1 by default, if just one argument is passed.
Type in command window like `main()`or`main(1)`or`main(1,1)`, the result curves will appear as follows.
![States estimation curve](./imgs/SimResult.jpg)
## Related Knowledge
### 1. Thevenin equivalent circuit model
Thevenin equivalent circuit model(ECM) is a first-order RC circuit. The discharge direction is taken as the positive direction of current, as shown in the figure below.
![ECM](./imgs/Thevenin_equivalent_circuit.jpg)
The voltage on the polarization capacitor is denoted as Up. Then according to KVL and KCL we get the following equations.
```
UL(t) = UOC - Up(t) - Ro * I(t) 路路路路路路(1)
I(t) = Up(t) / Rp - Cp * (dUp(t)/dt) 路路路路路路(2)
```
The solution of the differential equation (2) is as follows.
```
Up(t) = C * exp(-t/tao) + I(t) * Rp 路路路路路路(3)
tao = Rp * Cp 路路路路路路(4)
```
Here `C` is an arbitrary constant. The zero input response of the circuit model corresponds to the idle condition of the battery while zero state response corresponds to the working condition. The discretized form of Up in different states can be unified as follows.
```
Up(k+1) = Up(k) * exp(-螖t/tao) +
Rp * I(k) * (1 - exp(-螖t/tao)) 路路路路路路(5)
```
Here `螖t` denotes the sample interval. The parameters in the Thevenin ECM, including `UOC`, `Ro`, `Rp` and `Cp`, are deemed to be related to the SoC of the battery. The relationships are usually identified through the so call Hybrid Pulse Power Characterization(HPPC) test.
### 2. Extended Kalman Filter
The basis of Kalman filter is the process of fusing the information from the prediction and the observation, under the hypothesis that the process error and the observation error are both stochastic noises, obeying Gaussian distributions. The EKF mainly consist of three steps: prediction, linearization and update.
```
_______________________________________________________
| |
| |----------| |-------------| |------| |
---->|prediction|---->|linearization|---->|update|-----
|----------| |-------------| |------|
```
The prediction needs the knowledge of the state transition, expressed as equation (5) and (6), and observation estimate, expressed as equation (7) and (8).
```
SoC(k) = SoC(k-1) - eta/Qn * I(k-1) 路路路路路路(6)
UL(k) = UOC(k-1) - I(k-1) * Ro - Up(k-1) 路路路路路路(7)
UOC(k) = f(SoC(k-1)) 路路路路路路(8)
```
Here `eta` and `Qn` denote the coulombic efficiency and the rated capacity of the battery respectively. Let `X` be the state vector `[SoC, Up]'`, `A` be the state transformation matrix `[1, 0; 0, exp(-螖t/tao)]` and `B` be the input control matrix `[-eta/Qn, 0; 0, Rp*(1-exp(-螖t/tao))]`. Then equation (5) and (6) can be expressed as follows.
```
X(k) = A * X(k-1) + B * I(k-1) 路路路路路路(9)
```
The Kalman filter makes use of the process noise and observation noise for the state estimation. Then there's an important step of predicting the covariance of process error, expressed as `P`.
```
P(k) = A(k-1) * P(k-1) * A'(k-1) + Q 路路路路路路(10)
```
Here `Q` is a diagonal matrix containing the variances of the process noises. For the state `X=[SoC, Up]'`, `Q` is a 2x2 diagonal matrix `[Qs, 0; 0, Qu]`, in which `Qs` is the variances of process noises for `SoC` and `Qu` is that for `Up`.
Note that `UOC` is a nonlinear function of `SoC`, which makes the `UL=g(X, I)` is nonlinear. The linearization step is Taylor expanding `g(X, I)` around `X(k)` with first order approximation.
```
UL = g(X(k), I(k)) + 蓹g/蓹X(k) * (X - X(k)) 路路路路路路(11)
C(k) = 蓹g/蓹X(k)
= [蓹g/蓹SoC(k) 蓹g/蓹Up(k)]
= [蓹(UoC-Ro*I(k))/蓹SoC(k) -1] 路路路路路路(12)
```
Hence `UL = C(k) * X + (g(X(k), I(k)) - C(k)*X(k))`. `C(k)` is a constant matrix and `(g(X(k), I(k)) - C(k)*X(k))` is a constant too. The linearization is completed.
Based on the result of linearization, the update step include updating the state vector and the covariance of process error by using the variance of observation noise `R` and observation value `UL_ob`.
```
K(k) = P(k) * C'(k) *
(C(k) * P(k) * C'(k) + R)^(-1) 路路路路路路(13)
X(k) = X(k) + K(k) * (UL_ob - UL(k)) 路路路路路路(14)
P(k) = P(k) - K(k) * C(k) * P(k) 路路路路路路(15)
```
An Intuitive Derivation of the Kalman filter process is [Here](https://courses.engr.illinois.edu/ece420/sp2017/UnderstandingKalmanFilter.pdf). An detailed explanation of UKF is [Here](https://www.cs.ubc.ca/~murphyk/Papers/Julier_Uhlmann_mar04.pdf).
没有合适的资源?快使用搜索试试~ 我知道了~
基于卡尔曼滤波器的电池充电状态估计(Matlab完整源码)
共48个文件
mat:24个
jpg:9个
l:6个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 121 浏览量
2024-10-27
11:47:11
上传
评论
收藏 1.58MB ZIP 举报
温馨提示
1.基于matlab的锂电池的模型构建、参数识别和验证、SoC估计,Simulink采用扩展卡尔曼滤波器(EKF)。 2.采用m脚本(EKF和(无迹卡尔曼滤波)UKF)。程序已调通,可直接运行。运行环境Matlab2023b及以上。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。 5.作者介绍:机器学习之心,博客专家认证,机器学习领域创作者,2023博客之星TOP50,主做机器学习和深度学习时序、回归、分类、聚类和降维等程序设计和案例分析,文章底部有博主联系方式。从事Matlab、Python算法仿真工作8年,更多仿真源码、数据集定制私信
资源推荐
资源详情
资源评论
收起资源包目录
matlab_利用卡尔曼滤波器估计电池充电状态.zip (48个子文件)
matlab_利用卡尔曼滤波器估计电池充电状态
LICENSE 34KB
slprj
_jitprj
s9fWU9xNgnIreqtm5qYk2aE.l 50KB
sAb9LUbwSAkK5BclTYHuev.mat 902B
s9fWU9xNgnIreqtm5qYk2aE.mat 1KB
sAb9LUbwSAkK5BclTYHuev.l 10KB
sl7ze3tcKvCCkywvl7WmeiE.l 11KB
jitEngineAccessInfo.mat 896B
stNSrNpwwEla49eE7RpwsQD.mat 892B
su7CyjSmcnniZLoWZt9gSpE.l 21KB
sMTBOehAyxtcvfKXe0rjIAD.mat 886B
stNSrNpwwEla49eE7RpwsQD.l 12KB
su7CyjSmcnniZLoWZt9gSpE.mat 926B
sl7ze3tcKvCCkywvl7WmeiE.mat 883B
sMTBOehAyxtcvfKXe0rjIAD.l 11KB
_sfprj
precompile
autoInferAccessInfo.mat 960B
cwxFwPcWrVjaXbqHTsRrzC.mat 884B
bGvt8zLYWja71z60kF58uF.mat 647B
MoHeaxMonO1oTWXosmoD4C.mat 845B
NPDGMbfmtIestR10j46BO.mat 604B
wrLp6224KJHyOYDRndSOOC.mat 642B
mgY7fc70qFJMW6xV1gA5IF.mat 662B
hWBJLhgEKaWjKQwvuGQxjC.mat 642B
Improved_EKFSim
_self
sfun
info
binfo.mat 851B
EKFSim_R2016b
_self
sfun
info
binfo.mat 797B
EMLReport
sAb9LUbwSAkK5BclTYHuev.mat 5KB
s9fWU9xNgnIreqtm5qYk2aE.mat 91KB
stNSrNpwwEla49eE7RpwsQD
sMTBOehAyxtcvfKXe0rjIAD
su7CyjSmcnniZLoWZt9gSpE
s9fWU9xNgnIreqtm5qYk2aE
stNSrNpwwEla49eE7RpwsQD.mat 54KB
sMTBOehAyxtcvfKXe0rjIAD.mat 23KB
su7CyjSmcnniZLoWZt9gSpE.mat 83KB
sl7ze3tcKvCCkywvl7WmeiE
sl7ze3tcKvCCkywvl7WmeiE.mat 21KB
sAb9LUbwSAkK5BclTYHuev
emlReportAccessInfo.mat 894B
README_zh_CN.md 6KB
.gitignore 13B
imgs
ImprovedSim.jpg 215KB
SimResult.jpg 157KB
SimOutput.jpg 49KB
simulink.jpg 61KB
BBDST.jpg 87KB
Error_EKF_AH.jpg 86KB
Thevenin_equivalent_circuit.jpg 46KB
UL.jpg 32KB
Simulink_EKF_AH.jpg 38KB
README.md 7KB
simulinks
Improved_EKFSim.slx 296KB
EKFSim_R2016b.slx 1.6MB
scripts
main.m 1KB
BBDST_workingcondition.slx 283KB
EKF_UKF_Thev.m 9KB
共 48 条
- 1
资源评论
机器学习之心
- 粉丝: 2w+
- 资源: 1044
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 二顺序结构Fortran程序设计.pptx
- 二轮复习基因工程概要.pptx
- 分相式电流纵差保护原理及光纤通道与保护接口一天.pptx
- 服装行业的电子商务分析.pptx
- 泛微软件流程管理解决方案培训.pptx
- 复旦大学计算机科学与工程系吴永辉离散数学组合数学省公共课一等奖全国赛课获奖课件.pptx
- 钢筋加工配送信息化管理技术.pptx
- 钢筋抽样软件GGJ2009自学课程.pptx
- 高等教育chp关系数据库标准语言.pptx
- 高等教育A数据库基础与应用.pptx
- 钢筋平法讲座-广联达钢筋抽样软件.pptx
- 高等教育ch电子商务与国际物流.pptx
- 高等教育大学计算机多媒体技术基础.pptx
- 高等教育单片机.pptx
- 高等教育关系数据理论与数据库设计一.pptx
- 基于ADI公司ADuC7061的智能压力测量仪.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功