Browse Source

PROBE_DOUBLE_TOUCH => MULTIPLE_PROBING

Scott Lahteine 8 years ago
parent
commit
44800e9899
4 changed files with 55 additions and 19 deletions
  1. 5
    3
      Marlin/Configuration.h
  2. 1
    1
      Marlin/Configuration_adv.h
  3. 43
    15
      Marlin/Marlin_main.cpp
  4. 6
    0
      Marlin/SanityCheck.h

+ 5
- 3
Marlin/Configuration.h View File

@@ -690,14 +690,16 @@
690 690
 // X and Y axis travel speed (mm/m) between probes
691 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 694
 #define Z_PROBE_SPEED_FAST HOMING_FEEDRATE_Z
695 695
 
696 696
 // Speed for the "accurate" probe of each point
697 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 705
  * Z probes require clearance when deploying, stowing, and moving between

+ 1
- 1
Marlin/Configuration_adv.h View File

@@ -742,7 +742,7 @@
742 742
 //#define BEZIER_CURVE_SUPPORT
743 743
 
744 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 746
 //#define G38_PROBE_TARGET
747 747
 #if ENABLED(G38_PROBE_TARGET)
748 748
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 43
- 15
Marlin/Marlin_main.cpp View File

@@ -2215,7 +2215,7 @@ static void clean_up_after_endstop_or_probe_move() {
2215 2215
   }
2216 2216
 
2217 2217
   /**
2218
-   * @details Used by probe_pt to do a single Z probe.
2218
+   * @details Used by probe_pt to do a single Z probe at the current position.
2219 2219
    *          Leaves current_position[Z_AXIS] at the height where the probe triggered.
2220 2220
    *
2221 2221
    * @return The raw Z position where the probe was triggered
@@ -2229,7 +2229,8 @@ static void clean_up_after_endstop_or_probe_move() {
2229 2229
     // Prevent stepper_inactive_time from running out and EXTRUDER_RUNOUT_PREVENT from extruding
2230 2230
     refresh_cmd_timeout();
2231 2231
 
2232
-    #if ENABLED(PROBE_DOUBLE_TOUCH)
2232
+    // Double-probing does a fast probe followed by a slow probe
2233
+    #if MULTIPLE_PROBING == 2
2233 2234
 
2234 2235
       // Do a first probe at the fast speed
2235 2236
       if (do_probe_move(-10, Z_PROBE_SPEED_FAST)) return NAN;
@@ -2257,22 +2258,49 @@ static void clean_up_after_endstop_or_probe_move() {
2257 2258
       }
2258 2259
     #endif
2259 2260
 
2260
-    // move down slowly to find bed
2261
-    if (do_probe_move(-10, Z_PROBE_SPEED_SLOW)) return NAN;
2262
-
2263
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
2264
-      if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
2261
+    #if MULTIPLE_PROBING > 2
2262
+      float probes_total = 0;
2263
+      for (uint8_t p = MULTIPLE_PROBING + 1; --p;) {
2265 2264
     #endif
2266 2265
 
2267
-    // Debug: compare probe heights
2268
-    #if ENABLED(PROBE_DOUBLE_TOUCH) && ENABLED(DEBUG_LEVELING_FEATURE)
2269
-      if (DEBUGGING(LEVELING)) {
2270
-        SERIAL_ECHOPAIR("2nd Probe Z:", current_position[Z_AXIS]);
2271
-        SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]);
2266
+        // move down slowly to find bed
2267
+        if (do_probe_move(-10, Z_PROBE_SPEED_SLOW)) return NAN;
2268
+
2269
+    #if MULTIPLE_PROBING > 2
2270
+        probes_total += current_position[Z_AXIS];
2271
+        if (p > 1) do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
2272 2272
       }
2273 2273
     #endif
2274 2274
 
2275
-    return current_position[Z_AXIS];
2275
+    #if MULTIPLE_PROBING > 2
2276
+
2277
+      // Return the average value of all probes
2278
+      return probes_total * (1.0 / (MULTIPLE_PROBING));
2279
+
2280
+    #elif MULTIPLE_PROBING == 2
2281
+
2282
+      const float z2 = current_position[Z_AXIS];
2283
+
2284
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
2285
+        if (DEBUGGING(LEVELING)) {
2286
+          SERIAL_ECHOPAIR("2nd Probe Z:", z2);
2287
+          SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - z2);
2288
+        }
2289
+      #endif
2290
+
2291
+      // Return a weighted average of the fast and slow probes
2292
+      return (z2 * 3.0 + first_probe_z * 2.0) * 0.2;
2293
+
2294
+    #else
2295
+
2296
+      // Return the single probe result
2297
+      return current_position[Z_AXIS];
2298
+
2299
+    #endif
2300
+
2301
+    #if ENABLED(DEBUG_LEVELING_FEATURE)
2302
+      if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
2303
+    #endif
2276 2304
   }
2277 2305
 
2278 2306
   /**
@@ -6005,7 +6033,7 @@ void home_all_axes() { gcode_G28(true); }
6005 6033
 
6006 6034
     bool G38_pass_fail = false;
6007 6035
 
6008
-    #if ENABLED(PROBE_DOUBLE_TOUCH)
6036
+    #if MULTIPLE_PROBING > 1
6009 6037
       // Get direction of move and retract
6010 6038
       float retract_mm[XYZ];
6011 6039
       LOOP_XYZ(i) {
@@ -6032,7 +6060,7 @@ void home_all_axes() { gcode_G28(true); }
6032 6060
 
6033 6061
       G38_pass_fail = true;
6034 6062
 
6035
-      #if ENABLED(PROBE_DOUBLE_TOUCH)
6063
+      #if MULTIPLE_PROBING > 1
6036 6064
         // Move away by the retract distance
6037 6065
         set_destination_from_current();
6038 6066
         LOOP_XYZ(i) destination[i] += retract_mm[i];

+ 6
- 0
Marlin/SanityCheck.h View File

@@ -224,6 +224,8 @@
224 224
   #error "UBL_GRANULAR_SEGMENTATION_FOR_CARTESIAN is now SEGMENT_LEVELED_MOVES. Please update your configuration."
225 225
 #elif HAS_PID_HEATING && (defined(K1) || !defined(PID_K1))
226 226
   #error "K1 is now PID_K1. Please update your configuration."
227
+#elif defined(PROBE_DOUBLE_TOUCH)
228
+  #error "PROBE_DOUBLE_TOUCH is now MULTIPLE_PROBING. Please update your configuration."
227 229
 #endif
228 230
 
229 231
 /**
@@ -698,6 +700,10 @@ static_assert(1 >= 0
698 700
     #error "Probes need Z_CLEARANCE_BETWEEN_PROBES >= 0."
699 701
   #endif
700 702
 
703
+  #if MULTIPLE_PROBING && MULTIPLE_PROBING < 2
704
+    #error "MULTIPLE_PROBING must be >= 2."
705
+  #endif
706
+
701 707
 #else
702 708
 
703 709
   /**

Loading…
Cancel
Save