Batterymodel, 20sec wait time after charging/discharging
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Sources 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!