|
@@ -103,24 +103,24 @@ int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 },
|
103
|
103
|
#endif
|
104
|
104
|
|
105
|
105
|
#if WATCH_HOTENDS
|
106
|
|
- int Temperature::watch_target_temp[HOTENDS] = { 0 };
|
|
106
|
+ uint16_t Temperature::watch_target_temp[HOTENDS] = { 0 };
|
107
|
107
|
millis_t Temperature::watch_heater_next_ms[HOTENDS] = { 0 };
|
108
|
108
|
#endif
|
109
|
109
|
|
110
|
110
|
#if WATCH_THE_BED
|
111
|
|
- int Temperature::watch_target_bed_temp = 0;
|
|
111
|
+ uint16_t Temperature::watch_target_bed_temp = 0;
|
112
|
112
|
millis_t Temperature::watch_bed_next_ms = 0;
|
113
|
113
|
#endif
|
114
|
114
|
|
115
|
115
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
116
|
116
|
bool Temperature::allow_cold_extrude = false;
|
117
|
|
- float Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
|
|
117
|
+ uint16_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
|
118
|
118
|
#endif
|
119
|
119
|
|
120
|
120
|
// private:
|
121
|
121
|
|
122
|
122
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
123
|
|
- int Temperature::redundant_temperature_raw = 0;
|
|
123
|
+ uint16_t Temperature::redundant_temperature_raw = 0;
|
124
|
124
|
float Temperature::redundant_temperature = 0.0;
|
125
|
125
|
#endif
|
126
|
126
|
|
|
@@ -695,66 +695,47 @@ void Temperature::manage_heater() {
|
695
|
695
|
updateTemperaturesFromRawValues(); // also resets the watchdog
|
696
|
696
|
|
697
|
697
|
#if ENABLED(HEATER_0_USES_MAX6675)
|
698
|
|
- if (current_temperature[0] > min(HEATER_0_MAXTEMP, MAX6675_TMAX - 1)) max_temp_error(0);
|
699
|
|
- if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + 0.01)) min_temp_error(0);
|
|
698
|
+ if (current_temperature[0] > min(HEATER_0_MAXTEMP, MAX6675_TMAX - 1.0)) max_temp_error(0);
|
|
699
|
+ if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + .01)) min_temp_error(0);
|
700
|
700
|
#endif
|
701
|
701
|
|
702
|
702
|
#if WATCH_HOTENDS || WATCH_THE_BED || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN
|
703
|
703
|
millis_t ms = millis();
|
704
|
704
|
#endif
|
705
|
705
|
|
706
|
|
- // Loop through all hotends
|
707
|
706
|
HOTEND_LOOP() {
|
708
|
707
|
|
709
|
708
|
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
|
|
709
|
+ // Check for thermal runaway
|
710
|
710
|
thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
|
711
|
711
|
#endif
|
712
|
712
|
|
713
|
|
- float pid_output = get_pid_output(e);
|
|
713
|
+ soft_pwm_amount[e] = (current_temperature[e] > minttemp[e] || is_preheating(e)) && current_temperature[e] < maxttemp[e] ? (int)get_pid_output(e) >> 1 : 0;
|
714
|
714
|
|
715
|
|
- // Check if temperature is within the correct range
|
716
|
|
- soft_pwm_amount[e] = (current_temperature[e] > minttemp[e] || is_preheating(e)) && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;
|
717
|
|
-
|
718
|
|
- // Check if the temperature is failing to increase
|
719
|
715
|
#if WATCH_HOTENDS
|
720
|
|
-
|
721
|
|
- // Is it time to check this extruder's heater?
|
722
|
|
- if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) {
|
723
|
|
- // Has it failed to increase enough?
|
724
|
|
- if (degHotend(e) < watch_target_temp[e]) {
|
725
|
|
- // Stop!
|
|
716
|
+ // Make sure temperature is increasing
|
|
717
|
+ if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) { // Time to check this extruder?
|
|
718
|
+ if (degHotend(e) < watch_target_temp[e]) // Failed to increase enough?
|
726
|
719
|
_temp_error(e, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
|
727
|
|
- }
|
728
|
|
- else {
|
729
|
|
- // Start again if the target is still far off
|
|
720
|
+ else // Start again if the target is still far off
|
730
|
721
|
start_watching_heater(e);
|
731
|
|
- }
|
732
|
722
|
}
|
|
723
|
+ #endif
|
733
|
724
|
|
734
|
|
- #endif // THERMAL_PROTECTION_HOTENDS
|
735
|
|
-
|
736
|
|
- // Check if the temperature is failing to increase
|
737
|
725
|
#if WATCH_THE_BED
|
738
|
|
-
|
739
|
|
- // Is it time to check the bed?
|
740
|
|
- if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) {
|
741
|
|
- // Has it failed to increase enough?
|
742
|
|
- if (degBed() < watch_target_bed_temp) {
|
743
|
|
- // Stop!
|
|
726
|
+ // Make sure temperature is increasing
|
|
727
|
+ if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) { // Time to check the bed?
|
|
728
|
+ if (degBed() < watch_target_bed_temp) // Failed to increase enough?
|
744
|
729
|
_temp_error(-1, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
|
745
|
|
- }
|
746
|
|
- else {
|
747
|
|
- // Start again if the target is still far off
|
|
730
|
+ else // Start again if the target is still far off
|
748
|
731
|
start_watching_bed();
|
749
|
|
- }
|
750
|
732
|
}
|
751
|
|
-
|
752
|
|
- #endif // THERMAL_PROTECTION_HOTENDS
|
|
733
|
+ #endif
|
753
|
734
|
|
754
|
735
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
755
|
|
- if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
|
|
736
|
+ // Make sure measured temperatures are close together
|
|
737
|
+ if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
|
756
|
738
|
_temp_error(0, PSTR(MSG_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP));
|
757
|
|
- }
|
758
|
739
|
#endif
|
759
|
740
|
|
760
|
741
|
} // HOTEND_LOOP
|
|
@@ -792,9 +773,7 @@ void Temperature::manage_heater() {
|
792
|
773
|
#endif
|
793
|
774
|
|
794
|
775
|
#if ENABLED(PIDTEMPBED)
|
795
|
|
- float pid_output = get_pid_output_bed();
|
796
|
|
-
|
797
|
|
- soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)pid_output >> 1 : 0;
|
|
776
|
+ soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
|
798
|
777
|
|
799
|
778
|
#elif ENABLED(BED_LIMIT_SWITCHING)
|
800
|
779
|
// Check if temperature is within the correct band
|