Batterymodel, 20sec wait time after charging/discharging
2 views (last 30 days)
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
if (Simtime < t+20)
but nothing worked.
Here is the default code:
function [ibatt, Status] = fcn(SOC, SOCmin, SOCmax, Idis, Icharge, PreviousStatus, Simtime)
%Status: 1 = Entladen; 0 = Laden
% 1 sec Idis & Icharge = 0
if (Simtime < 1)
Icharge = 0;
if(PreviousStatus==1 && SOC<=SOCmin) %if discharge and SOC <=SOCmin -> charge
if(PreviousStatus==0 && SOC>=SOCmax) %if charge and SOC >=SOCmax -> discharge
Thanks very much for any help.