Browse Source

G38 optional double touch

Made the double touch portion a conditional compile based on the
PROBE_DOUBLE_TOUCH flag.

==============================================

Bugfix

The current G38 only stopped a move if it involved the Z axis.

Moved all the G38 code to it's own section and put it where it would
always be executed no matter what axis was moving or if the endstop was
enabled.

Also added a comment to configuration_adv to alert the user the double
tap had to be turned on.

==============================================

Change G38 back to using Z_MIN_PROBE

There's no Z_MIN endstop if Z_DUAL_ENDSTOPS is enabled and you have them
set to the top of the gantry.

G38 started out as using the Z_MIN_PROBE pin.  I don't remember why we
changed it to the Z_MIN endstop.
Bob-the-Kuhn 7 years ago
parent
commit
0934563b97

+ 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
@@ -4488,31 +4488,32 @@ inline void gcode_G28() {
4488 4488
     set_current_from_steppers_for_axis(ALL_AXES);
4489 4489
     SYNC_PLAN_POSITION_KINEMATIC();
4490 4490
 
4491
-    // Only do remaining moves if target was hit
4492 4491
     if (G38_endstop_hit) {
4493 4492
 
4494 4493
       G38_pass_fail = true;
4495 4494
 
4496
-      // Move away by the retract distance
4497
-      set_destination_to_current();
4498
-      LOOP_XYZ(i) destination[i] += retract_mm[i];
4499
-      endstops.enable(false);
4500
-      prepare_move_to_destination();
4501
-      stepper.synchronize();
4495
+      #if ENABLED(PROBE_DOUBLE_TOUCH)
4496
+        // Move away by the retract distance
4497
+        set_destination_to_current();
4498
+        LOOP_XYZ(i) destination[i] += retract_mm[i];
4499
+        endstops.enable(false);
4500
+        prepare_move_to_destination();
4501
+        stepper.synchronize();
4502 4502
 
4503
-      feedrate_mm_s /= 4;
4503
+        feedrate_mm_s /= 4;
4504 4504
 
4505
-      // Bump the target more slowly
4506
-      LOOP_XYZ(i) destination[i] -= retract_mm[i] * 2;
4505
+        // Bump the target more slowly
4506
+        LOOP_XYZ(i) destination[i] -= retract_mm[i] * 2;
4507 4507
 
4508
-      endstops.enable(true);
4509
-      G38_move = true;
4510
-      prepare_move_to_destination();
4511
-      stepper.synchronize();
4512
-      G38_move = false;
4508
+        endstops.enable(true);
4509
+        G38_move = true;
4510
+        prepare_move_to_destination();
4511
+        stepper.synchronize();
4512
+        G38_move = false;
4513 4513
 
4514
-      set_current_from_steppers_for_axis(ALL_AXES);
4515
-      SYNC_PLAN_POSITION_KINEMATIC();
4514
+        set_current_from_steppers_for_axis(ALL_AXES);
4515
+        SYNC_PLAN_POSITION_KINEMATIC();
4516
+      #endif
4516 4517
     }
4517 4518
 
4518 4519
     endstops.hit_on_purpose();
@@ -4524,7 +4525,7 @@ inline void gcode_G28() {
4524 4525
    * G38.2 - probe toward workpiece, stop on contact, signal error if failure
4525 4526
    * G38.3 - probe toward workpiece, stop on contact
4526 4527
    *
4527
-   * Like G28 except uses Z min endstop for all axes
4528
+   * Like G28 except uses Z min probe for all axes
4528 4529
    */
4529 4530
   inline void gcode_G38(bool is_38_2) {
4530 4531
     // Get X Y Z E F

+ 12
- 13
Marlin/endstops.cpp View File

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