Cédric Sylvestre / Mbed 2 deprecated PIDHeater82

Dependencies:   PID mbed millis ttmath

Fork of PIDHeater by FRDM-K64F Code Share

Revision:
0:8b77aea74642
--- /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