Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max31865 support for heated bed #26441

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,10 @@
* ================================================================
* SPI RTD/Thermocouple Boards
* ================================================================
* -5 : MAX31865 with Pt100/Pt1000, 2, 3, or 4-wire (only for sensors 0-1)
* -5 : MAX31865 with Pt100/Pt1000, 2, 3, or 4-wire (only for sensors 0-2 and bed)
* NOTE: You must uncomment/set the MAX31865_*_OHMS_n defines below.
* -3 : MAX31855 with Thermocouple, -200°C to +700°C (only for sensors 0-1)
* -2 : MAX6675 with Thermocouple, 0°C to +700°C (only for sensors 0-1)
* -3 : MAX31855 with Thermocouple, -200°C to +700°C (only for sensors 0-2 and bed)
* -2 : MAX6675 with Thermocouple, 0°C to +700°C (only for sensors 0-2 and bed)
*
* NOTE: Ensure TEMP_n_CS_PIN is set in your pins file for each TEMP_SENSOR_n using an SPI Thermocouple. By default,
* Hardware SPI on the default serial bus is used. If you have also set TEMP_n_SCK_PIN and TEMP_n_MISO_PIN,
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,12 @@ void setup() {
#if TEMP_SENSOR_IS_MAX_TC(1) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1))
OUT_WRITE(TEMP_1_CS_PIN, HIGH);
#endif
#if TEMP_SENSOR_IS_MAX_TC(2) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E2))
OUT_WRITE(TEMP_2_CS_PIN, HIGH);
#endif
#if TEMP_SENSOR_IS_MAX_TC(BED)
OUT_WRITE(TEMP_BED_CS_PIN, HIGH);
#endif

#if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); // Put Smart Effector into NORMAL mode
Expand Down
56 changes: 37 additions & 19 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,33 +507,35 @@
#endif

#if TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
#define _REDUNDANT_E (REDUNDANT_TEMP_MATCH(SOURCE, E0) || REDUNDANT_TEMP_MATCH(SOURCE, E1) || REDUNDANT_TEMP_MATCH(SOURCE, E2))
#if TEMP_SENSOR_REDUNDANT == -5
#if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2)
#error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)."
#if !_REDUNDANT_E
#error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_[0-2]."
#endif

#define TEMP_SENSOR_REDUNDANT_IS_MAX31865 1
#define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN 0
#define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024
#elif TEMP_SENSOR_REDUNDANT == -3
#if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2)
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)."
#if !_REDUNDANT_E
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_[0-2]."
#endif

#define TEMP_SENSOR_REDUNDANT_IS_MAX31855 1
#define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN -270
#define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1800
#elif TEMP_SENSOR_REDUNDANT == -2
#if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2)
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)."
#if !_REDUNDANT_E
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_[0-2]."
#endif

#define TEMP_SENSOR_REDUNDANT_IS_MAX6675 1
#define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN 0
#define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024
#endif
#undef _REDUNDANT_E

// mimic setting up the source TEMP_SENSOR
// Mimic setting up the source TEMP_SENSOR
#if REDUNDANT_TEMP_MATCH(SOURCE, E0)
#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
Expand All @@ -556,11 +558,11 @@

#if (TEMP_SENSOR_IS_MAX_TC(0) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_IS_MAX_TC(1) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1) || (TEMP_SENSOR_IS_MAX_TC(2) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_2)
#if TEMP_SENSOR_REDUNDANT == -5
#error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 then TEMP_SENSOR_REDUNDANT must match."
#error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_[0-2] 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/TEMP_SENSOR_2 then TEMP_SENSOR_REDUNDANT must match."
#error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_[0-2] 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/TEMP_SENSOR_2 then TEMP_SENSOR_REDUNDANT must match."
#error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_[0-2] then TEMP_SENSOR_REDUNDANT must match."
#endif
#endif
#elif TEMP_SENSOR_REDUNDANT == -4
Expand All @@ -576,16 +578,16 @@
#endif
#endif

