From fdcd28a0ec923a609f16cd0221db2821cd39dae6 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Sun, 11 Oct 2020 22:40:39 -0700 Subject: [PATCH] Allow MAX31865 resistance values configuration (#19695) --- Marlin/Configuration.h | 6 ++++++ Marlin/src/inc/SanityCheck.h | 4 ++++ Marlin/src/module/temperature.cpp | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index ec8b162cd..59f2be18c 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -432,6 +432,12 @@ #define DUMMY_THERMISTOR_998_VALUE 25 #define DUMMY_THERMISTOR_999_VALUE 100 +// Resistor values when using a MAX31865 (sensor -5) +// Sensor value is typically 100 (PT100) or 1000 (PT1000) +// Calibration value is typically 430 ohm for AdaFruit PT100 modules and 4300 ohm for AdaFruit PT1000 modules. +//#define MAX31865_SENSOR_OHMS 100 +//#define MAX31865_CALIBRATION_OHMS 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 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index c3708c267..59a74411e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1845,6 +1845,10 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal #error "TEMP_SENSOR_1 is required with TEMP_SENSOR_1_AS_REDUNDANT." #endif +#if ENABLED(MAX6675_IS_MAX31865) && (!defined(MAX31865_SENSOR_OHMS) || !defined(MAX31865_CALIBRATION_OHMS)) + #error "MAX31865_SENSOR_OHMS and MAX31865_CALIBRATION_OHMS must be set in Configuration.h when using a MAX31865 temperature sensor." +#endif + /** * Test Heater, Temp Sensor, and Extruder Pins */ diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index f8ff972f8..9ecbb7c76 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1461,7 +1461,7 @@ void Temperature::manage_heater() { #elif ENABLED(HEATER_0_USES_MAX6675) return ( #if ENABLED(MAX6675_IS_MAX31865) - max31865.temperature(100, 400) // 100 ohms = PT100 resistance. 400 ohms = calibration resistor + max31865.temperature(MAX31865_SENSOR_OHMS, MAX31865_CALIBRATION_OHMS) #else raw * 0.25 #endif @@ -2236,7 +2236,7 @@ void Temperature::disable_all_heaters() { next_max6675_ms[hindex] = ms + MAX6675_HEAT_INTERVAL; #if ENABLED(MAX6675_IS_MAX31865) - max6675_temp = int(max31865.temperature(100, 400)); // 100 ohms = PT100 resistance. 400 ohms = calibration resistor + max6675_temp = int(max31865.temperature(MAX31865_SENSOR_OHMS, MAX31865_CALIBRATION_OHMS)); #endif //