Lemonergy · Studio block
SOC EKF
One-state extended Kalman observer with a calibrated fraction-to-OCV table, Joseph covariance update and explicit measurement validity.
- Implementation ID
battery-soc-ekf- Reviewed
- 2026-10-27
Behavior
Predicts a charge or energy fraction from signed throughput and corrects it using terminal voltage and a calibrated fraction-to-OCV table. Scalar Joseph covariance updates preserve nonnegative variance. Invalid voltage measurements skip correction; flat OCV regions report limited observability. Adaptive variants bound an innovation-based voltage-noise estimate.
Interface
| Name | Direction | Unit | Meaning |
|---|---|---|---|
current | input | A | Signed battery current; scalar. |
voltage | input | V | Measured voltage; scalar. |
valid | input | true / false | Voltage measurement valid; scalar. |
reset | input | true / false | Reset; scalar. |
fraction | output | 1 (fraction) | State of charge; scalar. |
variance | output | 1 | Posterior fraction variance; scalar. |
innovation | output | V | Voltage innovation; scalar. |
gain | output | 1 | Correction gain; scalar. |
noise | output | 1 | Voltage-noise variance; scalar. |
status | output | 1 | Status (0 prediction, 1 correction, 2 unobservable, 3 clipped); scalar. |
Parameters
Defaults are initial model values. Select values for your own model and operating conditions.
| Parameter | Unit | Default | Meaning and limits |
|---|---|---|---|
Sample interval (s)sampleTimeS | s | 1 | Positive sample interval. Initialization has zero elapsed time; subsequent accepted samples update memory. |
Charge capacity (Ah)capacity | Ah | 2 | Charge capacity (Ah). This is an editable model input; the default belongs to the synthetic worked example. |
Initial SOC (0–1)initialFraction | 0–1 | 0.6 | Initial SOC (0–1). This is an editable model input; the default belongs to the synthetic worked example. |
Initial fraction varianceinitialVariance | 1 | 0.04 | Initial fraction variance. This is an editable model input; the default belongs to the synthetic worked example. |
Process variance rate (fraction²/s)processNoise | fraction²/s | 0 | Process variance rate (fraction²/s). This is an editable model input; the default belongs to the synthetic worked example. |
Voltage measurement variance (V²)measurementNoise | V² | 0.01 | Voltage measurement variance (V²). This is an editable model input; the default belongs to the synthetic worked example. |
Series resistance (Ω)resistanceOhm | Ω | 0.05 | Series resistance (Ω). This is an editable model input; the default belongs to the synthetic worked example. |
Noise adaptation weight (0–1)adaptationRate | 0–1 | 0 | Noise adaptation weight (0–1). This is an editable model input; the default belongs to the synthetic worked example. |
Minimum voltage variance (V²)minimumNoise | V² | 1e-06 | Minimum voltage variance (V²). This is an editable model input; the default belongs to the synthetic worked example. |
Maximum voltage variance (V²)maximumNoise | V² | 1 | Maximum voltage variance (V²). This is an editable model input; the default belongs to the synthetic worked example. |
Open-circuit voltage table [SOC fraction, V]ocvTable | See field order | [[0, 3], [1, 4]] | Open-circuit voltage table [SOC fraction, V]. Rows are ordered coordinate/value pairs; the first column must be strictly increasing. |
Equations and rules
innovation = Vmeasured - VpredictedK = Ppredicted*H / (H^2*Ppredicted + R)fraction = predictedFraction + K*innovationP = (1-K*H)^2*Ppredicted + K^2*R
Worked example
SOC EKF worked example
Use the defaults below with Signed battery current = 0 A, Measured voltage = 3.8 V, Voltage measurement valid = 1 true / false, Reset = 0 true / false. At 0 s, State of charge is 0.76 1 (fraction). Additional checks are listed below.
Open Studio example after release →| Output | Time (s) | Expected value | Unit | Absolute tolerance |
|---|---|---|---|---|
State of chargefraction | 0 | 0.76 | 1 (fraction) | 1e-08 |
Posterior fraction variancevariance | 0 | 0.008 | 1 | 1e-08 |
Voltage innovationinnovation | 0 | 0.2 | V | 1e-08 |
Correction gaingain | 0 | 0.8 | 1 | 1e-08 |
Explore the recorded outputs
SOC EKF recorded example
SOC EKF / State of charge2 actual recorded samples. Lines are visual guides between samples. Synthetic example, not measured cell data.
Read the selected signal as a table
| Time (s) | Value |
|---|
Download the recorded samples (JSON) · Open this Studio example after release
Use in a workflow
SOC EKF worked example
One-state extended Kalman observer with a calibrated fraction-to-OCV table, Joseph covariance update and explicit measurement validity.
- SOC EKF: Predicts a charge or energy fraction from signed throughput and corrects it using terminal voltage and a calibrated fraction-to-OCV table. Scalar Joseph covariance updates preserve nonnegative variance. Invalid voltage measurements skip correction; flat OCV regions report limited observability. Adaptive variants bound an innovation-based voltage-noise estimate.
- Use the parameter values in the block reference.
- Implementation tested locally; public release pending.
Connected concepts
Limits and interpretation
- One-state extended Kalman observers, without an unscented transform, RC polarization states or automatic cell identification. SOE requires its own energy-fraction-to-OCV calibration. Synthetic filter settings are not accuracy guarantees.
- The example verifies numerical behavior for synthetic parameters. Cell characterization and validation for an intended use are separate tasks.
Scientific and mathematical references
These sources explain the scientific and mathematical background. The behavior, interface and limits above define the Lemonergy implementation; a citation does not imply every model option in the source is implemented.
- Extended Kalman filtering for battery management systems of LiPB-based HEV battery packs: Part 3. State and parameter estimation
Gregory L. Plett · Journal of Power Sources · 2004
Technical reference · Model-based battery state-of-charge and parameter estimation with extended Kalman filtering, including uncertainty and model dependence.
- Extended Kalman filtering for battery management systems of LiPB-based HEV battery packs: Part 2. Modeling and identification
Gregory L. Plett · Journal of Power Sources · 2004
Technical reference · Battery charge balance, open-circuit voltage, ohmic loss, polarization dynamics and model identification; parameters require cell-specific data.
Implementation sources
This reference follows the public interface and locally verified numerical checks for an upcoming release.
Contract: Lemonergy Studio public contract · Verification record: verification-2026-10-27
docs/glossary/native-block-verification.json
This implementation and its workflow uses (JSON) · Knowledge graph (JSON-LD)