#if TEMP_SENSOR_IS_MAX_TC(0) || TEMP_SENSOR_IS_MAX_TC(1) || TEMP_SENSOR_IS_MAX_TC(2) || TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
#if TEMP_SENSOR_IS_MAX_TC(0) || TEMP_SENSOR_IS_MAX_TC(1) || TEMP_SENSOR_IS_MAX_TC(2) || TEMP_SENSOR_IS_MAX_TC(BED) || TEMP_SENSOR_IS_MAX_TC(REDUNDANT)
#define HAS_MAX_TC 1
#endif
#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_2_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675
#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_2_IS_MAX6675 || TEMP_SENSOR_BED_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675
#define HAS_MAX6675 1
#endif
#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_2_IS_MAX31855 || TEMP_SENSOR_REDUNDANT_IS_MAX31855
#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_2_IS_MAX31855 || TEMP_SENSOR_BED_IS_MAX31855 || TEMP_SENSOR_REDUNDANT_IS_MAX31855
#define HAS_MAX31855 1
#endif
#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_2_IS_MAX31865 || TEMP_SENSOR_REDUNDANT_IS_MAX31865
#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_2_IS_MAX31865 || TEMP_SENSOR_BED_IS_MAX31865 || TEMP_SENSOR_REDUNDANT_IS_MAX31865
#define HAS_MAX31865 1
#endif

Expand Down Expand Up @@ -674,12 +676,28 @@
#endif
#endif

#if TEMP_SENSOR_BED == -4
#if TEMP_SENSOR_IS_MAX_TC(BED)
#if TEMP_SENSOR_BED == -5
#define TEMP_SENSOR_BED_IS_MAX31865 1
#define TEMP_SENSOR_BED_MAX_TC_TMIN 0
#define TEMP_SENSOR_BED_MAX_TC_TMAX 1024
#ifndef MAX31865_SENSOR_WIRES_BED
#define MAX31865_SENSOR_WIRES_BED 2
#endif
#ifndef MAX31865_WIRE_OHMS_BED
#define MAX31865_WIRE_OHMS_BED 0.0f
#endif
#elif TEMP_SENSOR_BED == -3
#define TEMP_SENSOR_BED_IS_MAX31855 1
#define TEMP_SENSOR_BED_MAX_TC_TMIN -270
#define TEMP_SENSOR_BED_MAX_TC_TMAX 1800
#elif TEMP_SENSOR_BED == -2
#define TEMP_SENSOR_BED_IS_MAX6675 1
#define TEMP_SENSOR_BED_MAX_TC_TMIN 0
#define TEMP_SENSOR_BED_MAX_TC_TMAX 1024
#endif
#elif TEMP_SENSOR_BED == -4
#define TEMP_SENSOR_BED_IS_AD8495 1
#elif TEMP_SENSOR_BED == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED."
#elif TEMP_SENSOR_BED == -2
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED."
#elif TEMP_SENSOR_BED == -1
#define TEMP_SENSOR_BED_IS_AD595 1
#elif TEMP_SENSOR_BED > 0
Expand Down
20 changes: 14 additions & 6 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -697,36 +697,44 @@
/**
* Compatibility layer for MAX (SPI) temp boards
*/

#define TEMP_SENSOR_IS_ANY_MAX_TC(n) (TEMP_SENSOR_IS_MAX_TC(n) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E##n)))

#if HAS_MAX_TC

// Software SPI - enable if MISO/SCK are defined.
#if (TEMP_SENSOR_IS_MAX_TC(0) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1))) \
&& PIN_EXISTS(TEMP_0_MISO) && PIN_EXISTS(TEMP_0_SCK) && DISABLED(TEMP_SENSOR_0_FORCE_HW_SPI)
#if TEMP_SENSOR_IS_ANY_MAX_TC(0) && DISABLED(TEMP_SENSOR_0_FORCE_HW_SPI) && PINS_EXIST(TEMP_0_MISO, TEMP_0_SCK)
#if TEMP_SENSOR_0_IS_MAX31865 && !PIN_EXISTS(TEMP_0_MOSI)
#error "TEMP_SENSOR_0 MAX31865 requires TEMP_0_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_0_FORCE_HW_SPI."
#else
#define TEMP_SENSOR_0_HAS_SPI_PINS 1
#endif
#endif

