PIDHeater82

Dependencies:   PID mbed millis ttmath

Fork of PIDHeater by FRDM-K64F Code Share

main.cpp

Committer:
unix_guru
Date:
2016-01-25
Revision:
0:8b77aea74642
Child:
2:6e731a17523c

File content as of revision 0:8b77aea74642:

/** A demo application to show how to mangage and control a heater element 
 * through a PID loop using a Thermistor input and PWM output.
 * For more information on PID control 
 *
 * Author(s): Michael Ball  unix_guru@hotmail.com
 *
 */

#include "mbed.h"

#include "PIDHeater.h"                  // PIDHeater simply takes two variables
                                        // The Thermistor input and the Heater output.
                                        // 
Serial pc(USBTX, USBRX);
Ticker ticker;                        

#define RATE 0.1                        // Check temp every 100ms
PIDHeater extruder(A3, PTC3);           // Thermistor on A3 heater on PTC3

void run_PID_loop() {                        // Periodically test temperature and set output
    extruder.run();
}    

int main(){
 
  extruder.configureRange(0,250);       // Set MIN/MAX temperature in degrees Celcius.
  extruder.setTemperature(25);         // Set target temperature to 25 degrees Celcius.
  
  ticker.attach(&run_PID_loop,RATE);    // Start PID process running at 100ms rate.

  while(1){
   
     pc.printf("Extruder Temperature is %f\r\n", extruder.getTemperature());
     
     wait(1);  

  }
 
}