From 6f85a8c7aa95474c653e326a3727e252d280d057 Mon Sep 17 00:00:00 2001 From: Alex Borro Date: Sat, 12 Oct 2013 17:28:11 -0300 Subject: [PATCH] Bed auto Leveling change: Raise Z before homing - Added "Z_RAISE_BEFORE_HOMING" for raising Z the defined distance before homing. This is useful to avoid Z-Probe collision when hotend is near bed. - Fixed the issue of Z not going bellow Z_PROBE_OFFSET when "min_software_endstops" is true. Now the Z_PROBE_OFFSET is not set in Z_MIN_POS, it is added after homing. --- Marlin/Configuration.h | 10 ++++------ Marlin/Marlin_main.cpp | 24 ++++++++++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 502ebd4389..459640fbc3 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -309,7 +309,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of #define X_PROBE_OFFSET_FROM_EXTRUDER -25 #define Y_PROBE_OFFSET_FROM_EXTRUDER -29 #define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35 - + + #define Z_RAISE_BEFORE_HOMING 4 // (in mm) Raise Z before homing (G28) for Probe Clearance. + // Be sure you have this distance over your Z_MAX_POS in case + #define XY_TRAVEL_SPEED 8000 // X and Y axis travel speed between probes, in mm/min #define Z_RAISE_BEFORE_PROBING 15 //How much the extruder will be raised before traveling to the first probing point. @@ -330,12 +333,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of #define Y_MAX_POS 205 #define Y_MIN_POS 0 #define Z_MAX_POS 200 - -#ifndef ENABLE_AUTO_BED_LEVELING #define Z_MIN_POS 0 -#else -#define Z_MIN_POS (-1*Z_PROBE_OFFSET_FROM_EXTRUDER) //With Auto Bed Leveling, the Z_MIN MUST have the same distance as Z_PROBE -#endif #define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS) #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index dc7edd0a5c..2a3534221e 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -920,19 +920,28 @@ static void homeaxis(int axis) { axis_home_dir = x_home_dir(active_extruder); #endif + current_position[axis] = 0; + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + // Engage Servo endstop if enabled #ifdef SERVO_ENDSTOPS -#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0) - if (axis==Z_AXIS) engage_z_probe(); - else -#endif + #if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0) + if (axis==Z_AXIS) { + #if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) + destination[axis] = Z_RAISE_BEFORE_HOMING * axis_home_dir * (-1); // Set destination away from bed + feedrate = max_feedrate[axis]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); + #endif + engage_z_probe(); + } + else + #endif if (servo_endstops[axis] > -1) { servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]); } #endif - current_position[axis] = 0; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); destination[axis] = 1.5 * max_length(axis) * axis_home_dir; feedrate = homing_feedrate[axis]; plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); @@ -1198,6 +1207,9 @@ void process_commands() current_position[Z_AXIS]=code_value()+add_homeing[2]; } } + #ifdef ENABLE_AUTO_BED_LEVELING + current_position[Z_AXIS] -= Z_PROBE_OFFSET_FROM_EXTRUDER; //Add Z_Probe offset (the distance is negative) + #endif plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); #endif // else DELTA