Browse Source

PROBE_DOUBLE_TOUCH => MULTIPLE_PROBING

Scott Lahteine 7 years ago
parent
commit
ae663a4198

+ 5
- 3
Marlin/Configuration.h View File

690
 // X and Y axis travel speed (mm/m) between probes
690
 // X and Y axis travel speed (mm/m) between probes
691
 #define XY_PROBE_SPEED 8000
691
 #define XY_PROBE_SPEED 8000
692
 
692
 
693
-// Speed for the first approach when double-probing (with PROBE_DOUBLE_TOUCH)
693
+// Speed for the first approach when double-probing (MULTIPLE_PROBING == 2)
694
 #define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
694
 #define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
695
 
695
 
696
 // Speed for the "accurate" probe of each point
696
 // Speed for the "accurate" probe of each point
697
 #define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
697
 #define Z_PROBE_SPEED_SLOW (Z_PROBE_SPEED_FAST / 2)
698
 
698
 
699
-// Use double touch for probing
700
-//#define PROBE_DOUBLE_TOUCH
699
+// The number of probes to perform at each point.
700
+//   Set to 2 for a fast/slow probe, using the second probe result.
701
+//   Set to 3 or more for slow probes, averaging the results.
702
+//#define MULTIPLE_PROBING 2
701
 
703
 
