Homing backoff enhancements

- Define homing bump as an array
- Add pre and post homing backoff options
- Consolidate homing config options
This commit is contained in:
George Fu 2020-03-25 16:18:48 +08:00 committed by Scott Lahteine
parent cbf349b5eb
commit a794538c54
7 changed files with 50 additions and 46 deletions

View file

@ -592,8 +592,7 @@
// Default x offset in duplication mode (typically set to half print bed width)
#define DEFAULT_DUPLICATION_X_OFFSET 100
#endif // DUAL_X_CARRIAGE
#endif
// Activate a solenoid on the active extruder with M380. Disable all with M381.
// Define SOL0_PIN, SOL1_PIN, etc., for each extruder that has a solenoid.
@ -601,19 +600,24 @@
// @section homing
// Homing hits each endstop, retracts by these distances, then does a slower bump.
#define X_HOME_BUMP_MM 5
#define Y_HOME_BUMP_MM 5
#define Z_HOME_BUMP_MM 2
/**
* Homing Procedure
* Homing (G28) does an indefinite move towards the endstops to establish
* the position of the toolhead relative to the workspace.
*/
//#define SENSORLESS_BACKOFF_MM { 2, 2 } // (mm) Backoff from endstops before sensorless homing
#define HOMING_BUMP_MM { 5, 5, 2 } // (mm) Backoff from endstops after first bump
#define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate)
//#define QUICK_HOME // If homing includes X and Y, do a diagonal move initially
//#define HOMING_BACKOFF_MM { 2, 2, 2 } // (mm) Move away from the endstops after homing
// When G28 is called, this option will make Y home before X
//#define HOME_Y_BEFORE_X
//#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm) Backoff from endstops after homing
// Enable this if X or Y can't home without homing the other axis first.
//#define CODEPENDENT_XY_HOMING
//#define QUICK_HOME // If G28 contains XY do a diagonal move first
//#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X
//#define CODEPENDENT_XY_HOMING // If X/Y can't home without homing Y/X first
// @section bltouch
#if ENABLED(BLTOUCH)
/**
@ -682,6 +686,8 @@
#endif // BLTOUCH
// @section extras
/**
* Z Steppers Auto-Alignment
* Add the G34 command to align multiple Z steppers using a bed probe.
@ -2319,7 +2325,7 @@
* HIGHEST 255 -64 (Too sensitive => False positive)
* LOWEST 0 63 (Too insensitive => No trigger)
*
* It is recommended to set [XYZ]_HOME_BUMP_MM to 0.
* It is recommended to set HOMING_BUMP_MM to { 0, 0, 0 }.
*
* SPI_ENDSTOPS *** Beta feature! *** TMC2130 Only ***
* Poll the driver through SPI to determine load when homing.

View file

@ -493,6 +493,10 @@
#error "ORIG_Ex_AUTO_FAN_PIN is now just Ex_AUTO_FAN_PIN. Make sure your pins are up to date."
#elif defined(ORIG_CHAMBER_AUTO_FAN_PIN)
#error "ORIG_CHAMBER_AUTO_FAN_PIN is now just CHAMBER_AUTO_FAN_PIN. Make sure your pins are up to date."
#elif defined(HOMING_BACKOFF_MM)
#error "HOMING_BACKOFF_MM is now HOMING_BACKOFF_POST_MM. Please update Configuration_adv.h."
#elif defined(X_HOME_BUMP_MM) || defined(Y_HOME_BUMP_MM) || defined(Z_HOME_BUMP_MM)
#error "[XYZ]_HOME_BUMP_MM is now HOMING_BUMP_MM. Please update Configuration_adv.h."
#endif
/**

View file

@ -280,8 +280,8 @@ void home_delta() {
sync_plan_position();
#if DISABLED(DELTA_HOME_TO_SAFE_ZONE) && defined(HOMING_BACKOFF_MM)
constexpr xyz_float_t endstop_backoff = HOMING_BACKOFF_MM;
#if DISABLED(DELTA_HOME_TO_SAFE_ZONE) && defined(HOMING_BACKOFF_POST_MM)
constexpr xyz_float_t endstop_backoff = HOMING_BACKOFF_POST_MM;
if (endstop_backoff.z) {
current_position.z -= ABS(endstop_backoff.z) * Z_HOME_DIR;
line_to_current_position(homing_feedrate(Z_AXIS));

View file

@ -74,15 +74,6 @@
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"
#define XYZ_CONSTS(T, NAME, OPT) const PROGMEM XYZval<T> NAME##_P = { X_##OPT, Y_##OPT, Z_##OPT }
XYZ_CONSTS(float, base_min_pos, MIN_POS);
XYZ_CONSTS(float, base_max_pos, MAX_POS);
XYZ_CONSTS(float, base_home_pos, HOME_POS);
XYZ_CONSTS(float, max_length, MAX_LENGTH);
XYZ_CONSTS(float, home_bump_mm, HOME_BUMP_MM);
XYZ_CONSTS(signed char, home_dir, HOME_DIR);
/**
* axis_homed
* Flags that each linear axis was homed.
@ -1567,14 +1558,13 @@ void homeaxis(const AxisEnum axis) {
if (axis == Z_AXIS && bltouch.deploy()) return; // The initial DEPLOY
#endif
do_homing_move(axis, 1.5f * max_length(
#if ENABLED(DELTA)
Z_AXIS
#else
axis
#if DISABLED(DELTA) && defined(SENSORLESS_BACKOFF_MM)
const xy_float_t backoff = SENSORLESS_BACKOFF_MM;
if (((ENABLED(X_SENSORLESS) && axis == X_AXIS) || (ENABLED(Y_SENSORLESS) && axis == Y_AXIS)) && backoff[axis])
do_homing_move(axis, -ABS(backoff[axis]) * axis_home_dir, homing_feedrate(axis));
#endif
) * axis_home_dir
);
do_homing_move(axis, 1.5f * max_length(TERN(DELTA, Z_AXIS, axis)) * axis_home_dir);
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH) && DISABLED(BLTOUCH_HS_MODE)
if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE)
@ -1583,14 +1573,14 @@ void homeaxis(const AxisEnum axis) {
// When homing Z with probe respect probe clearance
const float bump = axis_home_dir * (
#if HOMING_Z_WITH_PROBE
(axis == Z_AXIS && (Z_HOME_BUMP_MM)) ? _MAX(Z_CLEARANCE_BETWEEN_PROBES, Z_HOME_BUMP_MM) :
(axis == Z_AXIS && home_bump_mm(Z_AXIS)) ? _MAX(Z_CLEARANCE_BETWEEN_PROBES, home_bump_mm(Z_AXIS)) :
#endif
home_bump_mm(axis)
);
// If a second homing move is configured...
if (bump) {
// Move away from the endstop by the axis HOME_BUMP_MM
// Move away from the endstop by the axis HOMING_BUMP_MM
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Move Away:");
do_homing_move(axis, -bump
#if HOMING_Z_WITH_PROBE
@ -1785,8 +1775,8 @@ void homeaxis(const AxisEnum axis) {
if (axis == Z_AXIS && probe.stow()) return;
#endif
#if DISABLED(DELTA) && defined(HOMING_BACKOFF_MM)
const xyz_float_t endstop_backoff = HOMING_BACKOFF_MM;
#if DISABLED(DELTA) && defined(HOMING_BACKOFF_POST_MM)
const xyz_float_t endstop_backoff = HOMING_BACKOFF_POST_MM;
if (endstop_backoff[axis]) {
current_position[axis] -= ABS(endstop_backoff[axis]) * axis_home_dir;
line_to_current_position(

View file

@ -114,20 +114,25 @@ extern int16_t feedrate_percentage;
extern float e_move_accumulator;
#endif
FORCE_INLINE float pgm_read_any(const float *p) { return pgm_read_float(p); }
FORCE_INLINE signed char pgm_read_any(const signed char *p) { return pgm_read_byte(p); }
inline float pgm_read_any(const float *p) { return pgm_read_float(p); }
inline signed char pgm_read_any(const signed char *p) { return pgm_read_byte(p); }
#define XYZ_DEFS(T, NAME, OPT) \
extern const XYZval<T> NAME##_P; \
FORCE_INLINE T NAME(AxisEnum axis) { return pgm_read_any(&NAME##_P[axis]); }
inline T NAME(const AxisEnum axis) { \
static const XYZval<T> NAME##_P PROGMEM = { X_##OPT, Y_##OPT, Z_##OPT }; \
return pgm_read_any(&NAME##_P[axis]); \
}
XYZ_DEFS(float, base_min_pos, MIN_POS);
XYZ_DEFS(float, base_max_pos, MAX_POS);
XYZ_DEFS(float, base_home_pos, HOME_POS);
XYZ_DEFS(float, max_length, MAX_LENGTH);
XYZ_DEFS(float, home_bump_mm, HOME_BUMP_MM);
XYZ_DEFS(signed char, home_dir, HOME_DIR);
inline float home_bump_mm(const AxisEnum axis) {
static const xyz_pos_t home_bump_mm_P PROGMEM = HOMING_BUMP_MM;
return pgm_read_any(&home_bump_mm_P[axis]);
}
#if HAS_WORKSPACE_OFFSET
void update_workspace_offset(const AxisEnum axis);
#else

View file

@ -22,9 +22,7 @@ opt_set E0_DRIVER_TYPE TMC2209
opt_set RESTORE_LEVELING_AFTER_G28 false
opt_set LCD_LANGUAGE it
opt_set NUM_Z_STEPPER_DRIVERS 2
opt_set X_HOME_BUMP_MM 0
opt_set Y_HOME_BUMP_MM 0
opt_set Z_HOME_BUMP_MM 0
opt_set HOMING_BUMP_MM "{ 0, 0, 0 }"
opt_set SDCARD_CONNECTION LCD
opt_enable ENDSTOP_INTERRUPTS_FEATURE S_CURVE_ACCELERATION BLTOUCH Z_MIN_PROBE_REPEATABILITY_TEST \
FILAMENT_RUNOUT_SENSOR G26_MESH_VALIDATION MESH_EDIT_GFX_OVERLAY Z_SAFE_HOMING \

View file

@ -18,6 +18,7 @@ set -e
restore_configs
opt_set LCD_LANGUAGE an
opt_enable SPINDLE_FEATURE ULTIMAKERCONTROLLER LCD_BED_LEVELING \
SENSORLESS_BACKOFF_MM HOMING_BACKOFF_POST_MM HOME_Y_BEFORE_X CODEPENDENT_XY_HOMING \
MESH_BED_LEVELING ENABLE_LEVELING_FADE_HEIGHT MESH_G28_REST_ORIGIN \
G26_MESH_VALIDATION MESH_EDIT_MENU GCODE_QUOTED_STRINGS
exec_test $1 $2 "Spindle, MESH_BED_LEVELING, and LCD"