Browse Source

Fix: Thermal runaway if nonexistent bed's temp is set

Scott Lahteine 7 years ago
parent
commit
699310d1d2
4 changed files with 21 additions and 24 deletions
  1. 3
    0
      Marlin/Conditionals_post.h
  2. 7
    7
      Marlin/temperature.cpp
  3. 6
    6
      Marlin/temperature.h
  4. 5
    11
      Marlin/ultralcd.cpp

+ 3
- 0
Marlin/Conditionals_post.h View File

522
 
522
 
523
   #define HAS_THERMALLY_PROTECTED_BED (HAS_TEMP_BED && HAS_HEATER_BED && ENABLED(THERMAL_PROTECTION_BED))
523
   #define HAS_THERMALLY_PROTECTED_BED (HAS_TEMP_BED && HAS_HEATER_BED && ENABLED(THERMAL_PROTECTION_BED))
524
 
524
 
525
+  #define WATCH_HOTENDS (ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0)
526
+  #define WATCH_THE_BED (HAS_THERMALLY_PROTECTED_BED && WATCH_BED_TEMP_PERIOD > 0)
527
+
525
   /**
528
   /**
526
    * This setting is also used by M109 when trying to calculate
529
    * This setting is also used by M109 when trying to calculate
527
    * a ballpark safe margin to prevent wait-forever situation.
530
    * a ballpark safe margin to prevent wait-forever situation.

+ 7
- 7
Marlin/temperature.cpp View File

104
   volatile int Temperature::babystepsTodo[XYZ] = { 0 };
104
   volatile int Temperature::babystepsTodo[XYZ] = { 0 };
105
 #endif
105
 #endif
106
 
106
 
107
-#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
107
+#if WATCH_HOTENDS
108
   int Temperature::watch_target_temp[HOTENDS] = { 0 };
108
   int Temperature::watch_target_temp[HOTENDS] = { 0 };
109
   millis_t Temperature::watch_heater_next_ms[HOTENDS] = { 0 };
109
   millis_t Temperature::watch_heater_next_ms[HOTENDS] = { 0 };
110
 #endif
110
 #endif
111
 
111
 
112
-#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
112
+#if WATCH_THE_BED
113
   int Temperature::watch_target_bed_temp = 0;
113
   int Temperature::watch_target_bed_temp = 0;
114
   millis_t Temperature::watch_bed_next_ms = 0;
114
   millis_t Temperature::watch_bed_next_ms = 0;
115
 #endif
115
 #endif
690
     if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + 0.01)) min_temp_error(0);
690
     if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + 0.01)) min_temp_error(0);
691
   #endif
691
   #endif
692
 
692
 
693
-  #if (ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0) || (ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0) || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN
693
+  #if WATCH_HOTENDS || WATCH_THE_BED || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN
694
     millis_t ms = millis();
694
     millis_t ms = millis();
695
   #endif
695
   #endif
696
 
696
 
707
     soft_pwm[e] = (current_temperature[e] > minttemp[e] || is_preheating(e)) && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;
707
     soft_pwm[e] = (current_temperature[e] > minttemp[e] || is_preheating(e)) && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;
708
 
708
 
709
     // Check if the temperature is failing to increase
709
     // Check if the temperature is failing to increase
710
-    #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
710
+    #if WATCH_HOTENDS
711
 
711
 
712
       // Is it time to check this extruder's heater?
712
       // Is it time to check this extruder's heater?
713
       if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) {
713
       if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) {
725
     #endif // THERMAL_PROTECTION_HOTENDS
725
     #endif // THERMAL_PROTECTION_HOTENDS
726
 
726
 
727
     // Check if the temperature is failing to increase
727
     // Check if the temperature is failing to increase
728
-    #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
728
+    #if WATCH_THE_BED
729
 
729
 
730
       // Is it time to check the bed?
730
       // Is it time to check the bed?
731
       if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) {
731
       if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) {
1157
   #endif //BED_MAXTEMP
1157
   #endif //BED_MAXTEMP
1158
 }
1158
 }
1159
 
1159
 
1160
-#if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
1160
+#if WATCH_HOTENDS
1161
   /**
1161
   /**
1162
    * Start Heating Sanity Check for hotends that are below
1162
    * Start Heating Sanity Check for hotends that are below
1163
    * their target temperature by a configurable margin.
1163
    * their target temperature by a configurable margin.
1176
   }
1176
   }
1177
 #endif
1177
 #endif
1178
 
1178
 
1179
-#if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
1179
+#if WATCH_THE_BED
1180
   /**
1180
   /**
1181
    * Start Heating Sanity Check for hotends that are below
1181
    * Start Heating Sanity Check for hotends that are below
1182
    * their target temperature by a configurable margin.
1182
    * their target temperature by a configurable margin.

+ 6
- 6
Marlin/temperature.h View File

113
       static volatile int babystepsTodo[3];
113
       static volatile int babystepsTodo[3];
114
     #endif
114
     #endif
115
 
115
 
116
-    #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
116
+    #if WATCH_HOTENDS
117
       static int watch_target_temp[HOTENDS];
117
       static int watch_target_temp[HOTENDS];
118
       static millis_t watch_heater_next_ms[HOTENDS];
118
       static millis_t watch_heater_next_ms[HOTENDS];
119
     #endif
119
     #endif
120
 
120
 
121
-    #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
121
+    #if WATCH_THE_BED
122
       static int watch_target_bed_temp;
122
       static int watch_target_bed_temp;
123
       static millis_t watch_bed_next_ms;
123
       static millis_t watch_bed_next_ms;
124
     #endif
124
     #endif
306
     }
306
     }
307
     static float degTargetBed() { return target_temperature_bed; }
307
     static float degTargetBed() { return target_temperature_bed; }
308
 
308
 
309
-    #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
309
+    #if WATCH_HOTENDS
310
       static void start_watching_heater(uint8_t e = 0);
310
       static void start_watching_heater(uint8_t e = 0);
311
     #endif
311
     #endif
312
 
312
 
313
-    #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
313
+    #if WATCH_THE_BED
314
       static void start_watching_bed();
314
       static void start_watching_bed();
315
     #endif
315
     #endif
316
 
316
 
325
           start_preheat_time(HOTEND_INDEX);
325
           start_preheat_time(HOTEND_INDEX);
326
       #endif
326
       #endif
327
       target_temperature[HOTEND_INDEX] = celsius;
327
       target_temperature[HOTEND_INDEX] = celsius;
328
-      #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
328
+      #if WATCH_HOTENDS
329
         start_watching_heater(HOTEND_INDEX);
329
         start_watching_heater(HOTEND_INDEX);
330
       #endif
330
       #endif
331
     }
331
     }
332
 
332
 
333
     static void setTargetBed(const float& celsius) {
333
     static void setTargetBed(const float& celsius) {
334
       target_temperature_bed = celsius;
334
       target_temperature_bed = celsius;
335
-      #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
335
+      #if WATCH_THE_BED
336
         start_watching_bed();
336
         start_watching_bed();
337
       #endif
337
       #endif
338
     }
338
     }

+ 5
- 11
Marlin/ultralcd.cpp View File

918
   /**
918
   /**
919
    * Watch temperature callbacks
919
    * Watch temperature callbacks
920
    */
