@mariusrumpf/pid-controller
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

PID Controller

PID Controller written in Node.js.

Install

$ npm install @mariusrumpf/pid-controller

Usage

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);

API

update(value: number): number

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.

setTarget(target:number)

Set a new target value for the pid.

setOutputLimits(min: number, max: number)

Set the minimum and maximum value possible for the pid output.

setTunings(p: number, i: number, d: number)

Update the used pid tunings on the fly while operating.

setSampleTime(sampleTime: number)

Set the rate in milliseconds at which the pid update calculation is called

Readme

Keywords

none

Package Sidebar

Install

npm i @mariusrumpf/pid-controller

Weekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

18.3 kB

Total Files

13

Last publish

Collaborators

  • mariusrumpf