瀏覽代碼

Fix timeout in thermal_runaway when temperature is set higher

Scott Lahteine 10 年之前
父節點
當前提交
528e32a1d4
共有 1 個檔案被更改,包括 17 行新增6 行删除
  1. 17
    6
      Marlin/temperature.cpp

+ 17
- 6
Marlin/temperature.cpp 查看文件

1006
 #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
1006
 #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
1007
 
1007
 
1008
   void thermal_runaway_protection(TRState *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
1008
   void thermal_runaway_protection(TRState *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
1009
+
1010
+    static int tr_target_temperature = 0;
1011
+
1009
     /*
1012
     /*
1010
         SERIAL_ECHO_START;
1013
         SERIAL_ECHO_START;
1011
         SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:");
1014
         SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:");
1029
     switch (*state) {
1032
     switch (*state) {
1030
       // Inactive state waits for a target temperature to be set
1033
       // Inactive state waits for a target temperature to be set
1031
       case TRInactive:
1034
       case TRInactive:
1032
-        if (target_temperature > 0) *state = TRFirstHeating;
1035
+        if (target_temperature > 0) {
1036
+          *state = TRFirstHeating;
1037
+          tr_target_temperature = target_temperature;
1038
+        }
1033
         break;
1039
         break;
1034
       // When first heating, wait for the temperature to be reached then go to Stable state
1040
       // When first heating, wait for the temperature to be reached then go to Stable state
1035
       case TRFirstHeating:
1041
       case TRFirstHeating:
1036
-        if (temperature >= target_temperature) *state = TRStable;
1042
+        if (temperature >= tr_target_temperature) *state = TRStable;
1037
         break;
1043
         break;
1038
       // While the temperature is stable watch for a bad temperature
1044
       // While the temperature is stable watch for a bad temperature
1039
       case TRStable:
1045
       case TRStable:
1040
       {
1046
       {
1041
-        // Whenever the current temperature is over the target (-hysteresis) restart the timer
1042
-        if (temperature >= target_temperature - hysteresis_degc) {
1043
-          *timer = millis();
1047
+        // If the target temperature changes, restart
1048
+        if (tr_target_temperature != target_temperature) {
1049
+          *state = TRInactive;
1050
+          break;
1044
         }
1051
         }
1052
+
1053
+        // If the temperature is over the target (-hysteresis) restart the timer
1054
+        if (temperature >= tr_target_temperature - hysteresis_degc) *timer = millis();
1055
+
1045
         // If the timer goes too long without a reset, trigger shutdown
1056
         // If the timer goes too long without a reset, trigger shutdown
1046
         else if (millis() > *timer + period_seconds * 1000UL) {
1057
         else if (millis() > *timer + period_seconds * 1000UL) {
1047
           SERIAL_ERROR_START;
1058
           SERIAL_ERROR_START;
1060
     }
1071
     }
1061
   }
1072
   }
1062
 
1073
 
1063
-#endif // HAS_HEATER_THERMAL_PROTECTION
1074
+#endif // HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
1064
 
1075
 
1065
 void disable_heater() {
1076
 void disable_heater() {
1066
   for (int i=0; i<EXTRUDERS; i++) setTargetHotend(0, i);
1077
   for (int i=0; i<EXTRUDERS; i++) setTargetHotend(0, i);

Loading…
取消
儲存