Browse Source

Merge pull request #5678 from Bob-the-Kuhn/G38-optional-double-tap

G38 bug fix, made double touch optional & reverted to Z_MIN_PROBE
Scott Lahteine 7 years ago
parent
commit
deaad78df9

+ 1
- 0
Marlin/Configuration_adv.h View File

@@ -649,6 +649,7 @@
649 649
 //#define BEZIER_CURVE_SUPPORT
650 650
 
651 651
 // G38.2 and G38.3 Probe Target
652
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
652 653
 //#define G38_PROBE_TARGET
653 654
 #if ENABLED(G38_PROBE_TARGET)
654 655
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 20
- 19
Marlin/Marlin_main.cpp View File

@@ -61,7 +61,7 @@
61 61
  * G30 - Single Z probe, probes bed at X Y location (defaults to current XY location)
62 62
  * G31 - Dock sled (Z_PROBE_SLED only)
63 63
  * G32 - Undock sled (Z_PROBE_SLED only)
64
- * G38 - Probe target - similar to G28 except it uses the Z_MIN endstop for all three axes
64
+ * G38 - Probe target - similar to G28 except it uses the Z_MIN_PROBE for all three axes
65 65
  * G90 - Use Absolute Coordinates
66 66
  * G91 - Use Relative Coordinates
67 67
  * G92 - Set current position to coordinates given
@@ -4824,31 +4824,32 @@ inline void gcode_G28() {
4824 4824
     set_current_from_steppers_for_axis(ALL_AXES);
4825 4825
     SYNC_PLAN_POSITION_KINEMATIC();
4826 4826
 
4827
-    // Only do remaining moves if target was hit
4828 4827
     if (G38_endstop_hit) {
4829 4828
 
4830 4829
       G38_pass_fail = true;
4831 4830
 
4832
-      // Move away by the retract distance
4833
-      set_destination_to_current();
4834
-      LOOP_XYZ(i) destination[i] += retract_mm[i];
4835
-      endstops.enable(false);
4836
-      prepare_move_to_destination();
4837
-      stepper.synchronize();
4831
+      #if ENABLED(PROBE_DOUBLE_TOUCH)
4832
+        // Move away by the retract distance
4833
+        set_destination_to_current();
4834
+        LOOP_XYZ(i) destination[i] += retract_mm[i];
4835
+        endstops.enable(false);
4836
+        prepare_move_to_destination();
4837
+        stepper.synchronize();
4838 4838
 
4839
-      feedrate_mm_s /= 4;
4839
+        feedrate_mm_s /= 4;
4840 4840
 
4841
-      // Bump the target more slowly
4842
-      LOOP_XYZ(i) destination[i] -= retract_mm[i] * 2;
4841
+        // Bump the target more slowly
4842
+        LOOP_XYZ(i) destination[i] -= retract_mm[i] * 2;
4843 4843
 
4844
-      endstops.enable(true);
4845
-      G38_move = true;
4846
-      prepare_move_to_destination();
4847
-      stepper.synchronize();
4848
-      G38_move = false;
4844
+        endstops.enable(true);
4845
+        G38_move = true;
4846
+        prepare_move_to_destination();
4847
+        stepper.synchronize();
4848
+        G38_move = false;
4849 4849
 
4850
-      set_current_from_steppers_for_axis(ALL_AXES);
4851
-      SYNC_PLAN_POSITION_KINEMATIC();
4850
+        set_current_from_steppers_for_axis(ALL_AXES);
4851
+        SYNC_PLAN_POSITION_KINEMATIC();
4852
+      #endif
4852 4853
     }
4853 4854
 
4854 4855
     endstops.hit_on_purpose();
@@ -4860,7 +4861,7 @@ inline void gcode_G28() {
4860 4861
    * G38.2 - probe toward workpiece, stop on contact, signal error if failure
4861 4862
    * G38.3 - probe toward workpiece, stop on contact
4862 4863
    *
4863
-   * Like G28 except uses Z min endstop for all axes
4864
+   * Like G28 except uses Z min probe for all axes
4864 4865
    */
4865 4866
   inline void gcode_G38(bool is_38_2) {
4866 4867
     // Get X Y Z E F

+ 12
- 13
Marlin/endstops.cpp View File

@@ -257,26 +257,25 @@ void Endstops::update() {
257 257
   // COPY_BIT: copy the value of SRC_BIT to DST_BIT in DST
258 258
   #define COPY_BIT(DST, SRC_BIT, DST_BIT) SET_BIT(DST, DST_BIT, TEST(DST, SRC_BIT))
259 259
 
260
-  #define _UPDATE_ENDSTOP(AXIS,MINMAX,CODE) do { \
260
+  #define UPDATE_ENDSTOP(AXIS,MINMAX) do { \
261 261
       UPDATE_ENDSTOP_BIT(AXIS, MINMAX); \
262 262
       if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX)) && stepper.current_block->steps[_AXIS(AXIS)] > 0) { \
263 263
         _ENDSTOP_HIT(AXIS); \
264 264
         stepper.endstop_triggered(_AXIS(AXIS)); \
265
-        CODE; \
266 265
       } \
267 266
     } while(0)