702
 /**
704
 /**
703
  * Z probes require clearance when deploying, stowing, and moving between
705
  * Z probes require clearance when deploying, stowing, and moving between

+ 1
- 1
Marlin/Configuration_adv.h View File

742
 //#define BEZIER_CURVE_SUPPORT
742
 //#define BEZIER_CURVE_SUPPORT
743
 
743
 
744
 // G38.2 and G38.3 Probe Target
744
 // G38.2 and G38.3 Probe Target
745
-// Enable PROBE_DOUBLE_TOUCH if you want G38 to double touch
745
+// Set MULTIPLE_PROBING if you want G38 to double touch
746
 //#define G38_PROBE_TARGET
746
 //#define G38_PROBE_TARGET
747
 #if ENABLED(G38_PROBE_TARGET)
747
 #if ENABLED(G38_PROBE_TARGET)
748
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)
748
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 2
- 2
Marlin/src/gcode/probe/G38.cpp View File

35
 
35
 
36
   bool G38_pass_fail = false;
36
   bool G38_pass_fail = false;
37
 
37
 
38
-  #if ENABLED(PROBE_DOUBLE_TOUCH)
38
+  #if MULTIPLE_PROBING > 1
39
     // Get direction of move and retract
39
     // Get direction of move and retract
40
     float retract_mm[XYZ];
40
     float retract_mm[XYZ];
41
     LOOP_XYZ(i) {
41
     LOOP_XYZ(i) {
62
 
62
 
63
     G38_pass_fail = true;
63
     G38_pass_fail = true;
64
 
64
 
65
-    #if ENABLED(PROBE_DOUBLE_TOUCH)
65
+    #if MULTIPLE_PROBING > 1
66
       // Move away by the retract distance
66
       // Move away by the retract distance
67
       set_destination_from_current();
67
       set_destination_from_current();
68
       LOOP_XYZ(i) destination[i] += retract_mm[i];
68
       LOOP_XYZ(i) destination[i] += retract_mm[i];

+ 6
- 0
Marlin/src/inc/SanityCheck.h View File

227
   #error "UBL_GRANULAR_SEGMENTATION_FOR_CARTESIAN is now SEGMENT_LEVELED_MOVES. Please update your configuration."
227
   #error "UBL_GRANULAR_SEGMENTATION_FOR_CARTESIAN is now SEGMENT_LEVELED_MOVES. Please update your configuration."
228
 #elif HAS_PID_HEATING && (defined(K1) || !defined(PID_K1))
228
 #elif HAS_PID_HEATING && (defined(K1) || !defined(PID_K1))
229
   #error "K1 is now PID_K1. Please update your configuration."
229
   #error "K1 is now PID_K1. Please update your configuration."
230
+#elif defined(PROBE_DOUBLE_TOUCH)
231
+  #error "PROBE_DOUBLE_TOUCH is now MULTIPLE_PROBING. Please update your configuration."
230
 #endif
232
 #endif
231
 
233
 
232
 /**
234
 /**
711
     #error "Probes need Z_CLEARANCE_BETWEEN_PROBES >= 0."
713
     #error "Probes need Z_CLEARANCE_BETWEEN_PROBES >= 0."
712
   #endif
714
   #endif
713
 
715
 
716
+  #if MULTIPLE_PROBING && MULTIPLE_PROBING < 2
717
+    #error "MULTIPLE_PROBING must be >= 2."
718
+  #endif
719
+
714
 #else
720
 #else
715
 
721
 
716
   /**
722
   /**

+ 41
- 13
Marlin/src/module/probe.cpp View File

507
 }
507
 }
508
 
508
 
509
 /**
509
 /**
510
- * @details Used by probe_pt to do a single Z probe.
510
+ * @details Used by probe_pt to do a single Z probe at the current position.
511
  *          Leaves current_position[Z_AXIS] at the height where the probe triggered.
511
  *          Leaves current_position[Z_AXIS] at the height where the probe triggered.
512
  *
512
  *
513
  * @return The raw Z position where the probe was triggered
513
  * @return The raw Z position where the probe was triggered
521
   // Prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding
521
   // Prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding
522
   gcode.refresh_cmd_timeout();
522
   gcode.refresh_cmd_timeout();
523
 
523
 
524
-  #if ENABLED(PROBE_DOUBLE_TOUCH)
524
+  // Double-probing does a fast probe followed by a slow probe
525
+  #if MULTIPLE_PROBING == 2
525
 
526
 
526
     // Do a first probe at the fast speed
527
     // Do a first probe at the fast speed
527
     if (do_probe_move(-10, Z_PROBE_SPEED_FAST)) return NAN;
528
     if (do_probe_move(-10, Z_PROBE_SPEED_FAST)) return NAN;
549
     }
550
     }
550
   #endif
551
   #endif
551
 
552
 
552
-  // Move down slowly to find bed, not too far
553
-  if (do_probe_move(-10, Z_PROBE_SPEED_SLOW)) return NAN;
554
-
555
-  #if ENABLED(DEBUG_LEVELING_FEATURE)
556
-    if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
553
+  #if MULTIPLE_PROBING > 2
554
+    float probes_total = 0;
555
+    for (uint8_t p = MULTIPLE_PROBING + 1; --p;) {
557
   #endif
556
   #endif
558
 
557
 
559
-  // Debug: compare probe heights
560
-  #if ENABLED(PROBE_DOUBLE_TOUCH) && ENABLED(DEBUG_LEVELING_FEATURE)
561
-    if (DEBUGGING(LEVELING)) {
562
-      SERIAL_ECHOPAIR("2nd Probe Z:", current_position[Z_AXIS]);
563
-      SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]);
558
+      // Move down slowly to find bed, not too far
559
+      if (do_probe_move(-10, Z_PROBE_SPEED_SLOW)) return NAN;
560
+
561
+  #if MULTIPLE_PROBING > 2
562
+      probes_total += current_position[Z_AXIS];
563
+      if (p > 1) do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
564
     }
564
     }
565
   #endif
565
   #endif
566
 
566
 
567
-  return current_position[Z_AXIS];
567
+  #if MULTIPLE_PROBING > 2
568
+
569
+    // Return the average value of all probes
570
+    return probes_total * (1.0 / (MULTIPLE_PROBING));
571
+
572
+  #elif MULTIPLE_PROBING == 2
573
+
574
+    const float z2 = current_position[Z_AXIS];
575
+
576
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
577
+      if (DEBUGGING(LEVELING)) {
578
+        SERIAL_ECHOPAIR("2nd Probe Z:", z2);
579
+        SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - z2);
580
+      }
581
+    #endif
582
+
583
+    // Return a weighted average of the fast and slow probes
584
+    return (z2 * 3.0 + first_probe_z * 2.0) * 0.2;
585
+
586
+  #else
587
+
588
+    // Return the single probe result
589
+    return current_position[Z_AXIS];
590
+
591
+  #endif
592
+
593
+  #if ENABLED(DEBUG_LEVELING_FEATURE)
594
+    if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
595
+  #endif
568
 }
596
 }
569
 
597
 
570
 /**
598
 /**

Loading…
Cancel
Save