Browse Source

Merge pull request #4169 from thinkyhead/rc_wait_but_break

Allow wait-for-cooling, break at threshold or if cooling stalls
Scott Lahteine 8 years ago
parent
commit
725fde8b26
1 changed files with 34 additions and 15 deletions
  1. 34
    15
      Marlin/Marlin_main.cpp

+ 34
- 15
Marlin/Marlin_main.cpp View File

4550
       else print_job_timer.start();
4550
       else print_job_timer.start();
4551
     #endif
4551
     #endif
4552
 
4552
 
4553
-    if (temp > thermalManager.degHotend(target_extruder)) LCD_MESSAGEPGM(MSG_HEATING);
4553
+    if (thermalManager.isHeatingHotend(target_extruder)) LCD_MESSAGEPGM(MSG_HEATING);
4554
   }
4554
   }
4555
 
4555
 
4556
   #if ENABLED(AUTOTEMP)
4556
   #if ENABLED(AUTOTEMP)
4566
     #define TEMP_CONDITIONS (wants_to_cool ? thermalManager.isCoolingHotend(target_extruder) : thermalManager.isHeatingHotend(target_extruder))
4566
     #define TEMP_CONDITIONS (wants_to_cool ? thermalManager.isCoolingHotend(target_extruder) : thermalManager.isHeatingHotend(target_extruder))
4567
   #endif //TEMP_RESIDENCY_TIME > 0
4567
   #endif //TEMP_RESIDENCY_TIME > 0
4568
 
4568
 
4569
-  float theTarget = -1;
4569
+  float theTarget = -1.0, old_temp = 9999.0;
4570
   bool wants_to_cool;
4570
   bool wants_to_cool;
4571
   cancel_heatup = false;
4571
   cancel_heatup = false;
4572
-  millis_t now, next_temp_ms = 0;
4572
+  millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
4573
 
4573
 
4574
   KEEPALIVE_STATE(NOT_BUSY);
4574
   KEEPALIVE_STATE(NOT_BUSY);
4575
 
4575
 
4581
 
4581
 
4582
       // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4582
       // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4583
       if (no_wait_for_cooling && wants_to_cool) break;
4583
       if (no_wait_for_cooling && wants_to_cool) break;
4584
-
4585
-      // Prevent a wait-forever situation if R is misused i.e. M109 R0
4586
-      // Try to calculate a ballpark safe margin by halving EXTRUDE_MINTEMP
4587
-      if (wants_to_cool && theTarget < (EXTRUDE_MINTEMP)/2) break;
4588
     }
4584
     }
4589
 
4585
 
4590
     now = millis();
4586
     now = millis();
4608
     idle();
4604
     idle();
4609
     refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4605
     refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4610
 
4606
 
4607
+    float temp = thermalManager.degHotend(target_extruder);
4608
+
4611
     #if TEMP_RESIDENCY_TIME > 0
4609
     #if TEMP_RESIDENCY_TIME > 0
4612
 
4610
 
4613
-      float temp_diff = fabs(theTarget - thermalManager.degHotend(target_extruder));
4611
+      float temp_diff = fabs(theTarget - temp);
4614
 
4612
 
4615
       if (!residency_start_ms) {
4613
       if (!residency_start_ms) {
4616
         // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
4614
         // Start the TEMP_RESIDENCY_TIME timer when we reach target temp for the first time.
4623
 
4621
 
4624
     #endif //TEMP_RESIDENCY_TIME > 0
4622
     #endif //TEMP_RESIDENCY_TIME > 0
4625
 
4623
 
4624
+    // Prevent a wait-forever situation if R is misused i.e. M109 R0
4625
+    if (wants_to_cool) {
4626
+      if (temp < (EXTRUDE_MINTEMP) / 2) break; // always break at (default) 85°
4627
+      // break after 20 seconds if cooling stalls
4628
+      if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
4629
+        if (old_temp - temp < 1.0) break;
4630
+        next_cool_check_ms = now + 20000;
4631
+        old_temp = temp;
4632
+      }
4633
+    }
4634
+
4626
   } while (!cancel_heatup && TEMP_CONDITIONS);
