From 58d128b7a9178490252f76045e7d5282430549e4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 16 Apr 2015 07:41:19 -0700 Subject: [PATCH 1/3] Apply zprobe_zoffset in axis_is_at_home Ensure the probe offset will always be included when homing Z. --- Marlin/Marlin_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 64d3d1f35..5a396bb93 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1033,6 +1033,10 @@ static void axis_is_at_home(int axis) { min_pos[axis] = base_min_pos(axis) + home_offset[axis]; max_pos[axis] = base_max_pos(axis) + home_offset[axis]; #endif + + #if defined(ENABLE_AUTO_BED_LEVELING) && Z_HOME_DIR < 0 + if (axis == Z_AXIS) current_position[Z_AXIS] += zprobe_zoffset; + #endif } /** @@ -2041,10 +2045,6 @@ inline void gcode_G28() { if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) current_position[Z_AXIS] = code_value(); - #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0) - if (home_all_axis || homeZ) current_position[Z_AXIS] += zprobe_zoffset; // Add Z_Probe offset (the distance is negative) - #endif - sync_plan_position(); #endif // else DELTA From 01655603330b67319fa5dc4be27819099857a006 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 16 Apr 2015 07:41:19 -0700 Subject: [PATCH 2/3] Apply zprobe_zoffset in axis_is_at_home Ensure the probe offset will always be included when homing Z. --- Marlin/Marlin_main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index a51d483e8..5849fdd68 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1034,6 +1034,10 @@ static void axis_is_at_home(int axis) { min_pos[axis] = base_min_pos(axis) + home_offset[axis]; max_pos[axis] = base_max_pos(axis) + home_offset[axis]; #endif + + #if defined(ENABLE_AUTO_BED_LEVELING) && Z_HOME_DIR < 0 + if (axis == Z_AXIS) current_position[Z_AXIS] += zprobe_zoffset; + #endif } /** @@ -2042,10 +2046,6 @@ inline void gcode_G28() { if (code_seen(axis_codes[Z_AXIS]) && code_has_value()) current_position[Z_AXIS] = code_value(); - #if defined(ENABLE_AUTO_BED_LEVELING) && (Z_HOME_DIR < 0) - if (home_all_axis || homeZ) current_position[Z_AXIS] += zprobe_zoffset; // Add Z_Probe offset (the distance is negative) - #endif - sync_plan_position(); #endif // else DELTA From 182f2cda350b284db5d71cc194ed7f3ea7872d4c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 24 Apr 2015 21:26:36 -0700 Subject: [PATCH 3/3] Minor cleanup of M48 --- Marlin/Marlin_main.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 05a864e6a..65290b3cb 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1189,8 +1189,8 @@ inline void set_destination_to_current() { memcpy(destination, current_position, st_synchronize(); endstops_hit_on_purpose(); // clear endstop hit flags + // Get the current stepper position after bumping an endstop current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); - // make sure the planner knows where we are as it may be a bit different than we last said to move to sync_plan_position(); #endif // !DELTA @@ -2908,12 +2908,12 @@ inline void gcode_M42() { } } - double X_probe_location, Y_probe_location, - X_current = X_probe_location = st_get_position_mm(X_AXIS), - Y_current = Y_probe_location = st_get_position_mm(Y_AXIS), + double X_current = st_get_position_mm(X_AXIS), + Y_current = st_get_position_mm(Y_AXIS), Z_current = st_get_position_mm(Z_AXIS), - Z_start_location = Z_current + Z_RAISE_BEFORE_PROBING, - ext_position = st_get_position_mm(E_AXIS); + E_current = st_get_position_mm(E_AXIS), + X_probe_location = X_current, Y_probe_location = Y_current, + Z_start_location = Z_current + Z_RAISE_BEFORE_PROBING; bool deploy_probe_for_each_reading = code_seen('E') || code_seen('e'); @@ -2948,10 +2948,7 @@ inline void gcode_M42() { st_synchronize(); plan_bed_level_matrix.set_to_identity(); - plan_buffer_line(X_current, Y_current, Z_start_location, - ext_position, - homing_feedrate[Z_AXIS] / 60, - active_extruder); + plan_buffer_line(X_current, Y_current, Z_start_location, E_current, homing_feedrate[Z_AXIS] / 60, active_extruder); st_synchronize(); // @@ -2963,7 +2960,7 @@ inline void gcode_M42() { SERIAL_PROTOCOLPGM("Positioning the probe...\n"); plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, - ext_position, + E_current, homing_feedrate[X_AXIS]/60, active_extruder); st_synchronize(); @@ -2971,7 +2968,7 @@ inline void gcode_M42() { current_position[X_AXIS] = X_current = st_get_position_mm(X_AXIS); current_position[Y_AXIS] = Y_current = st_get_position_mm(Y_AXIS); current_position[Z_AXIS] = Z_current = st_get_position_mm(Z_AXIS); - current_position[E_AXIS] = ext_position = st_get_position_mm(E_AXIS); + current_position[E_AXIS] = E_current = st_get_position_mm(E_AXIS); // // OK, do the inital probe to get us close to the bed. @@ -2987,7 +2984,7 @@ inline void gcode_M42() { Z_start_location = st_get_position_mm(Z_AXIS) + Z_RAISE_BEFORE_PROBING; plan_buffer_line( X_probe_location, Y_probe_location, Z_start_location, - ext_position, + E_current, homing_feedrate[X_AXIS]/60, active_extruder); st_synchronize(); @@ -3017,8 +3014,8 @@ inline void gcode_M42() { if (radius < 0.0) radius = -radius; X_current = X_probe_location + cos(theta) * radius; - Y_current = Y_probe_location + sin(theta) * radius; X_current = constrain(X_current, X_MIN_POS, X_MAX_POS); + Y_current = Y_probe_location + sin(theta) * radius; Y_current = constrain(Y_current, Y_MIN_POS, Y_MAX_POS); if (verbose_level > 3) {