Merge pull request #3705 from thinkyhead/rc_runaway_logic

Fallthru in thermal runaway test when TRState changes
master
Scott Lahteine 9 years ago
commit 050e0bd2af

@ -1047,33 +1047,26 @@ void Temperature::init() {
int heater_index = heater_id >= 0 ? heater_id : EXTRUDERS; int heater_index = heater_id >= 0 ? heater_id : EXTRUDERS;
// If the target temperature changes, restart // If the target temperature changes, restart
if (tr_target_temperature[heater_index] != target_temperature) if (tr_target_temperature[heater_index] != target_temperature) {
*state = TRReset; tr_target_temperature[heater_index] = target_temperature;
*state = target_temperature > 0 ? TRFirstHeating : TRInactive;
}
switch (*state) { switch (*state) {
case TRReset:
*timer = 0;
*state = TRInactive;
// Inactive state waits for a target temperature to be set // Inactive state waits for a target temperature to be set
case TRInactive: case TRInactive: break;
if (target_temperature > 0) {
tr_target_temperature[heater_index] = target_temperature;
*state = TRFirstHeating;
}
break;
// When first heating, wait for the temperature to be reached then go to Stable state // When first heating, wait for the temperature to be reached then go to Stable state
case TRFirstHeating: case TRFirstHeating:
if (temperature >= tr_target_temperature[heater_index]) *state = TRStable; if (temperature < tr_target_temperature[heater_index]) break;
break; *state = TRStable;
// While the temperature is stable watch for a bad temperature // While the temperature is stable watch for a bad temperature
case TRStable: case TRStable:
// If the temperature is over the target (-hysteresis) restart the timer if (temperature < tr_target_temperature[heater_index] - hysteresis_degc && ELAPSED(millis(), *timer))
if (temperature >= tr_target_temperature[heater_index] - hysteresis_degc)
*timer = millis();
// If the timer goes too long without a reset, trigger shutdown
else if (ELAPSED(millis(), *timer + period_seconds * 1000UL))
*state = TRRunaway; *state = TRRunaway;
else {
*timer = millis() + period_seconds * 1000UL;
break; break;
}
case TRRunaway: case TRRunaway:
_temp_error(heater_id, PSTR(MSG_T_THERMAL_RUNAWAY), PSTR(MSG_THERMAL_RUNAWAY)); _temp_error(heater_id, PSTR(MSG_T_THERMAL_RUNAWAY), PSTR(MSG_THERMAL_RUNAWAY));
} }

@ -358,17 +358,17 @@ class Temperature {
#if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED #if ENABLED(THERMAL_PROTECTION_HOTENDS) || HAS_THERMALLY_PROTECTED_BED
typedef enum TRState { TRReset, TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate; typedef enum TRState { TRInactive, TRFirstHeating, TRStable, TRRunaway } TRstate;
void thermal_runaway_protection(TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc); void thermal_runaway_protection(TRState* state, millis_t* timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
#if ENABLED(THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
TRState thermal_runaway_state_machine[EXTRUDERS] = { TRReset }; TRState thermal_runaway_state_machine[EXTRUDERS] = { TRInactive };
millis_t thermal_runaway_timer[EXTRUDERS] = { 0 }; millis_t thermal_runaway_timer[EXTRUDERS] = { 0 };
#endif #endif
#if HAS_THERMALLY_PROTECTED_BED #if HAS_THERMALLY_PROTECTED_BED
TRState thermal_runaway_bed_state_machine = TRReset; TRState thermal_runaway_bed_state_machine = TRInactive;
millis_t thermal_runaway_bed_timer; millis_t thermal_runaway_bed_timer;
#endif #endif

Loading…
Cancel
Save