Lemonergy · Studio block

Discrete weighted PID

Combines proportional, integral and filtered derivative control with setpoint weights and limits.

Implementation ID
native-discrete-pid
Reviewed
2026-10-27

Behavior

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.

Interface

Discrete weighted PID interfaceInputs or arguments on the left, observed outputs on the right. Conserving terminals appear below the component. The tables give units and behavior.Discrete weighted PIDStudio blockin0in1out0
Original Lemonergy interface view. Lines identify ports; they are not a completed simulation circuit.
Ports and observed outputs
NameDirectionUnitMeaning
in0input1Setpoint; real scalar.
in1input1Measurement; real scalar.
out0output1Control; real scalar.

Parameters

Defaults are initial model values. Select values for your own model and operating conditions.

Configuration fields
ParameterUnitDefaultMeaning and limits
Sample period
sampleTimeS
s0.1Exact sample grid period. Elapsed-time integration begins after initialization.
Minimum 1e-06
Proportional gain
params[0]
11Configured finite numerical parameter.
Integral gain
params[1]
10.5Configured finite numerical parameter.
Derivative gain
params[2]
10Configured finite numerical parameter.
Derivative filter time
params[3]
s0.1Configured finite numerical parameter.
Lower output limit
params[4]
1-10Configured finite numerical parameter.
Upper output limit
params[5]
110Configured finite numerical parameter.
Proportional setpoint weight
params[6]
11Configured finite numerical parameter.
Derivative setpoint weight
params[7]
10Configured finite numerical parameter.
Initial integral state
tables[0]
1[0]Configured coefficients or initial values in column-major order.

Equations and rules

  • e = reference − measurement
  • I candidate = I previous + Ki × elapsed_time × e
  • u = clamp(Kp × (b reference − measurement) + I + filtered derivative, lower, upper)

Worked example

Discrete weighted PID — worked example

Setpoint = 1; Measurement = 0. Control at 1 s = 1.5.

Open Studio example after release →
Numerical checks for the bundled synthetic example
OutputTime (s)Expected valueUnitAbsolute tolerance
Control
out0
11.511e-08

Explore the recorded outputs

Discrete weighted PID recorded example

Discrete weighted PID
Discrete weighted PID against timeRecorded synthetic simulation values. Time in seconds; output in —.0.9601.1050.251.250.51.3950.751.541—Time (s)
Discrete weighted PID: 1 — at 0 s

11 actual recorded samples. Lines are visual guides between samples. Synthetic example, not measured cell data.

Download the recorded samples (JSON) · Open this Studio example after release

Use in a workflow

Discrete weighted PID — worked example

Combines proportional, integral and filtered derivative control with setpoint weights and limits.

  1. 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.
    • Use the block reference for settings and connections.
    • Implementation tested locally; public release pending.
Open Studio example after release

Connected concepts

Limits and interpretation

  • Shapes and element types are explicit. Values must be finite; automatic reshaping and unit conversion are not performed.

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.

  1. 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.

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)