1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-22 18:25:18 +00:00

More flexible redundant temp sensor (#22085)

This commit is contained in:
Katelyn Schiesser 2021-06-11 13:51:29 -07:00 committed by Scott Lahteine
parent 5d80f7006a
commit d322e495b2
65 changed files with 573 additions and 254 deletions

View File

@ -472,6 +472,7 @@
#define TEMP_SENSOR_PROBE 0
#define TEMP_SENSOR_CHAMBER 0
#define TEMP_SENSOR_COOLER 0
#define TEMP_SENSOR_REDUNDANT 0
// Dummy thermistor constant temperature readings, for use with 998 and 999
#define DUMMY_THERMISTOR_998_VALUE 25
@ -483,11 +484,6 @@
//#define MAX31865_SENSOR_OHMS_1 100
//#define MAX31865_CALIBRATION_OHMS_1 430
// Use temp sensor 1 as a redundant sensor with sensor 0. If the readings
// from the two sensors differ too much the print will be aborted.
//#define TEMP_SENSOR_1_AS_REDUNDANT
#define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
#define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109
#define TEMP_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
@ -500,6 +496,28 @@
#define TEMP_CHAMBER_WINDOW 1 // (°C) Temperature proximity for the "temperature reached" timer
#define TEMP_CHAMBER_HYSTERESIS 3 // (°C) Temperature proximity considered "close enough" to the target
/**
* Redundant Temperature Sensor (TEMP_SENSOR_REDUNDANT)
*
* Use a temp sensor as a redundant sensor for another reading. Select an unused temperature sensor, and another
* sensor you'd like it to be redundant for. If the two thermistors differ by TEMP_SENSOR_REDUNDANT_MAX_DIFF (°C),
* the print will be aborted. Whichever sensor is selected will have its normal functions disabled; i.e. selecting
* the Bed sensor (-1) will disable bed heating/monitoring.
*
* Use the following to select temp sensors:
* -5 : Cooler
* -4 : Probe
* -3 : not used
* -2 : Chamber
* -1 : Bed
* 0-7 : E0 through E7
*/
#if TEMP_SENSOR_REDUNDANT
#define TEMP_SENSOR_REDUNDANT_SOURCE 1 // The sensor that will provide the redundant reading.
#define TEMP_SENSOR_REDUNDANT_TARGET 0 // The sensor that we are providing a redundant reading for.
#define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10 // (°C) Temperature difference that will trigger a print abort.
#endif
// Below this temperature the heater will be switched off
// because it probably indicates a broken thermistor wire.
#define HEATER_0_MINTEMP 5

View File

@ -125,6 +125,12 @@
#define PROBE_BETA 3950 // Beta value
#endif
#if TEMP_SENSOR_REDUNDANT == 1000
#define REDUNDANT_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define REDUNDANT_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define REDUNDANT_BETA 3950 // Beta value
#endif
//
// Hephestos 2 24V heated bed upgrade kit.
// https://store.bq.com/en/heated-bed-kit-hephestos2

View File

@ -54,7 +54,7 @@ enum XPTCoordinate : uint8_t {
XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
};
#if !defined(XPT2046_Z1_THRESHOLD)
#ifndef XPT2046_Z1_THRESHOLD
#define XPT2046_Z1_THRESHOLD 10
#endif

View File

@ -56,7 +56,7 @@ enum XPTCoordinate : uint8_t {
XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
};
#if !defined(XPT2046_Z1_THRESHOLD)
#ifndef XPT2046_Z1_THRESHOLD
#define XPT2046_Z1_THRESHOLD 10
#endif

View File

@ -54,7 +54,7 @@ enum XPTCoordinate : uint8_t {
XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE,
};
#if !defined(XPT2046_Z1_THRESHOLD)
#ifndef XPT2046_Z1_THRESHOLD
#define XPT2046_Z1_THRESHOLD 10
#endif

View File

@ -1157,10 +1157,10 @@ void setup() {
SETUP_RUN(HAL_init());
// Init and disable SPI thermocouples; this is still needed
#if TEMP_SENSOR_0_IS_MAX_TC
#if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0)
OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable
#endif
#if TEMP_SENSOR_1_IS_MAX_TC
#if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1)
OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable
#endif

View File

@ -35,11 +35,7 @@ void GcodeSuite::M105() {
#if HAS_TEMP_SENSOR
thermalManager.print_heater_states(target_extruder
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
, parser.boolval('R')
#endif
);
thermalManager.print_heater_states(target_extruder OPTARG(HAS_TEMP_REDUNDANT, parser.boolval('R')));
SERIAL_EOL();

View File

@ -512,11 +512,99 @@
* Temp Sensor defines
*/
#define ANY_TEMP_SENSOR_IS(n) (TEMP_SENSOR_0 == (n) || TEMP_SENSOR_1 == (n) || TEMP_SENSOR_2 == (n) || TEMP_SENSOR_3 == (n) || TEMP_SENSOR_4 == (n) || TEMP_SENSOR_5 == (n) || TEMP_SENSOR_6 == (n) || TEMP_SENSOR_7 == (n) || TEMP_SENSOR_BED == (n) || TEMP_SENSOR_PROBE == (n) || TEMP_SENSOR_CHAMBER == (n) || TEMP_SENSOR_COOLER == (n))
#define ANY_TEMP_SENSOR_IS(n) ( \
n == TEMP_SENSOR_0 || n == TEMP_SENSOR_1 || n == TEMP_SENSOR_2 || n == TEMP_SENSOR_3 \
|| n == TEMP_SENSOR_4 || n == TEMP_SENSOR_5 || n == TEMP_SENSOR_6 || n == TEMP_SENSOR_7 \
|| n == TEMP_SENSOR_BED \
|| n == TEMP_SENSOR_PROBE \
|| n == TEMP_SENSOR_CHAMBER \
|| n == TEMP_SENSOR_COOLER \
|| n == TEMP_SENSOR_REDUNDANT )
#if ANY_TEMP_SENSOR_IS(1000)
#define HAS_USER_THERMISTORS 1
#endif
#undef ANY_TEMP_SENSOR_IS
// Usurp a sensor to do redundant readings
#if TEMP_SENSOR_REDUNDANT && !PIN_EXISTS(TEMP_REDUNDANT)
#if TEMP_SENSOR_REDUNDANT_SOURCE == -5
#if !PIN_EXISTS(TEMP_COOLER)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to COOLER requires TEMP_COOLER_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_COOLER_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == -4
#if !PIN_EXISTS(TEMP_PROBE)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to PROBE requires TEMP_PROBE_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_PROBE_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == -2
#if !PIN_EXISTS(TEMP_CHAMBER)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to CHAMBER requires TEMP_CHAMBER_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_CHAMBER_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == -1
#if !PIN_EXISTS(TEMP_BED)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to BED requires TEMP_BED_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_BED_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == 0
#if !PIN_EXISTS(TEMP_0)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to 0 requires TEMP_0_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_0_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == 1
#if !PIN_EXISTS(TEMP_1)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to 1 requires TEMP_1_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_1_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == 2
#if !PIN_EXISTS(TEMP_2)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to 2 requires TEMP_2_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_2_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == 3
#if !PIN_EXISTS(TEMP_3)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to 3 requires TEMP_3_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_3_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == 4
#if !PIN_EXISTS(TEMP_4)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to 4 requires TEMP_4_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_4_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == 5
#if !PIN_EXISTS(TEMP_5)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to 5 requires TEMP_5_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_5_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == 6
#if !PIN_EXISTS(TEMP_6)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to 6 requires TEMP_6_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_6_PIN
#endif
#elif TEMP_SENSOR_REDUNDANT_SOURCE == 7
#if !PIN_EXISTS(TEMP_7)
#error "TEMP_SENSOR_REDUNDANT_SOURCE set to 7 requires TEMP_7_PIN."
#else
#define TEMP_REDUNDANT_PIN TEMP_7_PIN
#endif
#endif
#ifndef TEMP_SENSOR_REDUNDANT_MAX_DIFF
#define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10
#endif
#endif
#if TEMP_SENSOR_0 == -5 || TEMP_SENSOR_0 == -3 || TEMP_SENSOR_0 == -2
#define TEMP_SENSOR_0_IS_MAX_TC 1
@ -540,7 +628,6 @@
#elif TEMP_SENSOR_0 == -1
#define TEMP_SENSOR_0_IS_AD595 1
#elif TEMP_SENSOR_0 > 0
#define TEMP_SENSOR_0_THERMISTOR_ID TEMP_SENSOR_0
#define TEMP_SENSOR_0_IS_THERMISTOR 1
#if TEMP_SENSOR_0 == 1000
#define TEMP_SENSOR_0_IS_CUSTOM 1
@ -583,7 +670,6 @@
#elif TEMP_SENSOR_1 == -1
#define TEMP_SENSOR_1_IS_AD595 1
#elif TEMP_SENSOR_1 > 0
#define TEMP_SENSOR_1_THERMISTOR_ID TEMP_SENSOR_1
#define TEMP_SENSOR_1_IS_THERMISTOR 1
#if TEMP_SENSOR_1 == 1000
#define TEMP_SENSOR_1_IS_CUSTOM 1
@ -595,35 +681,92 @@
#undef HEATER_1_MAXTEMP
#endif
#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855
#if TEMP_SENSOR_REDUNDANT == -5 || TEMP_SENSOR_REDUNDANT == -3 || TEMP_SENSOR_REDUNDANT == -2
#define TEMP_SENSOR_REDUNDANT_IS_MAX_TC 1
#define HAS_MAX_TC 1
#if TEMP_SENSOR_REDUNDANT == -3
#define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN -270
#define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1800
#else
#define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN 0
#define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024
#endif
#if TEMP_SENSOR_REDUNDANT_SOURCE == 0
#define TEMP_SENSOR_0_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN
#define TEMP_SENSOR_0_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX
#elif TEMP_SENSOR_REDUNDANT_SOURCE == 1
#define TEMP_SENSOR_1_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN
#define TEMP_SENSOR_1_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX
#endif
#if TEMP_SENSOR_REDUNDANT == -5
#if TEMP_SENSOR_REDUNDANT_SOURCE != 0 && TEMP_SENSOR_REDUNDANT_SOURCE != 1
#error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)."
#endif
#define TEMP_SENSOR_REDUNDANT_IS_MAX31865 1
#elif TEMP_SENSOR_REDUNDANT == -3
#if TEMP_SENSOR_REDUNDANT_SOURCE != 0 && TEMP_SENSOR_REDUNDANT_SOURCE != 1
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)."
#endif
#define TEMP_SENSOR_REDUNDANT_IS_MAX31855 1
#elif TEMP_SENSOR_REDUNDANT == -2
#if TEMP_SENSOR_REDUNDANT_SOURCE != 0 && TEMP_SENSOR_REDUNDANT_SOURCE != 1
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)."
#endif
#define TEMP_SENSOR_REDUNDANT_IS_MAX6675 1
#endif
#if (TEMP_SENSOR_0_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_1_IS_MAX_TC && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1)
#if TEMP_SENSOR_REDUNDANT == -5
#error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match."
#elif TEMP_SENSOR_REDUNDANT == -3
#error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match."
#elif TEMP_SENSOR_REDUNDANT == -2
#error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match."
#endif
#endif
#elif TEMP_SENSOR_REDUNDANT == -4
#define TEMP_SENSOR_REDUNDANT_IS_AD8495 1
#elif TEMP_SENSOR_REDUNDANT == -1
#define TEMP_SENSOR_REDUNDANT_IS_AD595 1
#elif TEMP_SENSOR_REDUNDANT > 0
#define TEMP_SENSOR_REDUNDANT_IS_THERMISTOR 1
#if TEMP_SENSOR_REDUNDANT == 1000
#define TEMP_SENSOR_REDUNDANT_IS_CUSTOM 1
#elif TEMP_SENSOR_REDUNDANT == 998 || TEMP_SENSOR_REDUNDANT == 999
#error "Dummy sensors are not supported for TEMP_SENSOR_REDUNDANT."
#endif
#endif
#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_REDUNDANT_IS_MAX31855
#define HAS_MAX31855 1
#endif
#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865
#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_REDUNDANT_IS_MAX31865
#define HAS_MAX31865 1
#endif
#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675
#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675
#define HAS_MAX6675 1
#endif
//
// Compatibility layer for MAX (SPI) temp boards
//
#define TEMP_SENSOR_IS_MAX(n, M) (ENABLED(TEMP_SENSOR_##n##_IS_##M) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_##M) && TEMP_SENSOR_REDUNDANT_SOURCE == (n)))
#if PIN_EXISTS(MAX6675_SS)
#if TEMP_SENSOR_0_IS_MAX31855
#if TEMP_SENSOR_IS_MAX(0, MAX31855)
#define MAX31855_CS_PIN MAX6675_SS_PIN
#elif TEMP_SENSOR_0_IS_MAX31865
#elif TEMP_SENSOR_IS_MAX(0, MAX31865)
#define MAX31865_CS_PIN MAX6675_SS_PIN
#elif TEMP_SENSOR_0_IS_MAX6675
#elif TEMP_SENSOR_IS_MAX(0, MAX6675)
#define MAX6675_CS_PIN MAX6675_SS_PIN
#endif
#endif
#if PIN_EXISTS(MAX6675_SS2)
#if TEMP_SENSOR_1_IS_MAX31855
#if TEMP_SENSOR_IS_MAX(1, MAX31855)
#define MAX31855_CS2_PIN MAX6675_SS2_PIN
#elif TEMP_SENSOR_1_IS_MAX31865
#elif TEMP_SENSOR_IS_MAX(1, MAX31865)
#define MAX31865_CS2_PIN MAX6675_SS2_PIN
#elif TEMP_SENSOR_1_IS_MAX6675
#elif TEMP_SENSOR_IS_MAX(1, MAX6675)
#define MAX6675_CS2_PIN MAX6675_SS2_PIN
#endif
#endif
@ -698,7 +841,6 @@
#elif TEMP_SENSOR_2 == -1
#define TEMP_SENSOR_2_IS_AD595 1
#elif TEMP_SENSOR_2 > 0
#define TEMP_SENSOR_2_THERMISTOR_ID TEMP_SENSOR_2
#define TEMP_SENSOR_2_IS_THERMISTOR 1
#if TEMP_SENSOR_2 == 1000
#define TEMP_SENSOR_2_IS_CUSTOM 1
@ -719,7 +861,6 @@
#elif TEMP_SENSOR_3 == -1
#define TEMP_SENSOR_3_IS_AD595 1
#elif TEMP_SENSOR_3 > 0
#define TEMP_SENSOR_3_THERMISTOR_ID TEMP_SENSOR_3
#define TEMP_SENSOR_3_IS_THERMISTOR 1
#if TEMP_SENSOR_3 == 1000
#define TEMP_SENSOR_3_IS_CUSTOM 1
@ -740,7 +881,6 @@
#elif TEMP_SENSOR_4 == -1
#define TEMP_SENSOR_4_IS_AD595 1
#elif TEMP_SENSOR_4 > 0
#define TEMP_SENSOR_4_THERMISTOR_ID TEMP_SENSOR_4
#define TEMP_SENSOR_4_IS_THERMISTOR 1
#if TEMP_SENSOR_4 == 1000
#define TEMP_SENSOR_4_IS_CUSTOM 1
@ -761,7 +901,6 @@
#elif TEMP_SENSOR_5 == -1
#define TEMP_SENSOR_5_IS_AD595 1
#elif TEMP_SENSOR_5 > 0
#define TEMP_SENSOR_5_THERMISTOR_ID TEMP_SENSOR_5
#define TEMP_SENSOR_5_IS_THERMISTOR 1
#if TEMP_SENSOR_5 == 1000
#define TEMP_SENSOR_5_IS_CUSTOM 1
@ -782,7 +921,6 @@
#elif TEMP_SENSOR_6 == -1
#define TEMP_SENSOR_6_IS_AD595 1
#elif TEMP_SENSOR_6 > 0
#define TEMP_SENSOR_6_THERMISTOR_ID TEMP_SENSOR_6
#define TEMP_SENSOR_6_IS_THERMISTOR 1
#if TEMP_SENSOR_6 == 1000
#define TEMP_SENSOR_6_IS_CUSTOM 1
@ -803,7 +941,6 @@
#elif TEMP_SENSOR_7 == -1
#define TEMP_SENSOR_7_IS_AD595 1
#elif TEMP_SENSOR_7 > 0
#define TEMP_SENSOR_7_THERMISTOR_ID TEMP_SENSOR_7
#define TEMP_SENSOR_7_IS_THERMISTOR 1
#if TEMP_SENSOR_7 == 1000
#define TEMP_SENSOR_7_IS_CUSTOM 1
@ -824,7 +961,6 @@
#elif TEMP_SENSOR_BED == -1
#define TEMP_SENSOR_BED_IS_AD595 1
#elif TEMP_SENSOR_BED > 0
#define TEMP_SENSOR_BED_THERMISTOR_ID TEMP_SENSOR_BED
#define TEMP_SENSOR_BED_IS_THERMISTOR 1
#if TEMP_SENSOR_BED == 1000
#define TEMP_SENSOR_BED_IS_CUSTOM 1
@ -845,7 +981,6 @@
#elif TEMP_SENSOR_CHAMBER == -1
#define TEMP_SENSOR_CHAMBER_IS_AD595 1
#elif TEMP_SENSOR_CHAMBER > 0
#define TEMP_SENSOR_CHAMBER_THERMISTOR_ID TEMP_SENSOR_CHAMBER
#define TEMP_SENSOR_CHAMBER_IS_THERMISTOR 1
#if TEMP_SENSOR_CHAMBER == 1000
#define TEMP_SENSOR_CHAMBER_IS_CUSTOM 1
@ -858,20 +993,19 @@
#endif
#if TEMP_SENSOR_COOLER == -4
#define COOLER_USES_AD8495 1
#define TEMP_SENSOR_COOLER_IS_AD8495 1
#elif TEMP_SENSOR_COOLER == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_COOLER."
#elif TEMP_SENSOR_COOLER == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_COOLER."
#elif TEMP_SENSOR_COOLER == -1
#define COOLER_USES_AD595 1
#define TEMP_SENSOR_COOLER_IS_AD595 1
#elif TEMP_SENSOR_COOLER > 0
#define TEMP_SENSOR_COOLER_THERMISTOR_ID TEMP_SENSOR_COOLER
#define TEMP_SENSOR_COOLER_IS_THERMISTOR 1
#if TEMP_SENSOR_COOLER == 1000
#define COOLER_USER_THERMISTOR 1
#define TEMP_SENSOR_COOLER_IS_CUSTOM 1
#elif TEMP_SENSOR_COOLER == 998 || TEMP_SENSOR_COOLER == 999
#define COOLER_DUMMY_THERMISTOR 1
#define TEMP_SENSOR_COOLER_IS_DUMMY 1
#endif
#else
#undef COOLER_MINTEMP
@ -887,7 +1021,6 @@
#elif TEMP_SENSOR_PROBE == -1
#define TEMP_SENSOR_PROBE_IS_AD595 1
#elif TEMP_SENSOR_PROBE > 0
#define TEMP_SENSOR_PROBE_THERMISTOR_ID TEMP_SENSOR_PROBE
#define TEMP_SENSOR_PROBE_IS_THERMISTOR 1
#if TEMP_SENSOR_PROBE == 1000
#define TEMP_SENSOR_PROBE_IS_CUSTOM 1
@ -2345,6 +2478,9 @@
#if HAS_ADC_TEST(COOLER)
#define HAS_TEMP_ADC_COOLER 1
#endif
#if HAS_ADC_TEST(REDUNDANT)
#define HAS_TEMP_ADC_REDUNDANT 1
#endif
#define HAS_TEMP(N) ANY(HAS_TEMP_ADC_##N, TEMP_SENSOR_##N##_IS_MAX_TC, TEMP_SENSOR_##N##_IS_DUMMY)
#if HAS_HOTEND && HAS_TEMP(0)
@ -2362,6 +2498,9 @@
#if HAS_TEMP(COOLER)
#define HAS_TEMP_COOLER 1
#endif
#if HAS_TEMP(REDUNDANT)
#define HAS_TEMP_REDUNDANT 1
#endif
#if ENABLED(JOYSTICK)
#if PIN_EXISTS(JOY_X)

