PID Controller written in Node.js.
$ npm install @mariusrumpf/pid-controller
const { PIDController } = require('@mariusrumpf/pid-controller');
const controller = new PIDController({
p: 1, i: 0, d: 0,
target: 0,
sampleTime: 1000, // in ms
outputMin: 0,
outputMax: 1000,
});
const correction = controller.update(10);
Call this function in a regular interval of the set sample time with the input value for the pid, will return the output value to apply.
Set a new target value for the pid.
Set the minimum and maximum value possible for the pid output.
Update the used pid tunings on the fly while operating.
Set the rate in milliseconds at which the pid update calculation is called