Batterymodel, 20sec wait time after charging/discharging
1 view (last 30 days)
Show older comments
Hello,
I made a Simulink model that compares a BMS's (Battery Management System) C-Code against the Outputs of the Battery Block. I based the model on the "power_battery_aging model", available through that command. It has a cycle generator, that changes from charging to discharging at 100% SOC (State-of-Charge) and vice-versa at 0% SOC. Now I wanted to add a wait time of 20 seconds (in simulation time) between charging and discharging, with 0 current flowing. I have tried many different things like
t=Simtime;
if (Simtime < t+20)
...
end
but nothing worked.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/820990/image.jpeg)
Here is the default code:
function [ibatt, Status] = fcn(SOC, SOCmin, SOCmax, Idis, Icharge, PreviousStatus, Simtime)
%#codegen
%Status: 1 = Entladen; 0 = Laden
Status=PreviousStatus;
% 1 sec Idis & Icharge = 0
if (Simtime < 1)
Idis= 0;
Icharge = 0;
end
if(PreviousStatus==1 && SOC<=SOCmin) %if discharge and SOC <=SOCmin -> charge
Status=0;
end
if(PreviousStatus==0 && SOC>=SOCmax) %if charge and SOC >=SOCmax -> discharge
Status=1;
end
if (PreviousStatus==1)
ibatt=Idis;
else
ibatt=-Icharge;
end
Thanks very much for any help.
0 Comments
Answers (0)
See Also
Categories
Find more on General Applications in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!