Filter löschen
Filter löschen

How can I use Matlab to control Battery Equivalent Circuit Model of Simulink?

4 Ansichten (letzte 30 Tage)
Hi,
I want to use Matlab(.m) to change the parameter of Battery Equivalent Circuit Model-short circuit resistance. But I don't know how to achieve it.
Thanks.

Antworten (1)

Xiangchun
Xiangchun am 25 Jan. 2024
Bearbeitet: Xiangchun am 25 Jan. 2024
Hi Yuyang,
If you question is about how to perform fault modeling for the Battery Equivalent Circuit block from Simscape Battery and change fault model parameters programmatically, here is an example script. It creates a new model, adds the Battery Equivalent Circuit block from Simscape Battery, adds "Internal short" fault to the block, adds timed trigger to the fault, and changes the default shorted resistance parameter to 1.2E-8 Ohm.
clear;
bdclose all;
modelname = 'BatteryModel';
if (exist(strcat(modelname,'.slx')))
delete(strcat(modelname,'*.slx'));
end
open_system (new_system(modelname));
add_block('batt_lib/Cells/Battery Equivalent Circuit','BatteryModel/mycell');
save_system(modelname);
faultableBlocks = simscape.findFaultableBlocks(modelname)
elementPath = simscape.getFaultableElementsInBlock(faultableBlocks)
simscape.addFaultsToBlock(faultableBlocks(1),Element=elementPath(2));
InternalShortFault = [Simulink.fault.findFaults(modelname)]
% Change the trigger type and the fault event time by changing the TriggerType
% and StartTime properties
InternalShortFault.TriggerType = "Timed";
InternalShortFault.StartTime = 30;
% Get the path to the behavior block in the fault model
faultBehaviorPath = InternalShortFault.getBehavior();
% Set the parameter directly in the fault behavior block, using set_param
% as usual.
set_param(faultBehaviorPath,'ShortedResistance','1.2e-8');
This is how the shorted resistance look after exectuing the script.
Best wishes,
Xiangchun

Kategorien

Mehr zu Simscape Battery finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by