npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-red-contrib-easy-pid-controller

v2.0.1

Published

A Node-RED node for implementing an easy PID controller

Downloads

304

Readme

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 over msg.topic.
  • Outputs full PID status: PV, SV, error, P, I, D, output, scaled Signal, and Value.
  • Choice of control signal types: 0-10V or 4-20mA.
  • Anti-windup (integral clamping) and output clamping (min/max).
  • Deadband support to suppress output when the error is negligible.
  • settled handling: stop the loop automatically when within tolerance.
  • Manual / Auto mode with bumpless transfer.
  • Runtime gain tuning (gains topic) and controller reset (reset topic).
  • Real-time status updates via node status text and optional MQTT/InfluxDB integration.

Installation

npm install node-red-contrib-easy-pid-controller

Usage

  1. Drag and drop the easy-pid-controller node into your Node-RED flow.
  2. 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-10V or 4-20mA) and engineering range.
  3. Connect MQTT / Inject / Function nodes to provide SV, PV, auto, and optional advanced topics (gains, mode, manual_output, reset).
  4. 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 mode
    • msg.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 → auto uses 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.payload can 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 by Integral Min/Max for 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 by Output Min/Max).

  • Signal (number)
    Output mapped to the configured signal range:

    • 0-10V → 0 to 10
    • 4-20mA → 4 to 20
  • Value (number)
    PV mapped 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; dt is 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 to 0 (disable with 0).
  • Settled Tolerance: When |error| falls below this value, the controller emits a settled event and the node stops the loop; restart with auto: true.
  • Signal Type: 0-10V or 4-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-controller v2.0.0 with:

    • Dynamic dt based on real timestamps (constructor dt used 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 update and settled events internally.
  • Inputs

    • Added: gains topic for runtime tuning of { k_p, k_i, k_d }.
    • Added: mode topic to switch auto/manual with bumpless transfer.
    • Added: manual_output topic to set fixed output in manual mode.
    • Added: reset topic to clear internal controller state.
    • Improved: auto topic now also sets mode to auto/manual instead of just starting/stopping the timer.
  • Outputs

    • Added: error, output, and mode in the payload.
    • Kept: PV, SV, P, I, D, Signal, Value for compatibility.
  • 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 to msg.payload with the topic SV.

v1.1.0

  • Added: New output value Value that 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-10V and 4-20mA signal 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