Patrice HAESAERT / Mbed 2 deprecated PID_perso

Dependencies:   PID mbed

Committer:
pathae
Date:
Fri Mar 17 08:17:10 2017 +0000
Revision:
0:a0e5295f2993
PID_mannequin

Who changed what in which revision?

UserRevisionLine numberNew contents of line
pathae 0:a0e5295f2993 1 #include "mbed.h"
pathae 0:a0e5295f2993 2 #include "PID.h"
pathae 0:a0e5295f2993 3 #define RATE 0.1
pathae 0:a0e5295f2993 4
pathae 0:a0e5295f2993 5 //Kc, Ti, Td, interval
pathae 0:a0e5295f2993 6 PID controller(1.0, 0.0, 0.0, RATE);
pathae 0:a0e5295f2993 7 AnalogIn pv(A0);
pathae 0:a0e5295f2993 8 PwmOut co(PWM_OUT);
pathae 0:a0e5295f2993 9
pathae 0:a0e5295f2993 10 int main(){
pathae 0:a0e5295f2993 11
pathae 0:a0e5295f2993 12 //Analog input from 0.0 to 3.3V
pathae 0:a0e5295f2993 13 controller.setInputLimits(0.0, 3.3);
pathae 0:a0e5295f2993 14 //Pwm output from 0.0 to 1.0
pathae 0:a0e5295f2993 15 controller.setOutputLimits(0.0, 1.0);
pathae 0:a0e5295f2993 16 //If there's a bias.
pathae 0:a0e5295f2993 17 controller.setBias(0.3);
pathae 0:a0e5295f2993 18 controller.setMode(AUTO_MODE);
pathae 0:a0e5295f2993 19 //We want the process variable to be 1.7V
pathae 0:a0e5295f2993 20 controller.setSetPoint(1.7);
pathae 0:a0e5295f2993 21
pathae 0:a0e5295f2993 22 while(1){
pathae 0:a0e5295f2993 23 //Update the process variable.
pathae 0:a0e5295f2993 24 controller.setProcessValue(pv.read());
pathae 0:a0e5295f2993 25 //Set the new output.
pathae 0:a0e5295f2993 26 co = controller.compute();
pathae 0:a0e5295f2993 27 //Wait for another loop calculation.
pathae 0:a0e5295f2993 28 wait(RATE);
pathae 0:a0e5295f2993 29 }
pathae 0:a0e5295f2993 30
pathae 0:a0e5295f2993 31 }