Browse Source

Merge branch 'Marlin_v1' of https://github.com/ErikZalm/Marlin into Marlin_v1

Neil Darlow 11 years ago
parent
commit
6e3406d228

+ 39
- 0
Marlin/Configuration.h View File

@@ -132,6 +132,7 @@
132 132
 // 1010 is Pt1000 with 1k pullup (non standard)
133 133
 // 147 is Pt100 with 4k7 pullup
134 134
 // 110 is Pt100 with 1k pullup (non standard)
135
+// 70 is 500C thermistor for Pico hot end
135 136
 
136 137
 #define TEMP_SENSOR_0 -1
137 138
 #define TEMP_SENSOR_1 -1
@@ -250,6 +251,44 @@
250 251
 #define EXTRUDE_MINTEMP 170
251 252
 #define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances.
252 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
+
253 292
 //===========================================================================
254 293
 //=============================Mechanical Settings===========================
255 294
 //===========================================================================

+ 7
- 4
Marlin/Marlin_main.cpp View File

@@ -1947,14 +1947,16 @@ void process_commands()
1947 1947
 
1948 1948
       /* See if we are heating up or cooling down */
1949 1949
       target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
1950
+      
1951
+      cancel_heatup = false;
1950 1952
 
1951 1953
       #ifdef TEMP_RESIDENCY_TIME
1952 1954
         long residencyStart;
1953 1955
         residencyStart = -1;
