Azzera filtri
Azzera filtri

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

4 visualizzazioni (ultimi 30 giorni)
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.

Risposte (1)

Xiangchun
Xiangchun il 25 Gen 2024
Modificato: Xiangchun il 25 Gen 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

Categorie

Scopri di più su Simscape Battery in Help Center e File Exchange

Tag

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by