Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions Marlin/G26_Mesh_Validation_Tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@
destination[E_AXIS] = current_position[E_AXIS];

G26_line_to_destination(feed_value);

stepper.synchronize();
set_destination_from_current();
}

Expand All @@ -220,8 +218,6 @@
destination[E_AXIS] += e_delta;

G26_line_to_destination(feed_value);

stepper.synchronize();
set_destination_from_current();
}

Expand Down Expand Up @@ -267,13 +263,12 @@
if (Total_Prime >= EXTRUDE_MAXLENGTH) return G26_ERR;
#endif
G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);

set_destination_from_current();
stepper.synchronize(); // Without this synchronize, the purge is more consistent,
// but because the planner has a buffer, we won't be able
// to stop as quickly. So we put up with the less smooth
// action to give the user a more responsive 'Stop'.
set_destination_from_current();
idle();

SERIAL_FLUSH(); // Prevent host M105 buffer overrun.
}

Expand All @@ -295,7 +290,6 @@
set_destination_from_current();
destination[E_AXIS] += g26_prime_length;
G26_line_to_destination(planner.max_feedrate_mm_s[E_AXIS] / 15.0);
stepper.synchronize();
set_destination_from_current();
retract_filament(destination);
}
Expand Down Expand Up @@ -703,7 +697,6 @@

if (current_position[Z_AXIS] < Z_CLEARANCE_BETWEEN_PROBES) {
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
stepper.synchronize();
set_current_from_destination();
}

Expand Down Expand Up @@ -738,7 +731,7 @@
lcd_external_control = true;
#endif

// debug_current_and_destination(PSTR("Starting G26 Mesh Validation Pattern."));
//debug_current_and_destination(PSTR("Starting G26 Mesh Validation Pattern."));

