
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
simple-pid-controller-2
Advanced tools
A simple application to demonstrate the usage of a PID Controller with examples
This is a fork of https://github.com/hj91/simple-pid-controller
A Proportional-Integral-Derivative (PID) controller is a control loop feedback mechanism widely used in industrial control systems. This module provides a PID controller implementation in Node.js.
To install this module, run the following command:
npm install simple-pid-controller-2
First, require the module:
const PIDController = require('simple-pid-controller');
Then, create a new PIDController instance. You can optionally provide proportional, integral, and derivative gains, as well as a time interval:
const controller = new PIDController(1.2, 1, 0.01, 1);
You can set a new target for the controller:
controller.setTarget(34);
And you can update the controller with the current value to get the control output:
let power = controller.update(currentValue);
This module exports the PIDController class, which has the following methods:
constructor(k_p = 1.0, k_i = 0.0, k_d = 0.0, i_max = Infinity, i_min = -Infinity, dt = 1.0): Constructs a new PIDController. The i_max and i_min parameters limit the accumulated integral term. The integral term is clamped to the maximum or minimum values to prevent windup.
setTarget(target): Sets a new target for the controller.
update(currentValue): Updates the controller with the current value and calculates the control output.
k_p: Proportional gain.k_i: Integral gain.k_d: Derivative gain.i_max: Maximum allowable integral contribution. Prevents the integral from growing indefinitely.i_min: Minimum allowable integral contribution. Prevents the integral from becoming too negative.dt: Time interval between updates.PID controllers are used in a wide variety of applications in industrial control systems and other areas, including:
By using this module, developers can implement PID control in their Node.js applications without having to understand all of the underlying mathematics.
This module is licensed under the Apache License.
Copyright 2025 Tomel218
FAQs
A simple application to demonstrate the usage of a PID Controller with examples
The npm package simple-pid-controller-2 receives a total of 4 weekly downloads. As such, simple-pid-controller-2 popularity was classified as not popular.
We found that simple-pid-controller-2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.