|
@@ -244,11 +244,11 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
|
244
|
244
|
;
|
245
|
245
|
const int8_t watch_temp_period =
|
246
|
246
|
#if ENABLED(THERMAL_PROTECTION_BED) && ENABLED(PIDTEMPBED) && ENABLED(THERMAL_PROTECTION_HOTENDS) && ENABLED(PIDTEMP)
|
247
|
|
- hotend < 0 ? THERMAL_PROTECTION_BED_PERIOD : THERMAL_PROTECTION_PERIOD
|
|
247
|
+ hotend < 0 ? WATCH_BED_TEMP_PERIOD : WATCH_TEMP_PERIOD
|
248
|
248
|
#elif ENABLED(THERMAL_PROTECTION_BED) && ENABLED(PIDTEMPBED)
|
249
|
|
- THERMAL_PROTECTION_BED_PERIOD
|
|
249
|
+ WATCH_BED_TEMP_PERIOD
|
250
|
250
|
#else
|
251
|
|
- THERMAL_PROTECTION_PERIOD
|
|
251
|
+ WATCH_TEMP_PERIOD
|
252
|
252
|
#endif
|
253
|
253
|
;
|
254
|
254
|
const int8_t watch_temp_increase =
|
|
@@ -437,7 +437,9 @@ uint8_t Temperature::soft_pwm_amount[HOTENDS],
|
437
|
437
|
next_watch_temp = input + watch_temp_increase;
|
438
|
438
|
temp_change_ms = ms + watch_temp_period * 1000UL;
|
439
|
439
|
}
|
440
|
|
- else if ((!heated && ELAPSED(ms, temp_change_ms)) || (heated && input < temp - MAX_OVERSHOOT_PID_AUTOTUNE))
|
|
440
|
+ else if (!heated && ELAPSED(ms, temp_change_ms))
|
|
441
|
+ _temp_error(hotend, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
|
|
442
|
+ else if (heated && input < temp - MAX_OVERSHOOT_PID_AUTOTUNE)
|
441
|
443
|
_temp_error(hotend, PSTR(MSG_T_THERMAL_RUNAWAY), PSTR(MSG_THERMAL_RUNAWAY));
|
442
|
444
|
#endif
|
443
|
445
|
} // every 2 seconds
|
|
@@ -834,10 +836,8 @@ void Temperature::manage_heater() {
|
834
|
836
|
#endif
|
835
|
837
|
|
836
|
838
|
#if HEATER_IDLE_HANDLER
|
837
|
|
- if (bed_idle_timeout_exceeded)
|
838
|
|
- {
|
|
839
|
+ if (bed_idle_timeout_exceeded) {
|
839
|
840
|
soft_pwm_amount_bed = 0;
|
840
|
|
-
|
841
|
841
|
#if DISABLED(PIDTEMPBED)
|
842
|
842
|
WRITE_HEATER_BED(LOW);
|
843
|
843
|
#endif
|
|
@@ -847,23 +847,17 @@ void Temperature::manage_heater() {
|
847
|
847
|
{
|
848
|
848
|
#if ENABLED(PIDTEMPBED)
|
849
|
849
|
soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
|
850
|
|
-
|
851
|
|
- #elif ENABLED(BED_LIMIT_SWITCHING)
|
|
850
|
+ #else
|
852
|
851
|
// Check if temperature is within the correct band
|
853
|
852
|
if (WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP)) {
|
854
|
|
- if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
|
855
|
|
- soft_pwm_amount_bed = 0;
|
856
|
|
- else if (current_temperature_bed <= target_temperature_bed - (BED_HYSTERESIS))
|
857
|
|
- soft_pwm_amount_bed = MAX_BED_POWER >> 1;
|
858
|
|
- }
|
859
|
|
- else {
|
860
|
|
- soft_pwm_amount_bed = 0;
|
861
|
|
- WRITE_HEATER_BED(LOW);
|
862
|
|
- }
|
863
|
|
- #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
|
864
|
|
- // Check if temperature is within the correct range
|
865
|
|
- if (WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP)) {
|
866
|
|
- soft_pwm_amount_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0;
|
|
853
|
+ #if ENABLED(BED_LIMIT_SWITCHING)
|
|
854
|
+ if (current_temperature_bed >= target_temperature_bed + BED_HYSTERESIS)
|
|
855
|
+ soft_pwm_amount_bed = 0;
|
|
856
|
+ else if (current_temperature_bed <= target_temperature_bed - (BED_HYSTERESIS))
|
|
857
|
+ soft_pwm_amount_bed = MAX_BED_POWER >> 1;
|
|
858
|
+ #else // !PIDTEMPBED && !BED_LIMIT_SWITCHING
|
|
859
|
+ soft_pwm_amount_bed = current_temperature_bed < target_temperature_bed ? MAX_BED_POWER >> 1 : 0;
|
|
860
|
+ #endif
|
867
|
861
|
}
|
868
|
862
|
else {
|
869
|
863
|
soft_pwm_amount_bed = 0;
|
|
@@ -878,7 +872,7 @@ void Temperature::manage_heater() {
|
878
|
872
|
|
879
|
873
|
// Derived from RepRap FiveD extruder::getTemperature()
|
880
|
874
|
// For hot end temperature measurement.
|
881
|
|
-float Temperature::analog2temp(int raw, uint8_t e) {
|
|
875
|
+float Temperature::analog2temp(const int raw, const uint8_t e) {
|
882
|
876
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
883
|
877
|
if (e > HOTENDS)
|
884
|
878
|
#else
|
|
@@ -919,39 +913,41 @@ float Temperature::analog2temp(int raw, uint8_t e) {
|
919
|
913
|
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
|
920
|
914
|
}
|
921
|
915
|
|
922
|
|
-// Derived from RepRap FiveD extruder::getTemperature()
|
923
|
|
-// For bed temperature measurement.
|
924
|
|
-float Temperature::analog2tempBed(const int raw) {
|
925
|
|
- #if ENABLED(BED_USES_THERMISTOR)
|
926
|
|
- float celsius = 0;
|
927
|
|
- byte i;
|
928
|
|
-
|
929
|
|
- for (i = 1; i < BEDTEMPTABLE_LEN; i++) {
|
930
|
|
- if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) {
|
931
|
|
- celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]) +
|
932
|
|
- (raw - PGM_RD_W(BEDTEMPTABLE[i - 1][0])) *
|
933
|
|
- (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i - 1][1])) /
|
934
|
|
- (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i - 1][0]));
|
935
|
|
- break;
|
|
916
|
+#if HAS_TEMP_BED
|
|
917
|
+ // Derived from RepRap FiveD extruder::getTemperature()
|
|
918
|
+ // For bed temperature measurement.
|
|
919
|
+ float Temperature::analog2tempBed(const int raw) {
|
|
920
|
+ #if ENABLED(BED_USES_THERMISTOR)
|
|
921
|
+ float celsius = 0;
|
|
922
|
+ byte i;
|
|
923
|
+
|
|
924
|
+ for (i = 1; i < BEDTEMPTABLE_LEN; i++) {
|
|
925
|
+ if (PGM_RD_W(BEDTEMPTABLE[i][0]) > raw) {
|
|
926
|
+ celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]) +
|
|
927
|
+ (raw - PGM_RD_W(BEDTEMPTABLE[i - 1][0])) *
|
|
928
|
+ (float)(PGM_RD_W(BEDTEMPTABLE[i][1]) - PGM_RD_W(BEDTEMPTABLE[i - 1][1])) /
|
|
929
|
+ (float)(PGM_RD_W(BEDTEMPTABLE[i][0]) - PGM_RD_W(BEDTEMPTABLE[i - 1][0]));
|
|
930
|
+ break;
|
|
931
|
+ }
|
936
|
932
|
}
|
937
|
|
- }
|
938
|
933
|
|
939
|
|
- // Overflow: Set to last value in the table
|
940
|
|
- if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]);
|
|
934
|
+ // Overflow: Set to last value in the table
|
|
935
|
+ if (i == BEDTEMPTABLE_LEN) celsius = PGM_RD_W(BEDTEMPTABLE[i - 1][1]);
|
941
|
936
|
|
942
|
|
- return celsius;
|
|
937
|
+ return celsius;
|
943
|
938
|
|
944
|
|
- #elif defined(BED_USES_AD595)
|
|
939
|
+ #elif defined(BED_USES_AD595)
|
945
|
940
|
|
946
|
|
- return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
|
|
941
|
+ return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN)) + TEMP_SENSOR_AD595_OFFSET;
|
947
|
942
|
|
948
|
|
- #else
|
|
943
|
+ #else
|
949
|
944
|
|
950
|
|
- UNUSED(raw);
|
951
|
|
- return 0;
|
|
945
|
+ UNUSED(raw);
|
|
946
|
+ return 0;
|
952
|
947
|
|
953
|
|
- #endif
|
954
|
|
-}
|
|
948
|
+ #endif
|
|
949
|
+ }
|
|
950
|
+#endif // HAS_TEMP_BED
|
955
|
951
|
|
956
|
952
|
/**
|
957
|
953
|
* Get the raw values into the actual temperatures.
|
|
@@ -1236,24 +1232,26 @@ void Temperature::init() {
|
1236
|
1232
|
#endif // HOTENDS > 2
|
1237
|
1233
|
#endif // HOTENDS > 1
|
1238
|
1234
|
|
1239
|
|
- #ifdef BED_MINTEMP
|
1240
|
|
- while (analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) {
|
1241
|
|
- #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
|
1242
|
|
- bed_minttemp_raw += OVERSAMPLENR;
|
1243
|
|
- #else
|
1244
|
|
- bed_minttemp_raw -= OVERSAMPLENR;
|
1245
|
|
- #endif
|
1246
|
|
- }
|
1247
|
|
- #endif // BED_MINTEMP
|
1248
|
|
- #ifdef BED_MAXTEMP
|
1249
|
|
- while (analog2tempBed(bed_maxttemp_raw) > BED_MAXTEMP) {
|
1250
|
|
- #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
|
1251
|
|
- bed_maxttemp_raw -= OVERSAMPLENR;
|
1252
|
|
- #else
|
1253
|
|
- bed_maxttemp_raw += OVERSAMPLENR;
|
1254
|
|
- #endif
|
1255
|
|
- }
|
1256
|
|
- #endif // BED_MAXTEMP
|
|
1235
|
+ #if HAS_TEMP_BED
|
|
1236
|
+ #ifdef BED_MINTEMP
|
|
1237
|
+ while (analog2tempBed(bed_minttemp_raw) < BED_MINTEMP) {
|
|
1238
|
+ #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
|
|
1239
|
+ bed_minttemp_raw += OVERSAMPLENR;
|
|
1240
|
+ #else
|
|
1241
|
+ bed_minttemp_raw -= OVERSAMPLENR;
|
|
1242
|
+ #endif
|
|
1243
|
+ }
|
|
1244
|
+ #endif // BED_MINTEMP
|
|
1245
|
+ #ifdef BED_MAXTEMP
|
|
1246
|
+ while (analog2tempBed(bed_maxttemp_raw) > BED_MAXTEMP) {
|
|
1247
|
+ #if HEATER_BED_RAW_LO_TEMP < HEATER_BED_RAW_HI_TEMP
|
|
1248
|
+ bed_maxttemp_raw -= OVERSAMPLENR;
|
|
1249
|
+ #else
|
|
1250
|
+ bed_maxttemp_raw += OVERSAMPLENR;
|
|
1251
|
+ #endif
|
|
1252
|
+ }
|
|
1253
|
+ #endif // BED_MAXTEMP
|
|
1254
|
+ #endif // HAS_TEMP_BED
|
1257
|
1255
|
|
1258
|
1256
|
#if ENABLED(PROBING_HEATERS_OFF)
|
1259
|
1257
|
paused = false;
|
|
@@ -1348,7 +1346,7 @@ void Temperature::init() {
|
1348
|
1346
|
millis_t Temperature::thermal_runaway_bed_timer;
|
1349
|
1347
|
#endif
|
1350
|
1348
|
|
1351
|
|
- void Temperature::thermal_runaway_protection(Temperature::TRState * const state, millis_t * const timer, const float current, const float target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
|
|
1349
|
+ void Temperature::thermal_runaway_protection(Temperature::TRState * const state, millis_t * const timer, const float ¤t, const float &target, const int8_t heater_id, const uint16_t period_seconds, const uint16_t hysteresis_degc) {
|
1352
|
1350
|
|
1353
|
1351
|
static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
|
1354
|
1352
|
|
|
@@ -1371,22 +1369,22 @@ void Temperature::init() {
|
1371
|
1369
|
|
1372
|
1370
|
#if HEATER_IDLE_HANDLER
|
1373
|
1371
|
// If the heater idle timeout expires, restart
|
1374
|
|
- if (heater_id >= 0 && heater_idle_timeout_exceeded[heater_id]) {
|
|
1372
|
+ if ((heater_id >= 0 && heater_idle_timeout_exceeded[heater_id])
|
|
1373
|
+ #if HAS_TEMP_BED
|
|
1374
|
+ || (heater_id < 0 && bed_idle_timeout_exceeded)
|
|
1375
|
+ #endif
|
|
1376
|
+ ) {
|
1375
|
1377
|
*state = TRInactive;
|
1376
|
1378
|
tr_target_temperature[heater_index] = 0;
|
1377
|
1379
|
}
|
1378
|
|
- #if HAS_TEMP_BED
|
1379
|
|
- else if (heater_id < 0 && bed_idle_timeout_exceeded) {
|
1380
|
|
- *state = TRInactive;
|
1381
|
|
- tr_target_temperature[heater_index] = 0;
|
1382
|
|
- }
|
1383
|
|
- #endif
|
1384
|
1380
|
else
|
1385
|
1381
|
#endif
|
1386
|
|
- // If the target temperature changes, restart
|
1387
|
|
- if (tr_target_temperature[heater_index] != target) {
|
1388
|
|
- tr_target_temperature[heater_index] = target;
|
1389
|
|
- *state = target > 0 ? TRFirstHeating : TRInactive;
|
|
1382
|
+ {
|
|
1383
|
+ // If the target temperature changes, restart
|
|
1384
|
+ if (tr_target_temperature[heater_index] != target) {
|
|
1385
|
+ tr_target_temperature[heater_index] = target;
|
|
1386
|
+ *state = target > 0 ? TRFirstHeating : TRInactive;
|
|
1387
|
+ }
|
1390
|
1388
|
}
|
1391
|
1389
|
|
1392
|
1390
|
switch (*state) {
|
|
@@ -2172,19 +2170,19 @@ void Temperature::isr() {
|
2172
|
2170
|
);
|
2173
|
2171
|
#endif
|
2174
|
2172
|
#if HAS_TEMP_BED
|
2175
|
|
- print_heater_state(degBed(), degTargetBed(),
|
|
2173
|
+ print_heater_state(degBed(), degTargetBed()
|
2176
|
2174
|
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
2177
|
|
- rawBedTemp(),
|
|
2175
|
+ , rawBedTemp()
|
2178
|
2176
|
#endif
|
2179
|
|
- -1 // BED
|
|
2177
|
+ , -1 // BED
|
2180
|
2178
|
);
|
2181
|
2179
|
#endif
|
2182
|
2180
|
#if HOTENDS > 1
|
2183
|
|
- HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e),
|
|
2181
|
+ HOTEND_LOOP() print_heater_state(degHotend(e), degTargetHotend(e)
|
2184
|
2182
|
#if ENABLED(SHOW_TEMP_ADC_VALUES)
|
2185
|
|
- rawHotendTemp(e),
|
|
2183
|
+ , rawHotendTemp(e)
|
2186
|
2184
|
#endif
|
2187
|
|
- e
|
|
2185
|
+ , e
|
2188
|
2186
|
);
|
2189
|
2187
|
#endif
|
2190
|
2188
|
SERIAL_PROTOCOLPGM(" @:");
|