メインコンテンツ

Generate Lookup Tables for Equivalent Circuit Battery Block

R2026b

This example shows how to use the characterizeBattery (Model-Based Calibration Toolbox) method to estimate equivalent circuit model lookup table parameters from battery cell test data for the Equivalent Circuit 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 electric vehicle powertrain modeling or 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("ECB.slx");

Set the batteryBlock variable to the battery block path.

batteryBlock = "ECB/Battery PTBS Example";

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.Em');
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 measured voltage data overlaid with the simulated data.

plot(results.voltage);
hold on
plot(results.Voltage3);
hold off
xlabel('Sample');ylabel('Voltage (V)');
legend('Data','Simulation');

Figure contains an axes object. The axes object with xlabel Sample, ylabel Voltage (V) contains 2 objects of type line. These objects represent Data, Simulation.

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.0225), ylabel Error contains a line object which displays its values using only markers.

Display the error distribution as a histogram.

histogram(results.voltage - results.Voltage3);
xlabel('Error (V)');ylabel('Count');
title('Error Distribution');

Figure contains an axes object. The axes object with title Error Distribution, xlabel Error (V), ylabel Count contains an object of type histogram.

See Also

(Model-Based Calibration Toolbox) | (Model-Based Calibration Toolbox)