#if (TEMP_SENSOR_IS_MAX_TC(1) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1))) \
&& PIN_EXISTS(TEMP_1_MISO) && PIN_EXISTS(TEMP_1_SCK) && DISABLED(TEMP_SENSOR_1_FORCE_HW_SPI)
#if TEMP_SENSOR_IS_ANY_MAX_TC(1) && DISABLED(TEMP_SENSOR_1_FORCE_HW_SPI) && PINS_EXIST(TEMP_1_MISO, TEMP_1_SCK)
#if TEMP_SENSOR_1_IS_MAX31865 && !PIN_EXISTS(TEMP_1_MOSI)
#error "TEMP_SENSOR_1 MAX31865 requires TEMP_1_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_1_FORCE_HW_SPI."
#else
#define TEMP_SENSOR_1_HAS_SPI_PINS 1
#endif
#endif

#if (TEMP_SENSOR_IS_MAX_TC(2) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E2))) \
&& PIN_EXISTS(TEMP_2_MISO) && PIN_EXISTS(TEMP_2_SCK) && DISABLED(TEMP_SENSOR_2_FORCE_HW_SPI)
#if TEMP_SENSOR_IS_ANY_MAX_TC(2) && DISABLED(TEMP_SENSOR_2_FORCE_HW_SPI) && PINS_EXIST(TEMP_2_MISO, TEMP_2_SCK)
#if TEMP_SENSOR_2_IS_MAX31865 && !PIN_EXISTS(TEMP_2_MOSI)
#error "TEMP_SENSOR_2 MAX31865 requires TEMP_2_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_2_FORCE_HW_SPI."
#else
#define TEMP_SENSOR_2_HAS_SPI_PINS 1
#endif
#endif

#if (TEMP_SENSOR_IS_MAX_TC(BED)) && DISABLED(TEMP_SENSOR_BED_FORCE_HW_SPI) && PINS_EXIST(TEMP_BED_MISO, TEMP_BED_SCK)
#if TEMP_SENSOR_BED_IS_MAX31865 && !PIN_EXISTS(TEMP_BED_MOSI)
#error "TEMP_SENSOR_BED MAX31865 requires TEMP_BED_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_BED_FORCE_HW_SPI."
#else
#define TEMP_SENSOR_BED_HAS_SPI_PINS 1
#endif
#endif

//
// User-defined thermocouple libraries
//
Expand Down
6 changes: 5 additions & 1 deletion Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2057,6 +2057,8 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE E0 requires TEMP_0_CS_PIN."
#elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1) && !PIN_EXISTS(TEMP_1_CS)
#error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE E1 requires TEMP_1_CS_PIN."
#elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E2) && !PIN_EXISTS(TEMP_2_CS)
#error "TEMP_SENSOR_REDUNDANT MAX Thermocouple with TEMP_SENSOR_REDUNDANT_SOURCE E2 requires TEMP_2_CS_PIN."
#endif
#endif

Expand Down Expand Up @@ -2089,7 +2091,9 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#error "TEMP_1_PIN or TEMP_1_CS_PIN not defined for this board."
#endif
#if HOTENDS > 2
#if TEMP_SENSOR_2 == 100
#if TEMP_SENSOR_IS_MAX_TC(2) && !PIN_EXISTS(TEMP_2_CS)
#error "TEMP_SENSOR_2 MAX thermocouple requires TEMP_2_CS_PIN."
#elif TEMP_SENSOR_2 == 100
#error "TEMP_SENSOR_2 can't use Soc temperature sensor."
#elif TEMP_SENSOR_2 == 0
#error "TEMP_SENSOR_2 is required with 3 or more HOTENDS."
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/inc/Warnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
#if HAS_COOLER && DISABLED(THERMAL_PROTECTION_COOLER)
#warning "Safety Alert! Enable THERMAL_PROTECTION_COOLER for the final build!"
#endif
#if ENABLED(IGNORE_THERMOCOUPLE_ERRORS)
#warning "Safety Alert! Disable IGNORE_THERMOCOUPLE_ERRORS for the final build!"
#endif
#if ANY_THERMISTOR_IS(998) || ANY_THERMISTOR_IS(999)
#warning "Warning! Don't use dummy thermistors (998/999) for final build!"
#endif
Expand Down
Loading
Loading