Lemonergy · Studio block
Charge counter
Integrates signed throughput. Changing capacity preserves fraction and reports revaluation separately.
- Implementation ID
battery-charge-counter- Reviewed
- 2026-10-27
Behavior
Integrates signed discharge current or power over elapsed sample time. Charge efficiency applies during charging. The initial sample has zero elapsed time. Variable-capacity variants preserve the current fraction when capacity changes and report the resulting amount revaluation separately. Reset restores the initial fraction without integrating that event.
Interface
| Name | Direction | Unit | Meaning |
|---|---|---|---|
rate | input | A | Signed battery current; scalar. |
reset | input | true / false | Reset; scalar. |
fraction | output | 1 (fraction) | State of charge; scalar. |
throughput | output | C | Net throughput (C); scalar. |
revaluation | output | C | Capacity revaluation (C); scalar. |
boundary | output | C | Boundary amount (C); 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.8 | Initial SOC (0–1). This is an editable model input; the default belongs to the synthetic worked example. |
Charging efficiency (0–1)chargeEfficiency | 0–1 | 1 | Charging efficiency (0–1). This is an editable model input; the default belongs to the synthetic worked example. |
Equations and rules
amount[k] = amount[k-1] - effectiveRate[k] * elapsedTimefraction = clamp(amount / capacity, 0, 1)charge capacity in coulombs = 3600 * capacityAh
Worked example
Charge counter worked example
Use the defaults below with Signed battery current = 2 A, Reset = 0 true / false. At 0 s, State of charge is 0.8 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.8 | 1 (fraction) | 1e-08 |
Net throughput (C)throughput | 0 | 0 | C | 0 |
State of chargefraction | 1 | 0.7997222222222222 | 1 (fraction) | 1e-08 |
Explore the recorded outputs
Charge counter recorded example
Charge counter / 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
Charge counter worked example
Integrates signed throughput. Changing capacity preserves fraction and reports revaluation separately.
- Charge counter: Integrates signed discharge current or power over elapsed sample time. Charge efficiency applies during charging. The initial sample has zero elapsed time. Variable-capacity variants preserve the current fraction when capacity changes and report the resulting amount revaluation separately. Reset restores the initial fraction without integrating that event.
- Use the parameter values in the block reference.
- Implementation tested locally; public release pending.
Connected concepts
Limits and interpretation
- Current or power bias accumulates. Fraction clipping is reported as a boundary amount; it does not make the connected plant respect that boundary. Energy variants need capacity in joules.
- 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 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)