Skip to main content
emobility.academy
B.Tech / BEBattery modellingBeginner About 4 weeksMATLAB & Simulink

Li-ion Cell Equivalent-Circuit Model in Simulink with Pulse-Test Validation

Build a second-order equivalent-circuit model of a Li-ion cell in Simulink and Simscape, identify its parameters from pulse-test data, and validate the model's terminal voltage against a held-out dynamic current profile.

Tools: Simulink · Simscape Electrical

Li-ion Cell Equivalent-Circuit Model in Simulink with Pulse-Test Validation: Students assembling a lithium-ion battery pack in a DIYguru workshop
Representative photo from DIYguru's EV lab, not of this specific project.

The problem

Every BMS algorithm and pack simulation needs a cell model that predicts terminal voltage under load. Equivalent-circuit models are simple enough for real-time use but their parameters vary with SOC and must be identified from test data. Learning to build, fit and validate one is a core skill for battery engineers.

Objectives

  • Implement an OCV source plus R0 and two RC branches with SOC-dependent parameters.
  • Prepare pulse-test data from a published dataset or a datasheet-based test.
  • Identify R0, R1, C1, R2 and C2 at several SOC levels.
  • Validate the model on a held-out dynamic profile and report voltage error.
  • Compare first-order and second-order models.

What you need

Tools and toolboxes

  • Simulink — The cell model built from Integrator, 1-D Lookup Table and MATLAB Function blocks, and the test harness.
  • Simscape Electrical — An alternative physical model from Simscape foundation and electrical elements (Controlled Voltage Source, Variable Resistor, Capacitor, Current Source).
  • MATLAB — Data handling, curve fitting with lsqcurvefit or fminsearch, and error analysis.
  • Simulink Design Optimization (optional) — Its Parameter Estimator app fits model parameters to measured data directly; manual fitting in MATLAB is the base-licence route.

Software

  • MATLAB R2023b or later
  • Simulink
  • CSV or MAT files of the chosen test data

Extra parts and data

  • Published cell test data (for example a NASA PCoE or CALCE dataset) or a cell datasheet — Pulse and dynamic test data are needed to identify and validate the model without running laboratory tests.

Key concepts

Second-order ECM
Terminal voltage V = OCV(SOC) − I·R0 − V1 − V2, with each RC branch obeying dVk/dt = −Vk/(Rk·Ck) + I/Ck. Two time constants capture fast and slow polarisation.
OCV–SOC curve
The equilibrium voltage at each SOC, measured with long rests or slow (C/20) charge and discharge. It is the backbone of the model.
Pulse test
A current pulse followed by a rest at several SOC levels. The instant voltage step gives R0 and the recovery curve gives the RC parameters.
Held-out validation
Testing the fitted model on data not used for fitting, so the reported error reflects predictive ability rather than curve fitting.

