From c43bbcce152b4d3b4697e1e188d3bcada76a24a7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 1 Jul 2020 16:27:28 -0500 Subject: [PATCH] Enforce sensor range for temperature target (#18465) * Mitigate stepper timeout * Add CHAMBER PWM code * Structured thermistor tables * Fix reversed sensor ranges * Prevent temps outside sensor range --- Marlin/src/MarlinCore.cpp | 23 ++- Marlin/src/MarlinCore.h | 3 - Marlin/src/feature/bedlevel/ubl/ubl.cpp | 2 +- Marlin/src/gcode/bedlevel/abl/G29.cpp | 4 +- Marlin/src/gcode/calibrate/G28.cpp | 11 +- Marlin/src/gcode/control/M17_M18_M84.cpp | 1 + Marlin/src/gcode/control/M85.cpp | 1 - Marlin/src/gcode/control/T.cpp | 3 + Marlin/src/gcode/gcode.cpp | 5 +- Marlin/src/gcode/gcode.h | 10 +- Marlin/src/module/temperature.cpp | 186 ++++++++++-------- Marlin/src/module/temperature.h | 2 +- Marlin/src/module/thermistor/thermistor_1.h | 2 +- Marlin/src/module/thermistor/thermistor_10.h | 2 +- .../src/module/thermistor/thermistor_1010.h | 2 +- .../src/module/thermistor/thermistor_1047.h | 2 +- Marlin/src/module/thermistor/thermistor_11.h | 2 +- Marlin/src/module/thermistor/thermistor_110.h | 2 +- Marlin/src/module/thermistor/thermistor_12.h | 2 +- Marlin/src/module/thermistor/thermistor_13.h | 2 +- Marlin/src/module/thermistor/thermistor_147.h | 2 +- Marlin/src/module/thermistor/thermistor_15.h | 2 +- Marlin/src/module/thermistor/thermistor_18.h | 2 +- Marlin/src/module/thermistor/thermistor_2.h | 2 +- Marlin/src/module/thermistor/thermistor_20.h | 4 +- Marlin/src/module/thermistor/thermistor_201.h | 4 +- Marlin/src/module/thermistor/thermistor_202.h | 2 +- Marlin/src/module/thermistor/thermistor_21.h | 4 +- Marlin/src/module/thermistor/thermistor_22.h | 2 +- Marlin/src/module/thermistor/thermistor_23.h | 2 +- Marlin/src/module/thermistor/thermistor_3.h | 2 +- Marlin/src/module/thermistor/thermistor_331.h | 2 +- Marlin/src/module/thermistor/thermistor_332.h | 2 +- Marlin/src/module/thermistor/thermistor_4.h | 2 +- Marlin/src/module/thermistor/thermistor_5.h | 2 +- Marlin/src/module/thermistor/thermistor_501.h | 2 +- Marlin/src/module/thermistor/thermistor_502.h | 2 +- Marlin/src/module/thermistor/thermistor_51.h | 2 +- Marlin/src/module/thermistor/thermistor_512.h | 2 +- Marlin/src/module/thermistor/thermistor_52.h | 2 +- Marlin/src/module/thermistor/thermistor_55.h | 2 +- Marlin/src/module/thermistor/thermistor_6.h | 2 +- Marlin/src/module/thermistor/thermistor_60.h | 2 +- Marlin/src/module/thermistor/thermistor_61.h | 2 +- Marlin/src/module/thermistor/thermistor_66.h | 2 +- Marlin/src/module/thermistor/thermistor_67.h | 2 +- Marlin/src/module/thermistor/thermistor_7.h | 2 +- Marlin/src/module/thermistor/thermistor_70.h | 2 +- Marlin/src/module/thermistor/thermistor_71.h | 2 +- Marlin/src/module/thermistor/thermistor_75.h | 2 +- Marlin/src/module/thermistor/thermistor_8.h | 2 +- Marlin/src/module/thermistor/thermistor_9.h | 2 +- Marlin/src/module/thermistor/thermistor_99.h | 2 +- Marlin/src/module/thermistor/thermistor_998.h | 2 +- Marlin/src/module/thermistor/thermistor_999.h | 2 +- Marlin/src/module/thermistor/thermistors.h | 119 +++++++++-- 56 files changed, 295 insertions(+), 167 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 976edfe7c..8a17d5c31 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -240,10 +240,6 @@ bool wait_for_heatup = true; #endif -// Inactivity shutdown -millis_t max_inactive_time, // = 0 - stepper_inactive_time = SEC_TO_MS(DEFAULT_STEPPER_DEACTIVE_TIME); - #if PIN_EXISTS(CHDK) extern millis_t chdk_timeout; #endif @@ -469,20 +465,23 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { const millis_t ms = millis(); - if (max_inactive_time && ELAPSED(ms, gcode.previous_move_ms + max_inactive_time)) { + // Prevent steppers timing-out in the middle of M600 + #define STAY_TEST (BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT) && did_pause_print) + + if (STAY_TEST || ignore_stepper_queue) + gcode.reset_stepper_timeout(ms); + + if (gcode.stepper_max_timed_out(ms)) { SERIAL_ERROR_START(); SERIAL_ECHOLNPAIR(STR_KILL_INACTIVE_TIME, parser.command_ptr); kill(); } - // Prevent steppers timing-out in the middle of M600 - #define STAY_TEST (BOTH(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_NO_STEPPER_TIMEOUT) && did_pause_print) - - if (stepper_inactive_time) { + if (gcode.stepper_inactive_time) { static bool already_shutdown_steppers; // = false if (planner.has_blocks_queued()) - gcode.reset_stepper_timeout(); - else if (!STAY_TEST && !ignore_stepper_queue && ELAPSED(ms, gcode.previous_move_ms + stepper_inactive_time)) { + gcode.reset_stepper_timeout(ms); + else if (!STAY_TEST && !ignore_stepper_queue && gcode.stepper_inactive_timeout()) { if (!already_shutdown_steppers) { already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this if (ENABLED(DISABLE_INACTIVE_X)) DISABLE_AXIS_X(); @@ -601,7 +600,7 @@ inline void manage_inactivity(const bool ignore_stepper_queue=false) { } #endif // !SWITCHING_EXTRUDER - gcode.reset_stepper_timeout(); + gcode.reset_stepper_timeout(ms); } #endif // EXTRUDER_RUNOUT_PREVENT diff --git a/Marlin/src/MarlinCore.h b/Marlin/src/MarlinCore.h index 1ed897483..18b679aca 100644 --- a/Marlin/src/MarlinCore.h +++ b/Marlin/src/MarlinCore.h @@ -87,9 +87,6 @@ extern bool wait_for_heatup; void wait_for_user_response(millis_t ms=0, const bool no_sleep=false); #endif -// Inactivity shutdown timer -extern millis_t max_inactive_time, stepper_inactive_time; - #if ENABLED(PSU_CONTROL) extern bool powersupply_on; #define PSU_PIN_ON() do{ OUT_WRITE(PS_ON_PIN, PSU_ACTIVE_HIGH); powersupply_on = true; }while(0) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 8d382e827..e08debf1d 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -206,7 +206,7 @@ if (human) SERIAL_CHAR(is_current ? ']' : ' '); SERIAL_FLUSHTX(); - idle(); + idle_no_sleep(); } if (!lcd) SERIAL_EOL(); diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index 01871ec7e..99f07bc19 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -164,6 +164,8 @@ */ G29_TYPE GcodeSuite::G29() { + reset_stepper_timeout(); + const bool seenQ = EITHER(DEBUG_LEVELING_FEATURE, PROBE_MANUALLY) && parser.seen('Q'); // G29 Q is also available if debugging @@ -675,7 +677,7 @@ G29_TYPE GcodeSuite::G29() { #endif abl_should_enable = false; - idle(); + idle_no_sleep(); } // inner } // outer diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 982c9e9d3..806a8d50d 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -203,15 +203,15 @@ */ void GcodeSuite::G28() { -#if ENABLED(LASER_MOVE_G28_OFF) - cutter.set_inline_enabled(false); // turn off laser -#endif - if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM(">>> G28"); log_machine_info(); } + #if ENABLED(LASER_MOVE_G28_OFF) + cutter.set_inline_enabled(false); // turn off laser + #endif + TERN_(DWIN_CREALITY_LCD, HMI_flag.home_flag = true); #if ENABLED(DUAL_X_CARRIAGE) @@ -251,6 +251,9 @@ void GcodeSuite::G28() { TERN_(CNC_WORKSPACE_PLANES, workspace_plane = PLANE_XY); + // Count this command as movement / activity + reset_stepper_timeout(); + #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) #if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) #define HAS_HOMING_CURRENT 1 diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index aee7d616a..55a219917 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -50,6 +50,7 @@ void GcodeSuite::M17() { */ void GcodeSuite::M18_M84() { if (parser.seenval('S')) { + reset_stepper_timeout(); stepper_inactive_time = parser.value_millis_from_seconds(); } else { diff --git a/Marlin/src/gcode/control/M85.cpp b/Marlin/src/gcode/control/M85.cpp index 1cdf49f60..224defed7 100644 --- a/Marlin/src/gcode/control/M85.cpp +++ b/Marlin/src/gcode/control/M85.cpp @@ -21,7 +21,6 @@ */ #include "../gcode.h" -#include "../../MarlinCore.h" // for max_inactive_time /** * M85: Set inactivity shutdown timer with parameter S. To disable set zero (default) diff --git a/Marlin/src/gcode/control/T.cpp b/Marlin/src/gcode/control/T.cpp index e6b3bb5d6..872b3d548 100644 --- a/Marlin/src/gcode/control/T.cpp +++ b/Marlin/src/gcode/control/T.cpp @@ -53,6 +53,9 @@ void GcodeSuite::T(const uint8_t tool_index) { DEBUG_POS("BEFORE", current_position); } + // Count this command as movement / activity + reset_stepper_timeout(); + #if ENABLED(PRUSA_MMU2) if (parser.string_arg) { mmu2.tool_change(parser.string_arg); // Special commands T?/Tx/Tc diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index d34e0665c..0b0a29cc2 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -59,7 +59,10 @@ GcodeSuite gcode; #include "../MarlinCore.h" // for idle() -millis_t GcodeSuite::previous_move_ms; +// Inactivity shutdown +millis_t GcodeSuite::previous_move_ms = 0, + GcodeSuite::max_inactive_time = 0, + GcodeSuite::stepper_inactive_time = SEC_TO_MS(DEFAULT_STEPPER_DEACTIVE_TIME); // Relative motion mode for each logical axis static constexpr xyze_bool_t ar_init = AXIS_RELATIVE_MODES; diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index ab17cc8d7..72ae1f92d 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -334,8 +334,14 @@ public: static bool select_coordinate_system(const int8_t _new); #endif - static millis_t previous_move_ms; - FORCE_INLINE static void reset_stepper_timeout() { previous_move_ms = millis(); } + static millis_t previous_move_ms, max_inactive_time, stepper_inactive_time; + FORCE_INLINE static void reset_stepper_timeout(const millis_t ms=millis()) { previous_move_ms = ms; } + FORCE_INLINE static bool stepper_max_timed_out(const millis_t ms=millis()) { + return max_inactive_time && ELAPSED(ms, previous_move_ms + max_inactive_time); + } + FORCE_INLINE static bool stepper_inactive_timeout(const millis_t ms=millis()) { + return ELAPSED(ms, previous_move_ms + stepper_inactive_time); + } static int8_t get_target_extruder_from_command(); static int8_t get_target_e_stepper_from_command(); diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index b95fdbdd8..1ca988e5d 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -110,12 +110,12 @@ #if HOTEND_USES_THERMISTOR #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) - static const void* heater_ttbl_map[2] = { (void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE }; + static const temp_entry_t* heater_ttbl_map[2] = { HEATER_0_TEMPTABLE, HEATER_1_TEMPTABLE }; static constexpr uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN }; #else #define NEXT_TEMPTABLE(N) ,HEATER_##N##_TEMPTABLE #define NEXT_TEMPTABLE_LEN(N) ,HEATER_##N##_TEMPTABLE_LEN - static const void* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE)); + static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE)); static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN)); #endif #endif @@ -900,11 +900,13 @@ void Temperature::min_temp_error(const heater_ind_t heater) { SERIAL_ECHO_START(); SERIAL_ECHOPAIR(STR_PID_DEBUG, ee, STR_PID_DEBUG_INPUT, temp_hotend[ee].celsius, STR_PID_DEBUG_OUTPUT, pid_output); #if DISABLED(PID_OPENLOOP) + { SERIAL_ECHOPAIR( STR_PID_DEBUG_PTERM, work_pid[ee].Kp, STR_PID_DEBUG_ITERM, work_pid[ee].Ki, STR_PID_DEBUG_DTERM, work_pid[ee].Kd #if ENABLED(PID_EXTRUSION_SCALING) , STR_PID_DEBUG_CTERM, work_pid[ee].Kc #endif ); + } #endif SERIAL_EOL(); } @@ -920,7 +922,7 @@ void Temperature::min_temp_error(const heater_ind_t heater) { return pid_output; } -#endif // HOTENDS +#endif // HAS_HOTEND #if ENABLED(PIDTEMPBED) @@ -1058,7 +1060,7 @@ void Temperature::manage_heater() { } // HOTEND_LOOP - #endif // HOTENDS + #endif // HAS_HOTEND #if HAS_AUTO_FAN if (ELAPSED(ms, next_auto_fan_check_ms)) { // only need to check fan state very infrequently @@ -1208,22 +1210,22 @@ void Temperature::manage_heater() { * Bisect search for the range of the 'raw' value, then interpolate * proportionally between the under and over values. */ -#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \ - uint8_t l = 0, r = LEN, m; \ - for (;;) { \ - m = (l + r) >> 1; \ - if (!m) return short(pgm_read_word(&TBL[0][1])); \ - if (m == l || m == r) return short(pgm_read_word(&TBL[LEN-1][1])); \ - short v00 = pgm_read_word(&TBL[m-1][0]), \ - v10 = pgm_read_word(&TBL[m-0][0]); \ - if (raw < v00) r = m; \ - else if (raw > v10) l = m; \ - else { \ - const short v01 = short(pgm_read_word(&TBL[m-1][1])), \ - v11 = short(pgm_read_word(&TBL[m-0][1])); \ - return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \ - } \ - } \ +#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \ + uint8_t l = 0, r = LEN, m; \ + for (;;) { \ + m = (l + r) >> 1; \ + if (!m) return int16_t(pgm_read_word(&TBL[0].celsius)); \ + if (m == l || m == r) return int16_t(pgm_read_word(&TBL[LEN-1].celsius)); \ + int16_t v00 = pgm_read_word(&TBL[m-1].value), \ + v10 = pgm_read_word(&TBL[m-0].value); \ + if (raw < v00) r = m; \ + else if (raw > v10) l = m; \ + else { \ + const int16_t v01 = int16_t(pgm_read_word(&TBL[m-1].celsius)), \ + v11 = int16_t(pgm_read_word(&TBL[m-0].celsius)); \ + return v01 + (raw - v00) * float(v11 - v01) / float(v10 - v00); \ + } \ + } \ }while(0) #if HAS_USER_THERMISTORS @@ -1452,13 +1454,13 @@ void Temperature::manage_heater() { #if HOTEND_USES_THERMISTOR // Thermistor with conversion table? - const short(*tt)[][2] = (short(*)[][2])(heater_ttbl_map[e]); + const temp_entry_t(*tt)[] = (temp_entry_t(*)[])(heater_ttbl_map[e]); SCAN_THERMISTOR_TABLE((*tt), heater_ttbllen_map[e]); #endif return 0; } -#endif // HOTENDS +#endif // HAS_HOTEND #if HAS_HEATED_BED // Derived from RepRap FiveD extruder::getTemperature() @@ -1790,80 +1792,91 @@ void Temperature::init() { #if HAS_HOTEND #define _TEMP_MIN_E(NR) do{ \ - temp_range[NR].mintemp = HEATER_ ##NR## _MINTEMP; \ - while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < HEATER_ ##NR## _MINTEMP) \ + const int16_t tmin = _MAX(HEATER_ ##NR## _MINTEMP, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MINTEMP_IND].celsius)); \ + temp_range[NR].mintemp = tmin; \ + while (analog_to_celsius_hotend(temp_range[NR].raw_min, NR) < tmin) \ temp_range[NR].raw_min += TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) #define _TEMP_MAX_E(NR) do{ \ - temp_range[NR].maxtemp = HEATER_ ##NR## _MAXTEMP; \ - while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > HEATER_ ##NR## _MAXTEMP) \ + const int16_t tmax = _MIN(HEATER_ ##NR## _MAXTEMP, (int16_t)pgm_read_word(&HEATER_ ##NR## _TEMPTABLE[HEATER_ ##NR## _SENSOR_MAXTEMP_IND].celsius) - 1); \ + temp_range[NR].maxtemp = tmax; \ + while (analog_to_celsius_hotend(temp_range[NR].raw_max, NR) > tmax) \ temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) - #ifdef HEATER_0_MINTEMP + #if THERMISTOR_HEATER_0 + #ifdef HEATER_0_MINTEMP _TEMP_MIN_E(0); + #endif + #ifdef HEATER_0_MAXTEMP + _TEMP_MAX_E(0); + #endif #endif - #ifdef HEATER_0_MAXTEMP - _TEMP_MAX_E(0); - #endif - #if HAS_MULTI_HOTEND + + #if HAS_MULTI_HOTEND && THERMISTOR_HEATER_1 #ifdef HEATER_1_MINTEMP _TEMP_MIN_E(1); #endif #ifdef HEATER_1_MAXTEMP _TEMP_MAX_E(1); #endif - #if HOTENDS > 2 - #ifdef HEATER_2_MINTEMP - _TEMP_MIN_E(2); - #endif - #ifdef HEATER_2_MAXTEMP - _TEMP_MAX_E(2); - #endif - #if HOTENDS > 3 - #ifdef HEATER_3_MINTEMP - _TEMP_MIN_E(3); - #endif - #ifdef HEATER_3_MAXTEMP - _TEMP_MAX_E(3); - #endif - #if HOTENDS > 4 - #ifdef HEATER_4_MINTEMP - _TEMP_MIN_E(4); - #endif - #ifdef HEATER_4_MAXTEMP - _TEMP_MAX_E(4); - #endif - #if HOTENDS > 5 - #ifdef HEATER_5_MINTEMP - _TEMP_MIN_E(5); - #endif - #ifdef HEATER_5_MAXTEMP - _TEMP_MAX_E(5); - #endif - #if HOTENDS > 6 - #ifdef HEATER_6_MINTEMP - _TEMP_MIN_E(6); - #endif - #ifdef HEATER_6_MAXTEMP - _TEMP_MAX_E(6); - #endif - #if HOTENDS > 7 - #ifdef HEATER_7_MINTEMP - _TEMP_MIN_E(7); - #endif - #ifdef HEATER_7_MAXTEMP - _TEMP_MAX_E(7); - #endif - #endif // HOTENDS > 7 - #endif // HOTENDS > 6 - #endif // HOTENDS > 5 - #endif // HOTENDS > 4 - #endif // HOTENDS > 3 - #endif // HOTENDS > 2 - #endif // HAS_MULTI_HOTEND + #endif - #endif // HOTENDS + #if HOTENDS > 2 && THERMISTOR_HEATER_2 + #ifdef HEATER_2_MINTEMP + _TEMP_MIN_E(2); + #endif + #ifdef HEATER_2_MAXTEMP + _TEMP_MAX_E(2); + #endif + #endif + + #if HOTENDS > 3 && THERMISTOR_HEATER_3 + #ifdef HEATER_3_MINTEMP + _TEMP_MIN_E(3); + #endif + #ifdef HEATER_3_MAXTEMP + _TEMP_MAX_E(3); + #endif + #endif + + #if HOTENDS > 4 && THERMISTOR_HEATER_4 + #ifdef HEATER_4_MINTEMP + _TEMP_MIN_E(4); + #endif + #ifdef HEATER_4_MAXTEMP + _TEMP_MAX_E(4); + #endif + #endif + + #if HOTENDS > 5 && THERMISTOR_HEATER_5 + #ifdef HEATER_5_MINTEMP + _TEMP_MIN_E(5); + #endif + #ifdef HEATER_5_MAXTEMP + _TEMP_MAX_E(5); + #endif + #endif + + #if HOTENDS > 6 && THERMISTOR_HEATER_6 + #ifdef HEATER_6_MINTEMP + _TEMP_MIN_E(6); + #endif + #ifdef HEATER_6_MAXTEMP + _TEMP_MAX_E(6); + #endif + #endif + + #if HOTENDS > 7 && THERMISTOR_HEATER_7 + #ifdef HEATER_7_MINTEMP + _TEMP_MIN_E(7); + #endif + #ifdef HEATER_7_MAXTEMP + _TEMP_MAX_E(7); + #endif + #endif + + #endif // HAS_HOTEND #if HAS_HEATED_BED #ifdef BED_MINTEMP @@ -2319,7 +2332,7 @@ void Temperature::readings_ready() { } } - #endif // HOTENDS + #endif // HAS_HOTEND #if HAS_HEATED_BED #if TEMPDIR(BED) < 0 @@ -2573,6 +2586,10 @@ void Temperature::tick() { _SLOW_PWM(BED, soft_pwm_bed, temp_bed); #endif + #if HAS_HEATED_CHAMBER + _SLOW_PWM(CHAMBER, soft_pwm_chamber, temp_chamber); + #endif + } // slow_pwm_count == 0 #if HAS_HOTEND @@ -2584,6 +2601,10 @@ void Temperature::tick() { _PWM_OFF(BED, soft_pwm_bed); #endif + #if HAS_HEATED_CHAMBER + _PWM_OFF(CHAMBER, soft_pwm_chamber); + #endif + #if ENABLED(FAN_SOFT_PWM) if (pwm_count_tmp >= 127) { pwm_count_tmp = 0; @@ -2662,6 +2683,7 @@ void Temperature::tick() { HOTEND_LOOP() soft_pwm_hotend[e].dec(); #endif TERN_(HAS_HEATED_BED, soft_pwm_bed.dec()); + TERN_(HAS_HEATED_CHAMBER, soft_pwm_chamber.dec()); } #endif // SLOW_PWM_HEATERS diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index d0d7858c7..2f8ddbf7b 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -608,7 +608,7 @@ class Temperature { return ABS(degHotend(e) - temp) < (TEMP_HYSTERESIS); } - #endif // HOTENDS + #endif // HAS_HOTEND #if HAS_HEATED_BED diff --git a/Marlin/src/module/thermistor/thermistor_1.h b/Marlin/src/module/thermistor/thermistor_1.h index f3226da47..75ec433ab 100644 --- a/Marlin/src/module/thermistor/thermistor_1.h +++ b/Marlin/src/module/thermistor/thermistor_1.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor -const short temptable_1[][2] PROGMEM = { +const temp_entry_t temptable_1[] PROGMEM = { { OV( 23), 300 }, { OV( 25), 295 }, { OV( 27), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_10.h b/Marlin/src/module/thermistor/thermistor_10.h index 9e89eab84..991440bce 100644 --- a/Marlin/src/module/thermistor/thermistor_10.h +++ b/Marlin/src/module/thermistor/thermistor_10.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3960 K, 4.7 kOhm pull-up, RS thermistor 198-961 -const short temptable_10[][2] PROGMEM = { +const temp_entry_t temptable_10[] PROGMEM = { { OV( 1), 929 }, { OV( 36), 299 }, { OV( 71), 246 }, diff --git a/Marlin/src/module/thermistor/thermistor_1010.h b/Marlin/src/module/thermistor/thermistor_1010.h index 200d9aed5..71e830d95 100644 --- a/Marlin/src/module/thermistor/thermistor_1010.h +++ b/Marlin/src/module/thermistor/thermistor_1010.h @@ -22,7 +22,7 @@ #pragma once // Pt1000 with 1k0 pullup -const short temptable_1010[][2] PROGMEM = { +const temp_entry_t temptable_1010[] PROGMEM = { PtLine( 0, 1000, 1000), PtLine( 25, 1000, 1000), PtLine( 50, 1000, 1000), diff --git a/Marlin/src/module/thermistor/thermistor_1047.h b/Marlin/src/module/thermistor/thermistor_1047.h index af41a20a1..4c89bd366 100644 --- a/Marlin/src/module/thermistor/thermistor_1047.h +++ b/Marlin/src/module/thermistor/thermistor_1047.h @@ -22,7 +22,7 @@ #pragma once // Pt1000 with 4k7 pullup -const short temptable_1047[][2] PROGMEM = { +const temp_entry_t temptable_1047[] PROGMEM = { // only a few values are needed as the curve is very flat PtLine( 0, 1000, 4700), PtLine( 50, 1000, 4700), diff --git a/Marlin/src/module/thermistor/thermistor_11.h b/Marlin/src/module/thermistor/thermistor_11.h index 1b2da4a71..339f11d56 100644 --- a/Marlin/src/module/thermistor/thermistor_11.h +++ b/Marlin/src/module/thermistor/thermistor_11.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3950 K, 4.7 kOhm pull-up, QU-BD silicone bed QWG-104F-3950 thermistor -const short temptable_11[][2] PROGMEM = { +const temp_entry_t temptable_11[] PROGMEM = { { OV( 1), 938 }, { OV( 31), 314 }, { OV( 41), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_110.h b/Marlin/src/module/thermistor/thermistor_110.h index fe8f4fbb8..32ee08580 100644 --- a/Marlin/src/module/thermistor/thermistor_110.h +++ b/Marlin/src/module/thermistor/thermistor_110.h @@ -22,7 +22,7 @@ #pragma once // Pt100 with 1k0 pullup -const short temptable_110[][2] PROGMEM = { +const temp_entry_t temptable_110[] PROGMEM = { // only a few values are needed as the curve is very flat PtLine( 0, 100, 1000), PtLine( 50, 100, 1000), diff --git a/Marlin/src/module/thermistor/thermistor_12.h b/Marlin/src/module/thermistor/thermistor_12.h index f9e994a95..3b8cda870 100644 --- a/Marlin/src/module/thermistor/thermistor_12.h +++ b/Marlin/src/module/thermistor/thermistor_12.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4700 K, 4.7 kOhm pull-up, (personal calibration for Makibox hot bed) -const short temptable_12[][2] PROGMEM = { +const temp_entry_t temptable_12[] PROGMEM = { { OV( 35), 180 }, // top rating 180C { OV( 211), 140 }, { OV( 233), 135 }, diff --git a/Marlin/src/module/thermistor/thermistor_13.h b/Marlin/src/module/thermistor/thermistor_13.h index 44c5243c1..9bf3e0208 100644 --- a/Marlin/src/module/thermistor/thermistor_13.h +++ b/Marlin/src/module/thermistor/thermistor_13.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4100 K, 4.7 kOhm pull-up, Hisens thermistor -const short temptable_13[][2] PROGMEM = { +const temp_entry_t temptable_13[] PROGMEM = { { OV( 20.04), 300 }, { OV( 23.19), 290 }, { OV( 26.71), 280 }, diff --git a/Marlin/src/module/thermistor/thermistor_147.h b/Marlin/src/module/thermistor/thermistor_147.h index 8fead6c42..61a82affa 100644 --- a/Marlin/src/module/thermistor/thermistor_147.h +++ b/Marlin/src/module/thermistor/thermistor_147.h @@ -22,7 +22,7 @@ #pragma once // Pt100 with 4k7 pullup -const short temptable_147[][2] PROGMEM = { +const temp_entry_t temptable_147[] PROGMEM = { // only a few values are needed as the curve is very flat PtLine( 0, 100, 4700), PtLine( 50, 100, 4700), diff --git a/Marlin/src/module/thermistor/thermistor_15.h b/Marlin/src/module/thermistor/thermistor_15.h index 85602abb3..04d022101 100644 --- a/Marlin/src/module/thermistor/thermistor_15.h +++ b/Marlin/src/module/thermistor/thermistor_15.h @@ -22,7 +22,7 @@ #pragma once // 100k bed thermistor in JGAurora A5. Calibrated by Sam Pinches 21st Jan 2018 using cheap k-type thermocouple inserted into heater block, using TM-902C meter. -const short temptable_15[][2] PROGMEM = { +const temp_entry_t temptable_15[] PROGMEM = { { OV( 31), 275 }, { OV( 33), 270 }, { OV( 35), 260 }, diff --git a/Marlin/src/module/thermistor/thermistor_18.h b/Marlin/src/module/thermistor/thermistor_18.h index f6a3edec4..0f12d6996 100644 --- a/Marlin/src/module/thermistor/thermistor_18.h +++ b/Marlin/src/module/thermistor/thermistor_18.h @@ -22,7 +22,7 @@ #pragma once // ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327 - version (measured/tested/approved) -const short temptable_18[][2] PROGMEM = { +const temp_entry_t temptable_18[] PROGMEM = { { OV( 1), 713 }, { OV( 17), 284 }, { OV( 20), 275 }, diff --git a/Marlin/src/module/thermistor/thermistor_2.h b/Marlin/src/module/thermistor/thermistor_2.h index f3fe47060..ec296ec67 100644 --- a/Marlin/src/module/thermistor/thermistor_2.h +++ b/Marlin/src/module/thermistor/thermistor_2.h @@ -26,7 +26,7 @@ // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance // -const short temptable_2[][2] PROGMEM = { +const temp_entry_t temptable_2[] PROGMEM = { { OV( 1), 848 }, { OV( 30), 300 }, // top rating 300C { OV( 34), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_20.h b/Marlin/src/module/thermistor/thermistor_20.h index 49b212da5..a2d3c7a61 100644 --- a/Marlin/src/module/thermistor/thermistor_20.h +++ b/Marlin/src/module/thermistor/thermistor_20.h @@ -21,10 +21,10 @@ */ #pragma once -#define REVERSE_TEMP_SENSOR_RANGE +#define REVERSE_TEMP_SENSOR_RANGE_20 1 // Pt100 with INA826 amp on Ultimaker v2.0 electronics -const short temptable_20[][2] PROGMEM = { +const temp_entry_t temptable_20[] PROGMEM = { { OV( 0), 0 }, { OV(227), 1 }, { OV(236), 10 }, diff --git a/Marlin/src/module/thermistor/thermistor_201.h b/Marlin/src/module/thermistor/thermistor_201.h index d92f95756..1ddd25917 100644 --- a/Marlin/src/module/thermistor/thermistor_201.h +++ b/Marlin/src/module/thermistor/thermistor_201.h @@ -21,10 +21,10 @@ */ #pragma once -#define REVERSE_TEMP_SENSOR_RANGE +#define REVERSE_TEMP_SENSOR_RANGE_201 1 // Pt100 with LMV324 amp on Overlord v1.1 electronics -const short temptable_201[][2] PROGMEM = { +const temp_entry_t temptable_201[] PROGMEM = { { OV( 0), 0 }, { OV( 8), 1 }, { OV( 23), 6 }, diff --git a/Marlin/src/module/thermistor/thermistor_202.h b/Marlin/src/module/thermistor/thermistor_202.h index 9da3d45f4..c5229607a 100644 --- a/Marlin/src/module/thermistor/thermistor_202.h +++ b/Marlin/src/module/thermistor/thermistor_202.h @@ -3,7 +3,7 @@ // Temptable sent from dealer technologyoutlet.co.uk // -const short temptable_202[][2] PROGMEM = { +const temp_entry_t temptable_202[] PROGMEM = { { OV( 1), 864 }, { OV( 35), 300 }, { OV( 38), 295 }, diff --git a/Marlin/src/module/thermistor/thermistor_21.h b/Marlin/src/module/thermistor/thermistor_21.h index 655f56685..144692cd1 100644 --- a/Marlin/src/module/thermistor/thermistor_21.h +++ b/Marlin/src/module/thermistor/thermistor_21.h @@ -21,13 +21,13 @@ */ #pragma once -#define REVERSE_TEMP_SENSOR_RANGE +#define REVERSE_TEMP_SENSOR_RANGE_21 1 #undef OV_SCALE #define OV_SCALE(N) (float((N) * 5) / 3.3f) // Pt100 with INA826 amp with 3.3v excitation based on "Pt100 with INA826 amp on Ultimaker v2.0 electronics" -const short temptable_21[][2] PROGMEM = { +const temp_entry_t temptable_21[] PROGMEM = { { OV( 0), 0 }, { OV(227), 1 }, { OV(236), 10 }, diff --git a/Marlin/src/module/thermistor/thermistor_22.h b/Marlin/src/module/thermistor/thermistor_22.h index e9b6acbb1..dd4d9d913 100644 --- a/Marlin/src/module/thermistor/thermistor_22.h +++ b/Marlin/src/module/thermistor/thermistor_22.h @@ -21,7 +21,7 @@ */ // 100k hotend thermistor with 4.7k pull up to 3.3v and 220R to analog input as in GTM32 Pro vB -const short temptable_22[][2] PROGMEM = { +const temp_entry_t temptable_22[] PROGMEM = { { OV( 1), 352 }, { OV( 6), 341 }, { OV( 11), 330 }, diff --git a/Marlin/src/module/thermistor/thermistor_23.h b/Marlin/src/module/thermistor/thermistor_23.h index 13918c589..eb156f435 100644 --- a/Marlin/src/module/thermistor/thermistor_23.h +++ b/Marlin/src/module/thermistor/thermistor_23.h @@ -21,7 +21,7 @@ */ // 100k hotbed thermistor with 4.7k pull up to 3.3v and 220R to analog input as in GTM32 Pro vB -const short temptable_23[][2] PROGMEM = { +const temp_entry_t temptable_23[] PROGMEM = { { OV( 1), 938 }, { OV( 11), 423 }, { OV( 21), 351 }, diff --git a/Marlin/src/module/thermistor/thermistor_3.h b/Marlin/src/module/thermistor/thermistor_3.h index e37c2ace7..1b44218d5 100644 --- a/Marlin/src/module/thermistor/thermistor_3.h +++ b/Marlin/src/module/thermistor/thermistor_3.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4120 K, 4.7 kOhm pull-up, mendel-parts -const short temptable_3[][2] PROGMEM = { +const temp_entry_t temptable_3[] PROGMEM = { { OV( 1), 864 }, { OV( 21), 300 }, { OV( 25), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_331.h b/Marlin/src/module/thermistor/thermistor_331.h index 434492d7e..b8d4959a3 100644 --- a/Marlin/src/module/thermistor/thermistor_331.h +++ b/Marlin/src/module/thermistor/thermistor_331.h @@ -24,7 +24,7 @@ #define OVM(V) OV((V)*(0.327/0.5)) // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor -const short temptable_331[][2] PROGMEM = { +const temp_entry_t temptable_331[] PROGMEM = { { OVM( 23), 300 }, { OVM( 25), 295 }, { OVM( 27), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_332.h b/Marlin/src/module/thermistor/thermistor_332.h index 3112751b9..21c82ca12 100644 --- a/Marlin/src/module/thermistor/thermistor_332.h +++ b/Marlin/src/module/thermistor/thermistor_332.h @@ -24,7 +24,7 @@ #define OVM(V) OV((V)*(0.327/0.327)) // R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor -const short temptable_332[][2] PROGMEM = { +const temp_entry_t temptable_332[] PROGMEM = { { OVM( 268), 150 }, { OVM( 293), 145 }, { OVM( 320), 141 }, diff --git a/Marlin/src/module/thermistor/thermistor_4.h b/Marlin/src/module/thermistor/thermistor_4.h index 00e0d9ed9..3cc6da9f2 100644 --- a/Marlin/src/module/thermistor/thermistor_4.h +++ b/Marlin/src/module/thermistor/thermistor_4.h @@ -22,7 +22,7 @@ #pragma once // R25 = 10 kOhm, beta25 = 3950 K, 4.7 kOhm pull-up, Generic 10k thermistor -const short temptable_4[][2] PROGMEM = { +const temp_entry_t temptable_4[] PROGMEM = { { OV( 1), 430 }, { OV( 54), 137 }, { OV( 107), 107 }, diff --git a/Marlin/src/module/thermistor/thermistor_5.h b/Marlin/src/module/thermistor/thermistor_5.h index 8f414de15..f1a04d2ed 100644 --- a/Marlin/src/module/thermistor/thermistor_5.h +++ b/Marlin/src/module/thermistor/thermistor_5.h @@ -26,7 +26,7 @@ // ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan) // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance -const short temptable_5[][2] PROGMEM = { +const temp_entry_t temptable_5[] PROGMEM = { { OV( 1), 713 }, { OV( 17), 300 }, // top rating 300C { OV( 20), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_501.h b/Marlin/src/module/thermistor/thermistor_501.h index 3db433644..a1ef6e53c 100644 --- a/Marlin/src/module/thermistor/thermistor_501.h +++ b/Marlin/src/module/thermistor/thermistor_501.h @@ -22,7 +22,7 @@ #pragma once // 100k Zonestar thermistor. Adjusted By Hally -const short temptable_501[][2] PROGMEM = { +const temp_entry_t temptable_501[] PROGMEM = { { OV( 1), 713 }, { OV( 14), 300 }, // Top rating 300C { OV( 16), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_502.h b/Marlin/src/module/thermistor/thermistor_502.h index 1a4019ed5..b414e562e 100644 --- a/Marlin/src/module/thermistor/thermistor_502.h +++ b/Marlin/src/module/thermistor/thermistor_502.h @@ -23,7 +23,7 @@ // Unknown thermistor for the Zonestar P802M hot bed. Adjusted By Nerseth // These were the shipped settings from Zonestar in original firmware: P802M_8_Repetier_V1.6_Zonestar.zip -const short temptable_502[][2] PROGMEM = { +const temp_entry_t temptable_502[] PROGMEM = { { OV( 56.0 / 4), 300 }, { OV( 187.0 / 4), 250 }, { OV( 615.0 / 4), 190 }, diff --git a/Marlin/src/module/thermistor/thermistor_51.h b/Marlin/src/module/thermistor/thermistor_51.h index f314777a5..092bcb640 100644 --- a/Marlin/src/module/thermistor/thermistor_51.h +++ b/Marlin/src/module/thermistor/thermistor_51.h @@ -26,7 +26,7 @@ // Verified by linagee. // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance // Advantage: Twice the resolution and better linearity from 150C to 200C -const short temptable_51[][2] PROGMEM = { +const temp_entry_t temptable_51[] PROGMEM = { { OV( 1), 350 }, { OV( 190), 250 }, // top rating 250C { OV( 203), 245 }, diff --git a/Marlin/src/module/thermistor/thermistor_512.h b/Marlin/src/module/thermistor/thermistor_512.h index 5528e56b9..ab59c5851 100644 --- a/Marlin/src/module/thermistor/thermistor_512.h +++ b/Marlin/src/module/thermistor/thermistor_512.h @@ -22,7 +22,7 @@ // 100k thermistor supplied with RPW-Ultra hotend, 4.7k pullup -const short temptable_512[][2] PROGMEM = { +const temp_entry_t temptable_512[] PROGMEM = { { OV(26), 300 }, { OV(28), 295 }, { OV(30), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_52.h b/Marlin/src/module/thermistor/thermistor_52.h index 9a54ef4b6..031b094d8 100644 --- a/Marlin/src/module/thermistor/thermistor_52.h +++ b/Marlin/src/module/thermistor/thermistor_52.h @@ -26,7 +26,7 @@ // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance // Advantage: More resolution and better linearity from 150C to 200C -const short temptable_52[][2] PROGMEM = { +const temp_entry_t temptable_52[] PROGMEM = { { OV( 1), 500 }, { OV( 125), 300 }, // top rating 300C { OV( 142), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_55.h b/Marlin/src/module/thermistor/thermistor_55.h index ead481e86..e137f174c 100644 --- a/Marlin/src/module/thermistor/thermistor_55.h +++ b/Marlin/src/module/thermistor/thermistor_55.h @@ -26,7 +26,7 @@ // Verified by linagee. Source: http://shop.arcol.hu/static/datasheets/thermistors.pdf // Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance // Advantage: More resolution and better linearity from 150C to 200C -const short temptable_55[][2] PROGMEM = { +const temp_entry_t temptable_55[] PROGMEM = { { OV( 1), 500 }, { OV( 76), 300 }, { OV( 87), 290 }, diff --git a/Marlin/src/module/thermistor/thermistor_6.h b/Marlin/src/module/thermistor/thermistor_6.h index f84c64413..35aeeabd7 100644 --- a/Marlin/src/module/thermistor/thermistor_6.h +++ b/Marlin/src/module/thermistor/thermistor_6.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 4092 K, 8.2 kOhm pull-up, 100k Epcos (?) thermistor -const short temptable_6[][2] PROGMEM = { +const temp_entry_t temptable_6[] PROGMEM = { { OV( 1), 350 }, { OV( 28), 250 }, // top rating 250C { OV( 31), 245 }, diff --git a/Marlin/src/module/thermistor/thermistor_60.h b/Marlin/src/module/thermistor/thermistor_60.h index 167e0edcf..3f43740b5 100644 --- a/Marlin/src/module/thermistor/thermistor_60.h +++ b/Marlin/src/module/thermistor/thermistor_60.h @@ -31,7 +31,7 @@ // beta: 3950 // min adc: 1 at 0.0048828125 V // max adc: 1023 at 4.9951171875 V -const short temptable_60[][2] PROGMEM = { +const temp_entry_t temptable_60[] PROGMEM = { { OV( 51), 272 }, { OV( 61), 258 }, { OV( 71), 247 }, diff --git a/Marlin/src/module/thermistor/thermistor_61.h b/Marlin/src/module/thermistor/thermistor_61.h index 5f8171a1d..837ee3781 100644 --- a/Marlin/src/module/thermistor/thermistor_61.h +++ b/Marlin/src/module/thermistor/thermistor_61.h @@ -30,7 +30,7 @@ // Resistance Tolerance + / -1% // B Value 3950K at 25/50 deg. C // B Value Tolerance + / - 1% -const short temptable_61[][2] PROGMEM = { +const temp_entry_t temptable_61[] PROGMEM = { { OV( 2.00), 420 }, // Guestimate to ensure we dont lose a reading and drop temps to -50 when over { OV( 12.07), 350 }, { OV( 12.79), 345 }, diff --git a/Marlin/src/module/thermistor/thermistor_66.h b/Marlin/src/module/thermistor/thermistor_66.h index 97f082348..0ab45d64d 100644 --- a/Marlin/src/module/thermistor/thermistor_66.h +++ b/Marlin/src/module/thermistor/thermistor_66.h @@ -22,7 +22,7 @@ #pragma once // R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign 500 °C Thermistor -const short temptable_66[][2] PROGMEM = { +const temp_entry_t temptable_66[] PROGMEM = { { OV( 17.5), 850 }, { OV( 17.9), 500 }, { OV( 21.7), 480 }, diff --git a/Marlin/src/module/thermistor/thermistor_67.h b/Marlin/src/module/thermistor/thermistor_67.h index 5af203c8a..11fdca856 100644 --- a/Marlin/src/module/thermistor/thermistor_67.h +++ b/Marlin/src/module/thermistor/thermistor_67.h @@ -22,7 +22,7 @@ #pragma once // R25 = 500 KOhm, beta25 = 3800 K, 4.7 kOhm pull-up, SliceEngineering 450 °C Thermistor -const short temptable_67[][2] PROGMEM = { +const temp_entry_t temptable_67[] PROGMEM = { { OV( 22 ), 500 }, { OV( 23 ), 490 }, { OV( 25 ), 480 }, diff --git a/Marlin/src/module/thermistor/thermistor_7.h b/Marlin/src/module/thermistor/thermistor_7.h index e791d0c33..1e6ab1d34 100644 --- a/Marlin/src/module/thermistor/thermistor_7.h +++ b/Marlin/src/module/thermistor/thermistor_7.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3974 K, 4.7 kOhm pull-up, Honeywell 135-104LAG-J01 -const short temptable_7[][2] PROGMEM = { +const temp_entry_t temptable_7[] PROGMEM = { { OV( 1), 941 }, { OV( 19), 362 }, { OV( 37), 299 }, // top rating 300C diff --git a/Marlin/src/module/thermistor/thermistor_70.h b/Marlin/src/module/thermistor/thermistor_70.h index b49804106..d81424f9b 100644 --- a/Marlin/src/module/thermistor/thermistor_70.h +++ b/Marlin/src/module/thermistor/thermistor_70.h @@ -26,7 +26,7 @@ // ANENG AN8009 DMM with a K-type probe used for measurements. // R25 = 100 kOhm, beta25 = 4100 K, 4.7 kOhm pull-up, bqh2 stock thermistor -const short temptable_70[][2] PROGMEM = { +const temp_entry_t temptable_70[] PROGMEM = { { OV( 18), 270 }, { OV( 27), 248 }, { OV( 34), 234 }, diff --git a/Marlin/src/module/thermistor/thermistor_71.h b/Marlin/src/module/thermistor/thermistor_71.h index c3a9193b7..c7bab2a0b 100644 --- a/Marlin/src/module/thermistor/thermistor_71.h +++ b/Marlin/src/module/thermistor/thermistor_71.h @@ -27,7 +27,7 @@ // Beta = 3974 // R1 = 0 Ohm // R2 = 4700 Ohm -const short temptable_71[][2] PROGMEM = { +const temp_entry_t temptable_71[] PROGMEM = { { OV( 35), 300 }, { OV( 51), 269 }, { OV( 59), 258 }, diff --git a/Marlin/src/module/thermistor/thermistor_75.h b/Marlin/src/module/thermistor/thermistor_75.h index 3a3cdc636..1df64cc42 100644 --- a/Marlin/src/module/thermistor/thermistor_75.h +++ b/Marlin/src/module/thermistor/thermistor_75.h @@ -34,7 +34,7 @@ //#define HIGH_TEMP_RANGE_75 -const short temptable_75[][2] PROGMEM = { // Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor +const temp_entry_t temptable_75[] PROGMEM = { // Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor { OV(111.06), 200 }, // v=0.542 r=571.747 res=0.501 degC/count #ifdef HIGH_TEMP_RANGE_75 diff --git a/Marlin/src/module/thermistor/thermistor_8.h b/Marlin/src/module/thermistor/thermistor_8.h index f6e407a73..ec97df613 100644 --- a/Marlin/src/module/thermistor/thermistor_8.h +++ b/Marlin/src/module/thermistor/thermistor_8.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3950 K, 10 kOhm pull-up, NTCS0603E3104FHT -const short temptable_8[][2] PROGMEM = { +const temp_entry_t temptable_8[] PROGMEM = { { OV( 1), 704 }, { OV( 54), 216 }, { OV( 107), 175 }, diff --git a/Marlin/src/module/thermistor/thermistor_9.h b/Marlin/src/module/thermistor/thermistor_9.h index 5023fbe1d..e194df57c 100644 --- a/Marlin/src/module/thermistor/thermistor_9.h +++ b/Marlin/src/module/thermistor/thermistor_9.h @@ -22,7 +22,7 @@ #pragma once // R25 = 100 kOhm, beta25 = 3960 K, 4.7 kOhm pull-up, GE Sensing AL03006-58.2K-97-G1 -const short temptable_9[][2] PROGMEM = { +const temp_entry_t temptable_9[] PROGMEM = { { OV( 1), 936 }, { OV( 36), 300 }, { OV( 71), 246 }, diff --git a/Marlin/src/module/thermistor/thermistor_99.h b/Marlin/src/module/thermistor/thermistor_99.h index 045a42b73..b6d6bbac9 100644 --- a/Marlin/src/module/thermistor/thermistor_99.h +++ b/Marlin/src/module/thermistor/thermistor_99.h @@ -24,7 +24,7 @@ // 100k bed thermistor with a 10K pull-up resistor - made by $ buildroot/share/scripts/createTemperatureLookupMarlin.py --rp=10000 -const short temptable_99[][2] PROGMEM = { +const temp_entry_t temptable_99[] PROGMEM = { { OV( 5.81), 350 }, // v=0.028 r= 57.081 res=13.433 degC/count { OV( 6.54), 340 }, // v=0.032 r= 64.248 res=11.711 degC/count { OV( 7.38), 330 }, // v=0.036 r= 72.588 res=10.161 degC/count diff --git a/Marlin/src/module/thermistor/thermistor_998.h b/Marlin/src/module/thermistor/thermistor_998.h index 6f631d4b9..2802121c5 100644 --- a/Marlin/src/module/thermistor/thermistor_998.h +++ b/Marlin/src/module/thermistor/thermistor_998.h @@ -27,7 +27,7 @@ #define DUMMY_THERMISTOR_998_VALUE 25 #endif -const short temptable_998[][2] PROGMEM = { +const temp_entry_t temptable_998[] PROGMEM = { { OV( 1), DUMMY_THERMISTOR_998_VALUE }, { OV(1023), DUMMY_THERMISTOR_998_VALUE } }; diff --git a/Marlin/src/module/thermistor/thermistor_999.h b/Marlin/src/module/thermistor/thermistor_999.h index d750d5597..cf6ebb3ae 100644 --- a/Marlin/src/module/thermistor/thermistor_999.h +++ b/Marlin/src/module/thermistor/thermistor_999.h @@ -27,7 +27,7 @@ #define DUMMY_THERMISTOR_999_VALUE 25 #endif -const short temptable_999[][2] PROGMEM = { +const temp_entry_t temptable_999[] PROGMEM = { { OV( 1), DUMMY_THERMISTOR_999_VALUE }, { OV(1023), DUMMY_THERMISTOR_999_VALUE } }; diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 04b091b2a..afb3148df 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -42,6 +42,8 @@ #define ANY_THERMISTOR_IS(n) (THERMISTOR_HEATER_0 == n || THERMISTOR_HEATER_1 == n || THERMISTOR_HEATER_2 == n || THERMISTOR_HEATER_3 == n || THERMISTOR_HEATER_4 == n || THERMISTOR_HEATER_5 == n || THERMISTOR_HEATER_6 == n || THERMISTOR_HEATER_7 == n || THERMISTORBED == n || THERMISTORCHAMBER == n || THERMISTORPROBE == n) +typedef struct { int16_t value, celsius; } temp_entry_t; + // Pt1000 and Pt100 handling // // Rt=R0*(1+a*T+b*T*T) [for T>0] @@ -185,12 +187,13 @@ #include "thermistor_999.h" #endif #if ANY_THERMISTOR_IS(1000) // Custom - const short temptable_1000[][2] PROGMEM = { { 0, 0 } }; + const temp_entry_t temptable_1000[] PROGMEM = { { 0, 0 } }; #endif #define _TT_NAME(_N) temptable_ ## _N #define TT_NAME(_N) _TT_NAME(_N) + #if THERMISTOR_HEATER_0 #define HEATER_0_TEMPTABLE TT_NAME(THERMISTOR_HEATER_0) #define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE) @@ -288,9 +291,12 @@ #else #define CHAMBER_TEMPTABLE_LEN 0 #endif + #ifdef THERMISTORPROBE #define PROBE_TEMPTABLE TT_NAME(THERMISTORPROBE) #define PROBE_TEMPTABLE_LEN COUNT(PROBE_TEMPTABLE) +#elif defined(HEATER_PROBE_USES_THERMISTOR) + #error "No probe thermistor table specified" #else #define PROBE_TEMPTABLE_LEN 0 #endif @@ -300,7 +306,7 @@ static_assert( HEATER_0_TEMPTABLE_LEN < 256 && HEATER_1_TEMPTABLE_LEN < 256 && HEATER_2_TEMPTABLE_LEN < 256 && HEATER_3_TEMPTABLE_LEN < 256 && HEATER_4_TEMPTABLE_LEN < 256 && HEATER_5_TEMPTABLE_LEN < 256 - && HEATER_6_TEMPTABLE_LEN < 258 && HEATER_7_TEMPTABLE_LEN < 258 + && HEATER_6_TEMPTABLE_LEN < 256 && HEATER_7_TEMPTABLE_LEN < 256 && BED_TEMPTABLE_LEN < 256 && CHAMBER_TEMPTABLE_LEN < 256 && PROBE_TEMPTABLE_LEN < 256, "Temperature conversion tables over 255 entries need special consideration." @@ -309,8 +315,85 @@ static_assert( // Set the high and low raw values for the heaters // For thermistors the highest temperature results in the lowest ADC value // For thermocouples the highest temperature results in the highest ADC value + +#define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N +#define TT_REV(N) _TT_REV(N) + +#ifdef HEATER_0_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_0) + #define HEATER_0_SENSOR_MINTEMP_IND 0 + #define HEATER_0_SENSOR_MAXTEMP_IND HEATER_0_TEMPTABLE_LEN - 1 + #else + #define HEATER_0_SENSOR_MINTEMP_IND HEATER_0_TEMPTABLE_LEN - 1 + #define HEATER_0_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_1_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_1) + #define HEATER_1_SENSOR_MINTEMP_IND 0 + #define HEATER_1_SENSOR_MAXTEMP_IND HEATER_1_TEMPTABLE_LEN - 1 + #else + #define HEATER_1_SENSOR_MINTEMP_IND HEATER_1_TEMPTABLE_LEN - 1 + #define HEATER_1_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_2_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_2) + #define HEATER_2_SENSOR_MINTEMP_IND 0 + #define HEATER_2_SENSOR_MAXTEMP_IND HEATER_2_TEMPTABLE_LEN - 1 + #else + #define HEATER_2_SENSOR_MINTEMP_IND HEATER_2_TEMPTABLE_LEN - 1 + #define HEATER_2_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_3_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_3) + #define HEATER_3_SENSOR_MINTEMP_IND 0 + #define HEATER_3_SENSOR_MAXTEMP_IND HEATER_3_TEMPTABLE_LEN - 1 + #else + #define HEATER_3_SENSOR_MINTEMP_IND HEATER_3_TEMPTABLE_LEN - 1 + #define HEATER_3_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_4_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_4) + #define HEATER_4_SENSOR_MINTEMP_IND 0 + #define HEATER_4_SENSOR_MAXTEMP_IND HEATER_4_TEMPTABLE_LEN - 1 + #else + #define HEATER_4_SENSOR_MINTEMP_IND HEATER_4_TEMPTABLE_LEN - 1 + #define HEATER_4_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_5_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_5) + #define HEATER_5_SENSOR_MINTEMP_IND 0 + #define HEATER_5_SENSOR_MAXTEMP_IND HEATER_5_TEMPTABLE_LEN - 1 + #else + #define HEATER_5_SENSOR_MINTEMP_IND HEATER_5_TEMPTABLE_LEN - 1 + #define HEATER_5_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_6_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_6) + #define HEATER_6_SENSOR_MINTEMP_IND 0 + #define HEATER_6_SENSOR_MAXTEMP_IND HEATER_6_TEMPTABLE_LEN - 1 + #else + #define HEATER_6_SENSOR_MINTEMP_IND HEATER_6_TEMPTABLE_LEN - 1 + #define HEATER_6_SENSOR_MAXTEMP_IND 0 + #endif +#endif +#ifdef HEATER_7_TEMPTABLE + #if TT_REV(THERMISTOR_HEATER_7) + #define HEATER_7_SENSOR_MINTEMP_IND 0 + #define HEATER_7_SENSOR_MAXTEMP_IND HEATER_7_TEMPTABLE_LEN - 1 + #else + #define HEATER_7_SENSOR_MINTEMP_IND HEATER_7_TEMPTABLE_LEN - 1 + #define HEATER_7_SENSOR_MAXTEMP_IND 0 + #endif +#endif + #ifndef HEATER_0_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_0_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_0) || !defined(HEATER_0_USES_THERMISTOR) #define HEATER_0_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_0_RAW_LO_TEMP 0 #else @@ -319,7 +402,7 @@ static_assert( #endif #endif #ifndef HEATER_1_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_1_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_1) || !defined(HEATER_1_USES_THERMISTOR) #define HEATER_1_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_1_RAW_LO_TEMP 0 #else @@ -328,7 +411,7 @@ static_assert( #endif #endif #ifndef HEATER_2_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_2_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_2) || !defined(HEATER_2_USES_THERMISTOR) #define HEATER_2_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_2_RAW_LO_TEMP 0 #else @@ -337,7 +420,7 @@ static_assert( #endif #endif #ifndef HEATER_3_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_3_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_3) || !defined(HEATER_3_USES_THERMISTOR) #define HEATER_3_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_3_RAW_LO_TEMP 0 #else @@ -346,7 +429,7 @@ static_assert( #endif #endif #ifndef HEATER_4_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_4_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_4) || !defined(HEATER_4_USES_THERMISTOR) #define HEATER_4_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_4_RAW_LO_TEMP 0 #else @@ -355,7 +438,7 @@ static_assert( #endif #endif #ifndef HEATER_5_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_5_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_5) || !defined(HEATER_5_USES_THERMISTOR) #define HEATER_5_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_5_RAW_LO_TEMP 0 #else @@ -364,7 +447,7 @@ static_assert( #endif #endif #ifndef HEATER_6_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_6_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_6) || !defined(HEATER_6_USES_THERMISTOR) #define HEATER_6_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_6_RAW_LO_TEMP 0 #else @@ -373,7 +456,7 @@ static_assert( #endif #endif #ifndef HEATER_7_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_7_USES_THERMISTOR) + #if TT_REV(THERMISTOR_HEATER_7) || !defined(HEATER_7_USES_THERMISTOR) #define HEATER_7_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_7_RAW_LO_TEMP 0 #else @@ -382,7 +465,7 @@ static_assert( #endif #endif #ifndef HEATER_BED_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_BED_USES_THERMISTOR) + #if TT_REV(THERMISTORBED) || !defined(HEATER_BED_USES_THERMISTOR) #define HEATER_BED_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_BED_RAW_LO_TEMP 0 #else @@ -391,7 +474,7 @@ static_assert( #endif #endif #ifndef HEATER_CHAMBER_RAW_HI_TEMP - #if defined(REVERSE_TEMP_SENSOR_RANGE) || !defined(HEATER_CHAMBER_USES_THERMISTOR) + #if TT_REV(THERMISTORCHAMBER) || !defined(HEATER_CHAMBER_USES_THERMISTOR) #define HEATER_CHAMBER_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE #define HEATER_CHAMBER_RAW_LO_TEMP 0 #else @@ -399,5 +482,15 @@ static_assert( #define HEATER_CHAMBER_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif +#ifndef HEATER_PROBE_RAW_HI_TEMP + #if TT_REV(THERMISTORPROBE) || !defined(HEATER_PROBE_USES_THERMISTOR) + #define HEATER_PROBE_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE + #define HEATER_PROBE_RAW_LO_TEMP 0 + #else + #define HEATER_PROBE_RAW_HI_TEMP 0 + #define HEATER_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE + #endif +#endif -#undef REVERSE_TEMP_SENSOR_RANGE +#undef _TT_REV +#undef TT_REV