From e2dd2268e81d8e593f9c9217a5798911167db1f3 Mon Sep 17 00:00:00 2001
From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com>
Date: Tue, 23 Apr 2019 20:40:55 +0200
Subject: [PATCH] Add a Z raise-between-probes to G34 (#13791)

---
 Marlin/src/gcode/calibrate/G34_M422.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp
index 9a26400a97..36550a7bd7 100644
--- a/Marlin/src/gcode/calibrate/G34_M422.cpp
+++ b/Marlin/src/gcode/calibrate/G34_M422.cpp
@@ -126,6 +126,12 @@ void GcodeSuite::G34() {
       extruder_duplication_enabled = false;
     #endif
 
+    // Before moving other axes raise Z, if needed. Never lower Z.
+    if (current_position[Z_AXIS] < Z_CLEARANCE_BETWEEN_PROBES) {
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before moving to probe pos) to ", Z_CLEARANCE_BETWEEN_PROBES);
+      do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
+    }
+
     // Remember corrections to determine errors on each iteration
     float last_z_align_move[Z_STEPPER_COUNT] = ARRAY_N(Z_STEPPER_COUNT, 10000.0f, 10000.0f, 10000.0f),
           z_measured[Z_STEPPER_COUNT] = { 0 };
-- 
GitLab