Browse Source

Fix G34 probing range/error bug (#17052)

jufimu12 4 years ago
parent
commit
ad4a9eb73a
No account linked to committer's email address
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      Marlin/src/gcode/calibrate/G34_M422.cpp

+ 9
- 3
Marlin/src/gcode/calibrate/G34_M422.cpp View File

153
     if (!all_axes_known()) home_all_axes();
153
     if (!all_axes_known()) home_all_axes();
154
 
154
 
155
     // Move the Z coordinate realm towards the positive - dirty trick
155
     // Move the Z coordinate realm towards the positive - dirty trick
156
-    current_position.z -= z_probe * 0.5f;
156
+    current_position.z += z_probe * 0.5f;
157
+    sync_plan_position();
158
+    // Now, the Z origin lies below the build plate. That allows to probe deeper, before run_z_probe throws an error.
157
 
159
 
158
     #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
160
     #if DISABLED(Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
159
       float last_z_align_move[NUM_Z_STEPPER_DRIVERS] = ARRAY_N(NUM_Z_STEPPER_DRIVERS, 10000.0f, 10000.0f, 10000.0f);
161
       float last_z_align_move[NUM_Z_STEPPER_DRIVERS] = ARRAY_N(NUM_Z_STEPPER_DRIVERS, 10000.0f, 10000.0f, 10000.0f);
171
       bool adjustment_reverse = false;
173
       bool adjustment_reverse = false;
172
     #endif
174
     #endif
173
 
175
 
174
-    LOOP_L_N(iteration, z_auto_align_iterations) {
176
+    // 'iteration' is declared above and is also used after the for-loop.
177
+    // *not* the same as LOOP_L_N(iteration, z_auto_align_iterations)
178
+    for (iteration = 0; iteration < z_auto_align_iterations; ++iteration) {
175
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> probing all positions.");
179
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> probing all positions.");
176
 
180
 
177
       SERIAL_ECHOLNPAIR("\nITERATION: ", int(iteration + 1));
181
       SERIAL_ECHOLNPAIR("\nITERATION: ", int(iteration + 1));
192
           DEBUG_ECHOLNPAIR_P(PSTR("Probing X"), z_stepper_align.xy[iprobe].x, SP_Y_STR, z_stepper_align.xy[iprobe].y);
196
           DEBUG_ECHOLNPAIR_P(PSTR("Probing X"), z_stepper_align.xy[iprobe].x, SP_Y_STR, z_stepper_align.xy[iprobe].y);
193
 
197
 
194
         // Probe a Z height for each stepper.
198
         // Probe a Z height for each stepper.
195
-        const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true);
199
+        // Probing sanity check is disabled, as it would trigger even in normal cases because
200
+        // current_position.z has been manually altered in the "dirty trick" above.
201
+        const float z_probed_height = probe.probe_at_point(z_stepper_align.xy[iprobe], raise_after, 0, true, false);
196
         if (isnan(z_probed_height)) {
202
         if (isnan(z_probed_height)) {
197
           SERIAL_ECHOLNPGM("Probing failed.");
203
           SERIAL_ECHOLNPGM("Probing failed.");
198
           err_break = true;
204
           err_break = true;

Loading…
Cancel
Save