Contenuto principale

Characterize Battery Equivalent Circuit Block (Code)

R2026b

This example shows how to use the characterizeBattery method to estimate equivalent circuit model lookup table parameters from battery cell test data for the Battery Equivalent Circuit (Simscape Battery) block. Use this workflow when you have transient data, including HPPC test data, and need to parameterize the block for system-level simulation. For example, you can use this approach for battery management system (BMS) algorithm development.

Create mbcrunner Object

Create a handle to a CAGE project.

r = mbcrunner;

Open Simulink Model

Open the Simulink model containing the Battery Equivalent Circuit block.

open("Simscape_BEC.slx");

Set the batteryBlock variable to the battery block path.

batteryBlock = "Simscape_BEC/Battery Equivalent Circuit";

Characterize Battery Cell

Characterize the battery using the data files located in the folder HPPC_data/origPreprocessedData. Set the number of iterations for the battery characterization process to 25.

[tbls,sfit] = characterizeBattery( ...
    r,batteryBlock,fullfile(pwd,'HPPC_data','origPreprocessedData'), ...
    NumIterations=25,ShowProgress=false);

Preview the open circuit voltage table.

surf(SOC_vec,Temperature_vec,tbls.OCV');
xlabel('SOC');ylabel('Temperature');zlabel('OCV Table');

Figure contains an axes object. The axes object with xlabel SOC, ylabel Temperature contains an object of type surface.

Evaluate Feature

Evaluate the Voltage3 feature using the hppcDataBAKcell0degC.mat data file.

[results,s] = evaluateFeature(r,"Voltage3", ...
    fullfile( ...
    pwd,'HPPC_data', 'origPreprocessedData','hppcDataBAKcell0degC.mat'));

Plot the voltage error to inspect the fit.

plot(results.voltage - results.Voltage3, '.');
ylabel('Error');
title(sprintf('Difference Between measured voltage and Voltage3 (RMSE: %.4f)', s));

Figure contains an axes object. The axes object with title Difference Between measured voltage and Voltage3 (RMSE: 0.0120), ylabel Error contains a line object which displays its values using only markers.

See Also

Topics