Browse Source

Fix the WATCHPERIOD implementation. It did not work correctly in a multi extruder setup, it did not work after 32 seconds after startup (int16 used as millies timestamp). And it did not work if you gave an M104 or M109 when the target was already around the target setpoint. So on average, it did not work at all. The new implementation should be robust in detecting a failure to heat up.

daid303 12 years ago
parent
commit
587154c01b
3 changed files with 24 additions and 35 deletions
  1. 5
    3
      Marlin/Configuration_adv.h
  2. 19
    26
      Marlin/temperature.cpp
  3. 0
    6
      Marlin/temperature.h

+ 5
- 3
Marlin/Configuration_adv.h View File

13
 //// Heating sanity check:
13
 //// Heating sanity check:
14
 // This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
14
 // This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
15
 // If the temperature has not increased at the end of that period, the target temperature is set to zero. 
15
 // If the temperature has not increased at the end of that period, the target temperature is set to zero. 
16
-// It can be reset with another M104/M109
17
-//#define WATCHPERIOD 20000 //20 seconds
16
+// It can be reset with another M104/M109. This check is also only triggered if the target temperature and the current temperature
17
+//  differ by at least 2x WATCH_TEMP_INCREASE
18
+//#define WATCH_TEMP_PERIOD 20000 //20 seconds
19
+//#define WATCH_TEMP_INCREASE 10  //Heat up at least 10 degree in 20 seconds
18
 
20
 
19
 // Wait for Cooldown
21
 // Wait for Cooldown
20
 // This defines if the M109 call should not block if it is cooling down.
22
 // This defines if the M109 call should not block if it is cooling down.
199
 //#define USE_WATCHDOG
201
 //#define USE_WATCHDOG
200
 
202
 
201
 #ifdef USE_WATCHDOG
203
 #ifdef USE_WATCHDOG
202
-// If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on.
204
+// If you have a watchdog reboot in an ArduinoMega2560 then the device will hang forever, as a watchdog reset will leave the watchdog on.
203
 // The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset.
205
 // The "WATCHDOG_RESET_MANUAL" goes around this by not using the hardware reset.
204
 //  However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled.
206
 //  However, THIS FEATURE IS UNSAFE!, as it will only work if interrupts are disabled. And the code could hang in an interrupt routine with interrupts disabled.
205
 //#define WATCHDOG_RESET_MANUAL
207
 //#define WATCHDOG_RESET_MANUAL

+ 19
- 26
Marlin/temperature.cpp View File

105
   static unsigned char soft_pwm[EXTRUDERS];
105
   static unsigned char soft_pwm[EXTRUDERS];
106
   static unsigned char soft_pwm_bed;
106
   static unsigned char soft_pwm_bed;
107
   
107
   
108
-#ifdef WATCHPERIOD
109
-  int watch_raw[EXTRUDERS] = { -1000 }; // the first value used for all
110
-  int watch_oldtemp[3] = {0,0,0};
111
-  unsigned long watchmillis = 0;
112
-#endif //WATCHPERIOD
113
-
114
 #if EXTRUDERS > 3
108
 #if EXTRUDERS > 3
115
 # error Unsupported number of extruders
109
 # error Unsupported number of extruders
116
 #elif EXTRUDERS > 2
110
 #elif EXTRUDERS > 2
129
 static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS((void *)heater_0_temptable, (void *)heater_1_temptable, (void *)heater_2_temptable);
123
 static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS((void *)heater_0_temptable, (void *)heater_1_temptable, (void *)heater_2_temptable);
130
 static int heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS(heater_0_temptable_len, heater_1_temptable_len, heater_2_temptable_len);
124
 static int heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS(heater_0_temptable_len, heater_1_temptable_len, heater_2_temptable_len);
131
 
125
 
126
+#ifdef WATCH_TEMP_PERIOD
127
+int watch_start_temp[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0);
128
+unsigned long watchmillis[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0);
129
+#endif //WATCH_TEMP_PERIOD
132
 
130
 
133
 //===========================================================================
131
 //===========================================================================
134
 //=============================   functions      ============================