/**
* Pre-generate radius offset values at 30 degree intervals to reduce CPU load.
Expand Down
10 changes: 5 additions & 5 deletions Marlin/I2CPositionEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@

stepper.synchronize();

planner.buffer_line(startCoord[X_AXIS],startCoord[Y_AXIS],startCoord[Z_AXIS],
planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS],
stepper.get_axis_position_mm(E_AXIS), feedrate, 0);
stepper.synchronize();

Expand Down Expand Up @@ -415,10 +415,10 @@
startCoord[encoderAxis] = startDistance;
endCoord[encoderAxis] = endDistance;

LOOP_L_N(i, iter) {
stepper.synchronize();
stepper.synchronize();

planner.buffer_line(startCoord[X_AXIS],startCoord[Y_AXIS],startCoord[Z_AXIS],
LOOP_L_N(i, iter) {
planner.buffer_line(startCoord[X_AXIS], startCoord[Y_AXIS], startCoord[Z_AXIS],
stepper.get_axis_position_mm(E_AXIS), feedrate, 0);
stepper.synchronize();

Expand All @@ -427,7 +427,7 @@

//do_blocking_move_to(endCoord[X_AXIS],endCoord[Y_AXIS],endCoord[Z_AXIS]);

planner.buffer_line(endCoord[X_AXIS],endCoord[Y_AXIS],endCoord[Z_AXIS],
planner.buffer_line(endCoord[X_AXIS], endCoord[Y_AXIS], endCoord[Z_AXIS],
stepper.get_axis_position_mm(E_AXIS), feedrate, 0);
stepper.synchronize();

Expand Down
38 changes: 17 additions & 21 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2984,7 +2984,7 @@ static void do_homing_move(const AxisEnum axis, const float distance, const floa
planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], current_position[E_AXIS], fr_mm_s ? fr_mm_s : homing_feedrate(axis), active_extruder);
#else
sync_plan_position();
current_position[axis] = distance;
current_position[axis] = distance; // Set delta/cartesian axes directly
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], fr_mm_s ? fr_mm_s : homing_feedrate(axis), active_extruder);
#endif

Expand Down Expand Up @@ -5337,8 +5337,8 @@ void home_all_axes() { gcode_G28(true); }
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
#endif
enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
stepper.synchronize();
enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
#endif

// Auto Bed Leveling is complete! Enable if possible.
Expand Down Expand Up @@ -6134,9 +6134,8 @@ void home_all_axes() { gcode_G28(true); }
}
#endif

stepper.synchronize(); // wait until the machine is idle

// Move until destination reached or target hit
stepper.synchronize();
endstops.enable(true);
G38_move = true;
G38_endstop_hit = false;
Expand All @@ -6158,13 +6157,13 @@ void home_all_axes() { gcode_G28(true); }
LOOP_XYZ(i) destination[i] += retract_mm[i];
endstops.enable(false);
prepare_move_to_destination();
stepper.synchronize();

feedrate_mm_s /= 4;

// Bump the target more slowly
LOOP_XYZ(i) destination[i] -= retract_mm[i] * 2;

stepper.synchronize();
endstops.enable(true);
G38_move = true;
prepare_move_to_destination();
Expand Down Expand Up @@ -6258,8 +6257,6 @@ void home_all_axes() { gcode_G28(true); }
*/
inline void gcode_G92() {

stepper.synchronize();

#if ENABLED(CNC_COORDINATE_SYSTEMS)
switch (parser.subcode) {
case 1:
Expand Down Expand Up @@ -6319,10 +6316,9 @@ inline void gcode_G92() {
COPY(coordinate_system[active_coordinate_system], position_shift);
#endif

if (didXYZ)
SYNC_PLAN_POSITION_KINEMATIC();
else if (didE)
sync_plan_position_e();
// Update planner/steppers only if the native coordinates changed
if (didXYZ) SYNC_PLAN_POSITION_KINEMATIC();
else if (didE) sync_plan_position_e();

report_current_position();
}
Expand All @@ -6349,6 +6345,8 @@ inline void gcode_G92() {

const bool has_message = !hasP && !hasS && args && *args;

stepper.synchronize();

#if ENABLED(ULTIPANEL)

if (has_message)
Expand All @@ -6372,8 +6370,6 @@ inline void gcode_G92() {
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;

stepper.synchronize();

if (ms > 0) {
ms += millis(); // wait until this time for a click
while (PENDING(millis(), ms) && wait_for_user) idle();
Expand Down Expand Up @@ -6524,8 +6520,8 @@ inline void gcode_M17() {
set_destination_from_current();
destination[E_AXIS] += length / planner.e_factor[active_extruder];
planner.buffer_line_kinematic(destination, fr, active_extruder);
stepper.synchronize();
set_current_from_destination();
stepper.synchronize();
}

static float resume_position[XYZE];
Expand Down Expand Up @@ -6813,12 +6809,12 @@ inline void gcode_M17() {
#endif
print_job_timer.pause();

// Wait for synchronize steppers
stepper.synchronize();

// Save current position
COPY(resume_position, current_position);

// Wait for synchronize steppers
stepper.synchronize();

// Initial retract before move to filament change position
if (retract && thermalManager.hotEnoughToExtrude(active_extruder))
do_pause_e_move(retract, PAUSE_PARK_RETRACT_FEEDRATE);
Expand Down Expand Up @@ -8508,7 +8504,6 @@ inline void gcode_M81() {
safe_delay(1000); // Wait 1 second before switching off

#if HAS_SUICIDE
stepper.synchronize();
suicide();
#elif HAS_POWER_SWITCH
PSU_OFF();
Expand Down Expand Up @@ -8644,8 +8639,6 @@ void report_current_position() {

void report_current_position_detail() {

stepper.synchronize();

SERIAL_PROTOCOLPGM("\nLogical:");
const float logical[XYZ] = {
LOGICAL_X_POSITION(current_position[X_AXIS]),
Expand Down Expand Up @@ -8680,6 +8673,8 @@ void report_current_position() {
report_xyz(delta);
#endif

stepper.synchronize();

SERIAL_PROTOCOLPGM("Stepper:");
LOOP_XYZE(i) {
SERIAL_CHAR(' ');
Expand Down Expand Up @@ -13369,8 +13364,8 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) {
current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS],
planner.max_feedrate_mm_s[X_AXIS], 1
);
SYNC_PLAN_POSITION_KINEMATIC();
stepper.synchronize();
SYNC_PLAN_POSITION_KINEMATIC();
extruder_duplication_enabled = true;
active_extruder_parked = false;
#if ENABLED(DEBUG_LEVELING_FEATURE)
Expand Down Expand Up @@ -13978,6 +13973,7 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
planner.buffer_line_kinematic(current_position, MMM_TO_MMS(EXTRUDER_RUNOUT_SPEED), active_extruder);
current_position[E_AXIS] = olde;
planner.set_e_position_mm(olde);

stepper.synchronize();
#if ENABLED(SWITCHING_EXTRUDER)
E0_ENABLE_WRITE(oldstatus);
Expand Down
33 changes: 13 additions & 20 deletions Marlin/fwretract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void FWRetract::retract(const bool retracting
// G11 priority to recover the long retract if activated
if (!retracting) swapping = retracted_swap[active_extruder];
#else
const bool swapping = false;
constexpr bool swapping = false;
#endif

/* // debugging
Expand All @@ -127,54 +127,47 @@ void FWRetract::retract(const bool retracting
SERIAL_ECHOLNPAIR("hop_amount ", hop_amount);
//*/

const float old_feedrate_mm_s = feedrate_mm_s;
const float old_feedrate_mm_s = feedrate_mm_s,
renormalize = RECIPROCAL(planner.e_factor[active_extruder]),
base_retract = swapping ? swap_retract_length : retract_length,
old_z = current_position[Z_AXIS],
old_e = current_position[E_AXIS];

// The current position will be the destination for E and Z moves
set_destination_from_current();
stepper.synchronize(); // Wait for buffered moves to complete

const float renormalize = 1.0 / planner.e_factor[active_extruder];

if (retracting) {
// Retract by moving from a faux E position back to the current E position
feedrate_mm_s = retract_feedrate_mm_s;
current_position[E_AXIS] += (swapping ? swap_retract_length : retract_length) * renormalize;
sync_plan_position_e();
prepare_move_to_destination(); // set_current_to_destination
destination[E_AXIS] -= base_retract * renormalize;
prepare_move_to_destination(); // set_current_to_destination

// Is a Z hop set, and has the hop not yet been done?
// No double zlifting
// Feedrate to the max
if (retract_zlift > 0.01 && !hop_amount) { // Apply hop only once
const float old_z = current_position[Z_AXIS];
hop_amount += retract_zlift; // Add to the hop total (again, only once)
destination[Z_AXIS] += retract_zlift; // Raise Z by the zlift (M207 Z) amount
feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Maximum Z feedrate
prepare_move_to_destination(); // Raise up, set_current_to_destination
current_position[Z_AXIS] = old_z; // Spoof the Z position in the planner
SYNC_PLAN_POSITION_KINEMATIC();
}
}
else {
// If a hop was done and Z hasn't changed, undo the Z hop
if (hop_amount) {
current_position[Z_AXIS] += hop_amount; // Set actual Z (due to the prior hop)
SYNC_PLAN_POSITION_KINEMATIC(); // Spoof the Z position in the planner
destination[Z_AXIS] -= hop_amount; // Move back down by the total hop amount
feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max
prepare_move_to_destination(); // Lower Z, set_current_to_destination
hop_amount = 0.0; // Clear the hop amount
}

// A retract multiplier has been added here to get faster swap recovery
destination[E_AXIS] += (base_retract + (swapping ? swap_retract_recover_length : retract_recover_length)) * renormalize;
feedrate_mm_s = swapping ? swap_retract_recover_feedrate_mm_s : retract_recover_feedrate_mm_s;

current_position[E_AXIS] -= (swapping ? swap_retract_length + swap_retract_recover_length
: retract_length + retract_recover_length) * renormalize;
sync_plan_position_e();
prepare_move_to_destination(); // Recover E, set_current_to_destination
}

feedrate_mm_s = old_feedrate_mm_s; // Restore original feedrate
current_position[Z_AXIS] = old_z; // Restore Z and E positions
current_position[E_AXIS] = old_e;
SYNC_PLAN_POSITION_KINEMATIC(); // As if the move never took place

retracted[active_extruder] = retracting; // Active extruder now retracted / recovered

Expand Down
Loading