Browse Source

More verbose probing error (#17482)

Davide Toldo 5 years ago
parent
commit
720795ac7d
No account linked to committer's email address
1 changed files with 23 additions and 18 deletions
  1. 23
    18
      Marlin/src/module/probe.cpp

+ 23
- 18
Marlin/src/module/probe.cpp View File

@@ -547,6 +547,25 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
547 547
 
548 548
   if (DEBUGGING(LEVELING)) DEBUG_POS(">>> Probe::run_z_probe", current_position);
549 549
 
550
+  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) {
551
+    // Do a first probe at the fast speed
552
+    const bool probe_fail = probe_down_to_z(z_probe_low_point, fr_mm_s),            // No probe trigger?
553
+               early_fail = (scheck && current_position.z > -offset.z + clearance); // Probe triggered too high?
554
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
555
+      if (DEBUGGING(LEVELING) && (probe_fail || early_fail)) {
556
+        DEBUG_PRINT_P(plbl);
557
+        DEBUG_ECHOPGM(" Probe fail! -");
558
+        if (probe_fail) DEBUG_ECHOPGM(" No trigger.");
559
+        if (early_fail) DEBUG_ECHOPGM(" Triggered early.");
560
+        DEBUG_EOL();
561
+        DEBUG_POS("<<< run_z_probe", current_position);
562
+      }
563
+    #else
564
+      UNUSED(plbl);
565
+    #endif
566
+    return probe_fail || early_fail;
567
+  };
568
+
550 569
   // Stop the probe before it goes too low to prevent damage.
551 570
   // If Z isn't known then probe to -10mm.
552 571
   const float z_probe_low_point = TEST(axis_known_position, Z_AXIS) ? -offset.z + Z_PROBE_LOW_POINT : -10.0;
@@ -555,15 +574,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
555 574
   #if TOTAL_PROBING == 2
556 575
 
557 576
     // Do a first probe at the fast speed
558
-    if (probe_down_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST))         // No probe trigger?
559
-      || (sanity_check && current_position.z > -offset.z + _MAX(Z_CLEARANCE_BETWEEN_PROBES, 4) / 2)  // Probe triggered too high?
560
-    ) {
561
-      if (DEBUGGING(LEVELING)) {
562
-        DEBUG_ECHOLNPGM("FAST Probe fail!");
563
-        DEBUG_POS("<<< run_z_probe", current_position);
564
-      }
565
-      return NAN;
566
-    }
577
+    if (try_to_probe(PSTR("FAST"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_FAST),
578
+                     sanity_check, _MAX(Z_CLEARANCE_BETWEEN_PROBES, 4) / 2) ) return NAN;
567 579
 
568 580
     const float first_probe_z = current_position.z;
569 581
 
@@ -600,15 +612,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
600 612
   #endif
601 613
     {
602 614
       // Probe downward slowly to find the bed
603
-      if (probe_down_to_z(z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW))      // No probe trigger?
604
-        || (sanity_check && current_position.z > -offset.z + _MAX(Z_CLEARANCE_MULTI_PROBE, 4) / 2)  // Probe triggered too high?
605
-      ) {
606
-        if (DEBUGGING(LEVELING)) {
607
-          DEBUG_ECHOLNPGM("SLOW Probe fail!");
608
-          DEBUG_POS("<<< run_z_probe", current_position);
609
-        }
610
-        return NAN;
611
-      }
615
+      if (try_to_probe(PSTR("SLOW"), z_probe_low_point, MMM_TO_MMS(Z_PROBE_SPEED_SLOW),
616
+                       sanity_check, _MAX(Z_CLEARANCE_MULTI_PROBE, 4) / 2) ) return NAN;
612 617
 
613 618
       #if ENABLED(MEASURE_BACKLASH_WHEN_PROBING)
614 619
         backlash.measure_with_probe();

Loading…
Cancel
Save