taurd for noam

Dependencies:   mbed Map

main.cpp

Committer:
aberk
Date:
2010-11-27
Revision:
1:c48bef0d5d3c
Parent:
0:85367d3ee779
Child:
2:fd1023193cc4

File content as of revision 1:c48bef0d5d3c:

#include "PID.h"

#define RATE 0.1

//Kc, Ti, Td, interval
PID controller(1.0, 0.0, 0.0, RATE);
AnalogIn pv(p15);
PwmOut   co(p26);

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);
  }

}