Sfoglia il codice sorgente

Add "Thermal Runaway Protection" feature

This is a feature to protect your printer from burn up in flames if it
has a thermistor coming off place (this happened to a friend of mine
recently and motivated me writing this feature).

The issue: If a thermistor come off, it will read a lower temperature
than actual. The system will turn the heater on forever, burning up the
filament and anything
else around.

After the temperature reaches the target for the first time, this
feature will start measuring for how long the current temperature stays
below the target minus _HYSTERESIS (set_temperature -
THERMAL_RUNAWAY_PROTECTION_HYSTERESIS).

If it stays longer than _PERIOD, it means the thermistor temperature
cannot catch up with the target, so something *may be* wrong. Then, to
be on the safe side, the system will he halt.

Bear in mind the count down will just start AFTER the first time the
thermistor temperature is over the target, so you will have no problem
if your extruder heater takes 2 minutes to hit the target on heating.
alexborro 11 anni fa
parent
commit
43c298a7a9
3 ha cambiato i file con 117 aggiunte e 0 eliminazioni
  1. 38
    0
      Marlin/Configuration.h
  2. 68
    0
      Marlin/temperature.cpp
  3. 11
    0
      Marlin/temperature.h

+ 38
- 0
Marlin/Configuration.h Vedi File

251
 #define EXTRUDE_MINTEMP 170
251
 #define EXTRUDE_MINTEMP 170
252
 #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
252
 #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
253
 
253
 
254
+/*================== Thermal Runaway Protection ==============================
255
+This is a feature to protect your printer from burn up in flames if it has
256
+a thermistor coming off place (this happened to a friend of mine recently and
257
+motivated me writing this feature).
258
+
259
+The issue: If a thermistor come off, it will read a lower temperature than actual.
260
+The system will turn the heater on forever, burning up the filament and anything
261
+else around.
262
+
263
+After the temperature reaches the target for the first time, this feature will 
264
+start measuring for how long the current temperature stays below the target 
265
+minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS).
266
+
267
+If it stays longer than _PERIOD, it means the thermistor temperature
268
+cannot catch up with the target, so something *may be* wrong. Then, to be on the
269
+safe side, the system will he halt.
270
+
271
+Bear in mind the count down will just start AFTER the first time the 
272
+thermistor temperature is over the target, so you will have no problem if
273
+your extruder heater takes 2 minutes to hit the target on heating.
274
+
275
+*/
276
+// If you want to enable this feature for all your extruder heaters,
277
+// uncomment the 2 defines below:
278
+
279
+// Parameters for all extruder heaters
280
+//#define THERMAL_RUNAWAY_PROTECTION_PERIOD 40 //in seconds
281
+//#define THERMAL_RUNAWAY_PROTECTION_HYSTERESIS 4 // in degree Celsius
282
+
283
+// If you want to enable this feature for your bed heater,
284
+// uncomment the 2 defines below:
285
+
286
+// Parameters for the bed heater
287
+//#define THERMAL_RUNAWAY_PROTECTION_BED_PERIOD 20 //in seconds
288
+//#define THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS 2 // in degree Celsius
289
+//===========================================================================
290
+
291
+
254
 //===========================================================================
292
 //===========================================================================
255
 //=============================Mechanical Settings===========================
293
 //=============================Mechanical Settings===========================
256
 //===========================================================================
294
 //===========================================================================

+ 68
- 0
Marlin/temperature.cpp Vedi File

416
   for(int e = 0; e < EXTRUDERS; e++) 
416
   for(int e = 0; e < EXTRUDERS; e++) 
417
   {
417
   {
418
 
418
 
419
+  #ifdef THERMAL_RUNAWAY_PROTECTION_PERIOD && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
420
+    thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS);
421
+  #endif
422
+
419
   #ifdef PIDTEMP
423
   #ifdef PIDTEMP
420
     pid_input = current_temperature[e];
424
     pid_input = current_temperature[e];
421
 
425
 
526
 
530
 
527
   #if TEMP_SENSOR_BED != 0
531
   #if TEMP_SENSOR_BED != 0
528
   
532
   
533
+    #ifdef THERMAL_RUNAWAY_PROTECTION_PERIOD && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
534
+      thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, 9, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS);
535
+    #endif
536
+
529
   #ifdef PIDTEMPBED
537
   #ifdef PIDTEMPBED
530
     pid_input = current_temperature_bed;
538
     pid_input = current_temperature_bed;
531
 
539
 
896
 #endif 
904
 #endif 
897
 }
905
 }
898
 
906
 
907
+#ifdef THERMAL_RUNAWAY_PROTECTION_PERIOD && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
908
+void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc)
909
+{
910
+/*
911
+      SERIAL_ECHO_START;
912
+      SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:");
913
+      SERIAL_ECHO(heater_id);
914
+      SERIAL_ECHO(" ;  State:");
915
+      SERIAL_ECHO(*state);
916
+      SERIAL_ECHO(" ;  Timer:");
917
+      SERIAL_ECHO(*timer);
918
+      SERIAL_ECHO(" ;  Temperature:");
919
+      SERIAL_ECHO(temperature);
920
+      SERIAL_ECHO(" ;  Target Temp:");
921
+      SERIAL_ECHO(target_temperature);
922
+      SERIAL_ECHOLN("");    
923
+*/
924
+  if ((target_temperature == 0) || thermal_runaway)
925
+  {
926
+    *state = 0;
927
+    *timer = 0;
928
+    return;
929
+  }
930
+  switch (*state)
931
+  {
932
+    case 0: // "Heater Inactive" state
933
+      if (target_temperature > 0) *state = 1;
934
+      break;
935
+    case 1: // "First Heating" state
936
+      if (temperature >= target_temperature) *state = 2;
937
+      break;
938
+    case 2: // "Temperature Stable" state
939
+      if (temperature >= (target_temperature - hysteresis_degc))
940
+      {
941
+        *timer = millis();
942
+      } 
943
+      else if ( (millis() - *timer) > period_seconds*1000)
944
+      {
945
+        SERIAL_ERROR_START;
946
+        SERIAL_ERRORLNPGM("Thermal Runaway, system stopped! Heater_ID: ");
947
+        SERIAL_ERRORLN((int)heater_id);
948
+        LCD_ALERTMESSAGEPGM("THERMAL RUNAWAY");
949
+        thermal_runaway = true;
950
+        while(1)
951
+        {
952
+          disable_heater();
953
+          disable_x();
954
+          disable_y();
955
+          disable_z();
956
+          disable_e0();
957
+          disable_e1();
958
+          disable_e2();
959
+          manage_heater();
960
+          lcd_update();
961
+        }
962
+      }
963
+      break;
964
+  }
965
+}
966
+#endif
899
 
967
 
900
 void disable_heater()
968
 void disable_heater()
901
 {
969
 {

+ 11
- 0
Marlin/temperature.h Vedi File

154
 void setWatch();
154
 void setWatch();
155
 void updatePID();
155
 void updatePID();
156
 
156
 
157
+#ifdef THERMAL_RUNAWAY_PROTECTION_PERIOD && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
158
+void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
159
+static int thermal_runaway_state_machine[3]; // = {0,0,0};
160
+static unsigned long thermal_runaway_timer[3]; // = {0,0,0};
161
+static bool thermal_runaway = false;
162
+  #if TEMP_SENSOR_BED != 0
163
+    static int thermal_runaway_bed_state_machine;
164
+    static unsigned long thermal_runaway_bed_timer;
165
+  #endif
166
+#endif
167
+
157
 FORCE_INLINE void autotempShutdown(){
168
 FORCE_INLINE void autotempShutdown(){
158
  #ifdef AUTOTEMP
169
  #ifdef AUTOTEMP
159
  if(autotemp_enabled)
170
  if(autotemp_enabled)

Loading…
Annulla
Salva