|
@ -256,7 +256,11 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if HAS_HOTEND |
|
|
#if HAS_HOTEND |
|
|
hotend_info_t Temperature::temp_hotend[HOTEND_TEMPS]; // = { 0 }
|
|
|
hotend_info_t Temperature::temp_hotend[HOTENDS]; |
|
|
|
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) |
|
|
|
|
|
temp_info_t Temperature::temp_redundant; |
|
|
|
|
|
#endif |
|
|
|
|
|
#define _HMT(N) HEATER_##N##_MAXTEMP, |
|
|
const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); |
|
|
const celsius_t Temperature::hotend_maxtemp[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_MAXTEMP, HEATER_1_MAXTEMP, HEATER_2_MAXTEMP, HEATER_3_MAXTEMP, HEATER_4_MAXTEMP, HEATER_5_MAXTEMP, HEATER_6_MAXTEMP, HEATER_7_MAXTEMP); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -420,11 +424,6 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY, |
|
|
bool Temperature::inited = false; |
|
|
bool Temperature::inited = false; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) |
|
|
|
|
|
int16_t Temperature::redundant_temperature_raw = 0; |
|
|
|
|
|
celsius_float_t Temperature::redundant_temperature = 0.0; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
volatile bool Temperature::raw_temps_ready = false; |
|
|
volatile bool Temperature::raw_temps_ready = false; |
|
|
|
|
|
|
|
|
#if ENABLED(PID_EXTRUSION_SCALING) |
|
|
#if ENABLED(PID_EXTRUSION_SCALING) |
|
@ -1225,12 +1224,12 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
|
#if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) |
|
|
#if DISABLED(IGNORE_THERMOCOUPLE_ERRORS) |
|
|
#if TEMP_SENSOR_0_IS_MAX_TC |
|
|
#if TEMP_SENSOR_0_IS_MAX_TC |
|
|
if (temp_hotend[0].celsius > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); |
|
|
if (degHotend(0) > _MIN(HEATER_0_MAXTEMP, TEMP_SENSOR_0_MAX_TC_TMAX - 1.0)) max_temp_error(H_E0); |
|
|
if (temp_hotend[0].celsius < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); |
|
|
if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0); |
|
|
#endif |
|
|
#endif |
|
|
#if TEMP_SENSOR_1_IS_MAX_TC |
|
|
#if TEMP_SENSOR_1_IS_MAX_TC |
|
|
if (temp_hotend[1].celsius > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); |
|
|
if (TERN(TEMP_SENSOR_1_AS_REDUNDANT, degHotendRedundant(), degHotend(1)) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); |
|
|
if (temp_hotend[1].celsius < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); |
|
|
if (TERN(TEMP_SENSOR_1_AS_REDUNDANT, degHotendRedundant(), degHotend(1)) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); |
|
|
#endif |
|
|
#endif |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -1266,7 +1265,7 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) |
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) |
|
|
// Make sure measured temperatures are close together
|
|
|
// Make sure measured temperatures are close together
|
|
|
if (ABS(temp_hotend[0].celsius - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) |
|
|
if (ABS(degHotend(0) - degHotendRedundant()) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) |
|
|
_temp_error(H_E0, PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP)); |
|
|
_temp_error(H_E0, PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP)); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
@ -1668,7 +1667,7 @@ void Temperature::manage_heater() { |
|
|
SERIAL_EOL(); |
|
|
SERIAL_EOL(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int raw) { |
|
|
celsius_float_t Temperature::user_thermistor_to_deg_c(const uint8_t t_index, const int16_t raw) { |
|
|
//#if (MOTHERBOARD == BOARD_RAMPS_14_EFB)
|
|
|
//#if (MOTHERBOARD == BOARD_RAMPS_14_EFB)
|
|
|
// static uint32_t clocks_total = 0;
|
|
|
// static uint32_t clocks_total = 0;
|
|
|
// static uint32_t calls = 0;
|
|
|
// static uint32_t calls = 0;
|
|
@ -1717,8 +1716,8 @@ void Temperature::manage_heater() { |
|
|
#if HAS_HOTEND |
|
|
#if HAS_HOTEND |
|
|
// Derived from RepRap FiveD extruder::getTemperature()
|
|
|
// Derived from RepRap FiveD extruder::getTemperature()
|
|
|
// For hot end temperature measurement.
|
|
|
// For hot end temperature measurement.
|
|
|
celsius_float_t Temperature::analog_to_celsius_hotend(const int raw, const uint8_t e) { |
|
|
celsius_float_t Temperature::analog_to_celsius_hotend(const int16_t raw, const uint8_t e) { |
|
|
if (e > HOTENDS - DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)) { |
|
|
if (e >= HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) { |
|
|
SERIAL_ERROR_START(); |
|
|
SERIAL_ERROR_START(); |
|
|
SERIAL_ECHO(e); |
|
|
SERIAL_ECHO(e); |
|
|
SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM); |
|
|
SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM); |
|
@ -1826,7 +1825,7 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
|
#if HAS_HEATED_BED |
|
|
#if HAS_HEATED_BED |
|
|
// For bed temperature measurement.
|
|
|
// For bed temperature measurement.
|
|
|
celsius_float_t Temperature::analog_to_celsius_bed(const int raw) { |
|
|
celsius_float_t Temperature::analog_to_celsius_bed(const int16_t raw) { |
|
|
#if TEMP_SENSOR_BED_IS_CUSTOM |
|
|
#if TEMP_SENSOR_BED_IS_CUSTOM |
|
|
return user_thermistor_to_deg_c(CTI_BED, raw); |
|
|
return user_thermistor_to_deg_c(CTI_BED, raw); |
|
|
#elif TEMP_SENSOR_BED_IS_THERMISTOR |
|
|
#elif TEMP_SENSOR_BED_IS_THERMISTOR |
|
@ -1844,7 +1843,7 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
|
#if HAS_TEMP_CHAMBER |
|
|
#if HAS_TEMP_CHAMBER |
|
|
// For chamber temperature measurement.
|
|
|
// For chamber temperature measurement.
|
|
|
celsius_float_t Temperature::analog_to_celsius_chamber(const int raw) { |
|
|
celsius_float_t Temperature::analog_to_celsius_chamber(const int16_t raw) { |
|
|
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM |
|
|
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM |
|
|
return user_thermistor_to_deg_c(CTI_CHAMBER, raw); |
|
|
return user_thermistor_to_deg_c(CTI_CHAMBER, raw); |
|
|
#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR |
|
|
#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR |
|
@ -1862,7 +1861,7 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
|
#if HAS_TEMP_COOLER |
|
|
#if HAS_TEMP_COOLER |
|
|
// For cooler temperature measurement.
|
|
|
// For cooler temperature measurement.
|
|
|
celsius_float_t Temperature::analog_to_celsius_cooler(const int raw) { |
|
|
celsius_float_t Temperature::analog_to_celsius_cooler(const int16_t raw) { |
|
|
#if TEMP_SENSOR_COOLER_IS_CUSTOM |
|
|
#if TEMP_SENSOR_COOLER_IS_CUSTOM |
|
|
return user_thermistor_to_deg_c(CTI_COOLER, raw); |
|
|
return user_thermistor_to_deg_c(CTI_COOLER, raw); |
|
|
#elif TEMP_SENSOR_COOLER_IS_THERMISTOR |
|
|
#elif TEMP_SENSOR_COOLER_IS_THERMISTOR |
|
@ -1880,7 +1879,7 @@ void Temperature::manage_heater() { |
|
|
|
|
|
|
|
|
#if HAS_TEMP_PROBE |
|
|
#if HAS_TEMP_PROBE |
|
|
// For probe temperature measurement.
|
|
|
// For probe temperature measurement.
|
|
|
celsius_float_t Temperature::analog_to_celsius_probe(const int raw) { |
|
|
celsius_float_t Temperature::analog_to_celsius_probe(const int16_t raw) { |
|
|
#if TEMP_SENSOR_PROBE_IS_CUSTOM |
|
|
#if TEMP_SENSOR_PROBE_IS_CUSTOM |
|
|
return user_thermistor_to_deg_c(CTI_PROBE, raw); |
|
|
return user_thermistor_to_deg_c(CTI_PROBE, raw); |
|
|
#elif TEMP_SENSOR_PROBE_IS_THERMISTOR |
|
|
#elif TEMP_SENSOR_PROBE_IS_THERMISTOR |
|
@ -1904,15 +1903,15 @@ void Temperature::manage_heater() { |
|
|
*/ |
|
|
*/ |
|
|
void Temperature::updateTemperaturesFromRawValues() { |
|
|
void Temperature::updateTemperaturesFromRawValues() { |
|
|
TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0)); |
|
|
TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0)); |
|
|
TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1)); |
|
|
TERN_(TEMP_SENSOR_1_IS_MAX_TC, TERN(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant, temp_hotend[1]).raw = READ_MAX_TC(1)); |
|
|
#if HAS_HOTEND |
|
|
#if HAS_HOTEND |
|
|
HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e); |
|
|
HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant.celsius = analog_to_celsius_hotend(temp_redundant.raw, 1)); |
|
|
TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw)); |
|
|
TERN_(HAS_HEATED_BED, temp_bed.celsius = analog_to_celsius_bed(temp_bed.raw)); |
|
|
TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw)); |
|
|
TERN_(HAS_TEMP_CHAMBER, temp_chamber.celsius = analog_to_celsius_chamber(temp_chamber.raw)); |
|
|
TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.raw)); |
|
|
TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.raw)); |
|
|
TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw)); |
|
|
TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.raw)); |
|
|
TERN_(TEMP_SENSOR_1_AS_REDUNDANT, redundant_temperature = analog_to_celsius_hotend(redundant_temperature_raw, 1)); |
|
|
|
|
|
TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); |
|
|
TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); |
|
|
TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); |
|
|
TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); |
|
|
|
|
|
|
|
@ -2707,7 +2706,7 @@ void Temperature::update_raw_temperatures() { |
|
|
|
|
|
|
|
|
#if HAS_TEMP_ADC_1 |
|
|
#if HAS_TEMP_ADC_1 |
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) |
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) |
|
|
redundant_temperature_raw = temp_hotend[1].acc; |
|
|
temp_redundant.update(); |
|
|
#elif !TEMP_SENSOR_1_IS_MAX_TC |
|
|
#elif !TEMP_SENSOR_1_IS_MAX_TC |
|
|
temp_hotend[1].update(); |
|
|
temp_hotend[1].update(); |
|
|
#endif |
|
|
#endif |
|
@ -2741,7 +2740,7 @@ void Temperature::readings_ready() { |
|
|
|
|
|
|
|
|
#if HAS_HOTEND |
|
|
#if HAS_HOTEND |
|
|
HOTEND_LOOP() temp_hotend[e].reset(); |
|
|
HOTEND_LOOP() temp_hotend[e].reset(); |
|
|
TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_hotend[1].reset()); |
|
|
TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant.reset()); |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
TERN_(HAS_HEATED_BED, temp_bed.reset()); |
|
|
TERN_(HAS_HEATED_BED, temp_bed.reset()); |
|
@ -3245,7 +3244,7 @@ void Temperature::isr() { |
|
|
|
|
|
|
|
|
#if HAS_TEMP_ADC_1 |
|
|
#if HAS_TEMP_ADC_1 |
|
|
case PrepareTemp_1: HAL_START_ADC(TEMP_1_PIN); break; |
|
|
case PrepareTemp_1: HAL_START_ADC(TEMP_1_PIN); break; |
|
|
case MeasureTemp_1: ACCUMULATE_ADC(temp_hotend[1]); break; |
|
|
case MeasureTemp_1: ACCUMULATE_ADC(TERN(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant, temp_hotend[1])); break; |
|
|
#endif |
|
|
#endif |
|
|
|
|
|
|
|
|
#if HAS_TEMP_ADC_2 |
|
|
#if HAS_TEMP_ADC_2 |
|
@ -3443,9 +3442,9 @@ void Temperature::isr() { |
|
|
#endif |
|
|
#endif |
|
|
); |
|
|
); |
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) |
|
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) |
|
|
if (include_r) print_heater_state(redundant_temperature, degTargetHotend(target_extruder) |
|
|
if (include_r) print_heater_state(degHotendRedundant(), degTargetHotend(0) |
|
|
#if ENABLED(SHOW_TEMP_ADC_VALUES) |
|
|
#if ENABLED(SHOW_TEMP_ADC_VALUES) |
|
|
, redundant_temperature_raw |
|
|
, rawHotendTempRedundant() |
|
|
#endif |
|
|
#endif |
|
|
, H_REDUNDANT |
|
|
, H_REDUNDANT |
|
|
); |
|
|
); |
|
|