⚡️ Improve Sensorless homing/probing accuracy for G28, G33, M48 (#24220)
Co-Authored-By: Robby Candra <robbycandra.mail@gmail.com> Co-Authored-By: ellensp <530024+ellensp@users.noreply.github.com>
This commit is contained in:
parent
047d0264c5
commit
b7b2286e49
|
@ -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)
|
#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
|
#define HAS_DISABLE_INACTIVE_AXIS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Delay Sensorless Homing/Probing
|
||||||
|
#if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING) && !defined(SENSORLESS_STALLGUARD_DELAY)
|
||||||
|
#define SENSORLESS_STALLGUARD_DELAY 0
|
||||||
|
#endif
|
||||||
|
|
|
@ -1365,46 +1365,50 @@ void Endstops::update() {
|
||||||
*/
|
*/
|
||||||
void Endstops::set_homing_current(const bool onoff) {
|
void Endstops::set_homing_current(const bool onoff) {
|
||||||
#define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT)
|
#define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT)
|
||||||
#define _HOME_ELEM(N) HAS_CURRENT_HOME(N) ||
|
#define HAS_DELTA_X_CURRENT (ENABLED(DELTA) && HAS_CURRENT_HOME(X))
|
||||||
#if MAIN_AXIS_MAP(_HOME_ELEM) 0
|
#define HAS_DELTA_Y_CURRENT (ENABLED(DELTA) && HAS_CURRENT_HOME(Y))
|
||||||
#if ENABLED(DELTA)
|
#if HAS_DELTA_X_CURRENT || HAS_DELTA_Y_CURRENT || HAS_CURRENT_HOME(Z)
|
||||||
static int16_t saved_current_X, saved_current_Y;
|
#if HAS_DELTA_X_CURRENT
|
||||||
|
static int16_t saved_current_x;
|
||||||
|
#endif
|
||||||
|
#if HAS_DELTA_Y_CURRENT
|
||||||
|
static int16_t saved_current_y;
|
||||||
#endif
|
#endif
|
||||||
#if HAS_CURRENT_HOME(Z)
|
#if HAS_CURRENT_HOME(Z)
|
||||||
static int16_t saved_current_Z;
|
static int16_t saved_current_z;
|
||||||
#endif
|
#endif
|
||||||
auto debug_current_on = [](PGM_P const s, const int16_t a, const int16_t b) {
|
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 (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); }
|
||||||
};
|
};
|
||||||
if (onoff) {
|
if (onoff) {
|
||||||
#if HAS_DELTA_X_CURRENT
|
#if HAS_DELTA_X_CURRENT
|
||||||
saved_current_X = stepperX.getMilliamps();
|
saved_current_x = stepperX.getMilliamps();
|
||||||
stepperX.rms_current(X_CURRENT_HOME);
|
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
|
#endif
|
||||||
#if HAS_DELTA_Y_CURRENT
|
#if HAS_DELTA_Y_CURRENT
|
||||||
saved_current_Y = stepperY.getMilliamps();
|
saved_current_y = stepperY.getMilliamps();
|
||||||
stepperY.rms_current(Y_CURRENT_HOME);
|
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
|
#endif
|
||||||
#if HAS_CURRENT_HOME(Z)
|
#if HAS_CURRENT_HOME(Z)
|
||||||
saved_current_Z = stepperZ.getMilliamps();
|
saved_current_z = stepperZ.getMilliamps();
|
||||||
stepperZ.rms_current(Z_CURRENT_HOME);
|
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
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if HAS_DELTA_X_CURRENT
|
#if HAS_DELTA_X_CURRENT
|
||||||
stepperX.rms_current(saved_current_X);
|
stepperX.rms_current(saved_current_x);
|
||||||
debug_current_on(PSTR("X"), X_CURRENT_HOME, saved_current_X);
|
debug_current_on(PSTR("X"), X_CURRENT_HOME, saved_current_x);
|
||||||
#endif
|
#endif
|
||||||
#if HAS_DELTA_Y_CURRENT
|
#if HAS_DELTA_Y_CURRENT
|
||||||
stepperY.rms_current(saved_current_Y);
|
stepperY.rms_current(saved_current_y);
|
||||||
debug_current_on(PSTR("Y"), Y_CURRENT_HOME, saved_current_Y);
|
debug_current_on(PSTR("Y"), Y_CURRENT_HOME, saved_current_y);
|
||||||
#endif
|
#endif
|
||||||
#if HAS_CURRENT_HOME(Z)
|
#if HAS_CURRENT_HOME(Z)
|
||||||
stepperZ.rms_current(saved_current_Z);
|
stepperZ.rms_current(saved_current_z);
|
||||||
debug_current_on(PSTR("Z"), Z_CURRENT_HOME, saved_current_Z);
|
debug_current_on(PSTR("Z"), Z_CURRENT_HOME, saved_current_z);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue