Skip to content

Commit

Permalink
Defer "quiet probing" till the last Z bump (MarlinFirmware#20610)
Browse files Browse the repository at this point in the history
  • Loading branch information
FanDjango authored and W4tel-BiDi committed Apr 5, 2021
1 parent 55554ee commit 4f3b11e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
29 changes: 13 additions & 16 deletions Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ feedRate_t get_homing_bump_feedrate(const AxisEnum axis) {
/**
* Home an individual linear axis
*/
void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t fr_mm_s=0.0) {
void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t fr_mm_s=0.0, const bool final_approach=true) {
DEBUG_SECTION(log_move, "do_homing_move", DEBUGGING(LEVELING));

const feedRate_t home_fr_mm_s = fr_mm_s ?: homing_feedrate(axis);
Expand Down Expand Up @@ -1320,7 +1320,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
thermalManager.wait_for_bed_heating();
#endif

TERN_(HAS_QUIET_PROBING, probe.set_probing_paused(true));
TERN_(HAS_QUIET_PROBING, if (final_approach) probe.set_probing_paused(true));
}

// Disable stealthChop if used. Enable diag1 pin on driver.
Expand Down Expand Up @@ -1359,7 +1359,7 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
if (is_home_dir) {

#if HOMING_Z_WITH_PROBE && HAS_QUIET_PROBING
if (axis == Z_AXIS) probe.set_probing_paused(false);
if (axis == Z_AXIS && final_approach) probe.set_probing_paused(false);
#endif

endstops.validate_homing_move();
Expand Down Expand Up @@ -1608,32 +1608,29 @@ void homeaxis(const AxisEnum axis) {
}
#endif

// Determine if a homing bump will be done and the bumps distance
// When homing Z with probe respect probe clearance
const bool use_probe_bump = TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS && home_bump_mm(Z_AXIS));
const float bump = axis_home_dir * (
use_probe_bump ? _MAX(TERN0(HOMING_Z_WITH_PROBE, Z_CLEARANCE_BETWEEN_PROBES), home_bump_mm(Z_AXIS)) : home_bump_mm(axis)
);

//
// Fast move towards endstop until triggered
//
const float move_length = 1.5f * max_length(TERN(DELTA, Z_AXIS, axis)) * axis_home_dir;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Home Fast: ", move_length, "mm");
do_homing_move(axis, move_length);
do_homing_move(axis, move_length, 0.0, !use_probe_bump);

#if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE)
if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE)
#endif

// When homing Z with probe respect probe clearance
const bool use_probe_bump = TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS && home_bump_mm(Z_AXIS));
const float bump = axis_home_dir * (
use_probe_bump ? _MAX(TERN0(HOMING_Z_WITH_PROBE, Z_CLEARANCE_BETWEEN_PROBES), home_bump_mm(Z_AXIS)) : home_bump_mm(axis)
);

// If a second homing move is configured...
if (bump) {
// Move away from the endstop by the axis HOMING_BUMP_MM
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Move Away: ", -bump, "mm");
do_homing_move(axis, -bump
#if HOMING_Z_WITH_PROBE
, MMM_TO_MMS(axis == Z_AXIS ? Z_PROBE_SPEED_FAST : 0)
#endif
);
do_homing_move(axis, -bump, TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS) ? MMM_TO_MMS(Z_PROBE_SPEED_FAST) : 0, false);

#if ENABLED(DETECT_BROKEN_ENDSTOP)
// Check for a broken endstop
Expand All @@ -1657,7 +1654,7 @@ void homeaxis(const AxisEnum axis) {
// Slow move towards endstop until triggered
const float rebump = bump * 2;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Re-bump: ", rebump, "mm");
do_homing_move(axis, rebump, get_homing_bump_feedrate(axis));
do_homing_move(axis, rebump, get_homing_bump_feedrate(axis), true);

#if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH)
if (axis == Z_AXIS) bltouch.stow(); // The final STOW
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ class Planner {
private:

// Allow do_homing_move to access internal functions, such as buffer_segment.
friend void do_homing_move(const AxisEnum, const float, const feedRate_t);
friend void do_homing_move(const AxisEnum, const float, const feedRate_t, const bool);
#endif

/**
Expand Down

0 comments on commit 4f3b11e

Please sign in to comment.