Simple heater library for controlling the temperature via analog temperature sensor and digital heater output.
Diff: Heater.h
- Revision:
- 0:eb243c2ffbfe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Heater.h Thu Jan 22 13:37:43 2015 +0000 @@ -0,0 +1,34 @@ +#ifndef HEATER_H +#define HEATER_H + +#include "mbed.h" + +/** A simple class for temperature control in the room using + * a heater driven via digital output and one analog temperature sensor. + * + * Author(s): TVZ Mechatronics Team + * + */ +class Heater { + public: + /** Constructor receives pin names of the temperature sensor and + * the DigitalOut pin to which the heater driver is connected. */ + Heater(PinName sensorPin, PinName digitalOutPin); + /** Set the temperature range of the sensor. */ + void configureSensor(float minTemperature, float maxTemperature); + /** Read the current room temperature from the sensor. */ + float readTemperature(); + /** Test if the heater in turned ON. */ + bool isHeaterOn(); + /** Set the desired room temperature. */ + void setTemperature(float temp); + private: + AnalogIn sensor; + DigitalOut driver; + Ticker ticker; + void regulateTemperature(); + bool heaterOn; + float currentTemp, desiredTemp, minTemp, maxTemp, hysteresis, heaterOnTemp, heaterOffTemp; +}; + +#endif // HEATER_H \ No newline at end of file