taurd for noam

Dependencies:   mbed Map

Committer:
aberk
Date:
Sat Nov 27 11:32:13 2010 +0000
Revision:
1:c48bef0d5d3c
Parent:
0:85367d3ee779
Child:
2:fd1023193cc4
Changed the method call from controller.getRealOuput() to controller.compute() to reflect changes in the library API.

Who changed what in which revision?

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