🧑💻 Modify try_to_probe sanity-checking
This commit is contained in:
@@ -702,6 +702,10 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
|
|||||||
* @details Used by probe_at_point to get the bed Z height at the current XY.
|
* @details Used by probe_at_point to get the bed Z height at the current XY.
|
||||||
* Leaves current_position.z at the height where the probe triggered.
|
* Leaves current_position.z at the height where the probe triggered.
|
||||||
*
|
*
|
||||||
|
* @param sanity_check Flag to compare the probe result with the expected result
|
||||||
|
* based on the probe Z offset. If the result is too far away
|
||||||
|
* (more than 2mm too early) then consider it an error.
|
||||||
|
*
|
||||||
* @return The Z position of the bed at the current XY or NAN on error.
|
* @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*/) {
|
float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
||||||
@@ -709,22 +713,24 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
|||||||
|
|
||||||
const float zoffs = SUM_TERN(HAS_HOTEND_OFFSET, -offset.z, hotend_offset[active_extruder].z);
|
const float zoffs = SUM_TERN(HAS_HOTEND_OFFSET, -offset.z, hotend_offset[active_extruder].z);
|
||||||
|
|
||||||
auto try_to_probe = [&](PGM_P const plbl, const_float_t z_probe_low_point, const feedRate_t fr_mm_s, const bool scheck, const float clearance) -> bool {
|
auto try_to_probe = [&](PGM_P const plbl, const_float_t z_probe_low_point, const feedRate_t fr_mm_s, const bool scheck) -> bool {
|
||||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("try_to_probe(..., ", z_probe_low_point, ", ", fr_mm_s, ", ", scheck, ", ", clearance);
|
constexpr float error_tolerance = 2.0f;
|
||||||
|
if (DEBUGGING(LEVELING)) {
|
||||||
|
DEBUG_ECHOPGM_P(plbl);
|
||||||
|
DEBUG_ECHOLNPGM("> try_to_probe(..., ", z_probe_low_point, ", ", fr_mm_s, ", ...)");
|
||||||
|
}
|
||||||
|
|
||||||
// Tare the probe, if supported
|
// Tare the probe, if supported
|
||||||
if (TERN0(PROBE_TARE, tare())) return true;
|
if (TERN0(PROBE_TARE, tare())) return true;
|
||||||
|
|
||||||
// Do a first probe at the fast speed
|
// Do a first probe at the fast speed
|
||||||
const bool probe_fail = probe_down_to_z(z_probe_low_point, fr_mm_s), // No probe trigger?
|
const bool probe_fail = probe_down_to_z(z_probe_low_point, fr_mm_s), // No probe trigger?
|
||||||
early_fail = (scheck && current_position.z > zoffs + clearance); // Probe triggered too high?
|
early_fail = (scheck && current_position.z > zoffs + error_tolerance); // Probe triggered too high?
|
||||||
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
#if ENABLED(DEBUG_LEVELING_FEATURE)
|
||||||
if (DEBUGGING(LEVELING) && (probe_fail || early_fail)) {
|
if (DEBUGGING(LEVELING) && (probe_fail || early_fail)) {
|
||||||
DEBUG_ECHOPGM_P(plbl);
|
DEBUG_ECHOPGM(" Probe fail! - ");
|
||||||
DEBUG_ECHOPGM(" Probe fail! -");
|
if (probe_fail) DEBUG_ECHOLNPGM("No trigger.");
|
||||||
if (probe_fail) DEBUG_ECHOPGM(" No trigger.");
|
if (early_fail) DEBUG_ECHOLNPGM("Triggered early (above ", zoffs + error_tolerance, "mm)");
|
||||||
if (early_fail) DEBUG_ECHOPGM(" Triggered early.");
|
|
||||||
DEBUG_EOL();
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
UNUSED(plbl);
|
UNUSED(plbl);
|
||||||
@@ -733,7 +739,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Stop the probe before it goes too low to prevent damage.
|
// Stop the probe before it goes too low to prevent damage.
|
||||||
// If Z isn't known then probe to -10mm.
|
// For known Z probe below the expected trigger point, otherwise -10mm.
|
||||||
const float z_probe_low_point = axis_is_trusted(Z_AXIS) ? zoffs + Z_PROBE_LOW_POINT : -10.0f;
|
const float z_probe_low_point = axis_is_trusted(Z_AXIS) ? zoffs + Z_PROBE_LOW_POINT : -10.0f;
|
||||||
|
|
||||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Probe Low Point: ", z_probe_low_point);
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Probe Low Point: ", z_probe_low_point);
|
||||||
@@ -745,9 +751,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
|||||||
if (TERN0(PROBE_TARE, tare())) return NAN;
|
if (TERN0(PROBE_TARE, tare())) return NAN;
|
||||||
|
|
||||||
// Do a first probe at the fast speed
|
// Do a first probe at the fast speed
|
||||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Fast Probe:");
|
if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s, sanity_check)) return NAN;
|
||||||
if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
|
|
||||||
sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
|
|
||||||
|
|
||||||
const float z1 = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj);
|
const float z1 = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj);
|
||||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("1st Probe Z:", z1);
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("1st Probe Z:", z1);
|
||||||
@@ -787,8 +791,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
|
|||||||
|
|
||||||
// Probe downward slowly to find the bed
|
// Probe downward slowly to find the bed
|
||||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Slow Probe:");
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Slow Probe:");
|
||||||
if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW),
|
if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW), sanity_check)) return NAN;
|
||||||
sanity_check, Z_CLEARANCE_MULTI_PROBE) ) return NAN;
|
|
||||||
|
|
||||||
TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe());
|
TERN_(MEASURE_BACKLASH_WHEN_PROBING, backlash.measure_with_probe());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user