@nanomatic/regulator
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Regulator

@nanomatic/regulator

Status License


Implementation of many types of automation regulators

📝 Table of Contents

🏁 Getting Started

Installing

npm i @nanomatic/regulator

Using

Example code below:

import { Hysteresis, Linear, PID, Regulator } from '@nanomatic/regulator';

let temperature = 0;

// Switch to hysteresis regulator
const regulator = new Regulator(new Hysteresis(10, 5));

// You can easly switch between different regulators with the same setpoint value
// Switch to linear regulator after 5s
setTimeout(() => regulator.regulator = new Linear(5, 15), 5000);

// Switch to PID regulator after 10s
setTimeout(() => {
    regulator.regulator = new PID(.5);
    setInterval(() => regulator.setpoint(Math.random() * 50), 5000);
}, 10000);

// Object simulation
setInterval(() => {
    temperature += regulator.output(temperature);
    // tslint:disable-next-line: no-console
    console.log(`${temperature.toFixed(2).padStart(5, ' ')} ℃  ➜  ${regulator.setpoint().toFixed(2).padStart(5, ' ')} ℃  (${regulator.toString()})`);
}, 100);

⛏️ Built With

✍️ Authors

Package Sidebar

Install

npm i @nanomatic/regulator

Homepage

nanomatic.pl

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

12.2 kB

Total Files

6

Last publish

Collaborators

  • nano_matic