Skip to content

Commit

Permalink
Introduce line_to_axis_pos(axis_codes axis, float where, float feed_r…
Browse files Browse the repository at this point in the history
…ate = 0.0)

and use it in homeaxis instead of `do_blocking_move_to_axis_pos()`.

`do_blocking_move_to_axis_pos` was wrong because it performes subdevided, delta-corrected moves for x- and y-axis.
  • Loading branch information
AnHardt committed Jul 18, 2016
1 parent 4611759 commit 1fc3250
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,14 @@ inline void line_to_current_position() {
inline void line_to_z(float zPosition) {
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], zPosition, current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder);
}
inline void line_to_axis_pos(AxisEnum axis, float where, float fr_mm_m = 0.0) {
float old_feedrate_mm_m = feedrate_mm_m;
current_position[axis] = where;
feedrate_mm_m = (fr_mm_m != 0.0) ? fr_mm_m : homing_feedrate_mm_m[axis];
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], MMM_TO_MMS(feedrate_mm_m), active_extruder);
feedrate_mm_m = old_feedrate_mm_m;
}

//
// line_to_destination
// Move the planner, not necessarily synced with current_position
Expand Down Expand Up @@ -2425,19 +2433,19 @@ static void homeaxis(AxisEnum axis) {
#endif

// Move towards the endstop until an endstop is triggered
do_blocking_move_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir, homing_feedrate_mm_m[axis]);
line_to_axis_pos(axis, 1.5 * max_length(axis) * axis_home_dir);

// Set the axis position as setup for the move
current_position[axis] = 0;
sync_plan_position();

// Move away from the endstop by the axis HOME_BUMP_MM
do_blocking_move_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir, homing_feedrate_mm_m[axis]);
line_to_axis_pos(axis, -home_bump_mm(axis) * axis_home_dir);

// Slow down the feedrate for the next move

// Move slowly towards the endstop until triggered
do_blocking_move_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis));
line_to_axis_pos(axis, 2 * home_bump_mm(axis) * axis_home_dir, set_homing_bump_feedrate(axis));

#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> TRIGGER ENDSTOP", current_position);
Expand Down Expand Up @@ -2475,7 +2483,7 @@ static void homeaxis(AxisEnum axis) {
DEBUG_POS("", current_position);
}
#endif
do_blocking_move_to_axis_pos(axis, endstop_adj[axis], set_homing_bump_feedrate(axis));
line_to_axis_pos(axis, endstop_adj[axis]);
}
#endif

Expand Down Expand Up @@ -2935,16 +2943,13 @@ inline void gcode_G28() {
sync_plan_position();

// Move all carriages up together until the first endstop is hit.
for (int i = X_AXIS; i <= Z_AXIS; i++) destination[i] = 3 * (Z_MAX_LENGTH);
for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = 3 * (Z_MAX_LENGTH);
feedrate_mm_m = 1.732 * homing_feedrate_mm_m[X_AXIS];
line_to_destination();
line_to_current_position();
stepper.synchronize();
endstops.hit_on_purpose(); // clear endstop hit flags

// Destination reached
for (int i = X_AXIS; i <= Z_AXIS; i++) current_position[i] = destination[i];

// take care of back off and rehome now we are all at the top
// take care of back off and rehome. Now one carriage is at the top.
HOMEAXIS(X);
HOMEAXIS(Y);
HOMEAXIS(Z);
Expand Down

0 comments on commit 1fc3250

Please sign in to comment.