kill heater and generate error if thermistor gives open or shorted reading
authorMichael Moon <triffid.hunter@gmail.com>
Thu, 20 Dec 2012 04:10:02 +0000 (15:10 +1100)
committerMichael Moon <triffid.hunter@gmail.com>
Wed, 2 Jan 2013 00:45:28 +0000 (11:45 +1100)
src/modules/tools/temperaturecontrol/TemperatureControl.cpp

index bca986a..8f80ba7 100644 (file)
@@ -157,11 +157,23 @@ double TemperatureControl::temperature_to_adc_value(double temperature){
 
 uint32_t TemperatureControl::thermistor_read_tick(uint32_t dummy){
     if( this->desired_adc_value != UNDEFINED ){
-        if( this->new_thermistor_reading() > this->desired_adc_value ){
+        double r = this->new_thermistor_reading();
+        if ((r > 0.01) &&
+            (r < 0.99) &&
+            (r > this->desired_adc_value))
+        {
             this->heater_pin->set(1);
-        }else{
+        }
+        else
+        {
+            if (((r <= 0.01) || (r >= 0.99)) && (this->desired_adc_value != UNDEFINED))
+            {
+                this->kernel->streams->printf("MINTEMP triggered on P%d.%d! check your thermistors!\n", this->thermistor_pin->port_number, this->thermistor_pin->pin);
+                this->desired_adc_value = UNDEFINED;
+            }
             this->heater_pin->set(0);
-            if( this->waiting ){
+            if (this->waiting)
+            {
                 this->kernel->pauser->release();
                 this->waiting = false;
             }