SOC estimation simulator
See how a battery management system estimates state of charge, and where it goes wrong. A lithium cell runs a drive, rest and charge cycle; the BMS reads its current and voltage through a sensor with offset, gain error and noise, and three estimators work from those readings: plain coulomb counting, coulomb counting with OCV and full-charge resets, and an extended Kalman filter. The second tab is a coulomb counting calculator that checks your SOC answer. Free, runs in your browser.
1-RC cell, MathWorks / Huria 2012 tables · checked against scipy Radau · Updated 20 Nov 2026
Cell and load
What the BMS knows and measures
Positive current discharges. 1C = the cell's capacity in A (25 A at 20 °C). "Drive, rest, CC-CV charge" drives for 3,000 s, rests 1,000 s, charges, then rests. The stop-go drive repeats every 120 s: 2C for 10 s, 0.5C for 60 s, 0.5C regen for 10 s, 40 s stopped (0.375C average; a made-up pattern, not a standard cycle). The charge is CC to 4.2 V, then CV until the current is C/20. Offset 0.25 A means the sensor reads 0.25 A of discharge when none flows. Rest reset 0 turns OCV resets off. Up to 6 hours.
Constant current, 100% charge efficiency. Type the answer from your report or code to see whether it matches and, if not, which slip gives your number.
- Error = estimate − true SOC, in SOC points. The CC + resets line lies on top of plain CC until its first reset. Dashed lines mark the resets: OCV (blue) at 59 min and 156 min, charge complete → 100% (purple) at 147 min.
- SOC = 80% − 100% × 10 A × 0.5 h / 25 Ah = 60%.
What is coulomb counting?
Coulomb counting estimates state of charge by adding up the charge that flows in and out of the battery. Start from a known SOC, integrate the current over time, divide by the capacity. It is the base of almost every battery management system because it needs only a current sensor and a clock:
A BMS does it one sample at a time, Δt seconds apart:
The 3600 is there because current is in amperes and time in seconds, while capacity is in ampere-hours. A 25 Ah cell at 80% discharged at 10 A for 30 minutes:
The sign convention is a choice, and it must match the current sensor. Here positive current discharges. 129 public reports write SOC(t) = SOC(t−1) + I(t)·Δt/Qn, which is right only if charging current is positive.
How does a BMS implement coulomb counting for SOC estimation?
The second question of the week 7 challenge. In short: a current sensor, a running sum and a set of corrections. A production BMS:
- Measures the pack current with a shunt resistor or a Hall-effect sensor, sampled by an ADC every few milliseconds up to a second.
- Adds η·I·Δt/(3600·Q) to a running SOC each sample, as in the MATLAB loop below. η, the charge efficiency, is close to 1 for lithium cells and often taken as exactly 1.
- Gets the starting SOC from the open-circuit voltage after the cell has rested (the OCV-SOC curve is a lookup table), because counting cannot know where it started.
- Uses a capacity Q that it keeps updating as the cell fades; a fresh-cell capacity on an aged cell scales every step wrong.
- Clamps the result to 0 to 100% and resets it at known points: 100% when a CV charge ends, the OCV value after a long rest.
- Often runs a model-based estimator alongside, such as an extended Kalman filter, that corrects the count from the measured voltage.
% coulomb counting as a BMS does it: one line per sample (current + = discharge)
Q = 25; % Ah, the capacity the BMS believes
dt = 1; % s, sample time
soc = 0.70; % start value, e.g. from the OCV after a long rest
for k = 1:numel(I_meas)
soc = soc - I_meas(k) * dt / (3600 * Q); % 3600 turns A*s into Ah
soc = min(max(soc, 0), 1);
soc_log(k) = soc;
endThe challenge's MathWorks harness model has three test sequences; 544 of the 682 reports describe them, and test case 1 is described the same way across reports: drive for 3,000 s, balance for 1,000 s, charge (CC, then CV), then rest. The simulator's default load copies that shape on one cell.
What does each estimator get in the default run?
One 25 Ah cell at 20 °C, truly at 80%, which the BMS thinks is at 70% (a 10-point start error). The current sensor reads 1% high with a 0.25 A offset and 0.2 A of noise; the voltage has 5 mV of noise; 1 sample per second. The drive takes the cell from 80% to 48.8% by 3,000 s, the charge starts at 4,000 s, switches to constant voltage at 115 min and stops at 146 min. After 3.3 hours:
| Estimator | Error at the end | Worst error | RMS error |
|---|---|---|---|
| Coulomb counting | −13.16 points | −13.16 | 11.71 |
| Coulomb counting + OCV and full-charge resets | −0.75 points | −11.30 | 5.83 |
| Extended Kalman filter | −0.04 points | +0.78 | 0.10 |
Plain coulomb counting never recovers the 10-point start error and adds 3.3 more from the offset (1.0 point per hour). The reset version is just as wrong until the first rest: it reads the OCV at 59 min, ten minutes into the rest, and drops to under a point. It then sets 100% when the charge completes, 0.49 points above the truth, and ends −0.75 points off because the offset keeps counting during the final rest. The EKF corrects the start error from the first voltage reading and stays within 0.8 points. Across 20 noise seeds the final errors stay within −13.17 to −13.11 (CC), −0.86 to −0.61 (resets) and −0.05 to −0.02 (EKF).
Change one thing at a time (final error, points):
| Change from the default | CC | CC + resets | EKF | EKF worst |
|---|---|---|---|---|
| As above | −13.16 | −0.75 | −0.04 | +0.78 |
| Perfect current sensor gain and offset (noise kept) | −10.02 | −0.02 | 0.00 | −0.36 |
| BMS starts at the true 80% | −3.16 | −0.75 | −0.04 | +0.74 |
| BMS believes 27.5 Ah: the cell has faded 9% and nobody told it | −14.64 | −0.69 | −0.03 | −1.23 |
| Real charge efficiency 98% (BMS assumes 100%) | −12.04 | −0.62 | −0.04 | +0.78 |
| Voltage noise 20 mV instead of 5 | −13.16 | −0.79 | −0.05 | +1.59 |
| Sample every 10 s instead of 1 | −12.99 | −0.75 | −0.44 | +0.52 |
| 5 °C (24 Ah cell, BMS told 24 Ah) | −13.30 | −0.74 | +0.05 | +1.04 |
| Cell R0 has grown 1.5× with age; the EKF still uses the table | −13.16 | −0.66 | +0.04 | −24.42 |
The last row is the catch with model-based estimators. The EKF trusts its cell model; when the real cell's resistance has grown 1.5 times, the voltage drop it sees under load looks like a lower SOC, and the EKF is off by up to 24.4 points while the current flows, before settling again in the final rest. Production filters estimate R0 too (a dual or joint filter) or adapt the model as the cell ages.
Why does coulomb counting drift?
Because every error in the inputs is integrated. With no noise, the error of the count against the truth has a closed form: e₀ is the start error, b the current offset in A, g the gain error, A(t) the charge discharged in ampere-seconds, Q the real capacity and Qb the one the BMS uses:
Skill-Lync's verifier checks the simulator against this formula on three noise-free discharge runs, at three times each, to 10⁻¹² SOC. What each term costs on a 25 Ah cell:
| Error source | Size | SOC error it adds |
|---|---|---|
| Start SOC | BMS 10 points off | 10 points, forever, until a reset |
| Current offset | 0.05 A | 0.20 points per hour, 4.8 per day |
| Current offset | 0.1 A | 0.40 points per hour, 9.6 per day |
| Current offset | 0.25 A | 1.00 points per hour, 24.0 per day |
| Current offset | 0.5 A | 2.00 points per hour, 48.0 per day |
| Current offset | 1 A | 4.00 points per hour, 96.0 per day |
| Current gain | 1% | 1% of the charge moved (0.31 points for the default drive) |
| Capacity | BMS 10% high | about 9% of the charge moved |
| Charge efficiency | 98% real, 100% assumed | 2% of the charge put in |
The offset term is the one that never stops: a BMS that stays awake while the car is parked keeps counting it. That is why every practical BMS resets the count against something it can measure.
How accurate is an OCV reset?
After a rest the RC branch relaxes and the terminal voltage approaches the open-circuit voltage, which the cell tables map to SOC. The reset is only as good as the voltage measurement divided by the slope of that curve. For the course NMC cell at 20 °C:
| SOC range | OCV slope | SOC error from a 5 mV voltage error |
|---|---|---|
| 0–10% | 6.03 mV per point | 0.8 points |
| 10–25% | 4.51 mV per point | 1.1 points |
| 25–50% | 3.16 mV per point | 1.6 points |
| 50–75% | 8.53 mV per point | 0.6 points |
| 75–90% | 10.12 mV per point | 0.5 points |
| 90–100% | 11.51 mV per point | 0.4 points |
The simulator averages the last 60 s of the rest, which shrinks random noise but not a calibration offset in the voltage channel. Two things the 1-RC model leaves out make real resets worse: real cells take far longer than ten minutes to relax fully, and many chemistries show voltage hysteresis between charge and discharge. LFP cells, with a very flat OCV over most of their range, are the hard case.
The full-charge reset has its own small bias. A CC-CV charge that stops at C/20 does not leave a full cell. With the course tables and a 0.5C charge to 4.2 V:
| Temperature | Capacity | True SOC when the charge stops |
|---|---|---|
| 5 °C | 24 Ah | 99.18% |
| 20 °C | 25 Ah | 99.51% |
| 40 °C | 26 Ah | 99.45% |
How does an extended Kalman filter estimate SOC?
The filter carries two states, SOC and the RC-branch voltage V₁, and a covariance P that says how sure it is of them. Each sample it predicts both forward with the measured current (the SOC step is coulomb counting), predicts the terminal voltage from the 1-RC model, and corrects the states by the gap between that prediction and the measured voltage:
The slope dEm/dSOC is what makes voltage informative: where the OCV curve is steep, a small voltage gap moves the SOC a little; where it is flat, the filter learns less. The voltage noise R ("EKF voltage σ" above) sets how far the filter trusts a single reading. Here the filter starts with a 20-point SOC uncertainty and uses the same tables as the simulated cell, so it has the perfect model, except when you change "Cell R0 ×".
Which mistakes show up in published reports?
From all 682 public reports of this challenge, read 20 Nov 2026. 625 explain coulomb counting, 245 mention Kalman filters and 88 the open-circuit voltage. The calculator tab catches the first two:
- The 3600 is missing. 137 reports write the recursive formula SOC(t) = SOC(t−1) ± I·Δt/Qn; 86 of them never write 3600 anywhere, so with Δt in seconds and Qn in Ah the step is 3,600 times too large.
- The sign is not stated. 129 use "+ I(t)·Δt/Qn" without saying that charging current is positive; 4 multiply SOC(t−1) by the integral instead of adding it.
- Drift is described, never sized. 140 reports say coulomb counting errors accumulate; 0 put a rate on it. The offset row of the table above does: 0.25 A on 25 Ah is 1.0 point per hour.
- Accuracy figures with no source. 8 reports carry the same sentence, "the SOC estimation error is 2.5% when compared with the real SOC", and 9 that accuracy "is less than 2%", without naming a cell, a test or a reference. An estimator's accuracy is a property of its sensors, model and load, as the tables above show.
- The start value is skipped. Only 148 mention the initial SOC, the one error coulomb counting can never correct on its own.
What this simulator does not cover
- Temperature changes during the run. The cell stays at the temperature you set; for heating see the battery thermal model calculator.
- Hysteresis, long relaxation, self-discharge and ageing during the run. The 1-RC tables have none of them; real OCV resets and EKFs are worse for it.
- A pack. One cell. In a series string the BMS also tracks the weakest cell and balances them, which the harness model does.
- Other estimators: unscented and sigma-point Kalman filters, observers and neural networks. The EKF here is the textbook form, tuned once, not a production design.
SOC estimation, cell models and BMS algorithms in MATLAB and Simulink are part of Skill-Lync's electric vehicle and battery courses, built around the projects BMS teams actually run.
Frequently asked questions
What is the coulomb counting formula for SOC?
SOC(t) = SOC(t0) − ∫η·I dt / (3600·Qn), with the current I in amperes (positive when discharging), time in seconds, the capacity Qn in ampere-hours and η the charge efficiency. The 3600 turns ampere-seconds into ampere-hours. Example: 10 A for 30 minutes from a 25 Ah cell at 80% leaves 80 − 20 = 60%.
How does a BMS implement coulomb counting?
It samples the pack current with a shunt or Hall sensor every few milliseconds to a second, adds I·Δt/(3600·Q) to a running SOC each sample, starts from an SOC read off the open-circuit voltage after a long rest, uses a capacity that it updates as the cell ages, clamps the result to 0-100% and resets it at known points such as the end of a full charge.
How accurate is coulomb counting?
It is exact for the charge that flows and only as good as its inputs. A start error never goes away; a current offset adds a steady drift (0.25 A on a 25 Ah cell is 1.0 SOC point per hour); a gain or capacity error grows with the charge moved. In Skill-Lync's default run plain coulomb counting ends 13.2 points off after 3.3 hours.
What is the difference between coulomb counting and Kalman filter SOC estimation?
Coulomb counting only integrates current. An extended Kalman filter also predicts the cell voltage from a model (here a 1-RC equivalent circuit) and corrects the SOC by the difference between predicted and measured voltage, so start errors and drift are pulled back. It is only as good as the model: with the cell's R0 grown 1.5 times, the EKF in this simulator is off by up to 24.4 points.
Is the battery at 100% SOC when a CC-CV charge ends?
Not quite. With the course cell tables at 20 °C, a 0.5C CC-CV charge to 4.2 V that stops when the current falls to C/20 leaves the cell at 99.51% of its 25 Ah. A BMS that resets to 100% at that point is 0.5 points high, a small, repeatable error.
How much voltage accuracy does an OCV-based SOC estimate need?
It depends on the slope of the OCV curve. For the course NMC cell at 20 °C, 1 SOC point is only 3.16 mV of open-circuit voltage between 25% and 50% SOC but 11.51 mV above 90%. A 10 mV voltage error is about 3.2 points in the flat middle. LFP cells are flatter still, which is why their BMS relies more on counting.
Related on Skill-Lync
- Battery thermal model calculator (the same cell tables with I²R heat and a fault cell)
- Battery pack calculator (cells in series and parallel for any kWh)
- Best BMS courses in India, compared
- Battery technology courses on Skill-Lync
- Electric vehicle courses on Skill-Lync
- All free engineering tools
Sources
- T. Huria, M. Ceraolo, J. Gazzarri, R. Jackey, "High Fidelity Electrical Model with Thermal Dependence for Characterization and Simulation of High Power Lithium Battery Cells", IEEE International Electric Vehicle Conference, March 2012, and the MathWorks ssc_lithium_cell_1RC initialisation script built on it: the Em, R0, R1, C1 and capacity tables used here.
- G. L. Plett, "Extended Kalman filtering for battery management systems of LiPB-based HEV battery packs", Parts 1 to 3, Journal of Power Sources 134 (2004): the EKF formulation on an equivalent-circuit model that the filter here follows in its simplest form.
- Skill-Lync, all 682 public student reports titled "State of charge estimation", read 20 Nov 2026: the challenge, the harness test sequences and the mistakes above.
- Skill-Lync, scripts/verify/soc-estimation.py: checks the cell simulation against scipy's Radau solver at a relative tolerance of 10⁻¹⁰ (including the CC to CV switch), coulomb counting against the closed-form drift formula, and the EKF against a second filter written with a Joseph-form update and a numerical Jacobian. This page re-runs every case in the browser code and checks it against that script at build time.