View File

@ -568,6 +568,10 @@
#error "MKS_LCD12864 is now MKS_LCD12864A or MKS_LCD12864B."
#elif defined(NEOPIXEL_BKGD_LED_INDEX)
#error "NEOPIXEL_BKGD_LED_INDEX is now NEOPIXEL_BKGD_INDEX_FIRST."
#elif defined(TEMP_SENSOR_1_AS_REDUNDANT)
#error "TEMP_SENSOR_1_AS_REDUNDANT is now TEMP_SENSOR_REDUNDANT, with associated TEMP_SENSOR_REDUNDANT_* config."
#elif defined(MAX_REDUNDANT_TEMP_SENSOR_DIFF)
#error "MAX_REDUNDANT_TEMP_SENSOR_DIFF is now TEMP_SENSOR_REDUNDANT_MAX_DIFF"
#endif
constexpr float arm[] = AXIS_RELATIVE_MODES;
@ -1887,19 +1891,88 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "TEMP_SENSOR_CHAMBER 1000 requires CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS and CHAMBER_BETA in Configuration_adv.h."
#elif TEMP_SENSOR_PROBE_IS_CUSTOM && !(defined(PROBE_PULLUP_RESISTOR_OHMS) && defined(PROBE_RESISTANCE_25C_OHMS) && defined(PROBE_BETA))
#error "TEMP_SENSOR_PROBE 1000 requires PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS and PROBE_BETA in Configuration_adv.h."
#elif TEMP_SENSOR_REDUNDANT_IS_CUSTOM && !(defined(REDUNDANT_PULLUP_RESISTOR_OHMS) && defined(REDUNDANT_RESISTANCE_25C_OHMS) && defined(REDUNDANT_BETA))
#error "TEMP_SENSOR_REDUNDANT 1000 requires REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS and REDUNDANT_BETA in Configuration_adv.h."
#endif
/**
* Pins and Sensor IDs must be set for each heater
*/
#if TEMP_SENSOR_0_IS_MAX6675 && !ANY_PIN(MAX6675_SS, MAX31855_CS, MAX31865_CS, MAX6675_CS)
#error "TEMP_SENSOR_0 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN."
#error "TEMP_SENSOR_0 -2 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN."
#elif HAS_HOTEND && !HAS_TEMP_HOTEND && !TEMP_SENSOR_0_IS_DUMMY
#error "TEMP_0_PIN (required for TEMP_SENSOR_0) not defined for this board."
#elif EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) && !HAS_HEATER_1
#error "HEATER_1_PIN is not defined. TEMP_SENSOR_1 might not be set, or the board (not EEB / EEF?) doesn't define a pin."
#endif
/**
* Redundant temperature sensor config
*/
#if HAS_TEMP_REDUNDANT
#if !defined(TEMP_SENSOR_REDUNDANT_SOURCE)
#error "TEMP_SENSOR_REDUNDANT requires TEMP_SENSOR_REDUNDANT_SOURCE."
#elif !defined(TEMP_SENSOR_REDUNDANT_TARGET)
#error "TEMP_SENSOR_REDUNDANT requires TEMP_SENSOR_REDUNDANT_TARGET."
#elif TEMP_SENSOR_REDUNDANT_SOURCE == TEMP_SENSOR_REDUNDANT_TARGET
#error "TEMP_SENSOR_REDUNDANT_SOURCE can't be the same as TEMP_SENSOR_REDUNDANT_TARGET."
#elif TEMP_SENSOR_REDUNDANT_SOURCE < -5 || TEMP_SENSOR_REDUNDANT_SOURCE > 7
#error "TEMP_SENSOR_REDUNDANT_SOURCE must be between -5 and 7."
#elif TEMP_SENSOR_REDUNDANT_TARGET < -5 || TEMP_SENSOR_REDUNDANT_TARGET > 7
#error "TEMP_SENSOR_REDUNDANT_TARGET must be between -5 and 7."
#elif TEMP_SENSOR_REDUNDANT_SOURCE == -3
#error "TEMP_SENSOR_REDUNDANT_SOURCE can't be -3 (not used)."
#elif TEMP_SENSOR_REDUNDANT_TARGET == -3
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be -3 (not used)."
#elif HAS_MULTI_HOTEND && TEMP_SENSOR_REDUNDANT_SOURCE < HOTENDS
#error "TEMP_SENSOR_REDUNDANT_SOURCE must be after the last TEMP_SENSOR used with a hotend; you can't use a sensor in the middle of two hotends."
#endif
#if TEMP_SENSOR_REDUNDANT_SOURCE == 0 && HAS_HOTEND
#error "TEMP_SENSOR_REDUNDANT_SOURCE can not be 0 if a hotend is used. E0 always uses TEMP_SENSOR_0."
#elif TEMP_SENSOR_REDUNDANT_SOURCE == -5 && HAS_TEMP_COOLER
#error "TEMP_SENSOR_REDUNDANT_SOURCE can't be Cooler (-5): TEMP_SENSOR_COOLER has already defined the sensor."
#elif TEMP_SENSOR_REDUNDANT_SOURCE == -4 && HAS_TEMP_PROBE
#error "TEMP_SENSOR_REDUNDANT_SOURCE can't be Probe (-4): TEMP_SENSOR_PROBE has already defined the sensor."
#elif TEMP_SENSOR_REDUNDANT_SOURCE == -2 && HAS_TEMP_CHAMBER
#error "TEMP_SENSOR_REDUNDANT_SOURCE can't be Chamber (-2): TEMP_SENSOR_CHAMBER has already defined the sensor."
#elif TEMP_SENSOR_REDUNDANT_SOURCE == -1 && HAS_TEMP_BED
#error "TEMP_SENSOR_REDUNDANT_SOURCE can't be Bed (-1): TEMP_SENSOR_BED has already defined the sensor."
#endif
#if TEMP_SENSOR_REDUNDANT_TARGET == 0 && !PIN_EXISTS(TEMP_0)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be E0 (0): requires TEMP_0_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == 1 && !PIN_EXISTS(TEMP_1)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be E1 (1): requires TEMP_1_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == 2 && !PIN_EXISTS(TEMP_2)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be E2 (2): requires TEMP_2_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == 3 && !PIN_EXISTS(TEMP_3)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be E3 (3): requires TEMP_3_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == 4 && !PIN_EXISTS(TEMP_4)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be E4 (4): requires TEMP_4_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == 5 && !PIN_EXISTS(TEMP_5)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be E5 (5): requires TEMP_5_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == 6 && !PIN_EXISTS(TEMP_6)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be E6 (6): requires TEMP_6_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == 7 && !PIN_EXISTS(TEMP_7)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be E7 (7): requires TEMP_7_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == -1 && !PIN_EXISTS(TEMP_BED)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be Bed (-1): requires TEMP_BED_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == -2 && !PIN_EXISTS(TEMP_CHAMBER)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be Chamber (-2): requires TEMP_CHAMBER_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == -4 && !PIN_EXISTS(TEMP_PROBE)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be Probe (-4): requires TEMP_PROBE_PIN"
#elif TEMP_SENSOR_REDUNDANT_TARGET == -5 && !PIN_EXISTS(TEMP_COOLER)
#error "TEMP_SENSOR_REDUNDANT_TARGET can't be Cooler (-5): requires TEMP_COOLER_PIN"
#endif
#if TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0 && !PIN_EXISTS(MAX6675_SS)
#error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE 0 requires a MAX6675_SS_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN."
#elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1 && !PIN_EXISTS(MAX6675_SS2)
#error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE 1 requires a MAX6675_SS2_PIN, MAX6675_CS_PIN, MAX31855_CS_PIN, or MAX31865_CS_PIN."
#endif
#endif
#if HAS_MULTI_HOTEND
#if TEMP_SENSOR_1_IS_MAX6675 && !ANY_PIN(MAX6675_SS2, MAX31855_CS2, MAX31865_CS2, MAX6675_CS2)
#error "TEMP_SENSOR_1 requires a MAX6675_SS2_PIN, MAX6675_CS2_PIN, MAX31855_CS2_PIN, or MAX31865_CS2_PIN."
@ -1907,8 +1980,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "TEMP_SENSOR_1 is required with 2 or more HOTENDS."
#elif !ANY_PIN(TEMP_1, MAX6675_SS2) && !TEMP_SENSOR_1_IS_DUMMY
#error "TEMP_1_PIN or MAX6675_SS2_PIN not defined for this board."
#elif ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#error "HOTENDS must be 1 with TEMP_SENSOR_1_AS_REDUNDANT."
#endif
#if HOTENDS > 2
#if TEMP_SENSOR_2 == 0
@ -2006,7 +2077,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#elif TEMP_SENSOR_7 != 0
#error "TEMP_SENSOR_7 shouldn't be set with only 2 HOTENDS."
#endif
#elif TEMP_SENSOR_1 != 0 && DISABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#elif TEMP_SENSOR_1 != 0
#error "TEMP_SENSOR_1 shouldn't be set with only 1 HOTEND."
#elif TEMP_SENSOR_2 != 0
#error "TEMP_SENSOR_2 shouldn't be set with only 1 HOTEND."
@ -2068,14 +2139,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif
#endif
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT) && TEMP_SENSOR_1 == 0
#error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT."
#endif
#if TEMP_SENSOR_0_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0))
#error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set if TEMP_SENSOR_0 is MAX31865."
#elif TEMP_SENSOR_1_IS_MAX31865 && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1))
#error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1 is MAX31865."
#if TEMP_SENSOR_IS_MAX(0, MAX31865) && !(defined(MAX31865_SENSOR_OHMS_0) && defined(MAX31865_CALIBRATION_OHMS_0))
#error "MAX31865_SENSOR_OHMS_0 and MAX31865_CALIBRATION_OHMS_0 must be set if TEMP_SENSOR_0/TEMP_SENSOR_REDUNDANT is MAX31865."
#elif TEMP_SENSOR_IS_MAX(1, MAX31865) && !(defined(MAX31865_SENSOR_OHMS_1) && defined(MAX31865_CALIBRATION_OHMS_1))
#error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1/TEMP_SENSOR_REDUNDANT is MAX31865."
#endif
/**

View File

@ -56,13 +56,15 @@
#include "../feature/host_actions.h"
#endif
#define TEMP_SENSOR_IS_ANY_MAX_TC(n) (ENABLED(TEMP_SENSOR_##n##_IS_MAX_TC) || (ENABLED(TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && ENABLED(TEMP_SENSOR_REDUNDANT_SOURCE) && TEMP_SENSOR_REDUNDANT_SOURCE == n))
// LIB_MAX31855 can be added to the build_flags in platformio.ini to use a user-defined library
#if LIB_USR_MAX31855
#include <Adafruit_MAX31855.h>
#if PIN_EXISTS(MAX31855_MISO) && PIN_EXISTS(MAX31855_SCK)
#define MAX31855_USES_SW_SPI 1
#endif
#if TEMP_SENSOR_0_IS_MAX31855 && PIN_EXISTS(MAX31855_CS)
#if TEMP_SENSOR_IS_MAX(0, MAX31855) && PIN_EXISTS(MAX31855_CS)
#define HAS_MAX31855_TEMP 1
Adafruit_MAX31855 max31855_0 = Adafruit_MAX31855(MAX31855_CS_PIN
#if MAX31855_USES_SW_SPI
@ -73,7 +75,7 @@
#endif
);
#endif
#if TEMP_SENSOR_1_IS_MAX31855 && PIN_EXISTS(MAX31855_CS2)
#if TEMP_SENSOR_IS_MAX(1, MAX31855) && PIN_EXISTS(MAX31855_CS2)
#define HAS_MAX31855_TEMP 1
Adafruit_MAX31855 max31855_1 = Adafruit_MAX31855(MAX31855_CS2_PIN
#if MAX31855_USES_SW_SPI
@ -96,7 +98,7 @@
#if PIN_EXISTS(MAX31865_MISO) && PIN_EXISTS(MAX31865_SCK)
#define MAX31865_USES_SW_SPI 1
#endif
#if TEMP_SENSOR_0_IS_MAX31865 && PIN_EXISTS(MAX31865_CS)
#if TEMP_SENSOR_IS_MAX(0, MAX31865) && PIN_EXISTS(MAX31865_CS)
#define HAS_MAX31865_TEMP 1
Adafruit_MAX31865 max31865_0 = Adafruit_MAX31865(MAX31865_CS_PIN
#if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI)
@ -107,7 +109,7 @@
#endif
);
#endif
#if TEMP_SENSOR_1_IS_MAX31865 && PIN_EXISTS(MAX31865_CS2)
#if TEMP_SENSOR_IS_MAX(1, MAX31865) && PIN_EXISTS(MAX31865_CS2)
#define HAS_MAX31865_TEMP 1
Adafruit_MAX31865 max31865_1 = Adafruit_MAX31865(MAX31865_CS2_PIN
#if MAX31865_USES_SW_SPI && PIN_EXISTS(MAX31865_MOSI)
@ -126,7 +128,7 @@
#if PIN_EXISTS(MAX6675_MISO) && PIN_EXISTS(MAX6675_SCK)
#define MAX6675_USES_SW_SPI 1
#endif
#if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS)
#if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX6675_CS)
#define HAS_MAX6675_TEMP 1
MAX6675 max6675_0 = MAX6675(MAX6675_CS_PIN
#if MAX6675_USES_SW_SPI
@ -137,7 +139,7 @@
#endif
);
#endif
#if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2)
#if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX6675_CS2)
#define HAS_MAX6675_TEMP 1
MAX6675 max6675_1 = MAX6675(MAX6675_CS2_PIN
#if MAX6675_USES_SW_SPI
@ -154,7 +156,7 @@
#define NO_THERMO_TEMPS 1
#endif
#if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS
#if (TEMP_SENSOR_0_IS_MAX_TC || TEMP_SENSOR_1_IS_MAX_TC || TEMP_SENSOR_REDUNDANT_IS_MAX_TC) && PINS_EXIST(MAX6675_SCK, MAX6675_DO) && NO_THERMO_TEMPS
#define THERMO_SEPARATE_SPI 1
#endif
@ -210,15 +212,10 @@
#endif
#if HAS_HOTEND_THERMISTOR
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
static const temp_entry_t* heater_ttbl_map[2] = { TEMPTABLE_0, TEMPTABLE_1 };
static constexpr uint8_t heater_ttbllen_map[2] = { TEMPTABLE_0_LEN, TEMPTABLE_1_LEN };
#else
#define NEXT_TEMPTABLE(N) ,TEMPTABLE_##N
#define NEXT_TEMPTABLE_LEN(N) ,TEMPTABLE_##N##_LEN
static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0 REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE));
static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN));
#endif
#define NEXT_TEMPTABLE(N) ,TEMPTABLE_##N
#define NEXT_TEMPTABLE_LEN(N) ,TEMPTABLE_##N##_LEN
static const temp_entry_t* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0 REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE));
static constexpr uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(TEMPTABLE_0_LEN REPEAT_S(1, HOTENDS, NEXT_TEMPTABLE_LEN));
#endif
Temperature thermalManager;
@ -257,13 +254,14 @@ const char str_t_thermal_runaway[] PROGMEM = STR_T_THERMAL_RUNAWAY,
#if HAS_HOTEND
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);
#endif
#if HAS_TEMP_REDUNDANT
redundant_temp_info_t Temperature::temp_redundant;
#endif
#if ENABLED(AUTO_POWER_E_FANS)
uint8_t Temperature::autofan_speed[HOTENDS]; // = { 0 }
#endif
@ -1219,8 +1217,12 @@ void Temperature::manage_heater() {
if (degHotend(0) < _MAX(HEATER_0_MINTEMP, TEMP_SENSOR_0_MAX_TC_TMIN + .01)) min_temp_error(H_E0);
#endif
#if TEMP_SENSOR_1_IS_MAX_TC
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 (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);
if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1);
if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1);
#endif
#if TEMP_SENSOR_REDUNDANT_IS_MAX_TC
if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) max_temp_error(H_REDUNDANT);
if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) min_temp_error(H_REDUNDANT);
#endif
#endif
@ -1254,16 +1256,16 @@ void Temperature::manage_heater() {
}
#endif
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
// Make sure measured temperatures are close together
if (ABS(degHotend(0) - degHotendRedundant()) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
_temp_error(H_E0, PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP));
#endif
} // HOTEND_LOOP
#endif // HAS_HOTEND
#if HAS_TEMP_REDUNDANT
// Make sure measured temperatures are close together
if (ABS(degRedundantTarget() - degRedundant()) > TEMP_SENSOR_REDUNDANT_MAX_DIFF)
_temp_error((heater_id_t)TEMP_SENSOR_REDUNDANT_TARGET, PSTR(STR_REDUNDANCY), GET_TEXT(MSG_ERR_REDUNDANT_TEMP));
#endif
#if HAS_AUTO_FAN
if (ELAPSED(ms, next_auto_fan_check_ms)) { // only need to check fan state very infrequently
checkExtruderAutoFans();
@ -1613,13 +1615,16 @@ void Temperature::manage_heater() {
{ true, 0, 0, BED_PULLUP_RESISTOR_OHMS, BED_RESISTANCE_25C_OHMS, 0, 0, BED_BETA, 0 },
#endif
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM
{ true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 }
{ true, 0, 0, CHAMBER_PULLUP_RESISTOR_OHMS, CHAMBER_RESISTANCE_25C_OHMS, 0, 0, CHAMBER_BETA, 0 },
#endif
#if TEMP_SENSOR_COOLER_IS_CUSTOM
{ true, 0, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_BETA, 0 }
{ true, 0, 0, COOLER_PULLUP_RESISTOR_OHMS, COOLER_RESISTANCE_25C_OHMS, 0, 0, COOLER_BETA, 0 },
#endif
#if TEMP_SENSOR_PROBE_IS_CUSTOM
{ true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 }
{ true, 0, 0, PROBE_PULLUP_RESISTOR_OHMS, PROBE_RESISTANCE_25C_OHMS, 0, 0, PROBE_BETA, 0 },
#endif
#if TEMP_SENSOR_REDUNDANT_IS_CUSTOM
{ true, 0, 0, REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS, 0, 0, REDUNDANT_BETA, 0 },
#endif
};
COPY(user_thermistor, default_user_thermistor);
@ -1653,6 +1658,7 @@ void Temperature::manage_heater() {
TERN_(TEMP_SENSOR_CHAMBER_IS_CUSTOM, t_index == CTI_CHAMBER ? PSTR("CHAMBER") :)
TERN_(TEMP_SENSOR_COOLER_IS_CUSTOM, t_index == CTI_COOLER ? PSTR("COOLER") :)
TERN_(TEMP_SENSOR_PROBE_IS_CUSTOM, t_index == CTI_PROBE ? PSTR("PROBE") :)
TERN_(TEMP_SENSOR_REDUNDANT_IS_CUSTOM, t_index == CTI_REDUNDANT ? PSTR("REDUNDANT") :)
nullptr
);
SERIAL_EOL();
@ -1708,7 +1714,7 @@ void Temperature::manage_heater() {
// Derived from RepRap FiveD extruder::getTemperature()
// For hot end temperature measurement.
celsius_float_t Temperature::analog_to_celsius_hotend(const int16_t raw, const uint8_t e) {
if (e >= HOTENDS + ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)) {
if (e >= HOTENDS) {
SERIAL_ERROR_START();
SERIAL_ECHO(e);
SERIAL_ECHOLNPGM(STR_INVALID_EXTRUDER_NUM);
@ -1886,6 +1892,28 @@ void Temperature::manage_heater() {
}
#endif // HAS_TEMP_PROBE
#if HAS_TEMP_REDUNDANT
// For redundant temperature measurement.
celsius_float_t Temperature::analog_to_celsius_redundant(const int16_t raw) {
#if TEMP_SENSOR_REDUNDANT_IS_CUSTOM
return user_thermistor_to_deg_c(CTI_REDUNDANT, raw);
#elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0
return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(MAX31865_SENSOR_OHMS_0, MAX31865_CALIBRATION_OHMS_0), raw * 0.25);
#elif TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1
return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature(MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1), raw * 0.25);
#elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR
SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN);
#elif TEMP_SENSOR_REDUNDANT_IS_AD595
return TEMP_AD595(raw);
#elif TEMP_SENSOR_REDUNDANT_IS_AD8495
return TEMP_AD8495(raw);
#else
UNUSED(raw);
return 0;
#endif
}
#endif // HAS_TEMP_REDUNDANT
/**
* Convert the raw sensor readings into actual Celsius temperatures and
* validate raw temperatures. Bad readings generate min/maxtemp errors.
@ -1903,26 +1931,34 @@ void Temperature::updateTemperaturesFromRawValues() {
watchdog_refresh(); // Reset because raw_temps_ready was set by the interrupt
TERN_(TEMP_SENSOR_0_IS_MAX_TC, temp_hotend[0].raw = READ_MAX_TC(0));
TERN_(TEMP_SENSOR_1_IS_MAX_TC, TERN(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant, temp_hotend[1]).raw = READ_MAX_TC(1));
TERN_(TEMP_SENSOR_1_IS_MAX_TC, temp_hotend[1].raw = READ_MAX_TC(1));
TERN_(TEMP_SENSOR_REDUNDANT_IS_MAX_TC, temp_redundant.raw = READ_MAX_TC(TEMP_SENSOR_REDUNDANT_SOURCE));
#if HAS_HOTEND
HOTEND_LOOP() temp_hotend[e].celsius = analog_to_celsius_hotend(temp_hotend[e].raw, e);
#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_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_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.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_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_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.raw));
TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm());
TERN_(HAS_POWER_MONITOR, power_monitor.capture_values());
#if HAS_HOTEND
static constexpr int8_t temp_dir[] = {
TERN(TEMP_SENSOR_0_IS_MAX_TC, 0, TEMPDIR(0))
#if TEMP_SENSOR_IS_ANY_MAX_TC(0)
0
#else
TEMPDIR(0)
#endif
#if HAS_MULTI_HOTEND
, TERN(TEMP_SENSOR_1_IS_MAX_TC, 0, TEMPDIR(1))
#if TEMP_SENSOR_IS_ANY_MAX_TC(1)
, 0
#else
, TEMPDIR(1)
#endif
#if HOTENDS > 2
#define _TEMPDIR(N) , TEMPDIR(N)
REPEAT_S(2, HOTENDS, _TEMPDIR)
@ -2031,42 +2067,42 @@ void Temperature::init() {
#endif
// Init (and disable) SPI thermocouples
#if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX6675_CS)
#if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX6675_CS)
OUT_WRITE(MAX6675_CS_PIN, HIGH);
#endif
#if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX6675_CS2)
#if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX6675_CS2)
OUT_WRITE(MAX6675_CS2_PIN, HIGH);
#endif
#if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX31855_CS)
#if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX31855_CS)
OUT_WRITE(MAX31855_CS_PIN, HIGH);
#endif
#if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX31855_CS2)
#if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX31855_CS2)
OUT_WRITE(MAX31855_CS2_PIN, HIGH);
#endif
#if TEMP_SENSOR_0_IS_MAX6675 && PIN_EXISTS(MAX31865_CS)
#if TEMP_SENSOR_IS_MAX(0, MAX6675) && PIN_EXISTS(MAX31865_CS)
OUT_WRITE(MAX31865_CS_PIN, HIGH);
#endif
#if TEMP_SENSOR_1_IS_MAX6675 && PIN_EXISTS(MAX31865_CS2)
#if TEMP_SENSOR_IS_MAX(1, MAX6675) && PIN_EXISTS(MAX31865_CS2)
OUT_WRITE(MAX31865_CS2_PIN, HIGH);
#endif
#if HAS_MAX31865_TEMP
TERN_(TEMP_SENSOR_0_IS_MAX31865, max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
TERN_(TEMP_SENSOR_1_IS_MAX31865, max31865_1.begin(MAX31865_2WIRE));
TERN_(TEMP_SENSOR_IS_MAX(0, MAX31865), max31865_0.begin(MAX31865_2WIRE)); // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE
TERN_(TEMP_SENSOR_IS_MAX(1, MAX31865), max31865_1.begin(MAX31865_2WIRE));
#endif
#if HAS_MAX31855_TEMP
TERN_(TEMP_SENSOR_0_IS_MAX31855, max31855_0.begin());
TERN_(TEMP_SENSOR_1_IS_MAX31855, max31855_1.begin());
TERN_(TEMP_SENSOR_IS_MAX(0, MAX31855), max31855_0.begin());
TERN_(TEMP_SENSOR_IS_MAX(1, MAX31855), max31855_1.begin());
#endif
#if HAS_MAX6675_TEMP
TERN_(TEMP_SENSOR_0_IS_MAX6675, max6675_0.begin());
TERN_(TEMP_SENSOR_1_IS_MAX6675, max6675_1.begin());
TERN_(TEMP_SENSOR_IS_MAX(0, MAX6675), max6675_0.begin());
TERN_(TEMP_SENSOR_IS_MAX(1, MAX6675), max6675_1.begin());
#endif
#if MB(RUMBA)
// Disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
#define _AD(N) (TEMP_SENSOR_##N##_IS_AD595 || TEMP_SENSOR_##N##_IS_AD8495)
#if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER)
#if _AD(0) || _AD(1) || _AD(2) || _AD(BED) || _AD(CHAMBER) || _AD(REDUNDANT)
MCUCR = _BV(JTD);
MCUCR = _BV(JTD);
#endif
@ -2074,10 +2110,22 @@ void Temperature::init() {
// Thermistor activation by MCU pin
#if PIN_EXISTS(TEMP_0_TR_ENABLE)
OUT_WRITE(TEMP_0_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_0_IS_MAX_TC));
OUT_WRITE(TEMP_0_TR_ENABLE_PIN,
#if TEMP_SENSOR_IS_ANY_MAX_TC(0)
1
#else
0
#endif
);
#endif
#if PIN_EXISTS(TEMP_1_TR_ENABLE)
OUT_WRITE(TEMP_1_TR_ENABLE_PIN, ENABLED(TEMP_SENSOR_1_IS_MAX_TC));
OUT_WRITE(TEMP_1_TR_ENABLE_PIN,
#if TEMP_SENSOR_IS_ANY_MAX_TC(1)
1
#else
0
#endif
);
#endif
#if HAS_HEATER_0
@ -2206,6 +2254,9 @@ void Temperature::init() {
#if HAS_TEMP_ADC_PROBE
HAL_ANALOG_SELECT(TEMP_PROBE_PIN);
#endif
#if HAS_TEMP_ADC_REDUNDANT
HAL_ANALOG_SELECT(TEMP_REDUNDANT_PIN);
#endif
#if ENABLED(FILAMENT_WIDTH_SENSOR)
HAL_ANALOG_SELECT(FILWIDTH_PIN);
#endif
@ -2268,7 +2319,7 @@ void Temperature::init() {
temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \
}while(0)
#define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_ ##N## _THERMISTOR_ID && TEMP_SENSOR_ ##N## _THERMISTOR_ID != 998 && TEMP_SENSOR_ ##N## _THERMISTOR_ID != 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);
@ -2335,6 +2386,22 @@ void Temperature::init() {
while (analog_to_celsius_cooler(mintemp_raw_COOLER) > COOLER_MINTEMP) mintemp_raw_COOLER += TEMPDIR(COOLER) * (OVERSAMPLENR);
while (analog_to_celsius_cooler(maxtemp_raw_COOLER) < COOLER_MAXTEMP) maxtemp_raw_COOLER -= TEMPDIR(COOLER) * (OVERSAMPLENR);
#endif
#if HAS_TEMP_REDUNDANT
temp_redundant.target = &(
#if TEMP_SENSOR_REDUNDANT_TARGET == -5 && HAS_TEMP_COOLER
temp_cooler
#elif TEMP_SENSOR_REDUNDANT_TARGET == -4 && HAS_TEMP_PROBE
temp_probe
#elif TEMP_SENSOR_REDUNDANT_TARGET == -2 && HAS_TEMP_CHAMBER
temp_chamber
#elif TEMP_SENSOR_REDUNDANT_TARGET == -1 && HAS_TEMP_BED
temp_bed
#else
temp_hotend[TEMP_SENSOR_REDUNDANT_TARGET]
#endif
);
#endif
}
#if HAS_THERMAL_PROTECTION
@ -2373,7 +2440,7 @@ void Temperature::init() {
, " ; Idle Timeout:", heater_idle[idle_index].timed_out
#endif
);
//*/
*/
#if HEATER_IDLE_HANDLER
// If the heater idle timeout expires, restart
@ -2570,12 +2637,12 @@ void Temperature::disable_all_heaters() {
#else
constexpr uint8_t hindex = 0;
#define THERMO_TEMP(I) max_tc_temp
#if TEMP_SENSOR_1_IS_MAX31865
#if TEMP_SENSOR_IS_ANY_MAX_TC(1)
#define THERMO_SEL(A,B) B
#else
#define THERMO_SEL(A,B) A
#endif
#if TEMP_SENSOR_0_IS_MAX6675
#if TEMP_SENSOR_IS_MAX(0, MAX6675)
#define MAX6675_WRITE(V) WRITE(MAX6675_SS_PIN, V)
#define MAX6675_SET_OUTPUT() SET_OUTPUT(MAX6675_SS_PIN)
#else
@ -2723,12 +2790,12 @@ void Temperature::update_raw_temperatures() {
temp_hotend[0].update();
#endif
#if HAS_TEMP_ADC_1
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
temp_redundant.update();
#elif !TEMP_SENSOR_1_IS_MAX_TC
temp_hotend[1].update();
#endif
#if HAS_TEMP_ADC_1 && !TEMP_SENSOR_1_IS_MAX_TC
temp_hotend[1].update();
#endif
#if HAS_TEMP_ADC_REDUNDANT && !TEMP_SENSOR_REDUNDANT_IS_MAX_TC
temp_redundant.update();
#endif
TERN_(HAS_TEMP_ADC_2, temp_hotend[2].update());
@ -2764,13 +2831,13 @@ void Temperature::readings_ready() {
#if HAS_HOTEND
HOTEND_LOOP() temp_hotend[e].reset();
TERN_(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant.reset());
#endif
TERN_(HAS_HEATED_BED, temp_bed.reset());
TERN_(HAS_TEMP_CHAMBER, temp_chamber.reset());
TERN_(HAS_TEMP_PROBE, temp_probe.reset());
TERN_(HAS_TEMP_COOLER, temp_cooler.reset());
TERN_(HAS_TEMP_REDUNDANT, temp_redundant.reset());
TERN_(HAS_JOY_ADC_X, joystick.x.reset());
TERN_(HAS_JOY_ADC_Y, joystick.y.reset());
@ -3196,9 +3263,14 @@ void Temperature::isr() {
case MeasureTemp_PROBE: ACCUMULATE_ADC(temp_probe); break;
#endif
#if HAS_TEMP_ADC_REDUNDANT
case PrepareTemp_REDUNDANT: HAL_START_ADC(TEMP_REDUNDANT_PIN); break;
case MeasureTemp_REDUNDANT: ACCUMULATE_ADC(temp_redundant); break;
#endif
#if HAS_TEMP_ADC_1
case PrepareTemp_1: HAL_START_ADC(TEMP_1_PIN); break;
case MeasureTemp_1: ACCUMULATE_ADC(TERN(TEMP_SENSOR_1_AS_REDUNDANT, temp_redundant, temp_hotend[1])); break;
case MeasureTemp_1: ACCUMULATE_ADC(temp_hotend[1]); break;
#endif
#if HAS_TEMP_ADC_2
@ -3332,6 +3404,7 @@ void Temperature::isr() {
* Chamber: " C:nnn.nn /nnn.nn"
* Probe: " P:nnn.nn /nnn.nn"
* Cooler: " L:nnn.nn /nnn.nn"
* Redundant: " R:nnn.nn /nnn.nn"
* Extruder: " T0:nnn.nn /nnn.nn"
* With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)"
*/
@ -3356,7 +3429,7 @@ void Temperature::isr() {
#if HAS_TEMP_COOLER
case H_COOLER: k = 'L'; break;
#endif
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
#if HAS_TEMP_REDUNDANT
case H_REDUNDANT: k = 'R'; break;
#endif
}
@ -3382,13 +3455,10 @@ void Temperature::isr() {
}
void Temperature::print_heater_states(const uint8_t target_extruder
OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r/*=false*/)
OPTARG(HAS_TEMP_REDUNDANT, const bool include_r/*=false*/)
) {
#if HAS_TEMP_HOTEND
print_heater_state(H_NONE, degHotend(target_extruder), degTargetHotend(target_extruder) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(target_extruder)));
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
if (include_r) print_heater_state(H_REDUNDANT, degHotendRedundant(), degTargetHotend(0) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTempRedundant()));
#endif
#endif
#if HAS_HEATED_BED
print_heater_state(H_BED, degBed(), degTargetBed() OPTARG(SHOW_TEMP_ADC_VALUES, rawBedTemp()));
@ -3402,6 +3472,9 @@ void Temperature::isr() {
#if HAS_TEMP_PROBE
print_heater_state(H_PROBE, degProbe(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawProbeTemp()) );
#endif
#if HAS_TEMP_REDUNDANT
if (include_r) print_heater_state(H_REDUNDANT, degRedundant(), degRedundantTarget() OPTARG(SHOW_TEMP_ADC_VALUES, rawRedundantTemp()));
#endif
#if HAS_MULTI_HOTEND
HOTEND_LOOP() print_heater_state((heater_id_t)e, degHotend(e), degTargetHotend(e) OPTARG(SHOW_TEMP_ADC_VALUES, rawHotendTemp(e)));
#endif

View File

@ -105,6 +105,9 @@ enum ADCSensorState : char {
#if HAS_TEMP_ADC_PROBE
PrepareTemp_PROBE, MeasureTemp_PROBE,
#endif
#if HAS_TEMP_ADC_REDUNDANT
PrepareTemp_REDUNDANT, MeasureTemp_REDUNDANT,
#endif
#if HAS_TEMP_ADC_1
PrepareTemp_1, MeasureTemp_1,
#endif
@ -185,6 +188,13 @@ typedef struct TempInfo {
inline void update() { raw = acc; }
} temp_info_t;
#if HAS_TEMP_REDUNDANT
// A redundant temperature sensor
typedef struct RedundantTempInfo : public TempInfo {
temp_info_t* target;
} redundant_temp_info_t;
#endif
// A PWM heater with temperature sensor
typedef struct HeaterInfo : public TempInfo {
celsius_t target;
@ -299,9 +309,12 @@ typedef struct { int16_t raw_min, raw_max; celsius_t mintemp, maxtemp; } temp_ra
#if TEMP_SENSOR_CHAMBER_IS_CUSTOM
CTI_CHAMBER,
#endif
#if COOLER_USER_THERMISTOR
#if TEMP_SENSOR_COOLER_IS_CUSTOM
CTI_COOLER,
#endif
#if TEMP_SENSOR_REDUNDANT_IS_CUSTOM
CTI_REDUNDANT,
#endif
USER_THERMISTORS
};
@ -323,9 +336,6 @@ class Temperature {
public:
#if HAS_HOTEND
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
static temp_info_t temp_redundant;
#endif
static hotend_info_t temp_hotend[HOTENDS];
static const celsius_t hotend_maxtemp[HOTENDS];
static inline celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); }
@ -342,6 +352,9 @@ class Temperature {
#if ENABLED(HAS_TEMP_COOLER)
static cooler_info_t temp_cooler;
#endif
#if HAS_TEMP_REDUNDANT
static redundant_temp_info_t temp_redundant;
#endif
#if ENABLED(AUTO_POWER_E_FANS)
static uint8_t autofan_speed[HOTENDS];
@ -538,6 +551,9 @@ class Temperature {
#if HAS_TEMP_COOLER
static celsius_float_t analog_to_celsius_cooler(const int16_t raw);
#endif
#if HAS_TEMP_REDUNDANT
static celsius_float_t analog_to_celsius_redundant(const int16_t raw);
#endif
#if HAS_FAN
@ -626,10 +642,6 @@ class Temperature {
return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].celsius);
}
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
static inline celsius_float_t degHotendRedundant() { return temp_redundant.celsius; }
#endif
static inline celsius_t wholeDegHotend(const uint8_t E_NAME) {
return TERN0(HAS_HOTEND, static_cast<celsius_t>(temp_hotend[HOTEND_INDEX].celsius + 0.5f));
}
@ -638,9 +650,6 @@ class Temperature {
static inline int16_t rawHotendTemp(const uint8_t E_NAME) {
return TERN0(HAS_HOTEND, temp_hotend[HOTEND_INDEX].raw);
}
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
static inline int16_t rawHotendTempRedundant() { return temp_redundant.raw; }
#endif
#endif
static inline celsius_t degTargetHotend(const uint8_t E_NAME) {
@ -778,6 +787,17 @@ class Temperature {
#endif
#endif
#if HAS_TEMP_REDUNDANT
#if ENABLED(SHOW_TEMP_ADC_VALUES)
static inline int16_t rawRedundantTemp() { return temp_redundant.raw; }
static inline int16_t rawRedundanTargetTemp() { return (*temp_redundant.target).raw; }
#endif
static inline celsius_float_t degRedundant() { return temp_redundant.celsius; }
static inline celsius_float_t degRedundantTarget() { return (*temp_redundant.target).celsius; }
static inline celsius_t wholeDegRedundant() { return static_cast<celsius_t>(temp_redundant.celsius + 0.5f); }
static inline celsius_t wholeDegRedundantTarget() { return static_cast<celsius_t>((*temp_redundant.target).celsius + 0.5f); }
#endif
#if HAS_COOLER
static inline void setTargetCooler(const celsius_t celsius) {
temp_cooler.target = constrain(celsius, COOLER_MIN_TARGET, COOLER_MAX_TARGET);
@ -855,7 +875,7 @@ class Temperature {
#if HAS_TEMP_SENSOR
static void print_heater_states(const uint8_t target_extruder
OPTARG(TEMP_SENSOR_1_AS_REDUNDANT, const bool include_r=false)
OPTARG(HAS_TEMP_REDUNDANT, const bool include_r=false)
);
#if ENABLED(AUTO_REPORT_TEMPERATURES)
struct AutoReportTemp { static void report(); };
@ -888,7 +908,7 @@ class Temperature {
// MAX Thermocouples
#if HAS_MAX_TC
#define MAX_TC_COUNT 1 + BOTH(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC)
#define MAX_TC_COUNT COUNT_ENABLED(TEMP_SENSOR_0_IS_MAX_TC, TEMP_SENSOR_1_IS_MAX_TC, TEMP_SENSOR_REDUNDANT_IS_MAX_TC)
#if MAX_TC_COUNT > 1
#define HAS_MULTI_MAX_TC 1
#define READ_MAX_TC(N) read_max_tc(N)

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 100 kOhm, beta25 = 4092 K, 4.7 kOhm pull-up, bed thermistor
const temp_entry_t temptable_1[] PROGMEM = {
constexpr temp_entry_t temptable_1[] PROGMEM = {
{ OV( 23), 300 },
{ OV( 25), 295 },
{ OV( 27), 290 },

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 100 kOhm, beta25 = 3960 K, 4.7 kOhm pull-up, RS thermistor 198-961
const temp_entry_t temptable_10[] PROGMEM = {
constexpr temp_entry_t temptable_10[] PROGMEM = {
{ OV( 1), 929 },
{ OV( 36), 299 },
{ OV( 71), 246 },

View File

@ -24,7 +24,7 @@
#define REVERSE_TEMP_SENSOR_RANGE_1010 1
// Pt1000 with 1k0 pullup
const temp_entry_t temptable_1010[] PROGMEM = {
constexpr temp_entry_t temptable_1010[] PROGMEM = {
PtLine( 0, 1000, 1000),
PtLine( 25, 1000, 1000),
PtLine( 50, 1000, 1000),

View File

@ -24,7 +24,7 @@
#define REVERSE_TEMP_SENSOR_RANGE_1047 1
// Pt1000 with 4k7 pullup
const temp_entry_t temptable_1047[] PROGMEM = {
constexpr 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),

View File

@ -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 temp_entry_t temptable_11[] PROGMEM = {
constexpr temp_entry_t temptable_11[] PROGMEM = {
{ OV( 1), 938 },
{ OV( 31), 314 },
{ OV( 41), 290 },

View File

@ -24,7 +24,7 @@
#define REVERSE_TEMP_SENSOR_RANGE_110 1
// Pt100 with 1k0 pullup
const temp_entry_t temptable_110[] PROGMEM = {
constexpr 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),

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 100 kOhm, beta25 = 4700 K, 4.7 kOhm pull-up, (personal calibration for Makibox hot bed)
const temp_entry_t temptable_12[] PROGMEM = {
constexpr temp_entry_t temptable_12[] PROGMEM = {
{ OV( 35), 180 }, // top rating 180C
{ OV( 211), 140 },
{ OV( 233), 135 },

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 100 kOhm, beta25 = 4100 K, 4.7 kOhm pull-up, Hisens thermistor
const temp_entry_t temptable_13[] PROGMEM = {
constexpr temp_entry_t temptable_13[] PROGMEM = {
{ OV( 20.04), 300 },
{ OV( 23.19), 290 },
{ OV( 26.71), 280 },

View File

@ -24,7 +24,7 @@
#define REVERSE_TEMP_SENSOR_RANGE_147 1
// Pt100 with 4k7 pullup
const temp_entry_t temptable_147[] PROGMEM = {
constexpr 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),

View File

@ -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 temp_entry_t temptable_15[] PROGMEM = {
constexpr temp_entry_t temptable_15[] PROGMEM = {
{ OV( 31), 275 },
{ OV( 33), 270 },
{ OV( 35), 260 },

View File

@ -22,7 +22,7 @@
#pragma once
// Dagoma NTC 100k white thermistor
const temp_entry_t temptable_17[] PROGMEM = {
constexpr temp_entry_t temptable_17[] PROGMEM = {
{ OV( 16), 309 },
{ OV( 18), 307 },
{ OV( 20), 300 },

View File

@ -22,7 +22,7 @@
#pragma once
// ATC Semitec 204GT-2 (4.7k pullup) Dagoma.Fr - MKS_Base_DKU001327 - version (measured/tested/approved)
const temp_entry_t temptable_18[] PROGMEM = {
constexpr temp_entry_t temptable_18[] PROGMEM = {
{ OV( 1), 713 },
{ OV( 17), 284 },
{ OV( 20), 275 },

View File

@ -26,7 +26,7 @@
// Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
//
const temp_entry_t temptable_2[] PROGMEM = {
constexpr temp_entry_t temptable_2[] PROGMEM = {
{ OV( 1), 848 },
{ OV( 30), 300 }, // top rating 300C
{ OV( 34), 290 },

View File

@ -24,7 +24,7 @@
#define REVERSE_TEMP_SENSOR_RANGE_20 1
// Pt100 with INA826 amp on Ultimaker v2.0 electronics
const temp_entry_t temptable_20[] PROGMEM = {
constexpr temp_entry_t temptable_20[] PROGMEM = {
{ OV( 0), 0 },
{ OV(227), 1 },
{ OV(236), 10 },

View File

@ -24,7 +24,7 @@
#define REVERSE_TEMP_SENSOR_RANGE_201 1
// Pt100 with LMV324 amp on Overlord v1.1 electronics
const temp_entry_t temptable_201[] PROGMEM = {
constexpr temp_entry_t temptable_201[] PROGMEM = {
{ OV( 0), 0 },
{ OV( 8), 1 },
{ OV( 23), 6 },

View File

@ -3,7 +3,7 @@
// Temptable sent from dealer technologyoutlet.co.uk
//
const temp_entry_t temptable_202[] PROGMEM = {
constexpr temp_entry_t temptable_202[] PROGMEM = {
{ OV( 1), 864 },
{ OV( 35), 300 },
{ OV( 38), 295 },

View File

@ -28,7 +28,7 @@
// Pt100 with INA826 amplifier board with 5v supply based on Thermistor 20, with 3v3 ADC reference on the mainboard.
// If the ADC reference and INA826 board supply voltage are identical, Thermistor 20 instead.
const temp_entry_t temptable_21[] PROGMEM = {
constexpr temp_entry_t temptable_21[] PROGMEM = {
{ OV( 0), 0 },
{ OV(227), 1 },
{ OV(236), 10 },

View File

@ -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 temp_entry_t temptable_22[] PROGMEM = {
constexpr temp_entry_t temptable_22[] PROGMEM = {
{ OV( 1), 352 },
{ OV( 6), 341 },
{ OV( 11), 330 },

View File

@ -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 temp_entry_t temptable_23[] PROGMEM = {
constexpr temp_entry_t temptable_23[] PROGMEM = {
{ OV( 1), 938 },
{ OV( 11), 423 },
{ OV( 21), 351 },

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 100 kOhm, beta25 = 4120 K, 4.7 kOhm pull-up, mendel-parts
const temp_entry_t temptable_3[] PROGMEM = {
constexpr temp_entry_t temptable_3[] PROGMEM = {
{ OV( 1), 864 },
{ OV( 21), 300 },
{ OV( 25), 290 },

View File

@ -28,7 +28,7 @@
// B Value Tolerance + / - 1%
// Kis3d Silicone Heater 24V 200W/300W with 6mm Precision cast plate (EN AW 5083)
// Temperature setting time 10 min to determine the 12Bit ADC value on the surface. (le3tspeak)
const temp_entry_t temptable_30[] PROGMEM = {
constexpr temp_entry_t temptable_30[] PROGMEM = {
{ OV( 1), 938 },
{ OV( 298), 125 }, // 1193 - 125°
{ OV( 321), 121 }, // 1285 - 121°

View File

@ -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 temp_entry_t temptable_331[] PROGMEM = {
constexpr temp_entry_t temptable_331[] PROGMEM = {
{ OVM( 23), 300 },
{ OVM( 25), 295 },
{ OVM( 27), 290 },

View File

@ -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 temp_entry_t temptable_332[] PROGMEM = {
constexpr temp_entry_t temptable_332[] PROGMEM = {
{ OVM( 268), 150 },
{ OVM( 293), 145 },
{ OVM( 320), 141 },

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 10 kOhm, beta25 = 3950 K, 4.7 kOhm pull-up, Generic 10k thermistor
const temp_entry_t temptable_4[] PROGMEM = {
constexpr temp_entry_t temptable_4[] PROGMEM = {
{ OV( 1), 430 },
{ OV( 54), 137 },
{ OV( 107), 107 },

View File

@ -26,7 +26,7 @@
// ATC Semitec 104GT-2/104NT-4-R025H42G (Used in ParCan)
// Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf
// Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance
const temp_entry_t temptable_5[] PROGMEM = {
constexpr temp_entry_t temptable_5[] PROGMEM = {
{ OV( 1), 713 },
{ OV( 17), 300 }, // top rating 300C
{ OV( 20), 290 },

View File

@ -22,7 +22,7 @@
#pragma once
// 100k Zonestar thermistor. Adjusted By Hally
const temp_entry_t temptable_501[] PROGMEM = {
constexpr temp_entry_t temptable_501[] PROGMEM = {
{ OV( 1), 713 },
{ OV( 14), 300 }, // Top rating 300C
{ OV( 16), 290 },

View File

@ -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 temp_entry_t temptable_502[] PROGMEM = {
constexpr temp_entry_t temptable_502[] PROGMEM = {
{ OV( 56.0 / 4), 300 },
{ OV( 187.0 / 4), 250 },
{ OV( 615.0 / 4), 190 },

View File

@ -23,7 +23,7 @@
// Zonestar (Z8XM2) Heated Bed thermistor. Added By AvanOsch
// These are taken from the Zonestar settings in original Repetier firmware: Z8XM2_ZRIB_LCD12864_V51.zip
const temp_entry_t temptable_503[] PROGMEM = {
constexpr temp_entry_t temptable_503[] PROGMEM = {
{ OV( 12), 300 },
{ OV( 27), 270 },
{ OV( 47), 250 },

View File

@ -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 temp_entry_t temptable_51[] PROGMEM = {
constexpr temp_entry_t temptable_51[] PROGMEM = {
{ OV( 1), 350 },
{ OV( 190), 250 }, // top rating 250C
{ OV( 203), 245 },

View File

@ -22,7 +22,7 @@
// 100k thermistor supplied with RPW-Ultra hotend, 4.7k pullup
const temp_entry_t temptable_512[] PROGMEM = {
constexpr temp_entry_t temptable_512[] PROGMEM = {
{ OV(26), 300 },
{ OV(28), 295 },
{ OV(30), 290 },

View File

@ -26,7 +26,7 @@
// Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf
// Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
// Advantage: More resolution and better linearity from 150C to 200C
const temp_entry_t temptable_52[] PROGMEM = {
constexpr temp_entry_t temptable_52[] PROGMEM = {
{ OV( 1), 500 },
{ OV( 125), 300 }, // top rating 300C
{ OV( 142), 290 },

View File

@ -26,7 +26,7 @@
// Verified by linagee. Source: https://www.mouser.com/datasheet/2/362/semitec%20usa%20corporation_gtthermistor-1202937.pdf
// Calculated using 1kohm pullup, voltage divider math, and manufacturer provided temp/resistance
// Advantage: More resolution and better linearity from 150C to 200C
const temp_entry_t temptable_55[] PROGMEM = {
constexpr temp_entry_t temptable_55[] PROGMEM = {
{ OV( 1), 500 },
{ OV( 76), 300 },
{ OV( 87), 290 },

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 100 kOhm, beta25 = 4092 K, 8.2 kOhm pull-up, 100k Epcos (?) thermistor
const temp_entry_t temptable_6[] PROGMEM = {
constexpr temp_entry_t temptable_6[] PROGMEM = {
{ OV( 1), 350 },
{ OV( 28), 250 }, // top rating 250C
{ OV( 31), 245 },

View File

@ -31,7 +31,7 @@
// beta: 3950
// min adc: 1 at 0.0048828125 V
// max adc: 1023 at 4.9951171875 V
const temp_entry_t temptable_60[] PROGMEM = {
constexpr temp_entry_t temptable_60[] PROGMEM = {
{ OV( 51), 272 },
{ OV( 61), 258 },
{ OV( 71), 247 },

View File

@ -30,7 +30,7 @@
// Resistance Tolerance + / -1%
// B Value 3950K at 25/50 deg. C
// B Value Tolerance + / - 1%
const temp_entry_t temptable_61[] PROGMEM = {
constexpr 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 },

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign 500 °C Thermistor
const temp_entry_t temptable_66[] PROGMEM = {
constexpr temp_entry_t temptable_66[] PROGMEM = {
{ OV( 17.5), 850 },
{ OV( 17.9), 500 },
{ OV( 21.7), 480 },

View File

@ -33,7 +33,7 @@
* B: 0.00031362
* C: -2.03978e-07
*/
const temp_entry_t temptable_666[] PROGMEM = {
constexpr temp_entry_t temptable_666[] PROGMEM = {
{ OV( 1), 794 },
{ OV( 18), 288 },
{ OV( 35), 234 },

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 500 KOhm, beta25 = 3800 K, 4.7 kOhm pull-up, SliceEngineering 450 °C Thermistor
const temp_entry_t temptable_67[] PROGMEM = {
constexpr temp_entry_t temptable_67[] PROGMEM = {
{ OV( 22 ), 500 },
{ OV( 23 ), 490 },
{ OV( 25 ), 480 },

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 100 kOhm, beta25 = 3974 K, 4.7 kOhm pull-up, Honeywell 135-104LAG-J01
const temp_entry_t temptable_7[] PROGMEM = {
constexpr temp_entry_t temptable_7[] PROGMEM = {
{ OV( 1), 941 },
{ OV( 19), 362 },
{ OV( 37), 299 }, // top rating 300C

View File

@ -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 temp_entry_t temptable_70[] PROGMEM = {
constexpr temp_entry_t temptable_70[] PROGMEM = {
{ OV( 18), 270 },
{ OV( 27), 248 },
{ OV( 34), 234 },

View File

@ -27,7 +27,7 @@
// Beta = 3974
// R1 = 0 Ohm
// R2 = 4700 Ohm
const temp_entry_t temptable_71[] PROGMEM = {
constexpr temp_entry_t temptable_71[] PROGMEM = {
{ OV( 35), 300 },
{ OV( 51), 269 },
{ OV( 59), 258 },

View File

@ -34,7 +34,7 @@
//#define HIGH_TEMP_RANGE_75
const temp_entry_t temptable_75[] PROGMEM = { // Generic Silicon Heat Pad with NTC 100K MGB18-104F39050L32 thermistor
constexpr 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

View File

@ -22,7 +22,7 @@
#pragma once
// R25 = 100 kOhm, beta25 = 3950 K, 10 kOhm pull-up, NTCS0603E3104FHT
const temp_entry_t temptable_8[] PROGMEM = {
constexpr temp_entry_t temptable_8[] PROGMEM = {
{ OV( 1), 704 },
{ OV( 54), 216 },
{ OV( 107), 175 },

View File

@ -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 temp_entry_t temptable_9[] PROGMEM = {
constexpr temp_entry_t temptable_9[] PROGMEM = {
{ OV( 1), 936 },
{ OV( 36), 300 },
{ OV( 71), 246 },

View File

@ -24,7 +24,7 @@
// 100k bed thermistor with a 10K pull-up resistor - made by $ buildroot/share/scripts/createTemperatureLookupMarlin.py --rp=10000
const temp_entry_t temptable_99[] PROGMEM = {
constexpr 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

View File

@ -27,7 +27,7 @@
#define DUMMY_THERMISTOR_998_VALUE 25
#endif
const temp_entry_t temptable_998[] PROGMEM = {
constexpr temp_entry_t temptable_998[] PROGMEM = {
{ OV( 1), DUMMY_THERMISTOR_998_VALUE },
{ OV(1023), DUMMY_THERMISTOR_998_VALUE }
};

View File

@ -27,7 +27,7 @@
#define DUMMY_THERMISTOR_999_VALUE 25
#endif
const temp_entry_t temptable_999[] PROGMEM = {
constexpr temp_entry_t temptable_999[] PROGMEM = {
{ OV( 1), DUMMY_THERMISTOR_999_VALUE },
{ OV(1023), DUMMY_THERMISTOR_999_VALUE }
};

View File

@ -42,7 +42,16 @@
#define OV_SCALE(N) (N)
#define OV(N) int16_t(OV_SCALE(N) * (OVERSAMPLENR) * (THERMISTOR_TABLE_SCALE))
#define ANY_THERMISTOR_IS(n) (TEMP_SENSOR_0_THERMISTOR_ID == n || TEMP_SENSOR_1_THERMISTOR_ID == n || TEMP_SENSOR_2_THERMISTOR_ID == n || TEMP_SENSOR_3_THERMISTOR_ID == n || TEMP_SENSOR_4_THERMISTOR_ID == n || TEMP_SENSOR_5_THERMISTOR_ID == n || TEMP_SENSOR_6_THERMISTOR_ID == n || TEMP_SENSOR_7_THERMISTOR_ID == n || TEMP_SENSOR_BED_THERMISTOR_ID == n || TEMP_SENSOR_CHAMBER_THERMISTOR_ID == n || TEMP_SENSOR_COOLER_THERMISTOR_ID == n || TEMP_SENSOR_PROBE_THERMISTOR_ID == n)
#define TEMP_SENSOR_IS(n,H) (n == TEMP_SENSOR_##H)
#define ANY_THERMISTOR_IS(n) ( TEMP_SENSOR_IS(n, 0) || TEMP_SENSOR_IS(n, 1) \
|| TEMP_SENSOR_IS(n, 2) || TEMP_SENSOR_IS(n, 3) \
|| TEMP_SENSOR_IS(n, 4) || TEMP_SENSOR_IS(n, 5) \
|| TEMP_SENSOR_IS(n, 6) || TEMP_SENSOR_IS(n, 7) \
|| TEMP_SENSOR_IS(n, BED) \
|| TEMP_SENSOR_IS(n, CHAMBER) \
|| TEMP_SENSOR_IS(n, COOLER) \
|| TEMP_SENSOR_IS(n, PROBE) \
|| TEMP_SENSOR_IS(n, REDUNDANT) )
typedef struct { int16_t value; celsius_t celsius; } temp_entry_t;
@ -198,146 +207,128 @@ typedef struct { int16_t value; celsius_t celsius; } temp_entry_t;
#include "thermistor_999.h"
#endif
#if ANY_THERMISTOR_IS(1000) // Custom
const temp_entry_t temptable_1000[] PROGMEM = { { 0, 0 } };
constexpr temp_entry_t temptable_1000[] PROGMEM = { { 0, 0 } };
#endif
#define _TT_NAME(_N) temptable_ ## _N
#define TT_NAME(_N) _TT_NAME(_N)
#if TEMP_SENSOR_0_THERMISTOR_ID
#define TEMPTABLE_0 TT_NAME(TEMP_SENSOR_0_THERMISTOR_ID)
#if TEMP_SENSOR_0 > 0
#define TEMPTABLE_0 TT_NAME(TEMP_SENSOR_0)
#define TEMPTABLE_0_LEN COUNT(TEMPTABLE_0)
#elif TEMP_SENSOR_0_IS_THERMISTOR
#error "No heater 0 thermistor table specified"
#else
#define TEMPTABLE_0 nullptr
#define TEMPTABLE_0_LEN 0
#endif
#if TEMP_SENSOR_1_THERMISTOR_ID
#define TEMPTABLE_1 TT_NAME(TEMP_SENSOR_1_THERMISTOR_ID)
#if TEMP_SENSOR_1 > 0
#define TEMPTABLE_1 TT_NAME(TEMP_SENSOR_1)
#define TEMPTABLE_1_LEN COUNT(TEMPTABLE_1)
#elif TEMP_SENSOR_1_IS_THERMISTOR
#error "No heater 1 thermistor table specified"
#else
#define TEMPTABLE_1 nullptr
#define TEMPTABLE_1_LEN 0
#endif
#if TEMP_SENSOR_2_THERMISTOR_ID
#define TEMPTABLE_2 TT_NAME(TEMP_SENSOR_2_THERMISTOR_ID)
#if TEMP_SENSOR_2 > 0
#define TEMPTABLE_2 TT_NAME(TEMP_SENSOR_2)
#define TEMPTABLE_2_LEN COUNT(TEMPTABLE_2)
#elif TEMP_SENSOR_2_IS_THERMISTOR
#error "No heater 2 thermistor table specified"
#else
#define TEMPTABLE_2 nullptr
#define TEMPTABLE_2_LEN 0
#endif
#if TEMP_SENSOR_3_THERMISTOR_ID
#define TEMPTABLE_3 TT_NAME(TEMP_SENSOR_3_THERMISTOR_ID)
#if TEMP_SENSOR_3 > 0
#define TEMPTABLE_3 TT_NAME(TEMP_SENSOR_3)
#define TEMPTABLE_3_LEN COUNT(TEMPTABLE_3)
#elif TEMP_SENSOR_3_IS_THERMISTOR
#error "No heater 3 thermistor table specified"
#else
#define TEMPTABLE_3 nullptr
#define TEMPTABLE_3_LEN 0
#endif
#if TEMP_SENSOR_4_THERMISTOR_ID
#define TEMPTABLE_4 TT_NAME(TEMP_SENSOR_4_THERMISTOR_ID)
#if TEMP_SENSOR_4 > 0
#define TEMPTABLE_4 TT_NAME(TEMP_SENSOR_4)
#define TEMPTABLE_4_LEN COUNT(TEMPTABLE_4)
#elif TEMP_SENSOR_4_IS_THERMISTOR
#error "No heater 4 thermistor table specified"
#else
#define TEMPTABLE_4 nullptr
#define TEMPTABLE_4_LEN 0
#endif
#if TEMP_SENSOR_5_THERMISTOR_ID
#define TEMPTABLE_5 TT_NAME(TEMP_SENSOR_5_THERMISTOR_ID)
#if TEMP_SENSOR_5 > 0
#define TEMPTABLE_5 TT_NAME(TEMP_SENSOR_5)
#define TEMPTABLE_5_LEN COUNT(TEMPTABLE_5)
#elif TEMP_SENSOR_5_IS_THERMISTOR
#error "No heater 5 thermistor table specified"
#else
#define TEMPTABLE_5 nullptr
#define TEMPTABLE_5_LEN 0
#endif
#if TEMP_SENSOR_6_THERMISTOR_ID
#define TEMPTABLE_6 TT_NAME(TEMP_SENSOR_6_THERMISTOR_ID)
#if TEMP_SENSOR_6 > 0
#define TEMPTABLE_6 TT_NAME(TEMP_SENSOR_6)
#define TEMPTABLE_6_LEN COUNT(TEMPTABLE_6)
#elif TEMP_SENSOR_6_IS_THERMISTOR
#error "No heater 6 thermistor table specified"
#else
#define TEMPTABLE_6 nullptr
#define TEMPTABLE_6_LEN 0
#endif
#if TEMP_SENSOR_7_THERMISTOR_ID
#define TEMPTABLE_7 TT_NAME(TEMP_SENSOR_7_THERMISTOR_ID)
#if TEMP_SENSOR_7 > 0
#define TEMPTABLE_7 TT_NAME(TEMP_SENSOR_7)
#define TEMPTABLE_7_LEN COUNT(TEMPTABLE_7)
#elif TEMP_SENSOR_7_IS_THERMISTOR
#error "No heater 7 thermistor table specified"
#else
#define TEMPTABLE_7 nullptr
#define TEMPTABLE_7_LEN 0
#endif
#ifdef TEMP_SENSOR_BED_THERMISTOR_ID
#define TEMPTABLE_BED TT_NAME(TEMP_SENSOR_BED_THERMISTOR_ID)
#if TEMP_SENSOR_BED > 0
#define TEMPTABLE_BED TT_NAME(TEMP_SENSOR_BED)
#define TEMPTABLE_BED_LEN COUNT(TEMPTABLE_BED)
#elif TEMP_SENSOR_BED_IS_THERMISTOR
#error "No bed thermistor table specified"
#else
#define TEMPTABLE_BED_LEN 0
#endif
#ifdef TEMP_SENSOR_CHAMBER_THERMISTOR_ID
#define TEMPTABLE_CHAMBER TT_NAME(TEMP_SENSOR_CHAMBER_THERMISTOR_ID)
#if TEMP_SENSOR_CHAMBER > 0
#define TEMPTABLE_CHAMBER TT_NAME(TEMP_SENSOR_CHAMBER)
#define TEMPTABLE_CHAMBER_LEN COUNT(TEMPTABLE_CHAMBER)
#elif TEMP_SENSOR_CHAMBER_IS_THERMISTOR
#error "No chamber thermistor table specified"
#else
#define TEMPTABLE_CHAMBER_LEN 0
#endif
#ifdef TEMP_SENSOR_COOLER_THERMISTOR_ID
#define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER_THERMISTOR_ID)
#if TEMP_SENSOR_COOLER > 0
#define TEMPTABLE_COOLER TT_NAME(TEMP_SENSOR_COOLER)
#define TEMPTABLE_COOLER_LEN COUNT(TEMPTABLE_COOLER)
#elif TEMP_SENSOR_COOLER_IS_THERMISTOR
#error "No cooler thermistor table specified"
#else
#define TEMPTABLE_COOLER_LEN 0
#endif
#ifdef TEMP_SENSOR_PROBE_THERMISTOR_ID
#define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE_THERMISTOR_ID)
#if TEMP_SENSOR_PROBE > 0
#define TEMPTABLE_PROBE TT_NAME(TEMP_SENSOR_PROBE)
#define TEMPTABLE_PROBE_LEN COUNT(TEMPTABLE_PROBE)
#elif TEMP_SENSOR_PROBE_IS_THERMISTOR
#error "No probe thermistor table specified"
#else
#define TEMPTABLE_PROBE_LEN 0
#endif
#if TEMP_SENSOR_REDUNDANT > 0
#define TEMPTABLE_REDUNDANT TT_NAME(TEMP_SENSOR_REDUNDANT)
#define TEMPTABLE_REDUNDANT_LEN COUNT(TEMPTABLE_REDUNDANT)
#else
#define TEMPTABLE_REDUNDANT_LEN 0
#endif
// The SCAN_THERMISTOR_TABLE macro needs alteration?
static_assert(
TEMPTABLE_0_LEN < 256 && TEMPTABLE_1_LEN < 256
&& TEMPTABLE_2_LEN < 256 && TEMPTABLE_3_LEN < 256
&& TEMPTABLE_4_LEN < 256 && TEMPTABLE_5_LEN < 256
&& TEMPTABLE_6_LEN < 256 && TEMPTABLE_7_LEN < 256
&& TEMPTABLE_BED_LEN < 256 && TEMPTABLE_CHAMBER_LEN < 256
&& TEMPTABLE_COOLER_LEN < 256 && TEMPTABLE_PROBE_LEN < 256,
"Temperature conversion tables over 255 entries need special consideration."
static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_2_LEN || 255 > TEMPTABLE_3_LEN
|| 255 > TEMPTABLE_4_LEN || 255 > TEMPTABLE_5_LEN || 255 > TEMPTABLE_6_LEN || 255 > TEMPTABLE_7_LEN
|| 255 > TEMPTABLE_BED_LEN
|| 255 > TEMPTABLE_CHAMBER_LEN
|| 255 > TEMPTABLE_COOLER_LEN
|| 255 > TEMPTABLE_PROBE_LEN
|| 255 > TEMPTABLE_REDUNDANT_LEN
, "Temperature conversion tables over 255 entries need special consideration."
);
// 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)
#define TT_REV(N) _TT_REV(TEMP_SENSOR_##N##_THERMISTOR_ID)
#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_REVRAW(N) !TEMP_SENSOR_##N##_IS_THERMISTOR
#define TT_REVRAW(N) (TT_REV(N) || _TT_REVRAW(N))
@ -522,6 +513,15 @@ static_assert(
#define TEMP_SENSOR_PROBE_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#ifndef TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP
#if TT_REVRAW(REDUNDANT)
#define TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE
#define TEMP_SENSOR_REDUNDANT_RAW_LO_TEMP 0
#else
#define TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP 0
#define TEMP_SENSOR_REDUNDANT_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE
#endif
#endif
#undef __TT_REV
#undef _TT_REV

View File

@ -37,7 +37,7 @@ env shortcuts: tree due esp lin lpc|lpc8 lpc9 m128 m256|mega stm|f1 f4 f7 s6 tee
TESTPATH=buildroot/tests
STATE_FILE="./.pio/.mftestrc"
SED=$(which gsed || which sed)
SED=$(which gsed sed | head -n1)
shopt -s extglob nocasematch

View File

@ -3,7 +3,7 @@
# exit on first failure
set -e
SED=$(which gsed || which sed)
SED=$(which gsed sed | head -n1)
for opt in "$@" ; do
DID=0 ; FOUND=0

View File

@ -3,7 +3,7 @@
# exit on first failure
set -e
SED=$(which gsed || which sed)
SED=$(which gsed sed | head -n1)
for opt in "$@" ; do
DID=0 ; FOUND=0

View File

@ -3,7 +3,7 @@
# exit on first failure
set -e
SED=$(which gsed || which sed)
SED=$(which gsed sed | head -n1)
while [[ $# > 1 ]]; do
DID=0

View File

@ -6,6 +6,6 @@ NAM=${PINPATH[1]}
PIN=$2
VAL=$3
SED=$(which gsed || which sed)
SED=$(which gsed sed | head -n1)
eval "${SED} -i '/^[[:blank:]]*\(\/\/\)*[[:blank:]]*\(#define \+${PIN}\b\).*$/{s//\2 ${VAL}/;h};\${x;/./{x;q0};x;q9}' Marlin/src/pins/$DIR/pins_${NAM}.h" ||
(echo "ERROR: pins_set Can't find ${PIN}" >&2 && exit 9)

View File

@ -149,7 +149,7 @@ if [[ $ACTION == "init" ]]; then
((COMMIT_STEPS)) && git add . >/dev/null && git commit -m "Reset TPARA..." >/dev/null
# Update the %VERSION% in the README.md file
SED=$(which gsed || which sed)
SED=$(which gsed sed | head -n1)
VERS=$( echo $EXPORT | $SED 's/release-//' )
eval "${SED} -E -i~ -e 's/%VERSION%/$VERS/g' README.md"
rm -f README.md~