Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: PID mbed millis ttmath
Fork of PIDHeater by
Diff: PIDHeater.h
- Revision:
- 0:8b77aea74642
diff -r 000000000000 -r 8b77aea74642 PIDHeater.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PIDHeater.h Mon Jan 25 22:38:30 2016 +0000
@@ -0,0 +1,43 @@
+#ifndef PID_HEATER_H
+#define PID_HEATER_H
+
+#include "mbed.h"
+
+#include "PID.h"
+// These values were borrowed from Marlin Firmware defaults
+#define DEFAULT_Kp 17.52
+#define DEFAULT_Ki 0.62
+#define DEFAULT_Kd 123.43
+
+
+/** A simple class for temperature control of a heater element using PID
+ * a heater driven via PWM digital output and one analog temperature sensor.
+ *
+ * Author(s): Michael Ball unix_guru@hotmail.com
+ *
+ */
+class PIDHeater{
+ public:
+ /** Constructor receives pin names of the temperature sensor and
+ * the DigitalOut pin to which the heater driver is connected. */
+ PIDHeater(PinName sensorPin, PinName digitalOutPin);
+ /** Set the temperature range of the sensor. */
+ void configureRange(float minTemperature, float maxTemperature);
+ /** Read the current room temperature from the sensor. */
+ float getTemperature();
+ /** Test if the heater in turned ON. */
+ bool isHeaterOn();
+ /** Set the desired room temperature. */
+ void setTemperature(float temp);
+ /** Attach run process to a timer */
+ void run();
+
+ private:
+ AnalogIn thermistor;
+ DigitalOut driver;
+ Ticker ticker;
+ bool heaterOn;
+ float currentTemp, desiredTemp, minTemp, maxTemp, hysteresis, pwmValue;
+};
+
+#endif // HEATER_H
\ No newline at end of file
