Cédric Sylvestre / Mbed 2 deprecated PIDHeater82

Dependencies:   PID mbed millis ttmath

Fork of PIDHeater by FRDM-K64F Code Share

PIDHeater.h

Committer:
unix_guru
Date:
2016-01-25
Revision:
0:8b77aea74642

File content as of revision 0:8b77aea74642:

#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