Browse Source

imported last Marlin changes

cocktailyogi 10 years ago
parent
commit
2f4a20257c
9 changed files with 1862 additions and 1647 deletions
  1. 38
    0
      Marlin/Configuration.h
  2. 2
    0
      Marlin/Configuration_adv.h
  3. 3
    3
      Marlin/Marlin.h
  4. 74
    14
      Marlin/Marlin_main.cpp
  5. 26
    0
      Marlin/language.h
  6. 68
    0
      Marlin/temperature.cpp
  7. 11
    0
      Marlin/temperature.h
  8. 1638
    1630
      Marlin/ultralcd.cpp
  9. 2
    0
      Marlin/ultralcd.h

+ 38
- 0
Marlin/Configuration.h View File

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

+ 2
- 0
Marlin/Configuration_adv.h View File

@@ -410,9 +410,11 @@ const unsigned int dropsegments=5; //everything with less than this number of st
410 410
 #ifdef FWRETRACT
411 411
   #define MIN_RETRACT 0.1                //minimum extruded mm to accept a automatic gcode retraction attempt
412 412
   #define RETRACT_LENGTH 3               //default retract length (positive mm)
413
+  #define RETRACT_LENGTH_SWAP 13         //default swap retract length (positive mm), for extruder change
413 414
   #define RETRACT_FEEDRATE 45            //default feedrate for retracting (mm/s)
414 415
   #define RETRACT_ZLIFT 0                //default retract Z-lift
415 416
   #define RETRACT_RECOVER_LENGTH 0       //default additional recover length (mm, added to retract length when recovering)
417
+  #define RETRACT_RECOVER_LENGTH_SWAP 0  //default additional swap recover length (mm, added to retract length when recovering from extruder change)
416 418
   #define RETRACT_RECOVER_FEEDRATE 8     //default feedrate for recovering from retraction (mm/s)
417 419
 #endif
418 420
 

+ 3
- 3
Marlin/Marlin.h View File

@@ -238,9 +238,9 @@ extern unsigned char fanSpeedSoftPwm;
238 238
 
239 239
 #ifdef FWRETRACT
240 240
 extern bool autoretract_enabled;
241
-extern bool retracted;
242
-extern float retract_length, retract_feedrate, retract_zlift;
243
-extern float retract_recover_length, retract_recover_feedrate;
241
+extern bool retracted[EXTRUDERS];
242
+extern float retract_length, retract_length_swap, retract_feedrate, retract_zlift;
243
+extern float retract_recover_length, retract_recover_length_swap, retract_recover_feedrate;
244 244
 #endif
245 245
 
246 246
 extern unsigned long starttime;

+ 74
- 14
Marlin/Marlin_main.cpp View File

@@ -254,11 +254,29 @@ int EtoPPressure=0;
254 254
 
255 255
 #ifdef FWRETRACT
256 256
   bool autoretract_enabled=false;
257
-  bool retracted=false;
257
+  bool retracted[EXTRUDERS]={false
258
+    #if EXTRUDERS > 1
259
+    , false
260
+     #if EXTRUDERS > 2
261
+      , false
262
+     #endif
263
+  #endif
264
+  };
265
+  bool retracted_swap[EXTRUDERS]={false
266
+    #if EXTRUDERS > 1
267
+    , false
268
+     #if EXTRUDERS > 2
269
+      , false
270
+     #endif
271
+  #endif
272
+  };
273
+
258 274
   float retract_length = RETRACT_LENGTH;
275
+  float retract_length_swap = RETRACT_LENGTH_SWAP;
259 276
   float retract_feedrate = RETRACT_FEEDRATE;
260 277
   float retract_zlift = RETRACT_ZLIFT;
261 278
   float retract_recover_length = RETRACT_RECOVER_LENGTH;
279
+  float retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
262 280
   float retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
263 281
 #endif
264 282
 
