Explorar el Código

Fix timeout in thermal_runaway when temperature is set higher

Scott Lahteine hace 10 años
padre
commit
528e32a1d4
Se han modificado 1 ficheros con 17 adiciones y 6 borrados
  1. 17
    6
      Marlin/temperature.cpp

+ 17
- 6
Marlin/temperature.cpp Ver fichero

@@ -1006,6 +1006,9 @@ void setWatch() {
1006 1006
 #if HAS_HEATER_THERMAL_PROTECTION || HAS_BED_THERMAL_PROTECTION
1007 1007
 
1008 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 1013
         SERIAL_ECHO_START;
1011 1014
         SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:");
@@ -1029,19 +1032,27 @@ void setWatch() {
1029 1032
     switch (*state) {
1030 1033
       // Inactive state waits for a target temperature to be set
1031 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 1039
         break;
1034 1040
       // When first heating, wait for the temperature to be reached then go to Stable state
1035 1041
       case TRFirstHeating:
1036
-        if (temperature >= target_temperature) *state = TRStable;
1042
+        if (temperature >= tr_target_temperature) *state = TRStable;
1037 1043
         break;
1038 1044
       // While the temperature is stable watch for a bad temperature
1039 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 1056
         // If the timer goes too long without a reset, trigger shutdown
1046 1057
         else if (millis() > *timer + period_seconds * 1000UL) {
1047 1058
           SERIAL_ERROR_START;
@@ -1060,7 +1071,7 @@ void setWatch() {
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 1076
 void disable_heater() {
1066 1077
   for (int i=0; i<EXTRUDERS; i++) setTargetHotend(0, i);

Loading…
Cancelar
Guardar