diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 57209236ac..a22e6dc902 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -649,6 +649,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 18fffc911e..10a2a9f661 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -61,7 +61,7 @@ * G30 - Single Z probe, probes bed at X Y location (defaults to current XY location) * G31 - Dock sled (Z_PROBE_SLED only) * G32 - Undock sled (Z_PROBE_SLED only) - * G38 - Probe target - similar to G28 except it uses the Z_MIN endstop for all three axes + * G38 - Probe target - similar to G28 except it uses the Z_MIN_PROBE for all three axes * G90 - Use Absolute Coordinates * G91 - Use Relative Coordinates * G92 - Set current position to coordinates given @@ -4488,31 +4488,32 @@ inline void gcode_G28() { set_current_from_steppers_for_axis(ALL_AXES); SYNC_PLAN_POSITION_KINEMATIC(); - // Only do remaining moves if target was hit if (G38_endstop_hit) { G38_pass_fail = true; - // Move away by the retract distance - set_destination_to_current(); - LOOP_XYZ(i) destination[i] += retract_mm[i]; - endstops.enable(false); - prepare_move_to_destination(); - stepper.synchronize(); + #if ENABLED(PROBE_DOUBLE_TOUCH) + // Move away by the retract distance + set_destination_to_current(); + LOOP_XYZ(i) destination[i] += retract_mm[i]; + endstops.enable(false); + prepare_move_to_destination(); + stepper.synchronize(); - feedrate_mm_s /= 4; + feedrate_mm_s /= 4; - // Bump the target more slowly - LOOP_XYZ(i) destination[i] -= retract_mm[i] * 2; + // Bump the target more slowly + LOOP_XYZ(i) destination[i] -= retract_mm[i] * 2; - endstops.enable(true); - G38_move = true; - prepare_move_to_destination(); - stepper.synchronize(); - G38_move = false; + endstops.enable(true); + G38_move = true; + prepare_move_to_destination(); + stepper.synchronize(); + G38_move = false; - set_current_from_steppers_for_axis(ALL_AXES); - SYNC_PLAN_POSITION_KINEMATIC(); + set_current_from_steppers_for_axis(ALL_AXES); + SYNC_PLAN_POSITION_KINEMATIC(); + #endif } endstops.hit_on_purpose(); @@ -4524,7 +4525,7 @@ inline void gcode_G28() { * G38.2 - probe toward workpiece, stop on contact, signal error if failure * G38.3 - probe toward workpiece, stop on contact * - * Like G28 except uses Z min endstop for all axes + * Like G28 except uses Z min probe for all axes */ inline void gcode_G38(bool is_38_2) { // Get X Y Z E F diff --git a/Marlin/endstops.cpp b/Marlin/endstops.cpp index 54a512787d..69162f80bf 100644 --- a/Marlin/endstops.cpp +++ b/Marlin/endstops.cpp @@ -259,26 +259,25 @@ void Endstops::update() { // COPY_BIT: copy the value of SRC_BIT to DST_BIT in DST #define COPY_BIT(DST, SRC_BIT, DST_BIT) SET_BIT(DST, DST_BIT, TEST(DST, SRC_BIT)) - #define _UPDATE_ENDSTOP(AXIS,MINMAX,CODE) do { \ + #define UPDATE_ENDSTOP(AXIS,MINMAX) do { \ UPDATE_ENDSTOP_BIT(AXIS, MINMAX); \ if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX)) && stepper.current_block->steps[_AXIS(AXIS)] > 0) { \ _ENDSTOP_HIT(AXIS); \ stepper.endstop_triggered(_AXIS(AXIS)); \ - CODE; \ } \ } while(0) - #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN) // If G38 command then check Z_MIN for every axis and every direction - - #define UPDATE_ENDSTOP(AXIS,MINMAX) do { \ - _UPDATE_ENDSTOP(AXIS,MINMAX,NOOP); \ - if (G38_move) _UPDATE_ENDSTOP(Z, MIN, G38_endstop_hit = true); \ - } while(0) - - #else - - #define UPDATE_ENDSTOP(AXIS,MINMAX) _UPDATE_ENDSTOP(AXIS,MINMAX,NOOP) - + #if ENABLED(G38_PROBE_TARGET) && PIN_EXISTS(Z_MIN_PROBE) && !(CORE_IS_XY || CORE_IS_XZ) + // If G38 command then check Z_MIN_PROBE for every axis and every direction + if (G38_move) { + UPDATE_ENDSTOP_BIT(Z, MIN_PROBE); + if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) { + if (stepper.current_block->steps[_AXIS(X)] > 0) {_ENDSTOP_HIT(X); stepper.endstop_triggered(_AXIS(X));} + else if (stepper.current_block->steps[_AXIS(Y)] > 0) {_ENDSTOP_HIT(Y); stepper.endstop_triggered(_AXIS(Y));} + else if (stepper.current_block->steps[_AXIS(Z)] > 0) {_ENDSTOP_HIT(Z); stepper.endstop_triggered(_AXIS(Z));} + G38_endstop_hit = true; + } + } #endif #if CORE_IS_XY || CORE_IS_XZ diff --git a/Marlin/example_configurations/Cartesio/Configuration_adv.h b/Marlin/example_configurations/Cartesio/Configuration_adv.h index c3e90d78fb..0972168d86 100644 --- a/Marlin/example_configurations/Cartesio/Configuration_adv.h +++ b/Marlin/example_configurations/Cartesio/Configuration_adv.h @@ -639,6 +639,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/Felix/Configuration_adv.h b/Marlin/example_configurations/Felix/Configuration_adv.h index 749573c8a4..06f8e74833 100644 --- a/Marlin/example_configurations/Felix/Configuration_adv.h +++ b/Marlin/example_configurations/Felix/Configuration_adv.h @@ -639,6 +639,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/Hephestos/Configuration_adv.h b/Marlin/example_configurations/Hephestos/Configuration_adv.h index 7d8d8a469c..ac7a7f7c73 100644 --- a/Marlin/example_configurations/Hephestos/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos/Configuration_adv.h @@ -639,6 +639,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h index 1b86b47736..0bd821de42 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration_adv.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration_adv.h @@ -622,6 +622,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/K8200/Configuration_adv.h b/Marlin/example_configurations/K8200/Configuration_adv.h index a8bf205645..2bcf1b8f5e 100644 --- a/Marlin/example_configurations/K8200/Configuration_adv.h +++ b/Marlin/example_configurations/K8200/Configuration_adv.h @@ -652,6 +652,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/K8400/Configuration_adv.h b/Marlin/example_configurations/K8400/Configuration_adv.h index feeb1dee97..9f1dd356aa 100644 --- a/Marlin/example_configurations/K8400/Configuration_adv.h +++ b/Marlin/example_configurations/K8400/Configuration_adv.h @@ -639,6 +639,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/RigidBot/Configuration_adv.h b/Marlin/example_configurations/RigidBot/Configuration_adv.h index f13eb5e608..12783507cb 100644 --- a/Marlin/example_configurations/RigidBot/Configuration_adv.h +++ b/Marlin/example_configurations/RigidBot/Configuration_adv.h @@ -639,6 +639,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/SCARA/Configuration_adv.h b/Marlin/example_configurations/SCARA/Configuration_adv.h index 21eed190cf..200407ccae 100644 --- a/Marlin/example_configurations/SCARA/Configuration_adv.h +++ b/Marlin/example_configurations/SCARA/Configuration_adv.h @@ -639,6 +639,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/TAZ4/Configuration_adv.h b/Marlin/example_configurations/TAZ4/Configuration_adv.h index f257b7f0a7..9ee5bf3e4f 100644 --- a/Marlin/example_configurations/TAZ4/Configuration_adv.h +++ b/Marlin/example_configurations/TAZ4/Configuration_adv.h @@ -647,6 +647,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/WITBOX/Configuration_adv.h b/Marlin/example_configurations/WITBOX/Configuration_adv.h index 7d8d8a469c..ac7a7f7c73 100644 --- a/Marlin/example_configurations/WITBOX/Configuration_adv.h +++ b/Marlin/example_configurations/WITBOX/Configuration_adv.h @@ -639,6 +639,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/delta/generic/Configuration_adv.h b/Marlin/example_configurations/delta/generic/Configuration_adv.h index ad8d1ec8db..3d97e4d8f2 100644 --- a/Marlin/example_configurations/delta/generic/Configuration_adv.h +++ b/Marlin/example_configurations/delta/generic/Configuration_adv.h @@ -641,6 +641,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h index ad8d1ec8db..3d97e4d8f2 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h @@ -641,6 +641,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h index 4ea6e9637a..86887a5f13 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h @@ -646,6 +646,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h index 7651a35e27..5c078bc700 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h @@ -641,6 +641,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/makibox/Configuration_adv.h b/Marlin/example_configurations/makibox/Configuration_adv.h index a3c7c764ec..f1c6d52118 100644 --- a/Marlin/example_configurations/makibox/Configuration_adv.h +++ b/Marlin/example_configurations/makibox/Configuration_adv.h @@ -639,6 +639,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move) diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h index db2b5f85b8..f00740759a 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h @@ -639,6 +639,7 @@ //#define BEZIER_CURVE_SUPPORT // G38.2 and G38.3 Probe Target +// ENABLE PROBE_DOUBLE_TOUCH if you want G38 to double touch //#define G38_PROBE_TARGET #if ENABLED(G38_PROBE_TARGET) #define G38_MINIMUM_MOVE 0.0275 // minimum distance in mm that will produce a move (determined using the print statement in check_move)