|
@@ -158,6 +158,13 @@ static float analog2temp(int raw, uint8_t e);
|
|
|
static float analog2tempBed(int raw);
|
|
|
static void updateTemperaturesFromRawValues();
|
|
|
|
|
|
+enum TempRunawayStates
|
|
|
+{
|
|
|
+ TempRunaway_INACTIVE = 0,
|
|
|
+ TempRunaway_PREHEAT = 1,
|
|
|
+ TempRunaway_ACTIVE = 2,
|
|
|
+};
|
|
|
+
|
|
|
#ifdef WATCH_TEMP_PERIOD
|
|
|
int watch_start_temp[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0);
|
|
|
unsigned long watchmillis[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0,0,0);
|
|
@@ -1049,6 +1056,9 @@ void temp_runaway_check(int _heater_id, float _target_temperature, float _curren
|
|
|
float __hysteresis = 0;
|
|
|
int __timeout = 0;
|
|
|
bool temp_runaway_check_active = false;
|
|
|
+ static float __preheat_start = 0;
|
|
|
+ static int __preheat_counter = 0;
|
|
|
+ static int __preheat_errors = 0;
|
|
|
|
|
|
_heater_id = (_isbed) ? _heater_id++ : _heater_id;
|
|
|
|
|
@@ -1069,8 +1079,8 @@ void temp_runaway_check(int _heater_id, float _target_temperature, float _curren
|
|
|
|
|
|
if (millis() - temp_runaway_timer[_heater_id] > 2000)
|
|
|
{
|
|
|
- temp_runaway_timer[_heater_id] = millis();
|
|
|
|
|
|
+ temp_runaway_timer[_heater_id] = millis();
|
|
|
if (_output == 0)
|
|
|
{
|
|
|
temp_runaway_check_active = false;
|
|
@@ -1081,19 +1091,42 @@ void temp_runaway_check(int _heater_id, float _target_temperature, float _curren
|
|
|
{
|
|
|
if (_target_temperature > 0)
|
|
|
{
|
|
|
- temp_runaway_status[_heater_id] = 1;
|
|
|
+ temp_runaway_status[_heater_id] = TempRunaway_PREHEAT;
|
|
|
temp_runaway_target[_heater_id] = _target_temperature;
|
|
|
+ __preheat_start = _current_temperature;
|
|
|
+ __preheat_counter = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- temp_runaway_status[_heater_id] = 0;
|
|
|
+ temp_runaway_status[_heater_id] = TempRunaway_INACTIVE;
|
|
|
temp_runaway_target[_heater_id] = _target_temperature;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (_current_temperature >= _target_temperature && temp_runaway_status[_heater_id] == 1)
|
|
|
+ if (temp_runaway_status[_heater_id] == TempRunaway_PREHEAT)
|
|
|
{
|
|
|
- temp_runaway_status[_heater_id] = 2;
|
|
|
+ __preheat_counter++;
|
|
|
+ if (__preheat_counter > 4)
|
|
|
+ {
|
|
|
+
|
|
|
+ if (_current_temperature - __preheat_start < 2){
|
|
|
+ __preheat_errors++;}
|
|
|
+ else{
|
|
|
+ __preheat_errors = 0;}
|
|
|
+
|
|
|
+ if (__preheat_errors > 5)
|
|
|
+ {
|
|
|
+ temp_runaway_stop(true);
|
|
|
+ }
|
|
|
+ __preheat_start = _current_temperature;
|
|
|
+ __preheat_counter = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_current_temperature >= _target_temperature && temp_runaway_status[_heater_id] == TempRunaway_PREHEAT)
|
|
|
+ {
|
|
|
+ temp_runaway_status[_heater_id] = TempRunaway_ACTIVE;
|
|
|
temp_runaway_check_active = false;
|
|
|
}
|
|
|
|
|
@@ -1109,16 +1142,16 @@ void temp_runaway_check(int _heater_id, float _target_temperature, float _curren
|
|
|
if (_target_temperature - __hysteresis < _current_temperature && _current_temperature < _target_temperature + __hysteresis)
|
|
|
{
|
|
|
temp_runaway_check_active = false;
|
|
|
+ temp_runaway_error_counter[_heater_id] = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (temp_runaway_status[_heater_id] > 1)
|
|
|
+ if (temp_runaway_status[_heater_id] > TempRunaway_PREHEAT)
|
|
|
{
|
|
|
temp_runaway_error_counter[_heater_id]++;
|
|
|
-
|
|
|
if (temp_runaway_error_counter[_heater_id] * 2 > __timeout)
|
|
|
{
|
|
|
- temp_runaway_stop();
|
|
|
+ temp_runaway_stop(false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1127,7 +1160,7 @@ void temp_runaway_check(int _heater_id, float _target_temperature, float _curren
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void temp_runaway_stop()
|
|
|
+void temp_runaway_stop(bool isPreheat)
|
|
|
{
|
|
|
cancel_heatup = true;
|
|
|
quickStop();
|
|
@@ -1136,7 +1169,7 @@ void temp_runaway_stop()
|
|
|
card.sdprinting = false;
|
|
|
card.closefile();
|
|
|
}
|
|
|
- LCD_ALERTMESSAGEPGM("THERMAL RUNAWAY");
|
|
|
+
|
|
|
disable_heater();
|
|
|
disable_x();
|
|
|
disable_y();
|
|
@@ -1149,6 +1182,23 @@ void temp_runaway_stop()
|
|
|
delayMicroseconds(500);
|
|
|
WRITE(BEEPER, LOW);
|
|
|
delayMicroseconds(100);
|
|
|
+
|
|
|
+ if (isPreheat)
|
|
|
+ {
|
|
|
+ Stop();
|
|
|
+ LCD_ALERTMESSAGEPGM(" PREHEAT ERROR");
|
|
|
+
|
|
|
+ SET_OUTPUT(EXTRUDER_0_AUTO_FAN_PIN);
|
|
|
+ SET_OUTPUT(FAN_PIN);
|
|
|
+ WRITE(EXTRUDER_0_AUTO_FAN_PIN, 1);
|
|
|
+ analogWrite(FAN_PIN, 255);
|
|
|
+ fanSpeed = 255;
|
|
|
+ delayMicroseconds(2000);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ LCD_ALERTMESSAGEPGM("THERMAL RUNAWAY");
|
|
|
+ }
|
|
|
}
|
|
|
#endif
|
|
|
|