@nanomatic/regulator
v1.0.0
Published
Implementation of many types of automation regulators
Downloads
6
Maintainers
Readme
📝 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
- ts-node-dev - TypeScript Node Dev
- tsc-watch - The nodemon for TypeScript
- TSLint - TypeScript linter
- NodeJs - Test Environment
✍️ Authors
- @NANOmatic - Idea & Initial work