![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
PIDHeater82
Dependencies: PID mbed millis ttmath
Fork of PIDHeater by
Diff: main.cpp
- Revision:
- 0:8b77aea74642
- Child:
- 2:6e731a17523c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jan 25 22:38:30 2016 +0000 @@ -0,0 +1,39 @@ +/** 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); + + } + +} \ No newline at end of file