diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 57209236acfd5f1d4dcfa5db7fbfbb02ffe7d85d..a22e6dc9020600514c6ab9a43b1ee6b7acef1c4e 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 18fffc911e4dfb5f68d343e07749e00abb8f5ea9..10a2a9f66133fa1a4692d9154011ce7b106e9368 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 54a512787d3f3086d1e35782b2f3411042af1424..69162f80bf7434e232a6bc76493a7f417cbf7049 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 c3e90d78fb900de3f2f8ac918155f9ef88b8c4b5..0972168d86bacad21a407de720c2a7a269a0d4cb 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 749573c8a48135c0f391f344bc88cb851fdae311..06f8e748331dd32b6feddc61867d886d6a7eebc7 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 7d8d8a469cb5dda2b142f10572eb8a453c9d0e4e..ac7a7f7c73dc0436656f1c2ebab44eb2c97df1c3 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 1b86b47736d31a64689f0fe858f2cf0bb53709f5..0bd821de4291cdbc3f1257608177cc30628f24ac 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 a8bf2056456a06856ab89b9da2207c6e871c7548..2bcf1b8f5eea2aa3732eacb9ccc9b7ed7179666b 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 feeb1dee97fd67e3271566c2cebf279450253846..9f1dd356aa0081339b637701d9b691536ac13951 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 f13eb5e6085090fca160e796c44d9bf8bd503a12..12783507cb2fb4073bab6a04d55b5a06074a4d02 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 21eed190cfb10b988545948d69055416948d3d7e..200407ccae4adf93ddd716c449c255db75988a10 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 f257b7f0a724f6053b8d0e9cf91ec8628341e7ae..9ee5bf3e4f6308ff4cdb36284560e22f5090b148 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 7d8d8a469cb5dda2b142f10572eb8a453c9d0e4e..ac7a7f7c73dc0436656f1c2ebab44eb2c97df1c3 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 ad8d1ec8dbb135e1e76ad253625728b0bcc2110a..3d97e4d8f2f646303418e19fea0816f7fe8b140a 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 ad8d1ec8dbb135e1e76ad253625728b0bcc2110a..3d97e4d8f2f646303418e19fea0816f7fe8b140a 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 4ea6e9637addeec0577e5443c0bc3ea046ceaf50..86887a5f138f7aee3f75b47ab2bf4df956778395 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 7651a35e27c050e2f546b054dc166c2aef4b193e..5c078bc70042a39971438afe5dc49571415d672f 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 a3c7c764ecd9c66c2f87adefdbc21da7e506e5b1..f1c6d52118a15bf4548d10d87da98d648be7625e 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 db2b5f85b82dedc361f93c39129a6284aa717fd2..f00740759a0ed26e1f8556b0140c665df764de5d 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)