battery soc estimation using EKF
28 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hello,
please i need help ! i'm trying to estimate the battery state of charge using kalman filtering ! but actually i have no clue :/
i've written this programme but it doesnt work ?!
any one can help me please ! i'm feeling really stuck :(
clc
tic
% Enter input data
i=tryfilekalmanS1(:,3);
vt=tryfilekalmanS1(:,2);
soc=tryfilekalmanS5(:,1);
t=tryfilekalman(:,1);
OCV=tryfilekalmanS2(:,2);
OCV=table2array(OCV);
current=table2array(i);
voltage=table2array(vt);
SOC=table2array(soc);
Time=table2array(t);
%battery parameters
Cn=2.6; %battery nominal capacity
deltat=5; %time step
R=0.1174; %internal resistance
taud=4.4925;
eff=1; %coulomb effeiciency (for discharging case it takes 1)
sigmaW =30; %process noise covariance
sigmaV=20; %sensor noise covariance
F=(-2.6/taud);A=-2.6;B=1;C=0.1;D=1; %plant definition matrices
maxIter=16; %number of iterations to execute simulation
% Providing the value of battery parameters (ocv(soc) curve fitting
% equation)
M0=277512.69155; % Coefficient from OCV fitting curve
M1=-110959.5326; % Coefficient from OCV fitting curve
M2=14761.90214; % Coefficient from OCV fitting curve
M3=-653.33323; % Coefficient from OCV fitting curve
I = current;
V=voltage;
for k=1:maxIter
%initialization
xtrue(1)=1; %initialise true system initial state
xhat(1)=0; %initialise kalman filter initial estimate
sigmaX(1)=0.005; %initialise kalman filter covariance
u=7.7783; %unknown initial driving input
%time update
xhat=A*(M0 + M1.*OCV(k) + M2.*OCV(k)^2+ M3.*OCV(k)^3)+w;
sigmaX=A*sigmaX*A'+sigmaW;
%
u=OCV;
w=0.012; v=0.023; %noises
ytrue = C.*xhat+D.*u+v;
xtrue = A*xtrue+B*u+w;
%Estimate system output
yhat=C*xhat+D*u;
%Compute kalman gain matrix
sigmaY=C*sigmaX*C'+sigmaV;
L=sigmaX*C'/sigmaY;
%measurement update
xhat=xhat+L*(ytrue-yhat);
sigmaX=sigmaX-L*sigmaY*L';
%store
xstore(1:16,k)= xtrue(1:16);
xhatstore(1:16,k)=xhat(1:16);
sigmaXstore(1:1,k)=sigmaX(1:1);
ytruestore(1:17,k)=ytrue(1:17);
yhatstore(1:17,k)=yhat(1:17);
end
toc
%code plot
figure(1);
plot(1:maxIter,xstore(1:maxIter)','r',1:maxIter,xhatstore',1:maxIter,xhatstore(1:maxIter)-xstore(1:maxIter)','b');
grid;
legend('true','estimate','error');
title('soc estimation');
xlabel('time'); ylabel('soc');
0 commentaires
Réponses (1)
Sabin
le 22 Sep 2023
Simscape Battery is a useful place to start with battery modeling and BMS functionality.
An example of SOC estimation:
I hope this helps.
0 commentaires
Voir également
Catégories
En savoir plus sur Estimators dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!