Skip to content

Commit

Permalink
🚸 Improve Z-Probe raise for deploy (#25498)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
neclimdul and thinkyhead committed Mar 18, 2023
1 parent 98c0cc0 commit 88da531
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
1 change: 0 additions & 1 deletion Marlin/src/gcode/bedlevel/G35.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ void GcodeSuite::G35() {
// length of the deployed pin (BLTOUCH stroke < 7mm)

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

if (isnan(z_probed_height)) {
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/gcode/calibrate/G76_M871.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
};

auto g76_probe = [](const TempSensorID sid, celsius_t &targ, const xy_pos_t &nozpos) {
do_z_clearance(5.0); // Raise nozzle before probing
ptc.set_enabled(false);
const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_STOW, 0, false); // verbose=0, probe_relative=false
ptc.set_enabled(true);
Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/lcd/menu/menu_tramming_wizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ static int8_t reference_index; // = 0
#endif

static bool probe_single_point() {
do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES));
// Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety
const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN0(BLTOUCH, bltouch.high_speed_mode) ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true);
const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], PROBE_PT_RAISE, 0, true);
z_measured[tram_index] = z_probed_height;
if (reference_index < 0) reference_index = tram_index;
move_to_tramming_wait_pos();
Expand Down
30 changes: 19 additions & 11 deletions Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
WRITE(MAGLEV_TRIGGER_PIN, LOW);
}

inline void maglev_idle() { do_blocking_move_to_z(10); }
inline void maglev_idle() { do_z_clearance(10); }

#elif ENABLED(TOUCH_MI_PROBE)

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

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

#elif Z_PROBE_FEEDRATE_FAST != Z_PROBE_FEEDRATE_SLOW

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

Expand Down Expand Up @@ -810,7 +810,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
#if EXTRA_PROBING > 0
< TOTAL_PROBING - 1
#endif
) do_blocking_move_to_z(z + Z_CLEARANCE_MULTI_PROBE, z_probe_fast_mm_s);
) do_z_clearance(z + Z_CLEARANCE_MULTI_PROBE);
#endif
}

Expand Down Expand Up @@ -878,13 +878,16 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
}

#if ENABLED(BLTOUCH)
if (bltouch.high_speed_mode && bltouch.triggered())
bltouch._reset();
// Reset a BLTouch in HS mode if already triggered
if (bltouch.high_speed_mode && bltouch.triggered()) bltouch._reset();
#endif

// Use a safe Z height for the XY move
const float safe_z = _MAX(current_position.z, SUM_TERN(BLTOUCH, Z_CLEARANCE_BETWEEN_PROBES, bltouch.z_extra_clearance()));

This comment has been minimized.

Copy link
@jamespearson04

jamespearson04 Mar 31, 2023

Contributor

What happens if you call bltouch.z_extra_clearance() with a different type of probe? should it not be #if'd?

// On delta keep Z below clip height or do_blocking_move_to will abort
xyz_pos_t npos = NUM_AXIS_ARRAY(
rx, ry, TERN(DELTA, _MIN(delta_clip_start_height, current_position.z), current_position.z),
rx, ry, TERN(DELTA, _MIN(delta_clip_start_height, safe_z), safe_z),
current_position.i, current_position.j, current_position.k,
current_position.u, current_position.v, current_position.w
);
Expand All @@ -907,17 +910,22 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
TERN_(HAS_PTC, ptc.apply_compensation(measured_z));
TERN_(X_AXIS_TWIST_COMPENSATION, measured_z += xatc.compensation(npos + offset_xy));
}

// Deploy succeeded and a successful measurement was done.
// Raise and/or stow the probe depending on 'raise_after' and settings.
if (!isnan(measured_z)) {
const bool big_raise = raise_after == PROBE_PT_BIG_RAISE;
if (big_raise || raise_after == PROBE_PT_RAISE)
do_blocking_move_to_z(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES), z_probe_fast_mm_s);
else if (raise_after == PROBE_PT_STOW || raise_after == PROBE_PT_LAST_STOW)
const ProbePtRaise raise_type = (TERN0(BLTOUCH, !bltouch.high_speed_mode) && raise_after == PROBE_PT_RAISE) ? PROBE_PT_STOW : raise_after;

This comment has been minimized.

Copy link
@jamespearson04

jamespearson04 Apr 1, 2023

Contributor

Another bltouch function without an #if

const bool big_raise = raise_type == PROBE_PT_BIG_RAISE;
if (big_raise || raise_type == PROBE_PT_RAISE)
do_z_clearance(current_position.z + (big_raise ? 25 : Z_CLEARANCE_BETWEEN_PROBES));
else if (raise_type == PROBE_PT_STOW || raise_type == PROBE_PT_LAST_STOW)
if (stow()) measured_z = NAN; // Error on stow?

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

// If any error occurred stow the probe and set an alert
if (isnan(measured_z)) {
stow();
LCD_MESSAGE(MSG_LCD_PROBING_FAILED);
Expand Down

0 comments on commit 88da531

Please sign in to comment.