268 267
 
269
-  #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN)  // If G38 command then check Z_MIN for every axis and every direction
270
-
271
-    #define UPDATE_ENDSTOP(AXIS,MINMAX) do { \
272
-        _UPDATE_ENDSTOP(AXIS,MINMAX,NOOP); \
273
-        if (G38_move) _UPDATE_ENDSTOP(Z, MIN, G38_endstop_hit = true); \
274
-      } while(0)
275
-
276
-  #else
277
-
278
-    #define UPDATE_ENDSTOP(AXIS,MINMAX) _UPDATE_ENDSTOP(AXIS,MINMAX,NOOP)
279
-
268
+  #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ)
269
+  // If G38 command then check Z_MIN_PROBE for every axis and every direction
270
+    if (G38_move) {
271
+      UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
272
+      if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) {
273
+        if      (stepper.current_block->steps[_AXIS(X)] > 0) {_ENDSTOP_HIT(X); stepper.endstop_triggered(_AXIS(X));}
274
+        else if (stepper.current_block->steps[_AXIS(Y)] > 0) {_ENDSTOP_HIT(Y); stepper.endstop_triggered(_AXIS(Y));}
275
+        else if (stepper.current_block->steps[_AXIS(Z)] > 0) {_ENDSTOP_HIT(Z); stepper.endstop_triggered(_AXIS(Z));}
276
+        G38_endstop_hit = true;
277
+      }
278
+    }
280 279
   #endif
281 280
 
282 281
   #if CORE_IS_XY || CORE_IS_XZ

+ 1
- 0
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

@@ -639,6 +639,7 @@
639 639
 //#define BEZIER_CURVE_SUPPORT
640 640
 
641 641
 // G38.2 and G38.3 Probe Target
642
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
642 643
 //#define G38_PROBE_TARGET
643 644
 #if ENABLED(G38_PROBE_TARGET)
644 645
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -639,6 +639,7 @@
639 639
 //#define BEZIER_CURVE_SUPPORT
640 640
 
641 641
 // G38.2 and G38.3 Probe Target
642
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
642 643
 //#define G38_PROBE_TARGET
643 644
 #if ENABLED(G38_PROBE_TARGET)
644 645
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

@@ -639,6 +639,7 @@
639 639
 //#define BEZIER_CURVE_SUPPORT
640 640
 
641 641
 // G38.2 and G38.3 Probe Target
642
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
642 643
 //#define G38_PROBE_TARGET
643 644
 #if ENABLED(G38_PROBE_TARGET)
644 645
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/Hephestos_2/Configuration_adv.h View File

@@ -622,6 +622,7 @@
622 622
 //#define BEZIER_CURVE_SUPPORT
623 623
 
624 624
 // G38.2 and G38.3 Probe Target
625
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
625 626
 //#define G38_PROBE_TARGET
626 627
 #if ENABLED(G38_PROBE_TARGET)
