Skip to content

Commit 131beaf

Browse files
neclimdulthinkyhead
authored andcommitted
🚸 Improve Z-Probe raise for deploy (MarlinFirmware#25498)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent ee54be1 commit 131beaf

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

Marlin/src/gcode/bedlevel/G35.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ void GcodeSuite::G35() {
108108
// length of the deployed pin (BLTOUCH stroke < 7mm)
109109

110110
// Unsure if this is even required. The probe seems to lift correctly after probe done.
111-
do_blocking_move_to_z(SUM_TERN(BLTOUCH, Z_CLEARANCE_BETWEEN_PROBES, bltouch.z_extra_clearance()));
112111
const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true);
113112

114113
if (isnan(z_probed_height)) {

Marlin/src/gcode/calibrate/G76_M871.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
};
109109

110110
auto g76_probe = [](const TempSensorID sid, celsius_t &targ, const xy_pos_t &nozpos) {
111-
do_z_clearance(5.0); // Raise nozzle before probing
112111
ptc.set_enabled(false);
113112
const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false
114113
ptc.set_enabled(true);

Marlin/src/module/probe.cpp

+19-11
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
147147
WRITE(MAGLEV_TRIGGER_PIN, LOW);
148148
}
149149

150-
inline void maglev_idle() { do_blocking_move_to_z(10); }
150+
inline void maglev_idle() { do_z_clearance(10); }
151151

152152
#elif ENABLED(TOUCH_MI_PROBE)
153153

@@ -749,7 +749,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
749749
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("1st Probe Z:", first_probe_z);
750750

751751
// Raise to give the probe clearance
752-
do_blocking_move_to_z(current_position.z + Z_CLEARANCE_MULTI_PROBE, z_probe_fast_mm_s);
752+
do_z_clearance(current_position.z + Z_CLEARANCE_MULTI_PROBE);
753753

754754
#elif Z_PROBE_FEEDRATE_FAST != Z_PROBE_FEEDRATE_SLOW
755755

@@ -759,7 +759,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
759759
if (current_position.z > z) {
760760
// Probe down fast. If the probe never triggered, raise for probe clearance
761761
if (!probe_down_to_z(z, z_probe_fast_mm_s))
762-
do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, z_probe_fast_mm_s);
762+
do_z_clearance(current_position.z + Z_CLEARANCE_BETWEEN_PROBES);
763763
}
764764
#endif
765765

@@ -810,7 +810,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
810810
#if EXTRA_PROBING > 0
811811
< TOTAL_PROBING - 1
812812
#endif
813-
) do_blocking_move_to_z(z + Z_CLEARANCE_MULTI_PROBE, z_probe_fast_mm_s);
813+
) do_z_clearance(z + Z_CLEARANCE_MULTI_PROBE);
814814
#endif
815815
}
816816

@@ -878,13 +878,16 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
878878
}
879879

880880
#if ENABLED(BLTOUCH)
881-
if (bltouch.high_speed_mode && bltouch.triggered())
882-
bltouch._reset();
881+
// Reset a BLTouch in HS mode if already triggered
882+
if (bltouch.high_speed_mode && bltouch.triggered()) bltouch._reset();
883883
#endif
884884

885+
// Use a safe Z height for the XY move
886+
const float safe_z = _MAX(current_position.z, SUM_TERN(BLTOUCH, Z_CLEARANCE_BETWEEN_PROBES, bltouch.z_extra_clearance()));
887+
885888
// On delta keep Z below clip height or do_blocking_move_to will abort
886889
xyz_pos_t npos = NUM_AXIS_ARRAY(
887-
rx, ry, TERN(DELTA, _MIN(delta_clip_start_height, current_position.z), current_position.z),
890+
rx, ry, TERN(DELTA, _MIN(delta_clip_start_height, safe_z), safe_z),
888891
current_position.i, current_position.j, current_position.k,
889892
current_position.u, current_position.v, current_position.w
890893
);
@@ -907,17 +910,22 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
907910
TERN_(HAS_PTC, ptc.apply_compensation(measured_z));
908911
TERN_(X_AXIS_TWIST_COMPENSATION, measured_z += xatc.compensation(npos + offset_xy));
909912
}
913+
914+
// Deploy succeeded and a successful measurement was done.
915+
// Raise and/or stow the probe depending on 'raise_after' and settings.
910916
if (!isnan(measured_z)) {
911-
const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
912-
if (big_raise || raise_after == PROBE_PT_RAISE)
913-
do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), z_probe_fast_mm_s);
914-
else if (raise_after == PROBE_PT_STOW || raise_after == PROBE_PT_LAST_STOW)
917+
const ProbePtRaise raise_type = (TERN0(BLTOUCH, !bltouch.high_speed_mode) && raise_after == PROBE_PT_RAISE) ? PROBE_PT_STOW : raise_after;
918+
const bool big_raise = raise_type == PROBE_PT_BIG_RAISE;
919+
if (big_raise || raise_type == PROBE_PT_RAISE)
920+
do_z_clearance(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES));
921+
else if (raise_type == PROBE_PT_STOW || raise_type == PROBE_PT_LAST_STOW)
915922
if (stow()) measured_z = NAN; // Error on stow?
916923

917924
if (verbose_level > 2)
918925
SERIAL_ECHOLNPGM("Bed X: ", LOGICAL_X_POSITION(rx), " Y: ", LOGICAL_Y_POSITION(ry), " Z: ", measured_z);
919926
}
920927

928+
// If any error occurred stow the probe and set an alert
921929
if (isnan(measured_z)) {
922930
stow();
923931
LCD_MESSAGE(MSG_LCD_PROBING_FAILED);

0 commit comments

Comments
 (0)