From f17a07df99fcb248af05872ee1bac0375d8ae174 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Sat, 1 Oct 2022 09:19:51 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Thermistor=20(66)=20sanity-check?= =?UTF-8?q?=20(#24803)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 2 +- Marlin/src/core/macros.h | 5 ++-- Marlin/src/inc/Conditionals_adv.h | 5 ++-- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/inc/SanityCheck.h | 31 ++++++++++++++++++++ Marlin/src/lcd/thermistornames.h | 2 +- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/module/thermistor/thermistor_66.h | 2 +- Marlin/src/module/thermistor/thermistors.h | 2 +- 9 files changed, 43 insertions(+), 10 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 1d2542e266..9783b2ec67 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -496,7 +496,7 @@ * 30 : 100kΩ Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K - beta 3950 * 60 : 100kΩ Maker's Tool Works Kapton Bed Thermistor - beta 3950 * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950 - * 66 : 4.7MΩ Dyze Design High Temperature Thermistor + * 66 : 4.7MΩ Dyze Design / Trianglelab T-D500 500°C High Temperature Thermistor * 67 : 500kΩ SliceEngineering 450°C Thermistor * 68 : PT100 amplifier board from Dyze Design * 70 : 100kΩ bq Hephestos 2 diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index cfeb9db33c..3029009c06 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -738,6 +738,7 @@ #define MAPLIST(OP,V...) EVAL(_MAPLIST(OP,V)) // Temperature Sensor Config -#define _HAS_E_TEMP(N) || (TEMP_SENSOR_##N != 0) +#define TEMP_SENSOR(N) TEMP_SENSOR_##N +#define _HAS_E_TEMP(N) || TEMP_SENSOR(N) #define HAS_E_TEMP_SENSOR (0 REPEAT(EXTRUDERS, _HAS_E_TEMP)) -#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR_##T == -5 || TEMP_SENSOR_##T == -3 || TEMP_SENSOR_##T == -2) +#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR(T) == -5 || TEMP_SENSOR(T) == -3 || TEMP_SENSOR(T) == -2) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 7d3306ffb8..c3f746dc72 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -161,9 +161,10 @@ #define HID_E6 6 #define HID_E7 7 -#define _SENSOR_IS(I,N) || (TEMP_SENSOR_##N == I) +#define _SENSOR_IS(I,N) || (TEMP_SENSOR(N) == I) #define _E_SENSOR_IS(I,N) _SENSOR_IS(N,I) -#define ANY_THERMISTOR_IS(N) (0 REPEAT2(HOTENDS, _E_SENSOR_IS, N) \ +#define ANY_E_SENSOR_IS(N) (0 REPEAT2(HOTENDS, _E_SENSOR_IS, N)) +#define ANY_THERMISTOR_IS(N) ( ANY_E_SENSOR_IS(N) \ _SENSOR_IS(N,BED) _SENSOR_IS(N,PROBE) _SENSOR_IS(N,CHAMBER) \ _SENSOR_IS(N,COOLER) _SENSOR_IS(N,BOARD) _SENSOR_IS(N,REDUNDANT) ) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index c208466dd0..45eccaade9 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2656,7 +2656,7 @@ // // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) // -#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && !TEMP_SENSOR_IS_MAX_TC(P) && !TEMP_SENSOR_##P##_IS_DUMMY) +#define HAS_ADC_TEST(P) (TEMP_SENSOR(P) && PIN_EXISTS(TEMP_##P) && !TEMP_SENSOR_IS_MAX_TC(P) && !TEMP_SENSOR_##P##_IS_DUMMY) #if HOTENDS > 0 && HAS_ADC_TEST(0) #define HAS_TEMP_ADC_0 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index e9675feaf1..95d0e74922 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2272,6 +2272,37 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_SENSOR_REDUNDANT 1000 requires REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS and REDUNDANT_BETA in Configuration_adv.h." #endif +/** + * Required thermistor 66 (Dyze Design / Trianglelab T-D500) settings + * https://docs.dyzedesign.com/hotends.html#_500-%C2%B0c-thermistor + */ +#if ANY_E_SENSOR_IS(66) + #define _BAD_MINTEMP(N) (TEMP_SENSOR(N) == 66 && HEATER_##N##_MINTEMP <= 20) + #if _BAD_MINTEMP(0) + #error "Thermistor 66 requires HEATER_0_MINTEMP > 20." + #elif _BAD_MINTEMP(1) + #error "Thermistor 66 requires HEATER_1_MINTEMP > 20." + #elif _BAD_MINTEMP(2) + #error "Thermistor 66 requires HEATER_2_MINTEMP > 20." + #elif _BAD_MINTEMP(3) + #error "Thermistor 66 requires HEATER_3_MINTEMP > 20." + #elif _BAD_MINTEMP(4) + #error "Thermistor 66 requires HEATER_4_MINTEMP > 20." + #elif _BAD_MINTEMP(5) + #error "Thermistor 66 requires HEATER_5_MINTEMP > 20." + #elif _BAD_MINTEMP(6) + #error "Thermistor 66 requires HEATER_6_MINTEMP > 20." + #elif _BAD_MINTEMP(7) + #error "Thermistor 66 requires HEATER_7_MINTEMP > 20." + #endif + #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED < 5 + #error "Thermistor 66 requires MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED ≥ 5." + #elif MILLISECONDS_PREHEAT_TIME < 30000 + #error "Thermistor 66 requires MILLISECONDS_PREHEAT_TIME ≥ 30000." + #endif + #undef _BAD_MINTEMP +#endif + /** * Required MAX31865 settings */ diff --git a/Marlin/src/lcd/thermistornames.h b/Marlin/src/lcd/thermistornames.h index 1b40a8c7d4..54542bed4e 100644 --- a/Marlin/src/lcd/thermistornames.h +++ b/Marlin/src/lcd/thermistornames.h @@ -141,7 +141,7 @@ #elif THERMISTOR_ID == 61 #define THERMISTOR_NAME "Formbot 350°C" #elif THERMISTOR_ID == 66 - #define THERMISTOR_NAME "Dyze 4.7M" + #define THERMISTOR_NAME "Dyze / TL 4.7M" #elif THERMISTOR_ID == 67 #define THERMISTOR_NAME "SliceEng 450°C" diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 8c662948bc..7954611bc4 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2649,7 +2649,7 @@ void Temperature::init() { temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) - #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_##N > 0 && TEMP_SENSOR_##N != 998 && TEMP_SENSOR_##N != 999 && defined(HEATER_##N##_##M##TEMP)) + #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR(N) > 0 && TEMP_SENSOR(N) != 998 && TEMP_SENSOR(N) != 999 && defined(HEATER_##N##_##M##TEMP)) #if _MINMAX_TEST(0, MIN) _TEMP_MIN_E(0); diff --git a/Marlin/src/module/thermistor/thermistor_66.h b/Marlin/src/module/thermistor/thermistor_66.h index 07cb297679..7c2455b7c6 100644 --- a/Marlin/src/module/thermistor/thermistor_66.h +++ b/Marlin/src/module/thermistor/thermistor_66.h @@ -21,7 +21,7 @@ */ #pragma once -// R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign 500 °C Thermistor +// R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign / Trianglelab T-D500 500 °C Thermistor constexpr temp_entry_t temptable_66[] PROGMEM = { { OV( 17.5), 850 }, { OV( 17.9), 500 }, diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 5d89dd3aa9..c596d746f7 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -338,7 +338,7 @@ static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_ // For thermocouples the highest temperature results in the highest ADC value #define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N -#define TT_REV(N) TERN0(TEMP_SENSOR_##N##_IS_THERMISTOR, DEFER4(_TT_REV)(TEMP_SENSOR_##N)) +#define TT_REV(N) TERN0(TEMP_SENSOR_##N##_IS_THERMISTOR, DEFER4(_TT_REV)(TEMP_SENSOR(N))) #define _TT_REVRAW(N) !TEMP_SENSOR_##N##_IS_THERMISTOR #define TT_REVRAW(N) (TT_REV(N) || _TT_REVRAW(N))