Step-by-step guide

  1. 1

    Select the data and define the target

    Choose one cell from a published dataset with pulse tests and a dynamic profile, or plan synthetic pulse data from a datasheet. Record nominal capacity, voltage limits and test temperature. Set a target: terminal voltage RMS error below about 20 mV on the held-out profile across 10–90 per cent SOC. Split the data into identification and validation sets before you start fitting.

    Checkpoint: A data summary table and a written split into identification and validation data.

  2. 2

    Extract the OCV–SOC curve

    From low-rate charge and discharge or rest points, compute SOC by coulomb counting from a full charge and build OCV against SOC, averaging charge and discharge curves to reduce hysteresis. Smooth gently and make the curve monotonic. Store it as a vector pair for a 1-D Lookup Table with linear interpolation and clipped end points. Note the test temperature and rate used, since both affect the curve.

    Checkpoint: A monotonic OCV–SOC plot covering 0–100 per cent SOC, with charge and discharge curves shown.

  3. 3

    Build the model in Simulink

    Integrate current to get SOC (SOC = SOC0 − ∫I dt / (3600·Q)), look up OCV and parameters from 1-D Lookup Tables against SOC, and implement the two RC branch equations with Integrator blocks. Use a positive-for-discharge sign convention and document it. Use a variable-step solver (ode23tb) with a maximum step of 1 s, or fixed-step ode4 at 0.1 s.

    Checkpoint: With constant parameters, a 1C step gives an instant drop of I·R0 followed by two exponential sags with the chosen time constants.

  4. 4

    Build the Simscape version

    Optionally, build the same circuit physically: a Controlled Voltage Source driven by the OCV lookup, Variable Resistor blocks for R0, R1 and R2 driven by lookups, Capacitor blocks for C1 and C2, a Controlled Current Source for the load, and Solver Configuration and Electrical Reference blocks. Run the same step test. Keep both versions in the project; the Simulink one is faster for sweeps, while the Simscape one connects easily to physical loads and chargers.

    Checkpoint: Simulink and Simscape versions give the same voltage response within 1 mV.

  5. 5

    Identify R0

    For each pulse in the identification data, compute R0 = ΔV/ΔI from the voltage just before and just after the current edge, using both the start and the end of the pulse. Check that the sample interval is short enough; if the first sample is late, part of the fast RC response is included. Tabulate R0 against SOC. Plot both estimates against SOC to see where they diverge.

    Checkpoint: An R0 against SOC table with start and end estimates agreeing within a stated margin.

  6. 6

    Identify the RC branches

    Fit the relaxation after each pulse with V(t) = OCV − V1·exp(−t/τ1) − V2·exp(−t/τ2) using lsqcurvefit with positive bounds and τ1 < τ2. Convert to R1 = V1/I, C1 = τ1/R1 and the same for branch 2. Use the Parameter Estimator app if available to refine all parameters on the full pulse sequence. Check that fitted time constants are well separated, typically seconds and tens of seconds or more, otherwise the two branches are not independently identifiable.

    Checkpoint: Residual plots for three SOC levels with RMS residuals of a few millivolts.

  7. 7

    Validate on the held-out profile

    Load parameter tables into the model and run the held-out dynamic profile from its known initial SOC. Compare simulated and measured voltage in the Simulation Data Inspector. Compute RMS and maximum error overall and by SOC band, and note where the model struggles (often below 20 per cent SOC). Plot the voltage error against time and against SOC, so that the regions where the model needs more detail are clear to the reader.

    Checkpoint: Validation RMS error reported overall and by SOC band, with the target met over 10–90 per cent SOC.

  8. 8

    Compare model orders

    Repeat identification and validation with a first-order model. Compare validation error, number of parameters and the simulation time. Also compare a model with constant parameters against SOC-dependent tables. Present a short table so a reader can decide which model suits a BMS and which suits a pack design study. Include the time taken to identify each model too, because a model that is quick to parametrise is easier to repeat for new cells.

    Checkpoint: A comparison table of 1RC, 2RC and constant-parameter models on validation error and complexity.

  9. 9

    Report

    Document data, OCV extraction, model equations, both implementations, identification, validation and comparison. State the limits: one temperature, no hysteresis model, and parameters valid only for the tested cell. Include scripts that rebuild the model from the raw data so the work can be repeated with another cell. Add a short section on how parameters would be re-identified for another temperature or an aged cell, and what extra test data that would need.

    Checkpoint: A report and scripts that rebuild the parameter tables and validation plots from the raw data.

Testing & validation

  • Step response matches the analytical RC solution.
  • Simulink and Simscape versions agree within 1 mV.
  • Validation RMS voltage error meets the stated target on held-out data.
  • Coulomb-counted SOC matches dataset capacity.

Expected results

A validated second-order ECM of a Li-ion cell in Simulink and Simscape with SOC-dependent parameter tables, identification scripts and a comparison of model orders on held-out data.

Take it further

  • Add temperature dependence using data at several temperatures.
  • Add a one-state hysteresis model for LFP cells.
  • Use the model inside an EKF SOC estimator.
  • Scale the cell model into a pack model with cell-to-cell variation.

Viva and review questions

Why do you need two RC branches?

Polarisation has fast and slow components, from charge transfer and diffusion. One branch cannot fit both time scales, so voltage error during and after pulses is larger.

Why must validation use separate data?

A model can fit identification data well and still predict poorly. Held-out data shows how it will perform on currents it has not seen.

Why does the model error grow at low SOC?

OCV slope and resistance change quickly at low SOC, and diffusion effects grow, so a table with coarse SOC steps and a two-branch model capture it less well.

Learn it at DIYguru

These DIYguru courses and programmes teach what this project needs.

Related EV projects

All 100 MATLAB & Simulink EV projects