How can I use Matlab to control Battery Equivalent Circuit Model of Simulink?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
Réponses (1)
Xiangchun
le 25 Jan 2024
Modifié(e) : Xiangchun
le 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1600651/image.png)
Best wishes,
Xiangchun
0 commentaires
Voir également
Catégories
En savoir plus sur Simscape Battery 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!