132
 //=============================   functions      ============================
376
     else {
374
     else {
377
       soft_pwm[e] = 0;
375
       soft_pwm[e] = 0;
378
     }
376
     }
379
-  } // End extruder for loop
380
-  
381
-  #ifdef WATCHPERIOD
382
-    if(watchmillis && millis() - watchmillis > WATCHPERIOD){
383
-        if(watch_oldtemp[0] >= degHotend(active_extruder)){
384
-            setTargetHotend(0,active_extruder);
377
+
378
+    #ifdef WATCH_TEMP_PERIOD
379
+    if(watchmillis[e] && millis() - watchmillis[e] > WATCH_TEMP_PERIOD)
380
+    {
381
+        if(degHotend(e) < watch_start_temp[e] + WATCH_TEMP_INCREASE)
382
+        {
383
+            setTargetHotend(0, e);
385
             LCD_MESSAGEPGM("Heating failed");
384
             LCD_MESSAGEPGM("Heating failed");
386
             SERIAL_ECHO_START;
385
             SERIAL_ECHO_START;
387
             SERIAL_ECHOLN("Heating failed");
386
             SERIAL_ECHOLN("Heating failed");
388
         }else{
387
         }else{
389
-            watchmillis = 0;
388
+            watchmillis[e] = 0;
390
         }
389
         }
391
     }
390
     }
392
-  #endif
391
+    #endif
392
+
393
+  } // End extruder for loop
393
   
394
   
394
 
395
 
395
 		#ifndef PIDTEMPBED
396
 		#ifndef PIDTEMPBED
625
   // Finish init of mult extruder arrays 
626
   // Finish init of mult extruder arrays 
626
   for(int e = 0; e < EXTRUDERS; e++) {
627
   for(int e = 0; e < EXTRUDERS; e++) {
627
     // populate with the first value 
628
     // populate with the first value 
628
-#ifdef WATCHPERIOD
629
-    watch_raw[e] = watch_raw[0];
630
-#endif
631
     maxttemp[e] = maxttemp[0];
629
     maxttemp[e] = maxttemp[0];
632
 #ifdef PIDTEMP
630
 #ifdef PIDTEMP
633
     temp_iState_min[e] = 0.0;
631
     temp_iState_min[e] = 0.0;
746
 #endif //BED_MAXTEMP
744
 #endif //BED_MAXTEMP
747
 }
745
 }
748
 
746
 
749
-
750
-
751
 void setWatch() 
747
 void setWatch() 
752
 {  
748
 {  
753
-#ifdef WATCHPERIOD
754
-  int t = 0;
749
+#ifdef WATCH_TEMP_PERIOD
755
   for (int e = 0; e < EXTRUDERS; e++)
750
   for (int e = 0; e < EXTRUDERS; e++)
756
   {
751
   {
757
-    if(isHeatingHotend(e))
758
-    watch_oldtemp[0] = degHotend(0);
752
+    if(degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE * 2))
759
     {
753
     {
760
-      t = max(t,millis());
761
-      watch_raw[e] = current_raw[e];
754
+      watch_start_temp[e] = degHotend(e);
755
+      watchmillis[e] = millis();
762
     } 
756
     } 
763
   }
757
   }
764
-  watchmillis = t;
765
 #endif 
758
 #endif 
766
 }
759
 }
767
 
760
 

+ 0
- 6
Marlin/temperature.h View File

56
   extern float pid_setpoint_bed;
56
   extern float pid_setpoint_bed;
57
 #endif
57
 #endif
58
   
58
   
59
-// #ifdef WATCHPERIOD
60
-  extern int watch_raw[EXTRUDERS] ;
61
-//   extern unsigned long watchmillis;
62
-// #endif
63
-
64
-
65
 //high level conversion routines, for use outside of temperature.cpp
59
 //high level conversion routines, for use outside of temperature.cpp
66
 //inline so that there is no performance decrease.
60
 //inline so that there is no performance decrease.
67
 //deg=degreeCelsius
61
 //deg=degreeCelsius

Loading…
Cancel
Save