Bläddra i källkod

Track target temperature separately for each heater

Scott Lahteine 10 år sedan
förälder
incheckning
9ba55baa5b
1 ändrade filer med 20 tillägg och 18 borttagningar
  1. 20
    18
      Marlin/temperature.cpp

+ 20
- 18
Marlin/temperature.cpp Visa fil

646
   #if TEMP_SENSOR_BED != 0
646
   #if TEMP_SENSOR_BED != 0
647
   
647
   
648
     #if HAS_BED_THERMAL_PROTECTION
648
     #if HAS_BED_THERMAL_PROTECTION
649
-      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);
649
+      thermal_runaway_protection(&thermal_runaway_bed_state_machine, &thermal_runaway_bed_timer, current_temperature_bed, target_temperature_bed, -1, THERMAL_RUNAWAY_PROTECTION_BED_PERIOD, THERMAL_RUNAWAY_PROTECTION_BED_HYSTERESIS);
650
     #endif
650
     #endif
651
 
651
 
652
     #ifdef PIDTEMPBED
652
     #ifdef PIDTEMPBED
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
 
1009
 
1010
-    static int tr_target_temperature = 0;
1010
+    static int tr_target_temperature[EXTRUDERS+1];
1011
 
1011
 
1012
     /*
1012
     /*
1013
         SERIAL_ECHO_START;
1013
         SERIAL_ECHO_START;
1014
-        SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:");
1015
-        SERIAL_ECHO(heater_id);
1016
-        SERIAL_ECHO(" ;  State:");
1017
-        SERIAL_ECHO(*state);
1018
-        SERIAL_ECHO(" ;  Timer:");
1019
-        SERIAL_ECHO(*timer);
1020
-        SERIAL_ECHO(" ;  Temperature:");
1021
-        SERIAL_ECHO(temperature);
1022
-        SERIAL_ECHO(" ;  Target Temp:");
1023
-        SERIAL_ECHO(target_temperature);
1024
-        SERIAL_ECHOLN("");    
1014
+        SERIAL_ECHOPGM("Thermal Thermal Runaway Running. Heater ID: ");
1015
+        if (heater_id < 0) SERIAL_ECHOPGM("bed"); else SERIAL_ECHOPGM(heater_id);
1016
+        SERIAL_ECHOPGM(" ;  State:");
1017
+        SERIAL_ECHOPGM(*state);
1018
+        SERIAL_ECHOPGM(" ;  Timer:");
1019
+        SERIAL_ECHOPGM(*timer);
1020
+        SERIAL_ECHOPGM(" ;  Temperature:");
1021
+        SERIAL_ECHOPGM(temperature);
1022
+        SERIAL_ECHOPGM(" ;  Target Temp:");
1023
+        SERIAL_ECHOPGM(target_temperature);
1024
+        SERIAL_EOL;
1025
     */
1025
     */
1026
     if (target_temperature == 0 || thermal_runaway) {
1026
     if (target_temperature == 0 || thermal_runaway) {
1027
       *state = TRInactive;
1027
       *state = TRInactive;
1029
       return;
1029
       return;
1030
     }
1030
     }
1031
 
1031
 
1032
+    int heater_index = heater_id >= 0 ? heater_id : EXTRUDERS;
1033
+
1032
     switch (*state) {
1034
     switch (*state) {
1033
       // Inactive state waits for a target temperature to be set
1035
       // Inactive state waits for a target temperature to be set
1034
       case TRInactive:
1036
       case TRInactive:
1035
         if (target_temperature > 0) {
1037
         if (target_temperature > 0) {
1036
           *state = TRFirstHeating;
1038
           *state = TRFirstHeating;
1037
-          tr_target_temperature = target_temperature;
1039
+          tr_target_temperature[heater_index] = target_temperature;
1038
         }
1040
         }
1039
         break;
1041
         break;
1040
       // When first heating, wait for the temperature to be reached then go to Stable state
1042
       // When first heating, wait for the temperature to be reached then go to Stable state
1041
       case TRFirstHeating:
1043
       case TRFirstHeating:
1042
-        if (temperature >= tr_target_temperature) *state = TRStable;
1044
+        if (temperature >= tr_target_temperature[heater_index]) *state = TRStable;
1043
         break;
1045
         break;
1044
       // While the temperature is stable watch for a bad temperature
1046
       // While the temperature is stable watch for a bad temperature
1045
       case TRStable:
1047
       case TRStable:
1046
       {
1048
       {
1047
         // If the target temperature changes, restart
1049
         // If the target temperature changes, restart
1048
-        if (tr_target_temperature != target_temperature) {
1050
+        if (tr_target_temperature[heater_index] != target_temperature) {
1049
           *state = TRInactive;
1051
           *state = TRInactive;
1050
           break;
1052
           break;
1051
         }
1053
         }
1052
 
1054
 
1053
         // If the temperature is over the target (-hysteresis) restart the timer
1055
         // If the temperature is over the target (-hysteresis) restart the timer
1054
-        if (temperature >= tr_target_temperature - hysteresis_degc) *timer = millis();
1056
+        if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc) *timer = millis();
1055
 
1057
 
1056
         // If the timer goes too long without a reset, trigger shutdown
1058
         // If the timer goes too long without a reset, trigger shutdown
1057
         else if (millis() > *timer + period_seconds * 1000UL) {
1059
         else if (millis() > *timer + period_seconds * 1000UL) {
1058
           SERIAL_ERROR_START;
1060
           SERIAL_ERROR_START;
1059
           SERIAL_ERRORLNPGM(MSG_THERMAL_RUNAWAY_STOP);
1061
           SERIAL_ERRORLNPGM(MSG_THERMAL_RUNAWAY_STOP);
1060
-          SERIAL_ERRORLN((int)heater_id);
1062
+          if (heater_id < 0) SERIAL_ERRORLNPGM("bed"); else SERIAL_ERRORLN(heater_id);
1061
           LCD_ALERTMESSAGEPGM(MSG_THERMAL_RUNAWAY);
1063
           LCD_ALERTMESSAGEPGM(MSG_THERMAL_RUNAWAY);
1062
           thermal_runaway = true;
1064
           thermal_runaway = true;
1063
           for (;;) {
1065
           for (;;) {

Laddar…
Avbryt
Spara