Battery knowledge · Data, communication and electronics
PID controller
A feedback controller whose output is a weighted sum of the present error, its accumulated integral and its rate of change. It is the workhorse of battery systems — holding coolant temperature with a pump or compressor, regulating charger current and voltage — and often runs as PI only, without the derivative term. [1]
- Abbreviation
- PID
- Also called
- proportional–integral–derivative controller, PI controller
- Relationship
- u = K_p·e + K_i·∫e dt + K_d·de/dt
Example
Separate three controller contributions
For an illustrative error e = 2, accumulated error 3 s and error slope −0.5/s, gains Kp = 1, Ki = 0.5/s and Kd = 0.2 s give u = 2 + 1.5 − 0.1 = 3.4. Output limits and anti-windup are separate design choices.
Explore the graph
Apply PID terms to a prescribed smooth error to see what each contribution does.
At t = 0⁺, output is 0.9. At long time, the stored integral approaches 1.
e(t) = exp(−t/10); u = Kp e + Ki ∫e dt + Kd de/dt
Illustrative model. Zero initial integral; no actuator limits, anti-windup, derivative filtering, sampled implementation or setpoint discontinuity. The smooth error is an input, not a simulated closed-loop result.
Use in Lemonergy
Lemonergy Studio blocks
Discrete weighted PID — worked example
Combines proportional, integral and filtered derivative control with setpoint weights and limits.
Blocks to use
- Discrete weighted PID
e = reference − measurement. I candidate = I previous + Ki × elapsed_time × e. u = clamp(Kp × (b reference − measurement) + I + filtered derivative, lower, upper). The worked example connects this operation to signals in Lemonergy Studio.
Inputs & settings
- Use the block reference for settings and connections.
- Bundled example verified on the production release of 28 October 2026.
This overview identifies the components to use. Follow the example in Lemonergy for their connections and settings.
- Review the interface, units and model limits.
- Open the Studio example and run its bundled model.
- Compare outputs with the numerical checks; change one input and run again.
Example. Setpoint = 1; Measurement = 0. Control at 1 s = 1.5.
Observe. Inspect the output channels and checks on the block reference page.
Shapes and element types are explicit. Values must be finite; automatic reshaping and unit conversion are not performed.
Open Studio example →Lemonergy Studio blocks
Continuous weighted PID — worked example
Combines continuous proportional, integral and filtered derivative control with weights and limits.
Blocks to use
- Continuous weighted PID
dx_integral/dt = Ki (reference − measurement), subject to conditional integration. τ dx_filter/dt = c reference − measurement − x_filter. u = clamp(Kp (b reference − measurement) + x_integral + Kd dx_filter/dt, lower, upper). The worked example connects this operation to signals in Lemonergy Studio.
Inputs & settings
- Use the block reference for settings and connections.
- Bundled example verified on the production release of 28 October 2026.
This overview identifies the components to use. Follow the example in Lemonergy for their connections and settings.
- Review the interface, units and model limits.
- Open the Studio example and run its bundled model.
- Compare outputs with the numerical checks; change one input and run again.
Example. Setpoint = 1; Measurement = 0. Control at 1 s = 1.5.
Observe. Inspect the output channels and checks on the block reference page.
Shapes and element types are explicit. Values must be finite; automatic reshaping and unit conversion are not performed.
Open Studio example →References & further reading
Technical references
- 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.
Further reading on this topic
These sources provide broader context; they are not presented as citations for every statement in this entry.
- 3rd generation of the CAN data link layer
CAN in Automation, CAN Newsletter · 2020
Topic background · Classical CAN, CAN FD and CAN XL data-link concepts; publication describes the 2020 state.
- Getting Started with the BQ76925
Texas Instruments · 2019
Topic background · A concrete BMS analog front-end example: cell voltage, current, temperature measurement and MCU integration.