node-red-contrib-easy-pid-controller 2.0.1
A Node-RED node for implementing an easy PID controller
Easy PID Controller Node for Node-RED
The easy-pid-controller is a Node-RED node that provides industrial-grade Proportional-Integral-Derivative (PID) control based on simple-pid-controller v2.0.0. It integrates easily with PLCs, MQTT, and SCADA systems, and supports 0-10V and 4-20mA control signals with safety features like anti-windup, output clamping, and bumpless transfer.
Features
- Easy to configure PID parameters: Kp, Ki, Kd.
- Setpoint (
SV) and Process Variable (PV) inputs overmsg.topic. - Outputs full PID status:
PV,SV,error,P,I,D,output, scaledSignal, andValue. - Choice of control signal types:
0-10Vor4-20mA. - Anti-windup (integral clamping) and output clamping (min/max).
- Deadband support to suppress output when the error is negligible.
settledhandling: stop the loop automatically when within tolerance.- Manual / Auto mode with bumpless transfer.
- Runtime gain tuning (
gainstopic) and controller reset (resettopic). - Real-time status updates via node status text and optional MQTT/InfluxDB integration.
Installation
npm install node-red-contrib-easy-pid-controller
Usage
- Drag and drop the
easy-pid-controllernode into your Node-RED flow. - Double click on the node to configure:
- PID gains: Kp, Ki, Kd.
- Loop interval
dt(seconds). - Output and integral limits.
- Deadband and settled tolerance.
- Signal type (
0-10Vor4-20mA) and engineering range.
- Connect MQTT / Inject / Function nodes to provide
SV,PV,auto, and optional advanced topics (gains,mode,manual_output,reset). - Deploy and monitor the outputs (
output,Signal,Value,mode) in real-time.
Inputs
All control is driven by msg.topic and msg.payload:
SV(number)
Desired setpoint value for the controller.msg.topic = "SV"msg.payload = <number>
PV(number)
Process variable / current state of the system.msg.topic = "PV"msg.payload = <number>
auto(boolean)
Start/stop the PID loop and auto mode.msg.topic = "auto"msg.payload = true→ start loop and switch to auto modemsg.payload = false→ stop loop and switch to manual mode
gains(object) — v2.0.0
Runtime PID gain tuning without restarting the node.msg.topic = "gains"msg.payload = { k_p: <number>, k_i: <number>, k_d: <number> }
mode(string) — v2.0.0
Explicitly switch controller mode.msg.topic = "mode"msg.payload = "auto"or"manual"- Switching
manual → autouses bumpless transfer (no output jump).
manual_output(number) — v2.0.0
Fixed output used in manual mode, also seeds bumpless transfer when returning to auto.msg.topic = "manual_output"msg.payload = <number>
reset(any) — v2.0.0
Reset controller internal state (integral, derivative, timestamp).msg.topic = "reset"msg.payloadcan be any value
Outputs
The node outputs an object on msg.payload with the following fields (from simple-pid-controller v2.0.0):
PV(number)
Current process variable.SV(number)
Current setpoint.error(number) — v2.0.0
Current control error:SV - PV.P(number)
Proportional component.I(number)
Integral component (clamped byIntegral Min/Maxfor anti-windup).D(number)
Derivative component (derivative on measurement — no kick on setpoint changes).output(number) — v2.0.0
Raw clamped PID output (P + I + D, limited byOutput Min/Max).Signal(number)
Output mapped to the configured signal range:0-10V→ 0 to 104-20mA→ 4 to 20
Value(number)PVmapped to the signal units for easier UI or Range node usage.mode(string) — v2.0.0
Current controller mode:"auto"or"manual".
Node Configuration Fields (Editor)
- Kp, Ki, Kd: PID gains.
- dt (s): Target loop interval in seconds (controller internally uses dynamic timestamps;
dtis a base rate / initial fallback). - Output Min / Output Max: Clamp bounds for
output. - Integral Min / Integral Max: Anti-windup clamps on the integral accumulator.
- Deadband: If
|error|is below this value, output is forced to0(disable with0). - Settled Tolerance: When
|error|falls below this value, the controller emits asettledevent and the node stops the loop; restart withauto: true. - Signal Type:
0-10Vor4-20mA. - Range Min / Range Max: Engineering range for mapping PV and output to signal units.
Changelog
v2.0.1
Updated core to use
simple-pid-controllerv2.0.0 with:- Dynamic
dtbased on real timestamps (constructordtused as fallback). - Anti-windup via configurable
Integral Min/Max. - Output clamping via
Output Min/Max. - Deadband support to suppress small-error output.
setTarget()now resets integral and derivative state.- Derivative on measurement, avoiding derivative kick on setpoint steps.
- EventEmitter-based
updateandsettledevents internally.
- Dynamic
Inputs
- Added:
gainstopic for runtime tuning of{ k_p, k_i, k_d }. - Added:
modetopic to switchauto/manualwith bumpless transfer. - Added:
manual_outputtopic to set fixed output in manual mode. - Added:
resettopic to clear internal controller state. - Improved:
autotopic now also sets mode toauto/manualinstead of just starting/stopping the timer.
- Added:
Outputs
- Added:
error,output, andmodein the payload. - Kept:
PV,SV,P,I,D,Signal,Valuefor compatibility.
- Added:
Node behaviour
- Improved: Node status messages show setpoint, PV, mode, and reset events.
- Improved: On node close, the controller is reset and the internal timer is cleared.
v1.2.1
- Added: Node status updates during runtime to display relevant information like current PV, PID activation state, and more.
v1.2.0
- Changed: Moved the Setpoint (
SV) from node configuration tomsg.payloadwith the topicSV.
v1.1.0
- Added: New output value
Valuethat provides the direct control signal based on the sensor type configuration. - Improved: Code documentation and error handling for invalid inputs.
v1.0.0
- Initial release with basic PID functionalities.
- Support for
0-10Vand4-20mAsignal types.
Contributing
Contributions to improve the node or fix any issues are welcome. Please submit an issue or pull request on the GitHub repository.
License
GPL-3.0 License. See the LICENSE file for details.
Example
See the examples/ directory for sample flows illustrating:
- Basic PID control.
- MQTT-based SV/PV input.
- InfluxDB logging of PID status.
- Runtime gain tuning and mode switching.
Author
Harshad Joshi @ Bufferstack.IO Analytics Technology LLP, Pune