From 7d063c111c1d84e08f04def5b7297549d8e1ca58 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Mon, 4 Jul 2016 09:40:59 +0200 Subject: [PATCH 1/4] Add a optional feedrate parameter to `do_blocking_move()` Add a optional feedrate parameter to `do_blocking_move()` and its companions. --- Marlin/Marlin_main.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index c31002bcaa..38d3c36a89 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1651,7 +1651,7 @@ static void clean_up_after_endstop_or_probe_move() { * Plan a move to (X, Y, Z) and set the current_position * The final current_position may not be the one that was requested */ - static void do_blocking_move_to(float x, float y, float z) { + static void do_blocking_move_to(float x, float y, float z, float feed_rate = 0.0) { float old_feedrate = feedrate; #if ENABLED(DEBUG_LEVELING_FEATURE) @@ -1660,7 +1660,7 @@ static void clean_up_after_endstop_or_probe_move() { #if ENABLED(DELTA) - feedrate = XY_PROBE_FEEDRATE; + feedrate = (feed_rate != 0.0) ? feed_rate : XY_PROBE_FEEDRATE; destination[X_AXIS] = x; destination[Y_AXIS] = y; @@ -1675,19 +1675,19 @@ static void clean_up_after_endstop_or_probe_move() { // If Z needs to raise, do it before moving XY if (current_position[Z_AXIS] < z) { - feedrate = homing_feedrate[Z_AXIS]; + feedrate = (feed_rate != 0.0) ? feed_rate : homing_feedrate[Z_AXIS]; current_position[Z_AXIS] = z; line_to_current_position(); } - feedrate = XY_PROBE_FEEDRATE; + feedrate = (feed_rate != 0.0) ? feed_rate : XY_PROBE_FEEDRATE; current_position[X_AXIS] = x; current_position[Y_AXIS] = y; line_to_current_position(); // If Z needs to lower, do it after moving XY if (current_position[Z_AXIS] > z) { - feedrate = homing_feedrate[Z_AXIS]; + feedrate = (feed_rate != 0.0) ? feed_rate : homing_feedrate[Z_AXIS]; current_position[Z_AXIS] = z; line_to_current_position(); } @@ -1699,12 +1699,12 @@ static void clean_up_after_endstop_or_probe_move() { feedrate = old_feedrate; } - inline void do_blocking_move_to_x(float x) { - do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS]); + inline void do_blocking_move_to_x(float x, float feed_rate = 0.0) { + do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS], feed_rate); } - inline void do_blocking_move_to_z(float z) { - do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z); + inline void do_blocking_move_to_z(float z, float feed_rate = 0.0) { + do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z, feed_rate); } /** @@ -2081,8 +2081,8 @@ static void clean_up_after_endstop_or_probe_move() { return current_position[Z_AXIS]; } - inline void do_blocking_move_to_xy(float x, float y) { - do_blocking_move_to(x, y, current_position[Z_AXIS]); + inline void do_blocking_move_to_xy(float x, float y, float feed_rate = 0.0) { + do_blocking_move_to(x, y, current_position[Z_AXIS], feed_rate); } // From 5126cce7fdd1eff9cab8968167879bf457c6a900 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Mon, 4 Jul 2016 09:46:22 +0200 Subject: [PATCH 2/4] Move Allen Key probe move scripts to their own functions There was an hidden extra move after the scripts. This is configurable now. Added the extra moves to the relevant configs. --- Marlin/Marlin_main.cpp | 245 +++++++++++------- .../delta/biv2.5/Configuration.h | 10 + .../delta/generic/Configuration.h | 10 + .../delta/kossel_mini/Configuration.h | 10 + .../delta/kossel_pro/Configuration.h | 10 + .../delta/kossel_xl/Configuration.h | 10 + 6 files changed, 208 insertions(+), 87 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 38d3c36a89..2aebe2fada 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1796,6 +1796,162 @@ static void clean_up_after_endstop_or_probe_move() { } #endif // Z_PROBE_SLED +#if ENABLED(Z_PROBE_ALLEN_KEY) + void run_deploy_moves_script() { + #if defined(Z_PROBE_ALLEN_KEY_DEPLOY_1_X) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_1_Y) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_1_Z) + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_X + #define Z_PROBE_ALLEN_KEY_DEPLOY_1_X current_position[X_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_Y + #define Z_PROBE_ALLEN_KEY_DEPLOY_1_Y current_position[Y_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_Z + #define Z_PROBE_ALLEN_KEY_DEPLOY_1_Z current_position[Z_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE + #define Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE 0.0 + #endif + do_blocking_move_to(Z_PROBE_ALLEN_KEY_DEPLOY_1_X, Z_PROBE_ALLEN_KEY_DEPLOY_1_Y, Z_PROBE_ALLEN_KEY_DEPLOY_1_Z, Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE); + #endif + #if defined(Z_PROBE_ALLEN_KEY_DEPLOY_2_X) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_2_Y) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_2_Z) + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_2_X + #define Z_PROBE_ALLEN_KEY_DEPLOY_2_X current_position[X_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_2_Y + #define Z_PROBE_ALLEN_KEY_DEPLOY_2_Y current_position[Y_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_2_Z + #define Z_PROBE_ALLEN_KEY_DEPLOY_2_Z current_position[Z_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE + #define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE 0.0 + #endif + do_blocking_move_to(Z_PROBE_ALLEN_KEY_DEPLOY_2_X, Z_PROBE_ALLEN_KEY_DEPLOY_2_Y, Z_PROBE_ALLEN_KEY_DEPLOY_2_Z, Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE); + #endif + #if defined(Z_PROBE_ALLEN_KEY_DEPLOY_3_X) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_3_Y) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_3_Z) + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_3_X + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_X current_position[X_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_3_Y + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Y current_position[Y_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_3_Z + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Z current_position[Z_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE 0.0 + #endif + do_blocking_move_to(Z_PROBE_ALLEN_KEY_DEPLOY_3_X, Z_PROBE_ALLEN_KEY_DEPLOY_3_Y, Z_PROBE_ALLEN_KEY_DEPLOY_3_Z, Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE); + #endif + #if defined(Z_PROBE_ALLEN_KEY_DEPLOY_4_X) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_4_Y) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_4_Z) + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_4_X + #define Z_PROBE_ALLEN_KEY_DEPLOY_4_X current_position[X_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_4_Y + #define Z_PROBE_ALLEN_KEY_DEPLOY_4_Y current_position[Y_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_4_Z + #define Z_PROBE_ALLEN_KEY_DEPLOY_4_Z current_position[Z_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_4_FEEDRATE + #define Z_PROBE_ALLEN_KEY_DEPLOY_4_FEEDRATE 0.0 + #endif + do_blocking_move_to(Z_PROBE_ALLEN_KEY_DEPLOY_4_X, Z_PROBE_ALLEN_KEY_DEPLOY_4_Y, Z_PROBE_ALLEN_KEY_DEPLOY_4_Z, Z_PROBE_ALLEN_KEY_DEPLOY_4_FEEDRATE); + #endif + #if defined(Z_PROBE_ALLEN_KEY_DEPLOY_5_X) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_5_Y) || defined(Z_PROBE_ALLEN_KEY_DEPLOY_5_Z) + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_5_X + #define Z_PROBE_ALLEN_KEY_DEPLOY_5_X current_position[X_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_5_Y + #define Z_PROBE_ALLEN_KEY_DEPLOY_5_Y current_position[Y_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_5_Z + #define Z_PROBE_ALLEN_KEY_DEPLOY_5_Z current_position[Z_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_DEPLOY_5_FEEDRATE + #define Z_PROBE_ALLEN_KEY_DEPLOY_5_FEEDRATE 0.0 + #endif + do_blocking_move_to(Z_PROBE_ALLEN_KEY_DEPLOY_5_X, Z_PROBE_ALLEN_KEY_DEPLOY_5_Y, Z_PROBE_ALLEN_KEY_DEPLOY_5_Z, Z_PROBE_ALLEN_KEY_DEPLOY_5_FEEDRATE); + #endif + } + void run_stow_moves_script() { + #if defined(Z_PROBE_ALLEN_KEY_STOW_1_X) || defined(Z_PROBE_ALLEN_KEY_STOW_1_Y) || defined(Z_PROBE_ALLEN_KEY_STOW_1_Z) + #ifndef Z_PROBE_ALLEN_KEY_STOW_1_X + #define Z_PROBE_ALLEN_KEY_STOW_1_X current_position[X_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_1_Y + #define Z_PROBE_ALLEN_KEY_STOW_1_Y current_position[Y_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_1_Z + #define Z_PROBE_ALLEN_KEY_STOW_1_Z current_position[Z_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE + #define Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE 0.0 + #endif + do_blocking_move_to(Z_PROBE_ALLEN_KEY_STOW_1_X, Z_PROBE_ALLEN_KEY_STOW_1_Y, Z_PROBE_ALLEN_KEY_STOW_1_Z, Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE); + #endif + #if defined(Z_PROBE_ALLEN_KEY_STOW_2_X) || defined(Z_PROBE_ALLEN_KEY_STOW_2_Y) || defined(Z_PROBE_ALLEN_KEY_STOW_2_Z) + #ifndef Z_PROBE_ALLEN_KEY_STOW_2_X + #define Z_PROBE_ALLEN_KEY_STOW_2_X current_position[X_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_2_Y + #define Z_PROBE_ALLEN_KEY_STOW_2_Y current_position[Y_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_2_Z + #define Z_PROBE_ALLEN_KEY_STOW_2_Z current_position[Z_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE + #define Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE 0.0 + #endif + do_blocking_move_to(Z_PROBE_ALLEN_KEY_STOW_2_X, Z_PROBE_ALLEN_KEY_STOW_2_Y, Z_PROBE_ALLEN_KEY_STOW_2_Z, Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE); + #endif + #if defined(Z_PROBE_ALLEN_KEY_STOW_3_X) || defined(Z_PROBE_ALLEN_KEY_STOW_3_Y) || defined(Z_PROBE_ALLEN_KEY_STOW_3_Z) + #ifndef Z_PROBE_ALLEN_KEY_STOW_3_X + #define Z_PROBE_ALLEN_KEY_STOW_3_X current_position[X_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_3_Y + #define Z_PROBE_ALLEN_KEY_STOW_3_Y current_position[Y_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_3_Z + #define Z_PROBE_ALLEN_KEY_STOW_3_Z current_position[Z_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE + #define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE 0.0 + #endif + do_blocking_move_to(Z_PROBE_ALLEN_KEY_STOW_3_X, Z_PROBE_ALLEN_KEY_STOW_3_Y, Z_PROBE_ALLEN_KEY_STOW_3_Z, Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE); + #endif + #if defined(Z_PROBE_ALLEN_KEY_STOW_4_X) || defined(Z_PROBE_ALLEN_KEY_STOW_4_Y) || defined(Z_PROBE_ALLEN_KEY_STOW_4_Z) + #ifndef Z_PROBE_ALLEN_KEY_STOW_4_X + #define Z_PROBE_ALLEN_KEY_STOW_4_X current_position[X_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_4_Y + #define Z_PROBE_ALLEN_KEY_STOW_4_Y current_position[Y_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_4_Z + #define Z_PROBE_ALLEN_KEY_STOW_4_Z current_position[Z_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE + #define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE 0.0 + #endif + do_blocking_move_to(Z_PROBE_ALLEN_KEY_STOW_4_X, Z_PROBE_ALLEN_KEY_STOW_4_Y, Z_PROBE_ALLEN_KEY_STOW_4_Z, Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE); + #endif + #if defined(Z_PROBE_ALLEN_KEY_STOW_5_X) || defined(Z_PROBE_ALLEN_KEY_STOW_5_Y) || defined(Z_PROBE_ALLEN_KEY_STOW_5_Z) + #ifndef Z_PROBE_ALLEN_KEY_STOW_5_X + #define Z_PROBE_ALLEN_KEY_STOW_5_X current_position[X_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_5_Y + #define Z_PROBE_ALLEN_KEY_STOW_5_Y current_position[Y_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_5_Z + #define Z_PROBE_ALLEN_KEY_STOW_5_Z current_position[Z_AXIS] + #endif + #ifndef Z_PROBE_ALLEN_KEY_STOW_5_FEEDRATE + #define Z_PROBE_ALLEN_KEY_STOW_5_FEEDRATE 0.0 + #endif + do_blocking_move_to(Z_PROBE_ALLEN_KEY_STOW_5_X, Z_PROBE_ALLEN_KEY_STOW_5_Y, Z_PROBE_ALLEN_KEY_STOW_5_Z, Z_PROBE_ALLEN_KEY_STOW_5_FEEDRATE); + #endif + } +#endif #if HAS_BED_PROBE @@ -1833,50 +1989,9 @@ static void clean_up_after_endstop_or_probe_move() { if (z_min_endstop) #endif { - // Move to the start position to initiate deployment - destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_1_X; - destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_1_Y; - destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_1_Z; - prepare_move_to_destination(); // this will also set_current_to_destination - - // Move to engage deployment - if (Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE) - feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE; - if (Z_PROBE_ALLEN_KEY_DEPLOY_2_X != Z_PROBE_ALLEN_KEY_DEPLOY_1_X) - destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_2_X; - if (Z_PROBE_ALLEN_KEY_DEPLOY_2_Y != Z_PROBE_ALLEN_KEY_DEPLOY_1_Y) - destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_2_Y; - if (Z_PROBE_ALLEN_KEY_DEPLOY_2_Z != Z_PROBE_ALLEN_KEY_DEPLOY_1_Z) - destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_2_Z; - prepare_move_to_destination(); - - #ifdef Z_PROBE_ALLEN_KEY_DEPLOY_3_X - if (Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE) - feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE; - - // Move to trigger deployment - if (Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE != Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE) - feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE; - if (Z_PROBE_ALLEN_KEY_DEPLOY_3_X != Z_PROBE_ALLEN_KEY_DEPLOY_2_X) - destination[X_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_X; - if (Z_PROBE_ALLEN_KEY_DEPLOY_3_Y != Z_PROBE_ALLEN_KEY_DEPLOY_2_Y) - destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_Y; - if (Z_PROBE_ALLEN_KEY_DEPLOY_3_Z != Z_PROBE_ALLEN_KEY_DEPLOY_2_Z) - destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_DEPLOY_3_Z; - - prepare_move_to_destination(); - #endif + run_deploy_moves_script(); } - // Partially Home X,Y for safety - destination[X_AXIS] *= 0.75; - destination[Y_AXIS] *= 0.75; - prepare_move_to_destination(); // this will also set_current_to_destination - - feedrate = old_feedrate; - - stepper.synchronize(); - #if ENABLED(Z_MIN_PROBE_ENDSTOP) z_probe_endstop = (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING); if (z_probe_endstop) @@ -1923,51 +2038,7 @@ static void clean_up_after_endstop_or_probe_move() { #elif ENABLED(Z_PROBE_ALLEN_KEY) - float old_feedrate = feedrate; - - // Move up for safety - feedrate = Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE; - - #if _Z_RAISE_PROBE_DEPLOY_STOW > 0 - destination[Z_AXIS] = current_position[Z_AXIS] + _Z_RAISE_PROBE_DEPLOY_STOW; - prepare_move_to_destination_raw(); // this will also set_current_to_destination - #endif - - // Move to the start position to initiate retraction - destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_1_X; - destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_1_Y; - destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_1_Z; - prepare_move_to_destination(); - - // Move the nozzle down to push the Z probe into retracted position - if (Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE != Z_PROBE_ALLEN_KEY_STOW_1_FEEDRATE) - feedrate = Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE; - if (Z_PROBE_ALLEN_KEY_STOW_2_X != Z_PROBE_ALLEN_KEY_STOW_1_X) - destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_X; - if (Z_PROBE_ALLEN_KEY_STOW_2_Y != Z_PROBE_ALLEN_KEY_STOW_1_Y) - destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_Y; - destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_2_Z; - prepare_move_to_destination(); - - // Move up for safety - if (Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE != Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE) - feedrate = Z_PROBE_ALLEN_KEY_STOW_2_FEEDRATE; - if (Z_PROBE_ALLEN_KEY_STOW_3_X != Z_PROBE_ALLEN_KEY_STOW_2_X) - destination[X_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_X; - if (Z_PROBE_ALLEN_KEY_STOW_3_Y != Z_PROBE_ALLEN_KEY_STOW_2_Y) - destination[Y_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_Y; - destination[Z_AXIS] = Z_PROBE_ALLEN_KEY_STOW_3_Z; - prepare_move_to_destination(); - - // Home XY for safety - feedrate = homing_feedrate[X_AXIS] / 2; - destination[X_AXIS] = 0; - destination[Y_AXIS] = 0; - prepare_move_to_destination(); // this will also set_current_to_destination - - feedrate = old_feedrate; - - stepper.synchronize(); + run_stow_moves_script(); #if ENABLED(Z_MIN_PROBE_ENDSTOP) bool z_probe_endstop = (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING); diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration.h b/Marlin/example_configurations/delta/biv2.5/Configuration.h index 5dd547a516..3dfd2dd93f 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -518,6 +518,11 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo #define Z_PROBE_ALLEN_KEY_DEPLOY_2_Z 100.0 #define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE XY_PROBE_SPEED + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_X Z_PROBE_ALLEN_KEY_DEPLOY_2_X * 0.75 + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Y Z_PROBE_ALLEN_KEY_DEPLOY_2_Y * 0.75 + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Z Z_PROBE_ALLEN_KEY_DEPLOY_2_Z + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE XY_PROBE_SPEED + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_X 45.00 // Move right to trigger deploy pin #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Y -125.00 #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Z 100.0 @@ -538,6 +543,11 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo #define Z_PROBE_ALLEN_KEY_STOW_3_Z 100.0 #define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE XY_PROBE_SPEED + #define Z_PROBE_ALLEN_KEY_STOW_4_X 0.0 + #define Z_PROBE_ALLEN_KEY_STOW_4_Y 0.0 + #define Z_PROBE_ALLEN_KEY_STOW_4_Z Z_PROBE_ALLEN_KEY_STOW_3_Z + #define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE XY_PROBE_SPEED + #endif // Z_PROBE_ALLEN_KEY // Enable Z_MIN_PROBE_ENDSTOP to use _both_ a Z Probe and a Z-min-endstop on the same machine. diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 509cfca31d..396a406710 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -517,6 +517,11 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo #define Z_PROBE_ALLEN_KEY_DEPLOY_2_Z 100.0 #define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE (XY_PROBE_SPEED)/10 + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_X Z_PROBE_ALLEN_KEY_DEPLOY_2_X * 0.75 + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Y Z_PROBE_ALLEN_KEY_DEPLOY_2_Y * 0.75 + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Z Z_PROBE_ALLEN_KEY_DEPLOY_2_Z + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE XY_PROBE_SPEED + #define Z_PROBE_ALLEN_KEY_STOW_1_X -64.0 // Move the probe into position #define Z_PROBE_ALLEN_KEY_STOW_1_Y 56.0 #define Z_PROBE_ALLEN_KEY_STOW_1_Z 23.0 @@ -532,6 +537,11 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo #define Z_PROBE_ALLEN_KEY_STOW_3_Z 50.0 #define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE XY_PROBE_SPEED + #define Z_PROBE_ALLEN_KEY_STOW_4_X 0.0 + #define Z_PROBE_ALLEN_KEY_STOW_4_Y 0.0 + #define Z_PROBE_ALLEN_KEY_STOW_4_Z Z_PROBE_ALLEN_KEY_STOW_3_Z + #define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE XY_PROBE_SPEED + #endif // Z_PROBE_ALLEN_KEY // Enable Z_MIN_PROBE_ENDSTOP to use _both_ a Z Probe and a Z-min-endstop on the same machine. diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index f2e3b46f95..53f0310b0b 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -518,6 +518,11 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #define Z_PROBE_ALLEN_KEY_DEPLOY_2_Z 100.0 #define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE (XY_PROBE_SPEED/10) + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_X Z_PROBE_ALLEN_KEY_DEPLOY_2_X * 0.75 + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Y Z_PROBE_ALLEN_KEY_DEPLOY_2_Y * 0.75 + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Z Z_PROBE_ALLEN_KEY_DEPLOY_2_Z + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE XY_PROBE_SPEED + #define Z_PROBE_ALLEN_KEY_STOW_DEPTH 20 // Move the probe into position #define Z_PROBE_ALLEN_KEY_STOW_1_X -64.0 @@ -535,6 +540,11 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #define Z_PROBE_ALLEN_KEY_STOW_3_Z (Z_PROBE_ALLEN_KEY_STOW_1_Z+Z_PROBE_ALLEN_KEY_STOW_DEPTH) #define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE (XY_PROBE_SPEED/2) + #define Z_PROBE_ALLEN_KEY_STOW_4_X 0.0 + #define Z_PROBE_ALLEN_KEY_STOW_4_Y 0.0 + #define Z_PROBE_ALLEN_KEY_STOW_4_Z Z_PROBE_ALLEN_KEY_STOW_3_Z + #define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE XY_PROBE_SPEED + #endif // Z_PROBE_ALLEN_KEY // Enable Z_MIN_PROBE_ENDSTOP to use _both_ a Z Probe and a Z-min-endstop on the same machine. diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index 66781c7966..ec37272def 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -509,6 +509,11 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #define Z_PROBE_ALLEN_KEY_DEPLOY_2_Z Z_PROBE_ALLEN_KEY_DEPLOY_1_Z #define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE XY_PROBE_SPEED + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_X Z_PROBE_ALLEN_KEY_DEPLOY_2_X * 0.75 + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Y Z_PROBE_ALLEN_KEY_DEPLOY_2_Y * 0.75 + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Z Z_PROBE_ALLEN_KEY_DEPLOY_2_Z + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE XY_PROBE_SPEED + #define Z_PROBE_ALLEN_KEY_DEPLOY_3_X 45.00 // Move right to trigger deploy pin #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Y -125.00 #define Z_PROBE_ALLEN_KEY_DEPLOY_3_Z Z_PROBE_ALLEN_KEY_DEPLOY_2_Z @@ -529,6 +534,11 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l #define Z_PROBE_ALLEN_KEY_STOW_3_Z 100.0 #define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE XY_PROBE_SPEED + #define Z_PROBE_ALLEN_KEY_STOW_4_X 0.0 + #define Z_PROBE_ALLEN_KEY_STOW_4_Y 0.0 + #define Z_PROBE_ALLEN_KEY_STOW_4_Z Z_PROBE_ALLEN_KEY_STOW_3_Z + #define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE XY_PROBE_SPEED + #endif // Z_PROBE_ALLEN_KEY // Enable Z_MIN_PROBE_ENDSTOP to use _both_ a Z Probe and a Z-min-endstop on the same machine. diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index c62d63d3fa..1d17d17f1f 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -515,6 +515,11 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define Z_PROBE_ALLEN_KEY_DEPLOY_2_Z 100.0 //#define Z_PROBE_ALLEN_KEY_DEPLOY_2_FEEDRATE (XY_PROBE_SPEED)/10 + //#define Z_PROBE_ALLEN_KEY_DEPLOY_3_X Z_PROBE_ALLEN_KEY_DEPLOY_2_X * 0.75 + //#define Z_PROBE_ALLEN_KEY_DEPLOY_3_Y Z_PROBE_ALLEN_KEY_DEPLOY_2_Y * 0.75 + //#define Z_PROBE_ALLEN_KEY_DEPLOY_3_Z Z_PROBE_ALLEN_KEY_DEPLOY_2_Z + //#define Z_PROBE_ALLEN_KEY_DEPLOY_3_FEEDRATE XY_PROBE_SPEED + //#define Z_PROBE_ALLEN_KEY_STOW_1_X -64.0 // Move the probe into position //#define Z_PROBE_ALLEN_KEY_STOW_1_Y 56.0 //#define Z_PROBE_ALLEN_KEY_STOW_1_Z 23.0 @@ -530,6 +535,11 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l //#define Z_PROBE_ALLEN_KEY_STOW_3_Z 50.0 //#define Z_PROBE_ALLEN_KEY_STOW_3_FEEDRATE XY_PROBE_SPEED + //#define Z_PROBE_ALLEN_KEY_STOW_4_X 0.0 + //#define Z_PROBE_ALLEN_KEY_STOW_4_Y 0.0 + //#define Z_PROBE_ALLEN_KEY_STOW_4_Z Z_PROBE_ALLEN_KEY_STOW_3_Z + //#define Z_PROBE_ALLEN_KEY_STOW_4_FEEDRATE XY_PROBE_SPEED + #endif // Z_PROBE_ALLEN_KEY // Enable Z_MIN_PROBE_ENDSTOP to use _both_ a Z Probe and a Z-min-endstop on the same machine. From 8555816a11a27730c9785606c97b8412777eeba1 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Wed, 6 Jul 2016 03:56:17 +0200 Subject: [PATCH 3/4] Generalize and simplify 'triggered when stowed test` The `PROBE_IS_TRIGGERED_WHEN_STOWED_TEST` is able to detect if a probe is successfully deployed/stowed. It was part of the Allen Key probes code only. Now the function is generally available. Currently this test is compulsory for Allen Key probes to not alter the used behaviour If you want to add the test for an other type of probe simply add ``` #define PROBE_IS_TRIGGERED_WHEN_STOWED_TEST ``` to your config. --- Marlin/Conditionals.h | 4 ++ Marlin/Marlin_main.cpp | 99 ++++++++++++++++++++++-------------------- 2 files changed, 56 insertions(+), 47 deletions(-) diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h index e3c72d76f2..734b644bee 100644 --- a/Marlin/Conditionals.h +++ b/Marlin/Conditionals.h @@ -753,6 +753,10 @@ #define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED) + #if ENABLED(Z_PROBE_ALLEN_KEY) + #define PROBE_IS_TRIGGERED_WHEN_STOWED_TEST + #endif + /** * Bed Probe dependencies */ diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 2aebe2fada..7fb99d6dad 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1955,6 +1955,15 @@ static void clean_up_after_endstop_or_probe_move() { #if HAS_BED_PROBE + // TRIGGERED_WHEN_STOWED_TEST can easily be extended to servo probes, ... if needed. + #if ENABLED(PROBE_IS_TRIGGERED_WHEN_STOWED_TEST) + #if ENABLED(Z_MIN_PROBE_ENDSTOP) + #define _TRIGGERED_WHEN_STOWED_TEST (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) + #else + #define _TRIGGERED_WHEN_STOWED_TEST (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) + #endif + #endif + static void deploy_z_probe() { #if ENABLED(DEBUG_LEVELING_FEATURE) @@ -1966,6 +1975,14 @@ static void clean_up_after_endstop_or_probe_move() { // Make room for probe do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW); + #ifdef _TRIGGERED_WHEN_STOWED_TEST + // If endstop is already false, the Z probe is deployed + if (_TRIGGERED_WHEN_STOWED_TEST) { // closed after the probe specific actions. + // Would a goto be less ugly? + //while (!_TRIGGERED_WHEN_STOWED_TEST) { idle(); // would offer the opportunity + // for a triggered when stowed manual probe. + #endif + #if ENABLED(Z_PROBE_SLED) dock_sled(false); @@ -1976,37 +1993,8 @@ static void clean_up_after_endstop_or_probe_move() { DEPLOY_Z_SERVO(); #elif ENABLED(Z_PROBE_ALLEN_KEY) - float old_feedrate = feedrate; - feedrate = Z_PROBE_ALLEN_KEY_DEPLOY_1_FEEDRATE; - - // If endstop is already false, the Z probe is deployed - #if ENABLED(Z_MIN_PROBE_ENDSTOP) - bool z_probe_endstop = (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING); - if (z_probe_endstop) - #else - bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING); - if (z_min_endstop) - #endif - { - run_deploy_moves_script(); - } - - #if ENABLED(Z_MIN_PROBE_ENDSTOP) - z_probe_endstop = (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING); - if (z_probe_endstop) - #else - z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING); - if (z_min_endstop) - #endif - { - if (IsRunning()) { - SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Z-Probe failed to engage!"); - LCD_ALERTMESSAGEPGM("Err: ZPROBE"); - } - stop(); - } + run_deploy_moves_script(); #else @@ -2014,6 +2002,19 @@ static void clean_up_after_endstop_or_probe_move() { #endif + #ifdef _TRIGGERED_WHEN_STOWED_TEST + }; // opened before the probe specific actions + + if (_TRIGGERED_WHEN_STOWED_TEST) { + if (IsRunning()) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM("Z-Probe failed"); + LCD_ALERTMESSAGEPGM("Err: ZPROBE"); + } + stop(); + } + #endif + endstops.enable_z_probe(); } @@ -2027,7 +2028,14 @@ static void clean_up_after_endstop_or_probe_move() { // Make more room for the servo do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW); - #if ENABLED(Z_PROBE_SLED) + #ifdef _TRIGGERED_WHEN_STOWED_TEST + // If endstop is already false, the Z probe is deployed + if (!_TRIGGERED_WHEN_STOWED_TEST) { // closed after the probe specific actions. + // Would a goto be less ugly? + //while (!_TRIGGERED_WHEN_STOWED_TEST) { idle(); // would offer the opportunity + // for a triggered when stowed manual probe. + + #if ENABLED(Z_PROBE_SLED) dock_sled(true); @@ -2040,28 +2048,25 @@ static void clean_up_after_endstop_or_probe_move() { run_stow_moves_script(); - #if ENABLED(Z_MIN_PROBE_ENDSTOP) - bool z_probe_endstop = (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING); - if (!z_probe_endstop) - #else - bool z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING); - if (!z_min_endstop) - #endif - { - if (IsRunning()) { - SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Z-Probe failed to retract!"); - LCD_ALERTMESSAGEPGM("Err: ZPROBE"); - } - stop(); - } - #else // Nothing to do here. Just clear endstops.z_probe_enabled #endif + #ifdef _TRIGGERED_WHEN_STOWED_TEST + }; // opened before the probe specific actions + if (!_TRIGGERED_WHEN_STOWED_TEST) { + if (IsRunning()) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM("Z-Probe failed!"); + LCD_ALERTMESSAGEPGM("Err: ZPROBE"); + } + stop(); + return true; + } + #endif + endstops.enable_z_probe(false); } From 16c83d203b9d5b0c797e2a0ee147ae3ecc3569a5 Mon Sep 17 00:00:00 2001 From: AnHardt Date: Wed, 6 Jul 2016 03:40:21 +0200 Subject: [PATCH 4/4] Make use of the good features of a sled probe for all probes. Move and extend axis_unhomed test to deploy/stow_z_probe(). Move and extend position store/restore to deploy/stow_z_probe(). Now all kinds of probes can use the 'E' parameter in G29/M48. Allen key probes can be used now for grid and 3-point levelling. Deploying the Allen Key probe uses big moves in z direction. Too dangerous for an unhomed z-axis. Throw a compile time error when we try to configure an Allen Key probe homing to z-min and having no other z-min-endstop. --- Marlin/Marlin_main.cpp | 146 +++++++++++++---------------------------- Marlin/SanityCheck.h | 11 ++-- 2 files changed, 49 insertions(+), 108 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 7fb99d6dad..b9a88b512a 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1735,7 +1735,7 @@ static void clean_up_after_endstop_or_probe_move() { #endif //HAS_BED_PROBE -#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || HAS_PROBING_PROCEDURE +#if ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || HAS_PROBING_PROCEDURE static bool axis_unhomed_error(const bool x, const bool y, const bool z) { const bool xx = x && !axis_homed[X_AXIS], yy = y && !axis_homed[Y_AXIS], @@ -1783,16 +1783,10 @@ static void clean_up_after_endstop_or_probe_move() { } #endif - if (axis_unhomed_error(true, false, false)) return; - - float oldXpos = current_position[X_AXIS]; // save x position - // Dock sled a bit closer to ensure proper capturing do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET - ((stow) ? 1 : 0)); digitalWrite(SLED_PIN, !stow); // switch solenoid - do_blocking_move_to_x(oldXpos); // return to position before docking - } #endif // Z_PROBE_SLED @@ -1964,110 +1958,69 @@ static void clean_up_after_endstop_or_probe_move() { #endif #endif - static void deploy_z_probe() { + #define DEPLOY_PROBE() set_probe_deployed( true ) + #define STOW_PROBE() set_probe_deployed( false ) + + // returns false for ok and true for failure + static bool set_probe_deployed(bool deploy) { #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) DEBUG_POS("deploy_z_probe", current_position); + if (DEBUGGING(LEVELING)) { + DEBUG_POS("set_probe_deployed", current_position); + SERIAL_ECHOPAIR("deploy: ", deploy); + } #endif - if (endstops.z_probe_enabled) return; + if (endstops.z_probe_enabled == deploy) return false; // Make room for probe do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW); + #if ENABLED(Z_PROBE_SLED) + if (axis_unhomed_error(true, false, false)) { stop(); return true; } + #elif ENABLED(Z_PROBE_ALLEN_KEY) + if (axis_unhomed_error(true, true, true )) { stop(); return true; } + #endif + + float oldXpos = current_position[X_AXIS]; // save x position + float oldYpos = current_position[Y_AXIS]; // save y position + #ifdef _TRIGGERED_WHEN_STOWED_TEST // If endstop is already false, the Z probe is deployed - if (_TRIGGERED_WHEN_STOWED_TEST) { // closed after the probe specific actions. - // Would a goto be less ugly? + if (_TRIGGERED_WHEN_STOWED_TEST == deploy) { // closed after the probe specific actions. + // Would a goto be less ugly? //while (!_TRIGGERED_WHEN_STOWED_TEST) { idle(); // would offer the opportunity // for a triggered when stowed manual probe. #endif #if ENABLED(Z_PROBE_SLED) - - dock_sled(false); - + dock_sled(!deploy); #elif HAS_Z_SERVO_ENDSTOP - - // Engage Z Servo endstop if enabled - DEPLOY_Z_SERVO(); - + servo[Z_ENDSTOP_SERVO_NR].move(z_servo_angle[((deploy) ? 0 : 1)]); #elif ENABLED(Z_PROBE_ALLEN_KEY) - - run_deploy_moves_script(); - - #else - + if (!deploy) run_stow_moves_script(); + else run_deploy_moves_script(); + #else // Nothing to be done. Just enable_z_probe below... - #endif #ifdef _TRIGGERED_WHEN_STOWED_TEST }; // opened before the probe specific actions - if (_TRIGGERED_WHEN_STOWED_TEST) { + if (_TRIGGERED_WHEN_STOWED_TEST == deploy) { if (IsRunning()) { SERIAL_ERROR_START; SERIAL_ERRORLNPGM("Z-Probe failed"); LCD_ALERTMESSAGEPGM("Err: ZPROBE"); } stop(); - } - #endif - - endstops.enable_z_probe(); - } - - static void stow_z_probe() { - #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) DEBUG_POS("stow_z_probe", current_position); - #endif - - if (!endstops.z_probe_enabled) return; - - // Make more room for the servo - do_probe_raise(_Z_RAISE_PROBE_DEPLOY_STOW); - - #ifdef _TRIGGERED_WHEN_STOWED_TEST - // If endstop is already false, the Z probe is deployed - if (!_TRIGGERED_WHEN_STOWED_TEST) { // closed after the probe specific actions. - // Would a goto be less ugly? - //while (!_TRIGGERED_WHEN_STOWED_TEST) { idle(); // would offer the opportunity - // for a triggered when stowed manual probe. - - #if ENABLED(Z_PROBE_SLED) - - dock_sled(true); - - #elif HAS_Z_SERVO_ENDSTOP - - // Change the Z servo angle - STOW_Z_SERVO(); - - #elif ENABLED(Z_PROBE_ALLEN_KEY) - - run_stow_moves_script(); - - #else - - // Nothing to do here. Just clear endstops.z_probe_enabled - - #endif - - #ifdef _TRIGGERED_WHEN_STOWED_TEST - }; // opened before the probe specific actions - if (!_TRIGGERED_WHEN_STOWED_TEST) { - if (IsRunning()) { - SERIAL_ERROR_START; - SERIAL_ERRORLNPGM("Z-Probe failed!"); - LCD_ALERTMESSAGEPGM("Err: ZPROBE"); - } - stop(); return true; } #endif - endstops.enable_z_probe(false); + do_blocking_move_to(oldXpos, oldYpos, current_position[Z_AXIS]); // return to position before deploy + endstops.enable_z_probe( deploy ); + return false; } // Do a single Z probe and return with current_position[Z_AXIS] @@ -2200,7 +2153,7 @@ static void clean_up_after_endstop_or_probe_move() { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> "); #endif - deploy_z_probe(); + if (DEPLOY_PROBE()) return NAN; float measured_z = run_z_probe(); @@ -2208,7 +2161,7 @@ static void clean_up_after_endstop_or_probe_move() { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> "); #endif - stow_z_probe(); + if (STOW_PROBE()) return NAN; } else { #if ENABLED(DEBUG_LEVELING_FEATURE) @@ -2416,7 +2369,7 @@ static void homeaxis(AxisEnum axis) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> "); #endif - deploy_z_probe(); + if (DEPLOY_PROBE()) return; } #endif @@ -2543,7 +2496,7 @@ static void homeaxis(AxisEnum axis) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) SERIAL_ECHOPGM("> "); #endif - stow_z_probe(); + if (STOW_PROBE()) return; } #endif @@ -3457,12 +3410,7 @@ inline void gcode_G28() { } bool dryrun = code_seen('D'); - - #if ENABLED(Z_PROBE_ALLEN_KEY) - const bool stow_probe_after_each = false; - #else - bool stow_probe_after_each = code_seen('E'); - #endif + bool stow_probe_after_each = code_seen('E'); #if ENABLED(AUTO_BED_LEVELING_GRID) @@ -3561,8 +3509,8 @@ inline void gcode_G28() { setup_for_endstop_or_probe_move(); - // Deploy the probe. Servo will raise if needed. - deploy_z_probe(); + // Deploy the probe. Probe will raise if needed. + if (DEPLOY_PROBE()) return; bed_leveling_in_progress = true; @@ -3667,7 +3615,7 @@ inline void gcode_G28() { #endif // !AUTO_BED_LEVELING_GRID // Raise to _Z_RAISE_PROBE_DEPLOY_STOW. Stow the probe. - stow_z_probe(); + if (STOW_PROBE()) return; // Restore state after probing clean_up_after_endstop_or_probe_move(); @@ -3874,12 +3822,12 @@ inline void gcode_G28() { /** * G31: Deploy the Z probe */ - inline void gcode_G31() { deploy_z_probe(); } + inline void gcode_G31() { DEPLOY_PROBE(); } /** * G32: Stow the Z probe */ - inline void gcode_G32() { stow_z_probe(); } + inline void gcode_G32() { STOW_PROBE(); } #endif // Z_PROBE_SLED @@ -4220,11 +4168,7 @@ inline void gcode_M42() { float X_current = current_position[X_AXIS], Y_current = current_position[Y_AXIS]; - #if ENABLED(Z_PROBE_ALLEN_KEY) - const bool stow_probe_after_each = false; - #else - bool stow_probe_after_each = code_seen('E'); - #endif + bool stow_probe_after_each = code_seen('E'); float X_probe_location = code_seen('X') ? code_value_axis_units(X_AXIS) : X_current + X_PROBE_OFFSET_FROM_EXTRUDER; #if DISABLED(DELTA) @@ -4391,7 +4335,7 @@ inline void gcode_M42() { } // End of probe loop - stow_z_probe(); + if (STOW_PROBE()) return; if (verbose_level > 0) { SERIAL_PROTOCOLPGM("Mean: "); @@ -5967,12 +5911,12 @@ inline void gcode_M400() { stepper.synchronize(); } /** * M401: Engage Z Servo endstop if available */ - inline void gcode_M401() { deploy_z_probe(); } + inline void gcode_M401() { DEPLOY_PROBE(); } /** * M402: Retract Z Servo endstop if enabled */ - inline void gcode_M402() { stow_z_probe(); } + inline void gcode_M402() { STOW_PROBE(); } #endif // HAS_BED_PROBE diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 941821be2f..b63877531e 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -425,14 +425,11 @@ #endif /** - * Allen Key Z probe requires Delta and Auto Bed Leveling grid + * Allen Key + * Deploying the Allen Key probe uses big moves in z direction. Too dangerous for an unhomed z-axis. */ -#if ENABLED(Z_PROBE_ALLEN_KEY) - #if !ENABLED(DELTA) - #error "Z_PROBE_ALLEN_KEY is only usable with DELTA." - #elif ENABLED(MESH_BED_LEVELING) || (ENABLED(AUTO_BED_LEVELING_FEATURE) && !ENABLED(AUTO_BED_LEVELING_GRID)) - #error "Z_PROBE_ALLEN_KEY can only use AUTO_BED_LEVELING_GRID leveling." - #endif +#if ENABLED(Z_PROBE_ALLEN_KEY) && (Z_HOME_DIR < 0) && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) + #error "You can't home to a z min endstop with a Z_PROBE_ALLEN_KEY" #endif /**