Trying out the code Wilberforce posted using the low pass filter as a test process.
CSV files are runs with different tuning parameters.
var PID = require('pid-controller');
var setpoint = 0.5;
var duty = 0;
var N=0;
var Kc= 1.5;
var Ti= 2.0;
var Td= 0.0;
var setPoint=0.5;
var cycleTime= 1000;
var ctr = new PID(0, setPoint, Kc,Ti, Td, PID.fwd);
ctr.mode(PID.auto);
ctr.setLimits(-0.5, 0.5);
ctr.out=0.0;
analogWrite("A4",ctr.sp);
console.log("N,error,input,output,setpoint");
var I=setInterval(function () {
N++;
if(N>20)ctr.setpoint(0.6);
if(N>50)clearInterval(I);
ctr.inp=analogRead("A1");
ctr.compute();
analogWrite("A4",ctr.out+0.5);
console.log(""+N+","+(ctr.sp-ctr.inp).toFixed(4)+","+
ctr.inp.toFixed(4)+","+
(ctr.out+0.5).toFixed(4)+","+ctr.sp.toFixed(4));
}, 1000);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Trying out the code Wilberforce posted using the low pass filter as a test process.
CSV files are runs with different tuning parameters.
5 Attachments