Episode 5 — Battery State of Charge: Coulomb Counting vs. Kalman Estimation
"Why Your Battery Gauge Is Secretly Running an Optimal Estimator"
Pillar: Power & Energy Systems (+ estimation) · Runtime ~16 min · ~2,500 words · Elena & Marcus
MARCUS: Episode five, the season finale. We opened with power systems, and we're closing with power — but fused with estimation theory, because today's topic is the algorithm that tells your phone and your car how much battery is left, and the honest version of it is far deeper than a fuel gauge. Elena, objective.
ELENA: By the end you'll understand why the obvious method for measuring state of charge — just counting the charge in and out — is fundamentally inadequate, and why every serious battery management system instead runs a Kalman filter over a model of the cell. We'll refresh the Kalman filter itself, because it's a graduate skill worth keeping sharp, and you'll see it do something genuinely elegant: optimally blend a model that drifts with a measurement that's noisy, and get something better than either.
MARCUS: The hook?
ELENA: Your battery percentage is not measured. It's estimated — there is no sensor that reads out state of charge. What's happening behind that number is an optimal estimator arbitrating, every second, between "what my model predicts" and "what my voltage sensor sees," weighted by exactly how much it trusts each. That arbitration is the Kalman filter, and it's one of the most beautiful ideas in all of engineering.
The Refresher: What State of Charge Is and the Obvious Method
ELENA: Let's define the problem cleanly. State of charge — SOC — is the fraction of usable capacity remaining in the cell, zero to a hundred percent. The trouble, and the entire reason this is hard, is that there's no instrument that directly reads charge remaining. You can't dip a stick in. You can only measure terminal voltage, current, and temperature, and infer SOC from those. So everything is inference.
MARCUS: And the obvious inference is just to count the charge going in and out.
ELENA: Right — coulomb counting, and let's respect it because it's not wrong, it's just insufficient. Charge is the integral of current over time. So if you know the SOC at some starting moment, you can track it forward by integrating the measured current: SOC now equals SOC at the start, minus the integral of current divided by the total capacity. Current out lowers SOC, current in raises it. It's just Coulomb's bookkeeping. In a perfect world with a perfect current sensor and perfectly known capacity, coulomb counting would be exact.
MARCUS: But it's an open-loop integrator, and I can already hear the problem.
ELENA: You've put your finger right on it, and this is the key insight of Part 1: coulomb counting is pure open-loop integration, and integration is unforgiving. Three failures stack up. First, your current sensor has a small bias — a tiny constant offset. Integrate a tiny constant offset over hours and it grows without bound; your estimate drifts steadily away from truth with nothing to pull it back. Second, you need to know the starting SOC, and at power-on you often don't. Third, you divide by the total capacity — but capacity isn't constant. It fades as the battery ages, and it shifts with temperature. So your denominator is wrong and slowly getting wronger over the life of the cell. An open-loop integrator with a biased input and an uncertain scale factor: it cannot be trusted alone over long periods. That's coulomb counting's fatal flaw.
What Changed: From Bookkeeping to Model-Based Estimation
ELENA: So what changed since your 2013 baseline? Model-based estimation went from a sophisticated option to the universal standard in any battery management system that matters — electric vehicles, grid storage, serious consumer electronics. And the second, more recent shift: these estimators stopped only tracking SOC and started simultaneously tracking the cell's parameters — its capacity and internal resistance — which means they now estimate state of health, the aging, at the same time. The fuel gauge became an online system identifier.
MARCUS: Before we get to the filter — there's a second simple method I always hear about. Just measure the voltage and look up the charge.
ELENA: Right, the open-circuit-voltage method, and understanding why it also fails alone is what motivates the whole Kalman approach. A battery has a characteristic relationship between its open-circuit voltage and its state of charge — a fairly repeatable curve. So in principle, measure the voltage, look up the SOC. The problem is the words "open circuit." That relationship only holds when the cell is at rest, fully relaxed, no current flowing. The moment you draw current, the terminal voltage sags below the true open-circuit value because of the internal resistance and slower electrochemical dynamics. So under load, the measured voltage is a corrupted, dynamic version of the thing you want. And on a flat part of the curve — and lithium iron phosphate has a notoriously flat voltage curve in the middle — a millivolt of voltage noise maps to a huge swing in inferred SOC. So voltage lookup is noisy and only valid at rest; coulomb counting is smooth but drifts. Each is broken in a way the other is strong.
MARCUS: Which is practically begging for a method that combines them.
ELENA: And that's exactly what the Kalman filter is. It is the optimal way to combine a drifting-but-smooth prediction with a noisy-but-anchored measurement. Coulomb counting is the prediction. Voltage is the measurement. The Kalman filter marries them. Let me build it.
The Mechanism: A Battery as a State Space
ELENA: To run a Kalman filter you need a model of the system as a state space — a set of internal states that evolve over time and produce the measurement. So we build an equivalent circuit model of the cell. The simplest useful one: an ideal voltage source whose value is the open-circuit voltage as a function of SOC, in series with an internal resistance, plus one or two resistor-capacitor pairs that capture the sluggish part of the response — the way the voltage takes seconds to minutes to settle after a current change, the diffusion and polarization dynamics.
MARCUS: And what are the states?
ELENA: That's the modeling move. The states are the things you can't measure but need to track: the state of charge itself, and the voltages across those RC pairs — the slow internal dynamics. SOC evolves by coulomb counting — that's its state equation, the integral of current. The RC voltages evolve by their own time constants. And the output equation says: the terminal voltage you actually measure equals the open-circuit voltage at the current SOC, minus the resistive drop, minus those RC voltages. So the model ties the hidden state, SOC, to the measurable quantity, terminal voltage, through the physics of the cell. That link is what lets a voltage measurement correct an SOC estimate.
MARCUS: Now refresh the filter itself, because that's the skill.
ELENA: Let's. The Kalman filter is a two-step recursion that repeats every time step: predict, then update. In the predict step, you use your model to advance the state — run coulomb counting forward to predict the new SOC, advance the RC voltages — and crucially you also advance your uncertainty. You track a covariance, a number representing how unsure you are about the state, and during prediction that uncertainty grows, because the model isn't perfect and bias is creeping in. So after predicting, you have an estimate and an inflated error bar.
MARCUS: That growing uncertainty is the coulomb-counting drift, quantified.
ELENA: Precisely — that's the whole conceptual unification. The covariance growing during prediction is the drift of open-loop integration, made into a number the filter is aware of. Now the update step. You take an actual voltage measurement. Your model predicts what the voltage should be given your predicted state. The difference between measured and predicted voltage is the innovation — the surprise. Then you compute the Kalman gain, and the gain is the heart of it: it decides how much to trust the surprise. The gain is large when your state uncertainty is high relative to the measurement noise — meaning "my prediction has drifted and I don't trust it, so lean hard on the measurement." The gain is small when the measurement is noisy relative to a confident prediction — "my voltage reading is garbage right now, mostly ignore it." You nudge the state by the gain times the innovation, and you shrink the covariance, because the measurement just bought you information.
MARCUS: So the gain is literally an automatic, optimal arbitration between the model and the sensor.
ELENA: That's the sentence I wanted you to leave with. The Kalman gain continuously answers "how much do I trust my drifting coulomb-counter versus my noisy voltmeter, right now?" — and it answers it optimally, in the least-squares sense, given the noise statistics. Notice what the gain actually depends on: how uncertain the state is, how steep the voltage curve is right here, and how noisy you've told it the measurement is. On a steep part of the curve, voltage is very informative, so the gain leans on it and corrects the coulomb-counting drift. On a flat plateau, a big change in SOC barely moves the voltage, so the gain shrinks and the filter trusts the model's prediction. And load? The model already predicts the sag from resistance and the RC pairs, so voltage under load is still useful — that's the whole point of having a model. Only when you expect the model itself to be wrong, say during violent current transients, do practical BMS designs inflate the measurement noise — an adaptive filter — to make the gain back off. Drift gets corrected; noise gets rejected. Neither method could do that alone. The filter does it every second.
Where It Gets Modern: EKF, UKF, and Tracking Aging
ELENA: Now the catch-up, because the plain Kalman filter has a hidden assumption: it's optimal for linear systems. And our battery is not linear — that open-circuit-voltage-versus- SOC relationship is a curve, sometimes a nasty one. So in practice you use a nonlinear variant, and which one is a real engineering choice worth knowing.
MARCUS: Give me the two.
ELENA: The extended Kalman filter — EKF — handles the nonlinearity by linearizing the model at each step: it takes the derivative, the slope, of that open-circuit-voltage curve at the current operating point and pretends the system is linear over that little neighborhood. Cheap, ubiquitous, and it works well where the curve is gently sloped. But it struggles where the curve bends sharply — near full charge and near empty — because one tangent line is a poor guide to a curve that's changing fast. The alternative is the unscented Kalman filter — UKF — which doesn't linearize at all. Instead it picks a small, clever set of sample points — sigma points — pushes each one through the true nonlinear model, and reconstructs the mean and covariance from where they land. It captures the curvature that the extended filter's single slope misses, at somewhat higher computational cost. So the trade is: extended is cheaper and fine for mild nonlinearity; unscented is more accurate through the sharp bends. One thing neither fixes: on a truly flat plateau the voltage simply doesn't carry SOC information, and no filter can extract information that isn't there. That's a real BMS design decision.
MARCUS: And the aging piece you teased — tracking the battery getting old.
ELENA: This is the most modern turn, and it's clever. Remember coulomb counting needs the true capacity, and capacity fades with age — that was failure number three back in Part 1. So instead of treating capacity and internal resistance as fixed numbers, you make them additional states and let the filter estimate them too. This is dual estimation, or joint estimation: one filter — or a pair of coupled filters running on different timescales — tracks the fast state, SOC, while simultaneously tracking the slow parameters, capacity and resistance. As the cell ages and its capacity drops, the filter learns the new capacity from the mismatch between predicted and measured voltage over time. And capacity fade and resistance growth are exactly the definition of state of health. So the same estimator that tells you SOC now also tells you how worn out the battery is — your range estimate and your "time to replace the pack" estimate fall out of one unified algorithm. That fusion of state and health estimation is the frontier your 2013 self would not have seen as standard, and now it is.
Industry Standard Today
MARCUS: Where does this live in real products?
ELENA: Everywhere that a battery is expensive or safety-critical. Every credible EV battery management system runs model-based Kalman estimation — extended or unscented — over an equivalent-circuit model, often with dual estimation for state of health, because range accuracy and pack longevity are direct selling points and safety requirements. Grid-scale battery storage — the same batteries we talked about doing grid-forming duty back in Episode 1 — runs the same class of estimator to manage thousands of cells. Even high-end consumer electronics moved this way. The pure coulomb-counting fuel gauge you might remember from older devices, the one that needed periodic full-discharge "recalibration" — that recalibration ritual was literally a human being forced to re-anchor an open-loop integrator that had drifted. Model-based estimation is what made that ritual disappear. If your devices stopped needing battery recalibration somewhere in the last decade, you were watching this exact upgrade happen.
Self-Test
MARCUS: Final exercises of the season. Make it skill.
ELENA: Two, and the first is the intuition pump that ties the whole season finale together. Reason through the Kalman gain at two operating points. Point one: the battery is resting, no load, and it's in a region where the open-circuit-voltage curve is steep — so the voltage measurement is both trustworthy and informative. What should the gain do, and what happens to the coulomb-counting drift? Point two: you're pulling hard current and sitting on a flat plateau of the voltage curve, where a millivolt of noise maps to a big SOC error. What should the gain do now — and which of those two conditions, the load or the flat curve, is actually responsible? Walk yourself through why the filter leans on voltage in the first case and on the model in the second, and why a good model means load alone isn't the reason. If that reasoning feels natural, you own the Kalman filter, not just its equations.
MARCUS: And the second?
ELENA: The synthesis question for the whole topic. Explain why neither coulomb counting alone nor voltage lookup alone is acceptable for a real battery — name the specific failure of each, the integrator drift and the load-and-noise corruption — and then explain how the Kalman filter's predict-update structure uses each one to cover precisely the other's weakness. If you can deliver that as a clean paragraph, you've not only learned battery state estimation, you've internalized the deepest idea in estimation theory: an optimal estimator is a disciplined argument between a model and a measurement, and the Kalman gain is the referee.
MARCUS: That closes Season 1 — grid-forming inverters, OFDM and 5G, field-oriented control, gate-all-around transistors, and battery estimation. Power, communications, control, devices, and estimation. Elena, send us out.
ELENA: Here's the thread I hope you pull from the whole season. Every single episode was the same intellectual move: the problem is hard in the obvious frame, so you change something — the coordinate frame, the basis, the geometry, the way you weigh evidence — and the hard problem becomes easy. The swing equation in firmware. The Fourier basis making a channel diagonal. The rotating frame making a motor a DC motor. The gate wrapping the channel. The filter refereeing model and measurement. Keep noticing that move. Once you see it, modern electrical engineering stops being a pile of acronyms and starts being a handful of deep ideas wearing different clothes. Thanks for spending the season with us.