|
@@ -416,6 +416,10 @@ void manage_heater()
|
416
|
416
|
for(int e = 0; e < EXTRUDERS; e++)
|
417
|
417
|
{
|
418
|
418
|
|
|
419
|
+ #ifdef THERMAL_RUNAWAY_PROTECTION_PERIOD && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
|
|
420
|
+ thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_RUNAWAY_PROTECTION_PERIOD, THERMAL_RUNAWAY_PROTECTION_HYSTERESIS);
|
|
421
|
+ #endif
|
|
422
|
+
|
419
|
423
|
#ifdef PIDTEMP
|
420
|
424
|
pid_input = current_temperature[e];
|
421
|
425
|
|
|
@@ -526,6 +530,10 @@ void manage_heater()
|
526
|
530
|
|
527
|
531
|
#if TEMP_SENSOR_BED != 0
|
528
|
532
|
|
|
533
|
+ #ifdef THERMAL_RUNAWAY_PROTECTION_PERIOD && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
|
|
534
|
+ 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);
|
|
535
|
+ #endif
|
|
536
|
+
|
529
|
537
|
#ifdef PIDTEMPBED
|
530
|
538
|
pid_input = current_temperature_bed;
|
531
|
539
|
|
|
@@ -896,6 +904,66 @@ void setWatch()
|
896
|
904
|
#endif
|
897
|
905
|
}
|
898
|
906
|
|
|
907
|
+#ifdef THERMAL_RUNAWAY_PROTECTION_PERIOD && THERMAL_RUNAWAY_PROTECTION_PERIOD > 0
|
|
908
|
+void thermal_runaway_protection(int *state, unsigned long *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc)
|
|
909
|
+{
|
|
910
|
+/*
|
|
911
|
+ SERIAL_ECHO_START;
|
|
912
|
+ SERIAL_ECHO("Thermal Thermal Runaway Running. Heater ID:");
|
|
913
|
+ SERIAL_ECHO(heater_id);
|
|
914
|
+ SERIAL_ECHO(" ; State:");
|
|
915
|
+ SERIAL_ECHO(*state);
|
|
916
|
+ SERIAL_ECHO(" ; Timer:");
|
|
917
|
+ SERIAL_ECHO(*timer);
|
|
918
|
+ SERIAL_ECHO(" ; Temperature:");
|
|
919
|
+ SERIAL_ECHO(temperature);
|
|
920
|
+ SERIAL_ECHO(" ; Target Temp:");
|
|
921
|
+ SERIAL_ECHO(target_temperature);
|
|
922
|
+ SERIAL_ECHOLN("");
|
|
923
|
+*/
|
|
924
|
+ if ((target_temperature == 0) || thermal_runaway)
|
|
925
|
+ {
|
|
926
|
+ *state = 0;
|
|
927
|
+ *timer = 0;
|
|
928
|
+ return;
|
|
929
|
+ }
|
|
930
|
+ switch (*state)
|
|
931
|
+ {
|
|
932
|
+ case 0: // "Heater Inactive" state
|
|
933
|
+ if (target_temperature > 0) *state = 1;
|
|
934
|
+ break;
|
|
935
|
+ case 1: // "First Heating" state
|
|
936
|
+ if (temperature >= target_temperature) *state = 2;
|
|
937
|
+ break;
|
|
938
|
+ case 2: // "Temperature Stable" state
|
|
939
|
+ if (temperature >= (target_temperature - hysteresis_degc))
|
|
940
|
+ {
|
|
941
|
+ *timer = millis();
|
|
942
|
+ }
|
|
943
|
+ else if ( (millis() - *timer) > period_seconds*1000)
|
|
944
|
+ {
|
|
945
|
+ SERIAL_ERROR_START;
|
|
946
|
+ SERIAL_ERRORLNPGM("Thermal Runaway, system stopped! Heater_ID: ");
|
|
947
|
+ SERIAL_ERRORLN((int)heater_id);
|
|
948
|
+ LCD_ALERTMESSAGEPGM("THERMAL RUNAWAY");
|
|
949
|
+ thermal_runaway = true;
|
|
950
|
+ while(1)
|
|
951
|
+ {
|
|
952
|
+ disable_heater();
|
|
953
|
+ disable_x();
|
|
954
|
+ disable_y();
|
|
955
|
+ disable_z();
|
|
956
|
+ disable_e0();
|
|
957
|
+ disable_e1();
|
|
958
|
+ disable_e2();
|
|
959
|
+ manage_heater();
|
|
960
|
+ lcd_update();
|
|
961
|
+ }
|
|
962
|
+ }
|
|
963
|
+ break;
|
|
964
|
+ }
|
|
965
|
+}
|
|
966
|
+#endif
|
899
|
967
|
|
900
|
968
|
void disable_heater()
|
901
|
969
|
{
|