Simple heater library for controlling the temperature via analog temperature sensor and digital heater output.
Heater.h@0:eb243c2ffbfe, 2015-01-22 (annotated)
- Committer:
- tbjazic
- Date:
- Thu Jan 22 13:37:43 2015 +0000
- Revision:
- 0:eb243c2ffbfe
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tbjazic | 0:eb243c2ffbfe | 1 | #ifndef HEATER_H |
tbjazic | 0:eb243c2ffbfe | 2 | #define HEATER_H |
tbjazic | 0:eb243c2ffbfe | 3 | |
tbjazic | 0:eb243c2ffbfe | 4 | #include "mbed.h" |
tbjazic | 0:eb243c2ffbfe | 5 | |
tbjazic | 0:eb243c2ffbfe | 6 | /** A simple class for temperature control in the room using |
tbjazic | 0:eb243c2ffbfe | 7 | * a heater driven via digital output and one analog temperature sensor. |
tbjazic | 0:eb243c2ffbfe | 8 | * |
tbjazic | 0:eb243c2ffbfe | 9 | * Author(s): TVZ Mechatronics Team |
tbjazic | 0:eb243c2ffbfe | 10 | * |
tbjazic | 0:eb243c2ffbfe | 11 | */ |
tbjazic | 0:eb243c2ffbfe | 12 | class Heater { |
tbjazic | 0:eb243c2ffbfe | 13 | public: |
tbjazic | 0:eb243c2ffbfe | 14 | /** Constructor receives pin names of the temperature sensor and |
tbjazic | 0:eb243c2ffbfe | 15 | * the DigitalOut pin to which the heater driver is connected. */ |
tbjazic | 0:eb243c2ffbfe | 16 | Heater(PinName sensorPin, PinName digitalOutPin); |
tbjazic | 0:eb243c2ffbfe | 17 | /** Set the temperature range of the sensor. */ |
tbjazic | 0:eb243c2ffbfe | 18 | void configureSensor(float minTemperature, float maxTemperature); |
tbjazic | 0:eb243c2ffbfe | 19 | /** Read the current room temperature from the sensor. */ |
tbjazic | 0:eb243c2ffbfe | 20 | float readTemperature(); |
tbjazic | 0:eb243c2ffbfe | 21 | /** Test if the heater in turned ON. */ |
tbjazic | 0:eb243c2ffbfe | 22 | bool isHeaterOn(); |
tbjazic | 0:eb243c2ffbfe | 23 | /** Set the desired room temperature. */ |
tbjazic | 0:eb243c2ffbfe | 24 | void setTemperature(float temp); |
tbjazic | 0:eb243c2ffbfe | 25 | private: |
tbjazic | 0:eb243c2ffbfe | 26 | AnalogIn sensor; |
tbjazic | 0:eb243c2ffbfe | 27 | DigitalOut driver; |
tbjazic | 0:eb243c2ffbfe | 28 | Ticker ticker; |
tbjazic | 0:eb243c2ffbfe | 29 | void regulateTemperature(); |
tbjazic | 0:eb243c2ffbfe | 30 | bool heaterOn; |
tbjazic | 0:eb243c2ffbfe | 31 | float currentTemp, desiredTemp, minTemp, maxTemp, hysteresis, heaterOnTemp, heaterOffTemp; |
tbjazic | 0:eb243c2ffbfe | 32 | }; |
tbjazic | 0:eb243c2ffbfe | 33 | |
tbjazic | 0:eb243c2ffbfe | 34 | #endif // HEATER_H |