Patrice HAESAERT
/
PID_perso
PID_mannequin
Revision 0:a0e5295f2993, committed 2017-03-17
- Comitter:
- pathae
- Date:
- Fri Mar 17 08:17:10 2017 +0000
- Commit message:
- PID_mannequin
Changed in this revision
diff -r 000000000000 -r a0e5295f2993 PID.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PID.lib Fri Mar 17 08:17:10 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/aberk/code/PID/#6e12a3e5af19
diff -r 000000000000 -r a0e5295f2993 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Mar 17 08:17:10 2017 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" +#include "PID.h" +#define RATE 0.1 + +//Kc, Ti, Td, interval +PID controller(1.0, 0.0, 0.0, RATE); +AnalogIn pv(A0); +PwmOut co(PWM_OUT); + +int main(){ + + //Analog input from 0.0 to 3.3V + controller.setInputLimits(0.0, 3.3); + //Pwm output from 0.0 to 1.0 + controller.setOutputLimits(0.0, 1.0); + //If there's a bias. + controller.setBias(0.3); + controller.setMode(AUTO_MODE); + //We want the process variable to be 1.7V + controller.setSetPoint(1.7); + + while(1){ + //Update the process variable. + controller.setProcessValue(pv.read()); + //Set the new output. + co = controller.compute(); + //Wait for another loop calculation. + wait(RATE); + } + +}
diff -r 000000000000 -r a0e5295f2993 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Mar 17 08:17:10 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8ed44a420e5c \ No newline at end of file