Consolidate probe clearance, add section debug (#18576)

* Better section / function log
* Add do_z_clearance motion function
This commit is contained in:
Scott Lahteine
2020-07-08 21:44:21 -05:00
committed by GitHub
parent 0eab9fc08c
commit 73fc0778b8
18 changed files with 132 additions and 131 deletions

View File

@ -233,7 +233,8 @@ void forward_kinematics_DELTA(const float &z1, const float &z2, const float &z3)
* This is like quick_home_xy() but for 3 towers.
*/
void home_delta() {
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
DEBUG_SECTION(log_home_delta, "home_delta", DEBUGGING(LEVELING));
// Init the current position of all carriages to 0,0,0
current_position.reset();
destination.reset();
@ -283,8 +284,6 @@ void home_delta() {
line_to_current_position(homing_feedrate(Z_AXIS));
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
}
#endif // DELTA

View File

@ -387,7 +387,8 @@ void _internal_move_to_destination(const feedRate_t &fr_mm_s/*=0.0f*/
* Plan a move to (X, Y, Z) and set the current_position
*/
void do_blocking_move_to(const float rx, const float ry, const float rz, const feedRate_t &fr_mm_s/*=0.0*/) {
if (DEBUGGING(LEVELING)) DEBUG_XYZ(">>> do_blocking_move_to", rx, ry, rz);
DEBUG_SECTION(log_move, "do_blocking_move_to", DEBUGGING(LEVELING));
if (DEBUGGING(LEVELING)) DEBUG_XYZ("> ", rx, ry, rz);
const feedRate_t z_feedrate = fr_mm_s ?: homing_feedrate(Z_AXIS),
xy_feedrate = fr_mm_s ?: feedRate_t(XY_PROBE_FEEDRATE_MM_S);
@ -471,8 +472,6 @@ void do_blocking_move_to(const float rx, const float ry, const float rz, const f
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< do_blocking_move_to");
planner.synchronize();
}
@ -507,6 +506,13 @@ void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRat
do_blocking_move_to(raw.x, raw.y, z, fr_mm_s);
}
void do_z_clearance(const float &zclear, const bool z_known/*=true*/, const bool raise_on_unknown/*=true*/, const bool lower_allowed/*=false*/) {
const bool rel = raise_on_unknown && !z_known;
float zdest = zclear + (rel ? current_position.z : 0.0f);
if (!lower_allowed) NOLESS(zdest, current_position.z);
do_blocking_move_to_z(_MIN(zdest, Z_MAX_POS), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
}
//
// Prepare to do endstop or probe moves with custom feedrates.
// - Save / restore current feedrate and multiplier
@ -1272,11 +1278,12 @@ 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) {
DEBUG_SECTION(log_move, "do_homing_move", DEBUGGING(LEVELING));
const feedRate_t real_fr_mm_s = fr_mm_s ?: homing_feedrate(axis);
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR(">>> do_homing_move(", axis_codes[axis], ", ", distance, ", ");
DEBUG_ECHOPAIR("...(", axis_codes[axis], ", ", distance, ", ");
if (fr_mm_s)
DEBUG_ECHO(fr_mm_s);
else
@ -1349,8 +1356,6 @@ void do_homing_move(const AxisEnum axis, const float distance, const feedRate_t
// Re-enable stealthChop if used. Disable diag1 pin on driver.
TERN_(SENSORLESS_HOMING, end_sensorless_homing_per_axis(axis, stealth_states));
}
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("<<< do_homing_move(", axis_codes[axis], ")");
}
/**

View File

@ -234,6 +234,8 @@ void remember_feedrate_and_scaling();
void remember_feedrate_scaling_off();
void restore_feedrate_and_scaling();
void do_z_clearance(const float &zclear, const bool z_known=true, const bool raise_on_unknown=true, const bool lower_allowed=false);
//
// Homing
//

View File

@ -260,15 +260,10 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
* Raise Z to a minimum height to make room for a probe to move
*/
void Probe::do_z_raise(const float z_raise) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probe::move_z(", z_raise, ")");
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probe::do_z_raise(", z_raise, ")");
float z_dest = z_raise;
if (offset.z < 0) z_dest -= offset.z;
NOMORE(z_dest, Z_MAX_POS);
if (z_dest > current_position.z)
do_blocking_move_to_z(z_dest);
do_z_clearance(z_dest);
}
FORCE_INLINE void probe_specific_action(const bool deploy) {
@ -410,16 +405,6 @@ bool Probe::set_deployed(const bool deploy) {
return false;
}
#ifdef Z_AFTER_PROBING
// After probing move to a preferred Z position
void Probe::move_z_after_probing() {
if (current_position.z != Z_AFTER_PROBING) {
do_blocking_move_to_z(Z_AFTER_PROBING);
current_position.z = Z_AFTER_PROBING;
}
}
#endif
/**
* @brief Used by run_z_probe to do a single Z probe move.
*
@ -439,7 +424,7 @@ bool Probe::set_deployed(const bool deploy) {
* @return TRUE if the probe failed to trigger.
*/
bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::probe_down_to_z", current_position);
DEBUG_SECTION(log_probe, "Probe::probe_down_to_z", DEBUGGING(LEVELING));
#if BOTH(HAS_HEATED_BED, WAIT_FOR_BED_HEATER)
thermalManager.wait_for_bed_heating();
@ -499,8 +484,6 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
// Tell the planner where we actually are
sync_plan_position();
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< Probe::probe_down_to_z", current_position);
return !probe_triggered;
}
@ -513,8 +496,7 @@ bool Probe::probe_down_to_z(const float z, const feedRate_t fr_mm_s) {
* @return The Z position of the bed at the current XY or NAN on error.
*/
float Probe::run_z_probe(const bool sanity_check/*=true*/) {
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::run_z_probe", current_position);
DEBUG_SECTION(log_probe, "Probe::run_z_probe", DEBUGGING(LEVELING));
auto try_to_probe = [&](PGM_P const plbl, const float &z_probe_low_point, const feedRate_t fr_mm_s, const bool scheck, const float clearance) {
// Do a first probe at the fast speed
@ -527,7 +509,6 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
if (probe_fail) DEBUG_ECHOPGM(" No trigger.");
if (early_fail) DEBUG_ECHOPGM(" Triggered early.");
DEBUG_EOL();
DEBUG_POS("<<< run_z_probe", current_position);
}
#else
UNUSED(plbl);
@ -651,8 +632,6 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
return measured_z;
}
@ -666,9 +645,11 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
* - Return the probed Z position
*/
float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after/*=PROBE_PT_NONE*/, const uint8_t verbose_level/*=0*/, const bool probe_relative/*=true*/, const bool sanity_check/*=true*/) {
DEBUG_SECTION(log_probe, "Probe::probe_at_point", DEBUGGING(LEVELING));
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR(
">>> Probe::probe_at_point(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),
"...(", LOGICAL_X_POSITION(rx), ", ", LOGICAL_Y_POSITION(ry),
", ", raise_after == PROBE_PT_RAISE ? "raise" : raise_after == PROBE_PT_STOW ? "stow" : "none",
", ", int(verbose_level),
", ", probe_relative ? "probe" : "nozzle", "_relative)"
@ -729,8 +710,6 @@ float Probe::probe_at_point(const float &rx, const float &ry, const ProbePtRaise
#endif
}
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< Probe::probe_at_point");
return measured_z;
}

View File

@ -79,9 +79,18 @@ public:
#endif
#ifdef Z_AFTER_PROBING
static void move_z_after_probing();
#endif
static inline void move_z_after_probing() {
#ifdef Z_AFTER_PROBING
do_z_clearance(Z_AFTER_PROBING, true, true, true); // Move down still permitted
#endif
}
static inline void move_z_after_homing() {
#ifdef Z_AFTER_HOMING
do_z_clearance(Z_AFTER_HOMING, true, true, true);
#elif defined(Z_AFTER_PROBING)
move_z_after_probing();
#endif
}
static float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true);
static inline float probe_at_point(const xy_pos_t &pos, const ProbePtRaise raise_after=PROBE_PT_NONE, const uint8_t verbose_level=0, const bool probe_relative=true, const bool sanity_check=true) {
return probe_at_point(pos.x, pos.y, raise_after, verbose_level, probe_relative, sanity_check);
@ -89,6 +98,8 @@ public:
#else
FORCE_INLINE static void move_z_after_homing() {}
static constexpr xyz_pos_t offset = xyz_pos_t({ 0, 0, 0 }); // See #16767
static bool set_deployed(const bool) { return false; }