@@ -291,6 +309,8 @@ int EtoPPressure=0;
291 309
 float axis_scaling[3]={1,1,1};  // Build size scaling, default to 1
292 310
 #endif				
293 311
 
312
+bool cancel_heatup = false ;
313
+
294 314
 //===========================================================================
295 315
 //=============================Private Variables=============================
296 316
 //===========================================================================
@@ -1184,23 +1204,27 @@ void refresh_cmd_timeout(void)
1184 1204
 }
1185 1205
 
1186 1206
 #ifdef FWRETRACT
1187
-  void retract(bool retracting) {
1188
-    if(retracting && !retracted) {
1207
+  void retract(bool retracting, bool swapretract = false) {
1208
+    if(retracting && !retracted[active_extruder]) {
1189 1209
       destination[X_AXIS]=current_position[X_AXIS];
1190 1210
       destination[Y_AXIS]=current_position[Y_AXIS];
1191 1211
       destination[Z_AXIS]=current_position[Z_AXIS];
1192 1212
       destination[E_AXIS]=current_position[E_AXIS];
1193
-      current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
1213
+      if (swapretract) {
1214
+        current_position[E_AXIS]+=retract_length_swap/volumetric_multiplier[active_extruder];
1215
+      } else {
1216
+        current_position[E_AXIS]+=retract_length/volumetric_multiplier[active_extruder];
1217
+      }
1194 1218
       plan_set_e_position(current_position[E_AXIS]);
1195 1219
       float oldFeedrate = feedrate;
1196 1220
       feedrate=retract_feedrate*60;
1197
-      retracted=true;
1221
+      retracted[active_extruder]=true;
1198 1222
       prepare_move();
1199 1223
       current_position[Z_AXIS]-=retract_zlift;
1200 1224
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1201 1225
       prepare_move();
1202 1226
       feedrate = oldFeedrate;
1203
-    } else if(!retracting && retracted) {
1227
+    } else if(!retracting && retracted[active_extruder]) {
1204 1228
       destination[X_AXIS]=current_position[X_AXIS];
1205 1229
       destination[Y_AXIS]=current_position[Y_AXIS];
1206 1230
       destination[Z_AXIS]=current_position[Z_AXIS];
@@ -1208,11 +1232,15 @@ void refresh_cmd_timeout(void)
1208 1232
       current_position[Z_AXIS]+=retract_zlift;
1209 1233
       plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
1210 1234
       //prepare_move();
1211
-      current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; 
1235
+      if (swapretract) {
1236
+        current_position[E_AXIS]-=(retract_length_swap+retract_recover_length_swap)/volumetric_multiplier[active_extruder]; 
1237
+      } else {
1238
+        current_position[E_AXIS]-=(retract_length+retract_recover_length)/volumetric_multiplier[active_extruder]; 
1239
+      }
1212 1240
       plan_set_e_position(current_position[E_AXIS]);
1213 1241
       float oldFeedrate = feedrate;
1214 1242
       feedrate=retract_recover_feedrate*60;
1215
-      retracted=false;
1243
+      retracted[active_extruder]=false;
1216 1244
       prepare_move();
1217 1245
       feedrate = oldFeedrate;
1218 1246
     }
@@ -1284,10 +1312,19 @@ void process_commands()
1284 1312
       break;
1285 1313
       #ifdef FWRETRACT
1286 1314
       case 10: // G10 retract
1315
+       #if EXTRUDERS > 1
1316
+        retracted_swap[active_extruder]=(code_seen('S') && code_value_long() == 1); // checks for swap retract argument
1317
+        retract(true,retracted_swap[active_extruder]);
1318
+       #else
1287 1319
         retract(true);
1320
+       #endif
1288 1321
       break;
1289 1322
       case 11: // G11 retract_recover
1323
+       #if EXTRUDERS > 1
1324
+        retract(false,retracted_swap[active_extruder]);
1325
+       #else
1290 1326
         retract(false);
1327
+       #endif 
1291 1328
       break;
1292 1329
       #endif //FWRETRACT
1293 1330
     case 28: //G28 Home all Axis one at a time
@@ -2038,14 +2075,16 @@ void process_commands()
2038 2075
 
2039 2076
       /* See if we are heating up or cooling down */
2040 2077
       target_direction = isHeatingHotend(tmp_extruder); // true if heating, false if cooling
2078
+      
2079
+      cancel_heatup = false;
2041 2080
 
2042 2081
       #ifdef TEMP_RESIDENCY_TIME
2043 2082
         long residencyStart;
2044 2083
         residencyStart = -1;
2045 2084
         /* continue to loop until we have reached the target temp
2046 2085
           _and_ until TEMP_RESIDENCY_TIME hasn't passed since we reached it */
2047
-        while((residencyStart == -1) ||
2048
-              (residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL))) ) {
2086
+        while((!cancel_heatup)&&((residencyStart == -1) ||
2087
+              (residencyStart >= 0 && (((unsigned int) (millis() - residencyStart)) < (TEMP_RESIDENCY_TIME * 1000UL)))) ) {
2049 2088
       #else
2050 2089
         while ( target_direction ? (isHeatingHotend(tmp_extruder)) : (isCoolingHotend(tmp_extruder)&&(CooldownNoWait==false)) ) {
2051 2090
       #endif //TEMP_RESIDENCY_TIME
@@ -2101,10 +2140,11 @@ void process_commands()
2101 2140
           CooldownNoWait = false;
2102 2141
         }
2103 2142
         codenum = millis();
2104
-
2143
+        
2144
+        cancel_heatup = false;
2105 2145
         target_direction = isHeatingBed(); // true if heating, false if cooling
2106 2146
 
2107
-        while ( target_direction ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) )
2147
+        while ( (target_direction)&&(!cancel_heatup) ? (isHeatingBed()) : (isCoolingBed()&&(CooldownNoWait==false)) )
2108 2148
         {
2109 2149
           if(( millis() - codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
2110 2150
           {
@@ -2514,8 +2554,28 @@ void process_commands()
2514 2554
         int t= code_value() ;
2515 2555
         switch(t)
2516 2556
         {
2517
-          case 0: autoretract_enabled=false;retracted=false;break;
2518
-          case 1: autoretract_enabled=true;retracted=false;break;
2557
+          case 0: 
2558
+          {
2559
+            autoretract_enabled=false;
2560
+            retracted[0]=false;
2561
+            #if EXTRUDERS > 1
2562
+              retracted[1]=false;
2563
+            #endif
2564
+            #if EXTRUDERS > 2
2565
+              retracted[2]=false;
2566
+            #endif
2567
+          }break;
2568
+          case 1: 
2569
+          {
2570
+            autoretract_enabled=true;
2571
+            retracted[0]=false;
2572
+            #if EXTRUDERS > 1
2573
+              retracted[1]=false;
2574
+            #endif
2575
+            #if EXTRUDERS > 2
2576
+              retracted[2]=false;
2577
+            #endif
2578
+          }break;
2519 2579
           default:
2520 2580
             SERIAL_ECHO_START;
2521 2581
             SERIAL_ECHOPGM(MSG_UNKNOWN_COMMAND);

+ 26
- 0
Marlin/language.h View File

@@ -171,9 +171,11 @@
171 171
 	#define MSG_KILLED "KILLED. "
172 172
 	#define MSG_STOPPED "STOPPED. "
173 173
 	#define MSG_CONTROL_RETRACT  "Retract mm"
174
+	#define MSG_CONTROL_RETRACT_SWAP  "Swap Re.mm"
174 175
 	#define MSG_CONTROL_RETRACTF "Retract  V"
175 176
 	#define MSG_CONTROL_RETRACT_ZLIFT "Hop mm"
176 177
 	#define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
178
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "S UnRet+mm"
177 179
 	#define MSG_CONTROL_RETRACT_RECOVERF "UnRet  V"
178 180
 	#define MSG_AUTORETRACT "AutoRetr."
179 181
 	#define MSG_FILAMENTCHANGE "Change filament"
@@ -371,9 +373,11 @@
371 373
 	#define MSG_STOPPED "Zatrzymany. "
372 374
 	#define MSG_STEPPER_RELEASED "Zwolniony."
373 375
 	#define MSG_CONTROL_RETRACT  "Wycofaj mm"
376
+	#define MSG_CONTROL_RETRACT_SWAP  "Z Wycof. mm"
374 377
 	#define MSG_CONTROL_RETRACTF "Wycofaj  V"
375 378
 	#define MSG_CONTROL_RETRACT_ZLIFT "Skok Z mm:"
376 379
 	#define MSG_CONTROL_RETRACT_RECOVER "Cof. wycof. +mm"
380
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Z Cof. wyc. +mm"
377 381
 	#define MSG_CONTROL_RETRACT_RECOVERF "Cof. wycof.  V"
378 382
 	#define MSG_AUTORETRACT "Auto. wycofanie"
379 383
 	#define MSG_FILAMENTCHANGE "Zmien filament"
@@ -572,9 +576,11 @@
572 576
 	#define MSG_STOPPED "STOPPE."
573 577
 	#define MSG_STEPPER_RELEASED "RELACHE."
574 578
 	#define MSG_CONTROL_RETRACT "Retraction mm"
579
+	#define MSG_CONTROL_RETRACT_SWAP "Ech. Retr. mm"
575 580
 	#define MSG_CONTROL_RETRACTF "Retraction V"
576 581
 	#define MSG_CONTROL_RETRACT_ZLIFT "Hop mm"
577 582
 	#define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
583
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Ech. UnRet +mm"
578 584
 	#define MSG_CONTROL_RETRACT_RECOVERF "UnRet V"
579 585
 	#define MSG_AUTORETRACT "Retract. Auto."
580 586
 	#define MSG_FILAMENTCHANGE "Changer filament"
@@ -774,9 +780,11 @@
774 780
 	#define MSG_STOPPED          "GESTOPPT"
775 781
 	#define MSG_STEPPER_RELEASED "Stepper frei"
776 782
 	#define MSG_CONTROL_RETRACT  "Retract mm"
783
+	#define MSG_CONTROL_RETRACT_SWAP  "Wechs. Retract mm"
777 784
 	#define MSG_CONTROL_RETRACTF "Retract  V"
778 785
 	#define MSG_CONTROL_RETRACT_ZLIFT "Hop mm"
779 786
 	#define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
787
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Wechs. UnRet +mm"
780 788
 	#define MSG_CONTROL_RETRACT_RECOVERF "UnRet  V"
781 789
 	#define MSG_AUTORETRACT      "AutoRetr."
782 790
 	#define MSG_FILAMENTCHANGE "Filament wechseln"
@@ -972,9 +980,11 @@
972 980
 	#define MSG_KILLED "PARADA DE EMERG."
973 981
 	#define MSG_STOPPED "PARADA"
974 982
 	#define MSG_CONTROL_RETRACT  "Retraer mm"
983
+	#define MSG_CONTROL_RETRACT_SWAP  "Interc. Retraer mm"
975 984
 	#define MSG_CONTROL_RETRACTF "Retraer  V"
976 985
 	#define MSG_CONTROL_RETRACT_ZLIFT "Levantar mm"
977 986
 	#define MSG_CONTROL_RETRACT_RECOVER "DesRet +mm"
987
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Interc. DesRet +mm"
978 988
 	#define MSG_CONTROL_RETRACT_RECOVERF "DesRet V"
979 989
 	#define MSG_AUTORETRACT "AutoRetr."
980 990
 	#define MSG_FILAMENTCHANGE "Cambiar filamento"
@@ -1179,9 +1189,11 @@
1179 1189
 	#define MSG_KILLED							"УБИТО."
1180 1190
 	#define MSG_STOPPED							"ОСТАНОВЛЕНО."
1181 1191
 	#define MSG_CONTROL_RETRACT					"Откат mm:"
1192
+	#define MSG_CONTROL_RETRACT_SWAP				"своп Откат mm:"
1182 1193
 	#define MSG_CONTROL_RETRACTF				"Откат  V:"
1183 1194
 	#define MSG_CONTROL_RETRACT_ZLIFT			"Прыжок mm:"
1184 1195
 	#define MSG_CONTROL_RETRACT_RECOVER			"Возврат +mm:"
1196
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP		"своп Возврат +mm:"
1185 1197
 	#define MSG_CONTROL_RETRACT_RECOVERF		"Возврат  V:"
1186 1198
 	#define MSG_AUTORETRACT						"АвтоОткат:"
1187 1199
 	#define MSG_FILAMENTCHANGE 					"Change filament"
@@ -1376,9 +1388,11 @@
1376 1388
 	#define MSG_KILLED               "UCCISO. "
1377 1389
 	#define MSG_STOPPED              "ARRESTATO. "
1378 1390
 	#define MSG_CONTROL_RETRACT      "Ritrai mm"
1391
+	#define MSG_CONTROL_RETRACT_SWAP "Scamb. Ritrai mm"
1379 1392
 	#define MSG_CONTROL_RETRACTF     "Ritrai  V"
1380 1393
 	#define MSG_CONTROL_RETRACT_ZLIFT "Salta mm"
1381 1394
 	#define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
1395
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Scamb. UnRet +mm"
1382 1396
 	#define MSG_CONTROL_RETRACT_RECOVERF "UnRet  V"
1383 1397
 	#define MSG_AUTORETRACT          "AutoArretramento"
1384 1398
 	#define MSG_FILAMENTCHANGE       "Cambia filamento"
@@ -1581,9 +1595,11 @@
1581 1595
 	#define MSG_STOPPED "PARADA. "
1582 1596
 	#define MSG_STEPPER_RELEASED "Lancado."
1583 1597
 	#define MSG_CONTROL_RETRACT  " Retrair mm:"
1598
+	#define MSG_CONTROL_RETRACT_SWAP  "Troca Retrair mm:"
1584 1599
 	#define MSG_CONTROL_RETRACTF " Retrair  V:"
1585 1600
 	#define MSG_CONTROL_RETRACT_ZLIFT " Levantar mm:"
1586 1601
 	#define MSG_CONTROL_RETRACT_RECOVER " DesRet +mm:"
1602
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Troca DesRet +mm:"
1587 1603
 	#define MSG_CONTROL_RETRACT_RECOVERF " DesRet  V:"
1588 1604
 	#define MSG_AUTORETRACT " AutoRetr.:"
1589 1605
 	#define MSG_FILAMENTCHANGE "Change filament"
@@ -1781,9 +1797,11 @@
1781 1797
 	#define MSG_KILLED "KILLED. "
1782 1798
 	#define MSG_STOPPED "STOPPED. "
1783 1799
 	#define MSG_CONTROL_RETRACT  "Veda mm"
1800
+	#define MSG_CONTROL_RETRACT_SWAP  "Va. Veda mm"
1784 1801
 	#define MSG_CONTROL_RETRACTF "Veda V"
1785 1802
 	#define MSG_CONTROL_RETRACT_ZLIFT "Z mm"
1786 1803
 	#define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
1804
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Va. UnRet +mm"
1787 1805
 	#define MSG_CONTROL_RETRACT_RECOVERF "UnRet  V"
1788 1806
 	#define MSG_AUTORETRACT "AutoVeto."
1789 1807
 	#define MSG_FILAMENTCHANGE "Change filament"
@@ -1979,9 +1997,11 @@
1979 1997
 	#define MSG_KILLED "ATURADA D'EMERCH."
1980 1998
 	#define MSG_STOPPED "ATURADA."
1981 1999
 	#define MSG_CONTROL_RETRACT  "Retraer mm"
2000
+	#define MSG_CONTROL_RETRACT_SWAP  "Swap Retraer mm"
1982 2001
 	#define MSG_CONTROL_RETRACTF "Retraer  F"
1983 2002
 	#define MSG_CONTROL_RETRACT_ZLIFT "Devantar mm"
1984 2003
 	#define MSG_CONTROL_RETRACT_RECOVER "DesRet +mm"
2004
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Swap DesRet +mm"
1985 2005
 	#define MSG_CONTROL_RETRACT_RECOVERF "DesRet F"
1986 2006
 	#define MSG_AUTORETRACT "AutoRetr."
1987 2007
 	#define MSG_FILAMENTCHANGE "Cambear"
@@ -2185,9 +2205,11 @@
2185 2205
 	#define MSG_KILLED "AFGEBROKEN. "
2186 2206
 	#define MSG_STOPPED "GESTOPT. "
2187 2207
 	#define MSG_CONTROL_RETRACT  "Retract mm"
2208
+	#define MSG_CONTROL_RETRACT_SWAP "Ruil Retract mm"
2188 2209
 	#define MSG_CONTROL_RETRACTF "Retract  F"
2189 2210
 	#define MSG_CONTROL_RETRACT_ZLIFT "Hop mm"
2190 2211
 	#define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
2212
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Ruil UnRet +mm"
2191 2213
 	#define MSG_CONTROL_RETRACT_RECOVERF "UnRet  F"
2192 2214
 	#define MSG_AUTORETRACT "AutoRetr."
2193 2215
 	#define MSG_FILAMENTCHANGE "Verv. Filament"
@@ -2384,9 +2406,11 @@
2384 2406
 	#define MSG_KILLED "PARADA DE EMERG. "
2385 2407
 	#define MSG_STOPPED "ATURAT. "
2386 2408
 	#define MSG_CONTROL_RETRACT  "Retreure mm"
2409
+	#define MSG_CONTROL_RETRACT_SWAP  "Swap Retreure mm"
2387 2410
 	#define MSG_CONTROL_RETRACTF "Retreure  F"
2388 2411
 	#define MSG_CONTROL_RETRACT_ZLIFT "Aixecar mm"
2389 2412
 	#define MSG_CONTROL_RETRACT_RECOVER "DesRet +mm"
2413
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Swap DesRet +mm"
2390 2414
 	#define MSG_CONTROL_RETRACT_RECOVERF "DesRet  F"
2391 2415
 	#define MSG_AUTORETRACT "AutoRetr."
2392 2416
 	#define MSG_FILAMENTCHANGE "Canviar filament"
@@ -2582,9 +2606,11 @@
2582 2606
 	#define MSG_KILLED "LARRIALDI GELDIA"
2583 2607
 	#define MSG_STOPPED "GELDITUTA. "
2584 2608
 	#define MSG_CONTROL_RETRACT  "Atzera egin mm"
2609
+	#define MSG_CONTROL_RETRACT_SWAP  "Swap Atzera egin mm"
2585 2610
 	#define MSG_CONTROL_RETRACTF "Atzera egin V"
2586 2611
 	#define MSG_CONTROL_RETRACT_ZLIFT "Igo mm"
2587 2612
 	#define MSG_CONTROL_RETRACT_RECOVER "Atzera egin +mm"
2613
+	#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Swap Atzera egin +mm"
2588 2614
 	#define MSG_CONTROL_RETRACT_RECOVERF "Atzera egin V"
2589 2615
 	#define MSG_AUTORETRACT "Atzera egin"
2590 2616
 	#define MSG_FILAMENTCHANGE "Aldatu filament."

+ 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)

+ 1638
- 1630
Marlin/ultralcd.cpp
File diff suppressed because it is too large
View File


+ 2
- 0
Marlin/ultralcd.h View File

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

Loading…
Cancel
Save