From b7b2286e49c3ddf5060e26b9c03bdb6c2207eeba Mon Sep 17 00:00:00 2001 From: lujios <83166168+lujios@users.noreply.github.com> Date: Fri, 3 Jun 2022 07:19:25 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Improve=20Sensorless=20hom?= =?UTF-8?q?ing/probing=20accuracy=20for=20G28,=20G33,=20M48=20(#24220)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Robby Candra Co-Authored-By: ellensp <530024+ellensp@users.noreply.github.com> --- Marlin/src/inc/Conditionals_adv.h | 5 ++++ Marlin/src/module/endstops.cpp | 38 +++++++++++++++++-------------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index a137b86e58..0b37f1654b 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1033,3 +1033,8 @@ #if ANY(DISABLE_INACTIVE_X, DISABLE_INACTIVE_Y, DISABLE_INACTIVE_Z, DISABLE_INACTIVE_I, DISABLE_INACTIVE_J, DISABLE_INACTIVE_K, DISABLE_INACTIVE_U, DISABLE_INACTIVE_V, DISABLE_INACTIVE_W, DISABLE_INACTIVE_E) #define HAS_DISABLE_INACTIVE_AXIS 1 #endif + +// Delay Sensorless Homing/Probing +#if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING) && !defined(SENSORLESS_STALLGUARD_DELAY) + #define SENSORLESS_STALLGUARD_DELAY 0 +#endif diff --git a/Marlin/src/module/endstops.cpp b/Marlin/src/module/endstops.cpp index c3252ca824..0620285e61 100644 --- a/Marlin/src/module/endstops.cpp +++ b/Marlin/src/module/endstops.cpp @@ -1365,46 +1365,50 @@ void Endstops::update() { */ void Endstops::set_homing_current(const bool onoff) { #define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT) - #define _HOME_ELEM(N) HAS_CURRENT_HOME(N) || - #if MAIN_AXIS_MAP(_HOME_ELEM) 0 - #if ENABLED(DELTA) - static int16_t saved_current_X, saved_current_Y; + #define HAS_DELTA_X_CURRENT (ENABLED(DELTA) && HAS_CURRENT_HOME(X)) + #define HAS_DELTA_Y_CURRENT (ENABLED(DELTA) && HAS_CURRENT_HOME(Y)) + #if HAS_DELTA_X_CURRENT || HAS_DELTA_Y_CURRENT || HAS_CURRENT_HOME(Z) + #if HAS_DELTA_X_CURRENT + static int16_t saved_current_x; + #endif + #if HAS_DELTA_Y_CURRENT + static int16_t saved_current_y; #endif #if HAS_CURRENT_HOME(Z) - static int16_t saved_current_Z; + static int16_t saved_current_z; #endif auto debug_current_on = [](PGM_P const s, const int16_t a, const int16_t b) { if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); } }; if (onoff) { #if HAS_DELTA_X_CURRENT - saved_current_X = stepperX.getMilliamps(); + saved_current_x = stepperX.getMilliamps(); stepperX.rms_current(X_CURRENT_HOME); - debug_current_on(PSTR("X"), saved_current_X, X_CURRENT_HOME); + debug_current_on(PSTR("X"), saved_current_x, X_CURRENT_HOME); #endif #if HAS_DELTA_Y_CURRENT - saved_current_Y = stepperY.getMilliamps(); + saved_current_y = stepperY.getMilliamps(); stepperY.rms_current(Y_CURRENT_HOME); - debug_current_on(PSTR("Y"), saved_current_Y, Y_CURRENT_HOME); + debug_current_on(PSTR("Y"), saved_current_y, Y_CURRENT_HOME); #endif #if HAS_CURRENT_HOME(Z) - saved_current_Z = stepperZ.getMilliamps(); + saved_current_z = stepperZ.getMilliamps(); stepperZ.rms_current(Z_CURRENT_HOME); - debug_current_on(PSTR("Z"), saved_current_Z, Z_CURRENT_HOME); + debug_current_on(PSTR("Z"), saved_current_z, Z_CURRENT_HOME); #endif } else { #if HAS_DELTA_X_CURRENT - stepperX.rms_current(saved_current_X); - debug_current_on(PSTR("X"), X_CURRENT_HOME, saved_current_X); + stepperX.rms_current(saved_current_x); + debug_current_on(PSTR("X"), X_CURRENT_HOME, saved_current_x); #endif #if HAS_DELTA_Y_CURRENT - stepperY.rms_current(saved_current_Y); - debug_current_on(PSTR("Y"), Y_CURRENT_HOME, saved_current_Y); + stepperY.rms_current(saved_current_y); + debug_current_on(PSTR("Y"), Y_CURRENT_HOME, saved_current_y); #endif #if HAS_CURRENT_HOME(Z) - stepperZ.rms_current(saved_current_Z); - debug_current_on(PSTR("Z"), Z_CURRENT_HOME, saved_current_Z); + stepperZ.rms_current(saved_current_z); + debug_current_on(PSTR("Z"), Z_CURRENT_HOME, saved_current_z); #endif }