627 628
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/K8200/Configuration_adv.h View File

@@ -652,6 +652,7 @@
652 652
 //#define BEZIER_CURVE_SUPPORT
653 653
 
654 654
 // G38.2 and G38.3 Probe Target
655
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
655 656
 //#define G38_PROBE_TARGET
656 657
 #if ENABLED(G38_PROBE_TARGET)
657 658
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/K8400/Configuration_adv.h View File

@@ -639,6 +639,7 @@
639 639
 //#define BEZIER_CURVE_SUPPORT
640 640
 
641 641
 // G38.2 and G38.3 Probe Target
642
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
642 643
 //#define G38_PROBE_TARGET
643 644
 #if ENABLED(G38_PROBE_TARGET)
644 645
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

@@ -639,6 +639,7 @@
639 639
 //#define BEZIER_CURVE_SUPPORT
640 640
 
641 641
 // G38.2 and G38.3 Probe Target
642
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
642 643
 //#define G38_PROBE_TARGET
643 644
 #if ENABLED(G38_PROBE_TARGET)
644 645
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

@@ -639,6 +639,7 @@
639 639
 //#define BEZIER_CURVE_SUPPORT
640 640
 
641 641
 // G38.2 and G38.3 Probe Target
642
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
642 643
 //#define G38_PROBE_TARGET
643 644
 #if ENABLED(G38_PROBE_TARGET)
644 645
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

@@ -647,6 +647,7 @@
647 647
 //#define BEZIER_CURVE_SUPPORT
648 648
 
649 649
 // G38.2 and G38.3 Probe Target
650
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
650 651
 //#define G38_PROBE_TARGET
651 652
 #if ENABLED(G38_PROBE_TARGET)
652 653
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

@@ -639,6 +639,7 @@
639 639
 //#define BEZIER_CURVE_SUPPORT
640 640
 
641 641
 // G38.2 and G38.3 Probe Target
642
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
642 643
 //#define G38_PROBE_TARGET
643 644
 #if ENABLED(G38_PROBE_TARGET)
644 645
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

@@ -641,6 +641,7 @@
641 641
 //#define BEZIER_CURVE_SUPPORT
642 642
 
643 643
 // G38.2 and G38.3 Probe Target
644
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
644 645
 //#define G38_PROBE_TARGET
645 646
 #if ENABLED(G38_PROBE_TARGET)
646 647
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

@@ -641,6 +641,7 @@
641 641
 //#define BEZIER_CURVE_SUPPORT
642 642
 
643 643
 // G38.2 and G38.3 Probe Target
644
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
644 645
 //#define G38_PROBE_TARGET
645 646
 #if ENABLED(G38_PROBE_TARGET)
646 647
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

@@ -646,6 +646,7 @@
646 646
 //#define BEZIER_CURVE_SUPPORT
647 647
 
648 648
 // G38.2 and G38.3 Probe Target
649
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
649 650
 //#define G38_PROBE_TARGET
650 651
 #if ENABLED(G38_PROBE_TARGET)
651 652
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

@@ -641,6 +641,7 @@
641 641
 //#define BEZIER_CURVE_SUPPORT
642 642
 
643 643
 // G38.2 and G38.3 Probe Target
644
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
644 645
 //#define G38_PROBE_TARGET
645 646
 #if ENABLED(G38_PROBE_TARGET)
646 647
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

@@ -639,6 +639,7 @@
639 639
 //#define BEZIER_CURVE_SUPPORT
640 640
 
641 641
 // G38.2 and G38.3 Probe Target
642
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
642 643
 //#define G38_PROBE_TARGET
643 644
 #if ENABLED(G38_PROBE_TARGET)
644 645
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

+ 1
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

@@ -639,6 +639,7 @@
639 639
 //#define BEZIER_CURVE_SUPPORT
640 640
 
641 641
 // G38.2 and G38.3 Probe Target
642
+// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch
642 643
 //#define G38_PROBE_TARGET
643 644
 #if ENABLED(G38_PROBE_TARGET)
644 645
   #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)

Loading…
Cancel
Save