4635
   } while (!cancel_heatup && TEMP_CONDITIONS);
4627
 
4636
 
4628
   LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
4637
   LCD_MESSAGEPGM(MSG_HEATING_COMPLETE);
4651
       #define TEMP_BED_CONDITIONS (wants_to_cool ? thermalManager.isCoolingBed() : thermalManager.isHeatingBed())
4660
       #define TEMP_BED_CONDITIONS (wants_to_cool ? thermalManager.isCoolingBed() : thermalManager.isHeatingBed())
4652
     #endif //TEMP_BED_RESIDENCY_TIME > 0
4661
     #endif //TEMP_BED_RESIDENCY_TIME > 0
4653
 
4662
 
4654
-    float theTarget = -1;
4663
+    float theTarget = -1.0, old_temp = 9999.0;
4655
     bool wants_to_cool;
4664
     bool wants_to_cool;
4656
     cancel_heatup = false;
4665
     cancel_heatup = false;
4657
-    millis_t now, next_temp_ms = 0;
4666
+    millis_t now, next_temp_ms = 0, next_cool_check_ms = 0;
4658
 
4667
 
4659
     KEEPALIVE_STATE(NOT_BUSY);
4668
     KEEPALIVE_STATE(NOT_BUSY);
4660
 
4669
 
4666
 
4675
 
4667
         // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4676
         // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4668
         if (no_wait_for_cooling && wants_to_cool) break;
4677
         if (no_wait_for_cooling && wants_to_cool) break;
4669
-
4670
-        // Prevent a wait-forever situation if R is misused i.e. M190 R0
4671
-        // Simply don't wait to cool a bed under 30C
4672
-        if (wants_to_cool && theTarget < 30) break;
4673
       }
4678
       }
4674
 
4679
 
4675
       now = millis();
4680
       now = millis();
4693
       idle();
4698
       idle();
4694
       refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4699
       refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4695
 
4700
 
4701
+      float temp = thermalManager.degBed();
4702
+
4696
       #if TEMP_BED_RESIDENCY_TIME > 0
4703
       #if TEMP_BED_RESIDENCY_TIME > 0
4697
 
4704
 
4698
-        float temp_diff = fabs(theTarget - thermalManager.degBed());
4705
+        float temp_diff = fabs(theTarget - temp);
4699
 
4706
 
4700
         if (!residency_start_ms) {
4707
         if (!residency_start_ms) {
4701
           // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
4708
           // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
4708
 
4715
 
4709
       #endif //TEMP_BED_RESIDENCY_TIME > 0
4716
       #endif //TEMP_BED_RESIDENCY_TIME > 0
4710
 
4717
 
4718
+      // Prevent a wait-forever situation if R is misused i.e. M190 R0
4719
+      if (wants_to_cool) {
4720
+        if (temp < 30.0) break; // always break at 30°
4721
+        // break after 20 seconds if cooling stalls
4722
+        if (!next_cool_check_ms || ELAPSED(now, next_cool_check_ms)) {
4723
+          if (old_temp - temp < 1.0) break;
4724
+          next_cool_check_ms = now + 20000;
4725
+          old_temp = temp;
4726
+        }
4727
+      }
4728
+
4711
     } while (!cancel_heatup && TEMP_BED_CONDITIONS);
4729
     } while (!cancel_heatup && TEMP_BED_CONDITIONS);
4730
+
4712
     LCD_MESSAGEPGM(MSG_BED_DONE);
4731
     LCD_MESSAGEPGM(MSG_BED_DONE);
4713
     KEEPALIVE_STATE(IN_HANDLER);
4732
     KEEPALIVE_STATE(IN_HANDLER);
4714
   }
4733
   }

Loading…
Cancel
Save