New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

simple-pid-controller-2

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-pid-controller-2

A simple application to demonstrate the usage of a PID Controller with examples

latest
Source
npmnpm
Version
1.0.8
Version published
Weekly downloads
6
100%
Maintainers
1
Weekly downloads
 
Created
Source

PID Controller

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.

Installation

To install this module, run the following command:

npm install simple-pid-controller-2

Usage

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

API

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.

Parameters

  • 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.

Applications

PID controllers are used in a wide variety of applications in industrial control systems and other areas, including:

  • Controlling the temperature of an oven
  • Regulating the speed of a car
  • Managing the flight controls of an airplane
  • Controlling the power output of a generator

By using this module, developers can implement PID control in their Node.js applications without having to understand all of the underlying mathematics.

License

This module is licensed under the Apache License.

Author

Copyright 2025 Tomel218

Keywords

PID

FAQs

Package last updated on 24 Apr 2025

Did you know?

Socket

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.

Install

Related posts