Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
🐛 Add USE_TEMP_EXT_COMPENSATION options (MarlinFirmware#23007)
Browse files Browse the repository at this point in the history
  • Loading branch information
tombrazier authored and 0xk1f0 committed Dec 26, 2021
1 parent d63e65a commit dfff6b0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
20 changes: 17 additions & 3 deletions Marlin/src/feature/probe_temp_comp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
};

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down

0 comments on commit dfff6b0

Please sign in to comment.