Skip to content

Commit

Permalink
✨ More flexible redundant temp sensor (MarlinFirmware#22085)
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbro authored and thinkyhead committed Jun 15, 2021
1 parent 5d80f70 commit d322e49
Show file tree
Hide file tree
Showing 65 changed files with 573 additions and 254 deletions.
28 changes: 23 additions & 5 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LPC1768/tft/xpt2046.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32/tft/xpt2046.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/tft/xpt2046.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions Marlin/src/gcode/temp/M105.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Loading

0 comments on commit d322e49

Please sign in to comment.