Lemonergy · Studio block
CC-CV current controller
PI voltage regulation with an external current envelope and anti-windup.
- Implementation ID
battery-cccv-controller- Reviewed
- 2026-10-27
Behavior
Uses a PI voltage loop and an external current magnitude envelope to request charge current. Conditional integration limits windup while the request is saturated. Charging is negative in the discharge-positive current convention; disabling resets control memory.
Interface
| Name | Direction | Unit | Meaning |
|---|---|---|---|
voltage | input | V | Highest cell voltage; scalar. |
limit | input | A | Charge-current magnitude limit; scalar. |
enable | input | true / false | Enable; scalar. |
request | output | A | Signed current request (charge negative); scalar. |
mode | output | 1 | Mode (0 disabled, 1 CC, 2 CV); 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 | 0.1 | Positive sample interval. Initialization has zero elapsed time; subsequent accepted samples update memory. |
Voltage target (V)targetV | V | 4 | Voltage target (V). This is an editable model input; the default belongs to the synthetic worked example. |
Proportional gain (A/V)kp | A/V | 10 | Proportional gain (A/V). This is an editable model input; the default belongs to the synthetic worked example. |
Integral gain (A/(V·s))ki | A/(V·s) | 0 | Integral gain (A/(V·s)). This is an editable model input; the default belongs to the synthetic worked example. |
Equations and rules
error = targetV - highestCellVoltagerequest = -clamp(kp * error + integral, 0, currentLimit)
Worked example
CC-CV current controller worked example
Use the defaults below with Highest cell voltage = 3.9 V, Charge-current magnitude limit = 2 A, Enable = 1 true / false. At 0 s, Signed current request (charge negative) is -1 A. Additional checks are listed below.
Open Studio example after release →| Output | Time (s) | Expected value | Unit | Absolute tolerance |
|---|---|---|---|---|
Signed current request (charge negative)request | 0 | -1 | A | 1e-08 |
Explore the recorded outputs
CC-CV current controller recorded example
CC-CV current controller / Signed current request (charge negative)11 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
CC-CV current controller worked example
PI voltage regulation with an external current envelope and anti-windup.
- CC-CV current controller: Uses a PI voltage loop and an external current magnitude envelope to request charge current. Conditional integration limits windup while the request is saturated. Charging is negative in the discharge-positive current convention; disabling resets control memory.
- Use the parameter values in the block reference.
- Implementation tested locally; public release pending.
Connected concepts
Limits and interpretation
- This block generates a current request. The plant, actuator limits and loop stability must be modeled separately.
- 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.
- Feedback Systems: An Introduction for Scientists and Engineers, second edition
Karl J. Åström, Richard M. Murray · Princeton University Press; author-maintained FBSwiki · 2021
Technical reference · State-space modeling, feedback and PID control. These mathematical foundations do not establish a particular software implementation.
- Lithium-ion battery fast charging: A review
Anna Tomaszewska et al. · eTransportation · 2019
Technical reference · CC-CV and alternative charging protocols, transport limitations, degradation and thermal implications; results depend on cell and test conditions. Software behavior is documented separately in Lemonergy block references.
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)