From fcb8c5a1c1220c0f9c48fcecdd848a060c998703 Mon Sep 17 00:00:00 2001 From: MoellerDi Date: Fri, 5 Jun 2020 02:09:01 +0200 Subject: [PATCH] Fix G34 move in wrong direction (#18188) --- Marlin/src/gcode/calibrate/G34_M422.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 0961cce59..d0fa84b9a 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -294,11 +294,14 @@ void GcodeSuite::G34() { // Check for less accuracy compared to last move if (last_z_align_move[zstepper] < z_align_abs * 0.7f) { SERIAL_ECHOLNPGM("Decreasing accuracy detected."); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " last_z_align_move = ", last_z_align_move[zstepper]); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " z_align_abs = ", z_align_abs); adjustment_reverse = !adjustment_reverse; } - // Remember the alignment for the next iteration - last_z_align_move[zstepper] = z_align_abs; + // Remember the alignment for the next iteration, but only if steppers move, + // otherwise it would be just zero (in case this stepper was at z_measured_min already) + if (z_align_abs > 0) last_z_align_move[zstepper] = z_align_abs; #endif // Stop early if all measured points achieve accuracy target @@ -312,8 +315,10 @@ void GcodeSuite::G34() { #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS) // Decreasing accuracy was detected so move was inverted. // Will match reversed Z steppers on dual steppers. Triple will need more work to map. - if (adjustment_reverse) + if (adjustment_reverse) { z_align_move = -z_align_move; + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " correction reversed to ", z_align_move); + } #endif // Do a move to correct part of the misalignment for the current stepper