1954 1956
         /* continue to loop until we have reached the target temp
1955 1957
           _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
1956
-        while((residencyStart == -1) ||
1957
-              (residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL))) ) {
1958
+        while((!cancel_heatup)&&((residencyStart == -1) ||
1959
+              (residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL)))) ) {
1958 1960
       #else
1959 1961
         while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
1960 1962
       #endif //TEMP_RESIDENCY_TIME
@@ -2010,10 +2012,11 @@ void process_commands()
2010 2012
           CooldownNoWait = false;
2011 2013
         }
2012 2014
         codenum = millis();
2013
-
2015
+        
2016
+        cancel_heatup = false;
2014 2017
         target_direction = isHeatingBed(); // true if heating, false if cooling
2015 2018
 
2016
-        while ( target_direction ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) )
2019
+        while ( (target_direction)&&(!cancel_heatup) ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) )
2017 2020
         {
2018 2021
           if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
2019 2022
           {

+ 68
- 0
Marlin/temperature.cpp View File

@@ -416,6 +416,10 @@ void manage_heater()
416 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 423
   #ifdef PIDTEMP
420 424
     pid_input = current_temperature[e];
421 425
 
@@ -526,6 +530,10 @@ void manage_heater()
526 530
 
527 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 537
   #ifdef PIDTEMPBED
530 538
     pid_input = current_temperature_bed;
531 539
 
@@ -896,6 +904,66 @@ void setWatch()
896 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 968
 void disable_heater()
901 969
 {

+ 11
- 0
Marlin/temperature.h View File

@@ -154,6 +154,17 @@ void disable_heater();
154 154
 void setWatch();
155 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 168
 FORCE_INLINE void autotempShutdown(){
158 169
  #ifdef AUTOTEMP
159 170
  if(autotemp_enabled)

+ 75
- 0
Marlin/thermistortables.h View File

@@ -1021,6 +1021,81 @@ const short temptable_1047[][2] PROGMEM = {
1021 1021
   PtLine(300,1000,4700)
1022 1022
 };
1023 1023
 #endif
1024
+#if (THERMISTORHEATER_0 == 70) || (THERMISTORHEATER_1 == 70) || (THERMISTORHEATER_2 == 70) || (THERMISTORBED == 70) // 500C thermistor for Pico hot end
1025
+const short temptable_70[][2] PROGMEM = {
1026
+  {  110.774119598719*OVERSAMPLENR ,  350 },
1027
+  {  118.214386957249*OVERSAMPLENR ,  345 },
1028
+  {  126.211418543166*OVERSAMPLENR ,  340 },
1029
+  {  134.789559066223*OVERSAMPLENR ,  335 },
1030
+  {  144.004513869701*OVERSAMPLENR ,  330 },
1031
+  {  153.884483790827*OVERSAMPLENR ,  325 },
1032
+  {  164.484880793637*OVERSAMPLENR ,  320 },
1033
+  {  175.848885102724*OVERSAMPLENR ,  315 },
1034
+  {  188.006799079015*OVERSAMPLENR ,  310 },
1035
+  {  201.008072969044*OVERSAMPLENR ,  305 },
1036
+  {  214.83716032276*OVERSAMPLENR ,  300 },
1037
+  {  229.784739779664*OVERSAMPLENR ,  295 },
1038
+  {  245.499466045473*OVERSAMPLENR ,  290 },
1039
+  {  262.2766342096*OVERSAMPLENR ,  285 },
1040
+  {  280.073883176433*OVERSAMPLENR ,  280 },
1041
+  {  298.952693467726*OVERSAMPLENR ,  275 },
1042
+  {  318.808251051674*OVERSAMPLENR ,  270 },
1043
+  {  337.490932563222*OVERSAMPLENR ,  265 },
1044
+  {  361.683649122745*OVERSAMPLENR ,  260 },
1045
+  {  384.717024083981*OVERSAMPLENR ,  255 },
1046
+  {  408.659301759076*OVERSAMPLENR ,  250 },
1047
+  {  433.471659455884*OVERSAMPLENR ,  245 },
1048
+  {  459.199039926034*OVERSAMPLENR ,  240 },
1049
+  {  485.566500982316*OVERSAMPLENR ,  235 },
1050
+  {  512.538918631075*OVERSAMPLENR ,  230 },
1051
+  {  539.980999544838*OVERSAMPLENR ,  225 },
1052
+  {  567.783095549935*OVERSAMPLENR ,  220 },
1053
+  {  595.698041673552*OVERSAMPLENR ,  215 },
1054
+  {  623.633922319597*OVERSAMPLENR ,  210 },
1055
+  {  651.356162750829*OVERSAMPLENR ,  205 },
1056
+  {  678.700901620956*OVERSAMPLENR ,  200 },
1057
+  {  705.528145361264*OVERSAMPLENR ,  195 },
1058
+  {  731.61267976339*OVERSAMPLENR ,  190 },
1059
+  {  756.786212184365*OVERSAMPLENR ,  185 },
1060
+  {  780.950223357761*OVERSAMPLENR ,  180 },
1061
+  {  804.012961595082*OVERSAMPLENR ,  175 },
1062
+  {  825.904975939166*OVERSAMPLENR ,  170 },
1063
+  {  846.403941639008*OVERSAMPLENR ,  165 },
1064
+  {  865.52326974895*OVERSAMPLENR ,  160 },
1065
+  {  883.246145367727*OVERSAMPLENR ,  155 },
1066
+  {  899.5821946515*OVERSAMPLENR ,  150 },
1067
+  {  914.544289228582*OVERSAMPLENR ,  145 },
1068
+  {  928.145628221761*OVERSAMPLENR ,  140 },
1069
+  {  940.422208546562*OVERSAMPLENR ,  135 },
1070
+  {  951.456922916497*OVERSAMPLENR ,  130 },
1071
+  {  961.303500633788*OVERSAMPLENR ,  125 },
1072
+  {  970.044756889055*OVERSAMPLENR ,  120 },
1073
+  {  977.761456230051*OVERSAMPLENR ,  115 },
1074
+  {  984.540978083453*OVERSAMPLENR ,  110 },
1075
+  {  990.440780765757*OVERSAMPLENR ,  105 },
1076
+  {  995.589621465301*OVERSAMPLENR ,  100 },
1077
+  {  1000.02514280144*OVERSAMPLENR ,  95 },
1078
+  {  1003.84429789876*OVERSAMPLENR ,  90 },
1079
+  {  1007.10199009318*OVERSAMPLENR ,  85 },
1080
+  {  1009.87151698323*OVERSAMPLENR ,  80 },
1081
+  {  1012.21633594237*OVERSAMPLENR ,  75 },
1082
+  {  1014.18959892949*OVERSAMPLENR ,  70 },
1083
+  {  1015.84079162998*OVERSAMPLENR ,  65 },
1084
+  {  1017.21555915335*OVERSAMPLENR ,  60 },
1085
+  {  1018.35284662863*OVERSAMPLENR ,  55 },
1086
+  {  1019.28926921888*OVERSAMPLENR ,  50 },
1087
+  {  1020.05398015669*OVERSAMPLENR ,  45 },
1088
+  {  1020.67737496272*OVERSAMPLENR ,  40 },
1089
+  {  1021.1802909627*OVERSAMPLENR ,  35 },
1090
+  {  1021.58459281248*OVERSAMPLENR ,  30 },
1091
+  {  1021.90701441192*OVERSAMPLENR ,  25 },
1092
+  {  1022.16215103698*OVERSAMPLENR ,  20 },
1093
+  {  1022.36275529549*OVERSAMPLENR ,  15 },
1094
+  {  1022.51930392497*OVERSAMPLENR ,  10 },
1095
+  {  1022.64051573734*OVERSAMPLENR ,  5 },
1096
+  {  1022.73355805611*OVERSAMPLENR ,  0 }
1097
+};
1098
+#endif
1024 1099
 
1025 1100
 #define _TT_NAME(_N) temptable_ ## _N
1026 1101
 #define TT_NAME(_N) _TT_NAME(_N)

+ 4
- 1
Marlin/ultralcd.cpp View File

@@ -19,6 +19,7 @@ int absPreheatHotendTemp;
19 19
 int absPreheatHPBTemp;
20 20
 int absPreheatFanSpeed;
21 21
 
22
+bool cancel_heatup = false ;
22 23
 
23 24
 #ifdef ULTIPANEL
24 25
 static float manual_feedrate[] = MANUAL_FEEDRATE;
@@ -194,7 +195,7 @@ static void lcd_status_screen()
194 195
         currentMenu = lcd_main_menu;
195 196
         encoderPosition = 0;
196 197
         lcd_quick_feedback();
197
-        lcd_implementation_init(); // to maybe revive the LCD if static electricity killed it.
198
+        lcd_implementation_init(); // to maybe revive the LCD if static electricity killed it.
198 199
     }
199 200
 
200 201
 #ifdef ULTIPANEL_FEEDMULTIPLY
@@ -256,6 +257,8 @@ static void lcd_sdcard_stop()
256 257
         enquecommand_P(PSTR(SD_FINISHED_RELEASECOMMAND));
257 258
     }
258 259
     autotempShutdown();
260
+    
261
+    cancel_heatup = true;
259 262
 }
260 263
 
261 264
 /* Menu implementation */

+ 2
- 0
Marlin/ultralcd.h View File

@@ -43,6 +43,8 @@
43 43
   extern int absPreheatHotendTemp;
44 44
   extern int absPreheatHPBTemp;
45 45
   extern int absPreheatFanSpeed;
46
+  
47
+  extern bool cancel_heatup;
46 48
     
47 49
   void lcd_buzz(long duration,uint16_t freq);
48 50
   bool lcd_clicked();

Loading…
Cancel
Save