From 130e36d76659182f50565243ad331e8f7765165c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 8 Feb 2020 17:47:54 -0600 Subject: [PATCH] Tweak ABL logging, document probing --- Marlin/src/feature/bedlevel/abl/abl.cpp | 5 +---- Marlin/src/gcode/bedlevel/abl/G29.cpp | 8 ++++---- Marlin/src/module/probe.cpp | 22 ++++++++++++++++------ Marlin/src/module/probe.h | 2 +- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Marlin/src/feature/bedlevel/abl/abl.cpp b/Marlin/src/feature/bedlevel/abl/abl.cpp index 5bc08bc695..74821ba2ec 100644 --- a/Marlin/src/feature/bedlevel/abl/abl.cpp +++ b/Marlin/src/feature/bedlevel/abl/abl.cpp @@ -43,6 +43,7 @@ bed_mesh_t z_values; * Extrapolate a single point from its neighbors */ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t xdir, const int8_t ydir) { + if (!isnan(z_values[x][y])) return; if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM("Extrapolate ["); if (x < 10) DEBUG_CHAR(' '); @@ -54,10 +55,6 @@ static void extrapolate_one_point(const uint8_t x, const uint8_t y, const int8_t DEBUG_CHAR(ydir ? (ydir > 0 ? '+' : '-') : ' '); DEBUG_ECHOLNPGM("]"); } - if (!isnan(z_values[x][y])) { - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(" (done)"); - return; // Don't overwrite good values. - } // Get X neighbors, Y neighbors, and XY neighbors const uint8_t x1 = x + xdir, y1 = y + ydir, x2 = x1 + xdir, y2 = y1 + ydir; diff --git a/Marlin/src/gcode/bedlevel/abl/G29.cpp b/Marlin/src/gcode/bedlevel/abl/G29.cpp index a92e368114..5173505164 100644 --- a/Marlin/src/gcode/bedlevel/abl/G29.cpp +++ b/Marlin/src/gcode/bedlevel/abl/G29.cpp @@ -958,10 +958,8 @@ G29_TYPE GcodeSuite::G29() { // Restore state after probing if (!faux) restore_feedrate_and_scaling(); - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G29"); - - if (planner.leveling_active) - sync_plan_position(); + // Sync the planner from the current_position + if (planner.leveling_active) sync_plan_position(); #if HAS_BED_PROBE && defined(Z_AFTER_PROBING) probe.move_z_after_probing(); @@ -975,6 +973,8 @@ G29_TYPE GcodeSuite::G29() { report_current_position(); + if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G29"); + G29_RETURN(isnan(measured_z)); } diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index c89c5eb087..4bb434a922 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -459,8 +459,18 @@ bool Probe::set_deployed(const bool deploy) { const char Probe::msg_wait_for_bed_heating[25] PROGMEM = "Wait for bed heating...\n"; #endif -bool Probe::move_to_z(const float z, const feedRate_t fr_mm_s) { - if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::move_to_z", current_position); +/** + * @brief Move down until the probe triggers or the low limit is reached + * + * @details Used by run_z_probe to get each bed Z height measurement. + * Sets current_position.z to the height where the probe triggered + * (according to the Z stepper count). The float Z is propagated + * back to the planner.position to preempt any rounding error. + * + * @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); #if HAS_HEATED_BED && ENABLED(WAIT_FOR_BED_HEATER) // Wait for bed to heat back up between probing points @@ -536,7 +546,7 @@ bool Probe::move_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::move_to_z", current_position); + if (DEBUGGING(LEVELING)) DEBUG_POS("<<< Probe::probe_down_to_z", current_position); return !probe_triggered; } @@ -561,7 +571,7 @@ float Probe::run_z_probe() { #if TOTAL_PROBING == 2 // Do a first probe at the fast speed - if (move_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) { + if (probe_down_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) { if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM("FAST Probe fail!"); DEBUG_POS("<<< run_z_probe", current_position); @@ -583,7 +593,7 @@ float Probe::run_z_probe() { const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0 + (offset.z < 0 ? -offset.z : 0); if (current_position.z > z) { // Probe down fast. If the probe never triggered, raise for probe clearance - if (!move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) + if (!probe_down_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST))) do_blocking_move_to_z(current_position.z + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST)); } #endif @@ -604,7 +614,7 @@ float Probe::run_z_probe() { #endif { // Probe downward slowly to find the bed - if (move_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) { + if (probe_down_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))) { if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPGM("SLOW Probe fail!"); DEBUG_POS("<<< run_z_probe", current_position); diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index d424f4d283..b70c01364a 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -162,7 +162,7 @@ public: #endif private: - static bool move_to_z(const float z, const feedRate_t fr_mm_s); + static bool probe_down_to_z(const float z, const feedRate_t fr_mm_s); static void do_z_raise(const float z_raise); static float run_z_probe(); };