From 29b048810c6b99ae080a85e6d067301c28ae5205 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 25 Mar 2018 15:00:42 -0400 Subject: [PATCH] Symmetrical FWRETRACT Z Hop Do the Z lift normally before setting Z back to its prior value. But do the Z lower using spoofing. This should produce proper symmetrical movement. --- Marlin/fwretract.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Marlin/fwretract.cpp b/Marlin/fwretract.cpp index b2e5f19068..2caa9222ce 100644 --- a/Marlin/fwretract.cpp +++ b/Marlin/fwretract.cpp @@ -126,7 +126,6 @@ void FWRetract::retract(const bool retracting SERIAL_ECHOLNPAIR("hop_amount ", hop_amount); //*/ - const bool has_zhop = retract_zlift > 0.01; // Is there a hop set? const float old_feedrate_mm_s = feedrate_mm_s; // The current position will be the destination for E and Z moves @@ -145,22 +144,24 @@ void FWRetract::retract(const bool retracting // Is a Z hop set, and has the hop not yet been done? // No double zlifting // Feedrate to the max - if (has_zhop && !hop_amount) { - hop_amount += retract_zlift; // Carriage is raised for retraction hop - feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max - current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z. - SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position + 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 to the old current pos + current_position[Z_AXIS] = old_z; // Spoof the Z position + 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] += retract_zlift; // Pretend current pos is higher. Next move lowers Z. - SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position + current_position[Z_AXIS] += hop_amount; // Set actual Z (due to the prior hop) feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max - prepare_move_to_destination(); // Lower down to the old current pos - hop_amount = 0.0; // Clear hop + prepare_move_to_destination(); // Lower Z and update current_position + SYNC_PLAN_POSITION_KINEMATIC(); // Update the planner + hop_amount = 0.0; // Clear the hop amount } // A retract multiplier has been added here to get faster swap recovery