Batterymodel, 20sec wait time after charging/discharging
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Sources에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!