Use blocking_move, current_position in G28 homing

This commit is contained in:
Scott Lahteine 2016-07-17 16:30:28 -07:00
parent f242aea032
commit 1e57a6af73

View file

@ -1594,7 +1594,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
/** /**
* Some planner shorthand inline functions * Some planner shorthand inline functions
*/ */
inline void set_homing_bump_feedrate(AxisEnum axis) { inline float set_homing_bump_feedrate(AxisEnum axis) {
const int homing_bump_divisor[] = HOMING_BUMP_DIVISOR; const int homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
int hbd = homing_bump_divisor[axis]; int hbd = homing_bump_divisor[axis];
if (hbd < 1) { if (hbd < 1) {
@ -1603,6 +1603,7 @@ inline void set_homing_bump_feedrate(AxisEnum axis) {
SERIAL_ECHOLNPGM("Warning: Homing Bump Divisor < 1"); SERIAL_ECHOLNPGM("Warning: Homing Bump Divisor < 1");
} }
feedrate_mm_m = homing_feedrate_mm_m[axis] / hbd; feedrate_mm_m = homing_feedrate_mm_m[axis] / hbd;
return feedrate_mm_m;
} }
// //
// line_to_current_position // line_to_current_position
@ -1707,6 +1708,11 @@ static void do_blocking_move_to(float x, float y, float z, float fr_mm_m = 0.0)
feedrate_mm_m = old_feedrate_mm_m; feedrate_mm_m = old_feedrate_mm_m;
} }
inline void do_blocking_move_to_axis_pos(AxisEnum axis, float where, float fr_mm_m = 0.0) {
current_position[axis] = where;
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m);
}
inline void do_blocking_move_to_x(float x, float fr_mm_m = 0.0) { inline void do_blocking_move_to_x(float x, float fr_mm_m = 0.0) {
do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m); do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS], fr_mm_m);
} }
@ -2419,27 +2425,19 @@ static void homeaxis(AxisEnum axis) {
#endif #endif
// Move towards the endstop until an endstop is triggered // Move towards the endstop until an endstop is triggered
destination[axis] = 1.5 * max_length(axis) * axis_home_dir; do_blocking_move_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir, homing_feedrate_mm_m[axis]);
feedrate_mm_m = homing_feedrate_mm_m[axis];
line_to_destination();
stepper.synchronize();
// Set the axis position as setup for the move // Set the axis position as setup for the move
current_position[axis] = 0; current_position[axis] = 0;
sync_plan_position(); sync_plan_position();
// Move away from the endstop by the axis HOME_BUMP_MM // Move away from the endstop by the axis HOME_BUMP_MM
destination[axis] = -home_bump_mm(axis) * axis_home_dir; do_blocking_move_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir, homing_feedrate_mm_m[axis]);
line_to_destination();
stepper.synchronize();
// Slow down the feedrate for the next move // Slow down the feedrate for the next move
set_homing_bump_feedrate(axis);
// Move slowly towards the endstop until triggered // Move slowly towards the endstop until triggered
destination[axis] = 2 * home_bump_mm(axis) * axis_home_dir; do_blocking_move_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis));
line_to_destination();
stepper.synchronize();
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
@ -2460,10 +2458,7 @@ static void homeaxis(AxisEnum axis) {
sync_plan_position(); sync_plan_position();
// Move to the adjusted endstop height // Move to the adjusted endstop height
feedrate_mm_m = homing_feedrate_mm_m[axis]; do_blocking_move_to_z(adj, homing_feedrate_mm_m[axis]);
destination[Z_AXIS] = adj;
line_to_destination();
stepper.synchronize();
if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false); if (lockZ1) stepper.set_z_lock(false); else stepper.set_z2_lock(false);
stepper.set_homing_flag(false); stepper.set_homing_flag(false);
@ -2474,15 +2469,13 @@ static void homeaxis(AxisEnum axis) {
// retrace by the amount specified in endstop_adj // retrace by the amount specified in endstop_adj
if (endstop_adj[axis] * axis_home_dir < 0) { if (endstop_adj[axis] * axis_home_dir < 0) {
sync_plan_position(); sync_plan_position();
destination[axis] = endstop_adj[axis];
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]); SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis]);
DEBUG_POS("", destination); DEBUG_POS("", current_position);
} }
#endif #endif
line_to_destination(); do_blocking_move_to_axis_pos(axis, endstop_adj[axis], set_homing_bump_feedrate(axis));
stepper.synchronize();
} }
#endif #endif
@ -2836,8 +2829,6 @@ inline void gcode_G4() {
static void quick_home_xy() { static void quick_home_xy() {
current_position[X_AXIS] = current_position[Y_AXIS] = 0;
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
int x_axis_home_dir = x_home_dir(active_extruder); int x_axis_home_dir = x_home_dir(active_extruder);
extruder_duplication_enabled = false; extruder_duplication_enabled = false;
@ -2845,17 +2836,15 @@ inline void gcode_G4() {
int x_axis_home_dir = home_dir(X_AXIS); int x_axis_home_dir = home_dir(X_AXIS);
#endif #endif
float mlx = max_length(X_AXIS), mly = max_length(Y_AXIS), float mlx = max_length(X_AXIS),
mlratio = mlx > mly ? mly / mlx : mlx / mly; mly = max_length(Y_AXIS),
mlratio = mlx > mly ? mly / mlx : mlx / mly,
fr_mm_m = min(homing_feedrate_mm_m[X_AXIS], homing_feedrate_mm_m[Y_AXIS]) * sqrt(sq(mlratio) + 1);
destination[X_AXIS] = 1.5 * mlx * x_axis_home_dir; do_blocking_move_to_xy(1.5 * mlx * x_axis_home_dir, 1.5 * mly * home_dir(Y_AXIS), fr_mm_m);
destination[Y_AXIS] = 1.5 * mly * home_dir(Y_AXIS);
feedrate_mm_m = min(homing_feedrate_mm_m[X_AXIS], homing_feedrate_mm_m[Y_AXIS]) * sqrt(sq(mlratio) + 1);
line_to_destination();
stepper.synchronize();
endstops.hit_on_purpose(); // clear endstop hit flags endstops.hit_on_purpose(); // clear endstop hit flags
current_position[X_AXIS] = current_position[Y_AXIS] = 0;
destination[X_AXIS] = destination[Y_AXIS] = 0;
} }
#endif // QUICK_HOME #endif // QUICK_HOME