From e0a6b978f5f549b4906ac3590aa3442e4135d624 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Jul 2016 18:32:24 -0700 Subject: [PATCH 1/3] Don't do_probe_raise with MIN_Z_HEIGHT_FOR_HOMING --- Marlin/Marlin_main.cpp | 48 ++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index e38b7bcb65..2bf87fd9af 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1728,9 +1728,8 @@ static void clean_up_after_endstop_or_probe_move() { if ((Z_HOME_DIR) < 0 && zprobe_zoffset < 0) z_dest -= zprobe_zoffset; - if (z_dest > current_position[Z_AXIS]) { + if (z_dest > current_position[Z_AXIS]) do_blocking_move_to_z(z_dest); - } } #endif //HAS_BED_PROBE @@ -2860,6 +2859,8 @@ inline void gcode_G28() { home_all_axis = (!homeX && !homeY && !homeZ) || (homeX && homeY && homeZ); + set_destination_to_current(); + #if Z_HOME_DIR > 0 // If homing away from BED do Z first if (home_all_axis || homeZ) { @@ -2871,34 +2872,25 @@ inline void gcode_G28() { #elif defined(MIN_Z_HEIGHT_FOR_HOMING) && MIN_Z_HEIGHT_FOR_HOMING > 0 - #if HAS_BED_PROBE - do_probe_raise(MIN_Z_HEIGHT_FOR_HOMING); - destination[Z_AXIS] = current_position[Z_AXIS]; - #else - // Raise Z before homing any other axes and z is not already high enough (never lower z) - if (current_position[Z_AXIS] <= MIN_Z_HEIGHT_FOR_HOMING) { - destination[Z_AXIS] = MIN_Z_HEIGHT_FOR_HOMING; - feedrate = planner.max_feedrate[Z_AXIS] * 60; // feedrate (mm/m) = max_feedrate (mm/s) - #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR("Raise Z (before homing) to ", (MIN_Z_HEIGHT_FOR_HOMING)); - SERIAL_EOL; - DEBUG_POS("> (home_all_axis || homeZ)", current_position); - DEBUG_POS("> (home_all_axis || homeZ)", destination); - } - #endif - line_to_destination(); - stepper.synchronize(); - - /** - * Update the current Z position even if it currently not real from - * Z-home otherwise each call to line_to_destination() will want to - * move Z-axis by MIN_Z_HEIGHT_FOR_HOMING. - */ - current_position[Z_AXIS] = destination[Z_AXIS]; + // Raise Z before homing any other axes and z is not already high enough (never lower z) + float z_dest = (current_position[Z_AXIS] += MIN_Z_HEIGHT_FOR_HOMING); + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) { + SERIAL_ECHOPAIR("Raise Z (before homing) to ", z_dest); + SERIAL_EOL; } #endif - #endif + + feedrate = homing_feedrate[Z_AXIS]; + + #if HAS_BED_PROBE + do_blocking_move_to_z(z_dest); + #else + line_to_z(z_dest); + stepper.synchronize(); + #endif + + #endif // MIN_Z_HEIGHT_FOR_HOMING #if ENABLED(QUICK_HOME) From d0b29cabf33832dc19ddd9dff0a6b1d1e090c703 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Jul 2016 20:10:15 -0700 Subject: [PATCH 2/3] Don't re-home X and Y if you quick homed --- Marlin/Marlin_main.cpp | 118 ++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 56 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 2bf87fd9af..37ccd983c8 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2763,6 +2763,57 @@ inline void gcode_G4() { } #endif +#if ENABLED(QUICK_HOME) + + static void quick_home_xy() { + + current_position[X_AXIS] = current_position[Y_AXIS] = 0; + + #if ENABLED(DUAL_X_CARRIAGE) + int x_axis_home_dir = x_home_dir(active_extruder); + extruder_duplication_enabled = false; + #else + int x_axis_home_dir = home_dir(X_AXIS); + #endif + + SYNC_PLAN_POSITION_KINEMATIC(); + + float mlx = max_length(X_AXIS), mly = max_length(Y_AXIS), + mlratio = mlx > mly ? mly / mlx : mlx / mly; + + destination[X_AXIS] = 1.5 * mlx * x_axis_home_dir; + destination[Y_AXIS] = 1.5 * mly * home_dir(Y_AXIS); + feedrate = min(homing_feedrate[X_AXIS], homing_feedrate[Y_AXIS]) * sqrt(mlratio * mlratio + 1); + line_to_destination(); + stepper.synchronize(); + + set_axis_is_at_home(X_AXIS); + set_axis_is_at_home(Y_AXIS); + SYNC_PLAN_POSITION_KINEMATIC(); + + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) DEBUG_POS("> QUICK_HOME 1", current_position); + #endif + + destination[X_AXIS] = current_position[X_AXIS]; + destination[Y_AXIS] = current_position[Y_AXIS]; + line_to_destination(); + stepper.synchronize(); + endstops.hit_on_purpose(); // clear endstop hit flags + + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; + #if DISABLED(SCARA) + current_position[Z_AXIS] = destination[Z_AXIS]; + #endif + + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) DEBUG_POS("> QUICK_HOME 2", current_position); + #endif + } + +#endif // QUICK_HOME + /** * G28: Home all axes according to settings * @@ -2814,16 +2865,9 @@ inline void gcode_G28() { setup_for_endstop_move(); - /** - * Directly after a reset this is all 0. Later we get a hint if we have - * to raise z or not. - */ - set_destination_to_current(); - #if ENABLED(DELTA) /** - * A delta can only safely home all axis at the same time - * all axis have to home at the same time + * A delta can only safely home all axes at the same time */ // Pretend the current position is 0,0,0 @@ -2894,67 +2938,29 @@ inline void gcode_G28() { #if ENABLED(QUICK_HOME) - if (home_all_axis || (homeX && homeY)) { // First diagonal move + bool quick_homed = home_all_axis || (homeX && homeY); + if (quick_homed) quick_home_xy(); - current_position[X_AXIS] = current_position[Y_AXIS] = 0; + #else - #if ENABLED(DUAL_X_CARRIAGE) - int x_axis_home_dir = x_home_dir(active_extruder); - extruder_duplication_enabled = false; - #else - int x_axis_home_dir = home_dir(X_AXIS); - #endif + const bool quick_homed = false; - SYNC_PLAN_POSITION_KINEMATIC(); - - float mlx = max_length(X_AXIS), mly = max_length(Y_AXIS), - mlratio = mlx > mly ? mly / mlx : mlx / mly; - - destination[X_AXIS] = 1.5 * mlx * x_axis_home_dir; - destination[Y_AXIS] = 1.5 * mly * home_dir(Y_AXIS); - feedrate = min(homing_feedrate[X_AXIS], homing_feedrate[Y_AXIS]) * sqrt(mlratio * mlratio + 1); - line_to_destination(); - stepper.synchronize(); - - set_axis_is_at_home(X_AXIS); - set_axis_is_at_home(Y_AXIS); - SYNC_PLAN_POSITION_KINEMATIC(); - - #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) DEBUG_POS("> QUICK_HOME 1", current_position); - #endif - - destination[X_AXIS] = current_position[X_AXIS]; - destination[Y_AXIS] = current_position[Y_AXIS]; - line_to_destination(); - stepper.synchronize(); - endstops.hit_on_purpose(); // clear endstop hit flags - - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; - #if DISABLED(SCARA) - current_position[Z_AXIS] = destination[Z_AXIS]; - #endif - - #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) DEBUG_POS("> QUICK_HOME 2", current_position); - #endif - } - - #endif // QUICK_HOME + #endif #if ENABLED(HOME_Y_BEFORE_X) + // Home Y - if (home_all_axis || homeY) { + if (!quick_homed && (home_all_axis || homeY)) { HOMEAXIS(Y); #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("> homeY", current_position); #endif } + #endif // Home X - if (home_all_axis || homeX) { + if (!quick_homed && (home_all_axis || homeX)) { #if ENABLED(DUAL_X_CARRIAGE) int tmp_extruder = active_extruder; extruder_duplication_enabled = false; @@ -2977,7 +2983,7 @@ inline void gcode_G28() { #if DISABLED(HOME_Y_BEFORE_X) // Home Y - if (home_all_axis || homeY) { + if (!quick_homed && (home_all_axis || homeY)) { HOMEAXIS(Y); #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) DEBUG_POS("> homeY", current_position); From d7e964750586db2b253adf79524c7b632adeea4d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 5 Jul 2016 20:09:30 -0700 Subject: [PATCH 3/3] Sanity Check for probe raises --- Marlin/Conditionals.h | 11 ++++------- Marlin/SanityCheck.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h index 734b644bee..1c6aa9abcd 100644 --- a/Marlin/Conditionals.h +++ b/Marlin/Conditionals.h @@ -783,14 +783,11 @@ #define XY_PROBE_SPEED 4000 #endif #endif - #ifndef Z_RAISE_PROBE_DEPLOY_STOW - #if defined(Z_RAISE_BEFORE_PROBING) && defined(Z_RAISE_AFTER_PROBING) - #define Z_RAISE_PROBE_DEPLOY_STOW (max(Z_RAISE_BEFORE_PROBING, Z_RAISE_AFTER_PROBING)) - #else - #error "You must set Z_RAISE_PROBE_DEPLOY_STOW in your configuration." - #endif + #if Z_RAISE_BETWEEN_PROBINGS > Z_RAISE_PROBE_DEPLOY_STOW + #define _Z_RAISE_PROBE_DEPLOY_STOW Z_RAISE_BETWEEN_PROBINGS + #else + #define _Z_RAISE_PROBE_DEPLOY_STOW Z_RAISE_PROBE_DEPLOY_STOW #endif - #define _Z_RAISE_PROBE_DEPLOY_STOW (max(Z_RAISE_PROBE_DEPLOY_STOW, Z_RAISE_BETWEEN_PROBINGS)) #endif /** diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index b63877531e..b075cd4c7b 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -293,6 +293,21 @@ //#endif #endif + /** + * Make sure Z raise values are set + */ + #if defined(Z_RAISE_BEFORE_PROBING) || defined(Z_RAISE_AFTER_PROBING) + #error "Z_RAISE_(BEFORE|AFTER)_PROBING are deprecated. Use Z_RAISE_PROBE_DEPLOY_STOW instead." + #elif !defined(Z_RAISE_PROBE_DEPLOY_STOW) + #error "You must set Z_RAISE_PROBE_DEPLOY_STOW in your configuration." + #elif !defined(Z_RAISE_BETWEEN_PROBINGS) + #error "You must set Z_RAISE_BETWEEN_PROBINGS in your configuration." + #elif Z_RAISE_PROBE_DEPLOY_STOW < 1 + #error "Probes need Z_RAISE_PROBE_DEPLOY_STOW >= 1." + #elif Z_RAISE_BETWEEN_PROBINGS < 1 + #error "Probes need Z_RAISE_BETWEEN_PROBINGS >= 1." + #endif + #else /**