From 8d21ea55a2e67712ca968807d9c0a86afa750373 Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Mon, 25 Oct 2021 06:33:40 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Add=20USE=5FTEMP=5FEXT=5FCOMPENS?= =?UTF-8?q?ATION=20options=20(#23007)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 8 +++++++- Marlin/src/feature/probe_temp_comp.h | 20 +++++++++++++++++--- Marlin/src/gcode/bedlevel/abl/G29.cpp | 2 +- Marlin/src/inc/SanityCheck.h | 16 ++++++++++++++++ 4 files changed, 41 insertions(+), 5 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index ac9bd9ae94..3e1bd2cce6 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2006,7 +2006,7 @@ #define PTC_PROBE_POS { 90, 100 } // Enable additional compensation using hotend temperature - // Note: this values cannot be calibrated automatically but have to be set manually + // Note: this values cannot be calibrated automatically but have to be set manually via M871. //#define USE_TEMP_EXT_COMPENSATION // Probe temperature calibration generates a table of values starting at PTC_SAMPLE_START @@ -2022,6 +2022,12 @@ //#define BTC_SAMPLE_RES 5 // (°C) //#define BTC_SAMPLE_COUNT 10 + #if ENABLED(USE_TEMP_EXT_COMPENSATION) + //#define ETC_SAMPLE_START 180 // (°C) + //#define ETC_SAMPLE_RES 5 // (°C) + //#define ETC_SAMPLE_COUNT 20 + #endif + // The temperature the probe should be at while taking measurements during bed temperature // calibration. //#define BTC_PROBE_TEMP 30 // (°C) diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index f24b9acd9b..e5d459b8e8 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -72,6 +72,20 @@ typedef struct { #endif #define BTC_SAMPLE_END (BTC_SAMPLE_START + (BTC_SAMPLE_COUNT) * BTC_SAMPLE_RES) +// Extruder temperature calibration constants +#if ENABLED(USE_TEMP_EXT_COMPENSATION) + #ifndef ETC_SAMPLE_COUNT + #define ETC_SAMPLE_COUNT 20 + #endif + #ifndef ETC_SAMPLE_RES + #define ETC_SAMPLE_RES 5 + #endif + #ifndef ETC_SAMPLE_START + #define ETC_SAMPLE_START 180 + #endif + #define ETC_SAMPLE_END (ETC_SAMPLE_START + (ETC_SAMPLE_COUNT) * ETC_SAMPLE_RES) +#endif + #ifndef PTC_PROBE_HEATING_OFFSET #define PTC_PROBE_HEATING_OFFSET 0.5f #endif @@ -81,10 +95,10 @@ typedef struct { #endif static constexpr temp_calib_t cali_info_init[TSI_COUNT] = { - { PTC_SAMPLE_COUNT, PTC_SAMPLE_RES, PTC_SAMPLE_START, PTC_SAMPLE_END }, // Probe - { BTC_SAMPLE_COUNT, BTC_SAMPLE_RES, BTC_SAMPLE_START, BTC_SAMPLE_END }, // Bed + { PTC_SAMPLE_COUNT, PTC_SAMPLE_RES, PTC_SAMPLE_START, PTC_SAMPLE_END }, // Probe + { BTC_SAMPLE_COUNT, BTC_SAMPLE_RES, BTC_SAMPLE_START, BTC_SAMPLE_END }, // Bed #if ENABLED(USE_TEMP_EXT_COMPENSATION) - { 20, 5, 180, 180 + 5 * 20 } // Extruder + { ETC_SAMPLE_COUNT, ETC_SAMPLE_RES, ETC_SAMPLE_START, ETC_SAMPLE_END }, // Extruder #endif }; diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index f7afd93c81..5d94797f16 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -648,7 +648,7 @@ G29_TYPE GcodeSuite::G29() { #if ENABLED(PROBE_TEMP_COMPENSATION) temp_comp.compensate_measurement(TSI_BED, thermalManager.degBed(), abl.measured_z); temp_comp.compensate_measurement(TSI_PROBE, thermalManager.degProbe(), abl.measured_z); - TERN_(USE_TEMP_EXT_COMPENSATION, temp_comp.compensate_measurement(TSI_EXT, thermalManager.degHotend(), abl.measured_z)); + TERN_(USE_TEMP_EXT_COMPENSATION, temp_comp.compensate_measurement(TSI_EXT, thermalManager.degHotend(0), abl.measured_z)); #endif #if ENABLED(AUTO_BED_LEVELING_LINEAR) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 0006fbad95..a015873fc0 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -648,6 +648,22 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L constexpr decltype(_btc_probe_temp) _test_btc_probe_temp = 12.3f; static_assert(_test_btc_probe_temp != 12.3f, "BTC_PROBE_TEMP must be a whole number."); #endif + #if ENABLED(USE_TEMP_EXT_COMPENSATION) + #ifdef ETC_SAMPLE_START + constexpr auto _etc_sample_start = ETC_SAMPLE_START; + constexpr decltype(_etc_sample_start) _test_etc_sample_start = 12.3f; + static_assert(_test_etc_sample_start != 12.3f, "ETC_SAMPLE_START must be a whole number."); + #endif + #ifdef ETC_SAMPLE_RES + constexpr auto _etc_sample_res = ETC_SAMPLE_RES; + constexpr decltype(_etc_sample_res) _test_etc_sample_res = 12.3f; + static_assert(_test_etc_sample_res != 12.3f, "ETC_SAMPLE_RES must be a whole number."); + #endif + #endif + + #if ENABLED(USE_TEMP_EXT_COMPENSATION) && EXTRUDERS != 1 + #error "USE_TEMP_EXT_COMPENSATION only works with a single extruder." + #endif #endif /**