920
    */
921
-  #if ENABLED(THERMAL_PROTECTION_HOTENDS) && WATCH_TEMP_PERIOD > 0
921
+  #if WATCH_HOTENDS
922
     #if TEMP_SENSOR_0 != 0
922
     #if TEMP_SENSOR_0 != 0
923
       void watch_temp_callback_E0() { thermalManager.start_watching_heater(0); }
923
       void watch_temp_callback_E0() { thermalManager.start_watching_heater(0); }
924
     #endif
924
     #endif
946
     #endif // HOTENDS > 3
946
     #endif // HOTENDS > 3
947
   #endif
947
   #endif
948
 
948
 
949
-  #if ENABLED(THERMAL_PROTECTION_BED) && WATCH_BED_TEMP_PERIOD > 0
950
-    #if TEMP_SENSOR_BED != 0
951
-      void watch_temp_callback_bed() { thermalManager.start_watching_bed(); }
952
-    #endif
953
-  #else
954
-    #if TEMP_SENSOR_BED != 0
955
-      void watch_temp_callback_bed() {}
956
-    #endif
949
+  #if WATCH_THE_BED
950
+    void watch_temp_callback_bed() { thermalManager.start_watching_bed(); }
957
   #endif
951
   #endif
958
 
952
 
959
   #if ENABLED(FILAMENT_CHANGE_FEATURE)
953
   #if ENABLED(FILAMENT_CHANGE_FEATURE)
1021
     //
1015
     //
1022
     // Bed:
1016
     // Bed:
1023
     //
1017
     //
1024
-    #if TEMP_SENSOR_BED != 0
1018
+    #if WATCH_THE_BED
1025
       MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &thermalManager.target_temperature_bed, 0, BED_MAXTEMP - 15, watch_temp_callback_bed);
1019
       MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &thermalManager.target_temperature_bed, 0, BED_MAXTEMP - 15, watch_temp_callback_bed);
1026
     #endif
1020
     #endif
1027
 
1021
 
2180
     //
2174
     //
2181
     // Bed:
2175
     // Bed:
2182
     //
2176
     //
2183
-    #if TEMP_SENSOR_BED != 0
2177
+    #if WATCH_THE_BED
2184
       MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &thermalManager.target_temperature_bed, 0, BED_MAXTEMP - 15, watch_temp_callback_bed);
2178
       MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &thermalManager.target_temperature_bed, 0, BED_MAXTEMP - 15, watch_temp_callback_bed);
2185
     #endif
2179
     #endif
2186
 
2180
 

Loading…
Cancel
Save