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.
2.0.x
Scott Lahteine 7 years ago
parent ac7e97f4fe
commit 53f0c7522a

@ -125,7 +125,6 @@ void FWRetract::retract(const bool retracting
SERIAL_ECHOLNPAIR("hop_amount ", hop_amount); 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; const float old_feedrate_mm_s = feedrate_mm_s;
// The current position will be the destination for E and Z moves // The current position will be the destination for E and Z moves
@ -144,22 +143,24 @@ void FWRetract::retract(const bool retracting
// Is a Z hop set, and has the hop not yet been done? // Is a Z hop set, and has the hop not yet been done?
// No double zlifting // No double zlifting
// Feedrate to the max // Feedrate to the max
if (has_zhop && !hop_amount) { if (retract_zlift > 0.01 && !hop_amount) { // Apply hop only once
hop_amount += retract_zlift; // Carriage is raised for retraction hop const float old_z = current_position[Z_AXIS];
feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max hop_amount += retract_zlift; // Add to the hop total (again, only once)
current_position[Z_AXIS] -= retract_zlift; // Pretend current pos is lower. Next move raises Z. destination[Z_AXIS] += retract_zlift; // Raise Z by the zlift (M207 Z) amount
SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Maximum Z feedrate
prepare_move_to_destination(); // Raise up to the old current pos 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 { else {
// If a hop was done and Z hasn't changed, undo the Z hop // If a hop was done and Z hasn't changed, undo the Z hop
if (hop_amount) { if (hop_amount) {
current_position[Z_AXIS] += retract_zlift; // Pretend current pos is higher. Next move lowers Z. current_position[Z_AXIS] += hop_amount; // Set actual Z (due to the prior hop)
SYNC_PLAN_POSITION_KINEMATIC(); // Set the planner to the new position
feedrate_mm_s = planner.max_feedrate_mm_s[Z_AXIS]; // Z feedrate to max 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 prepare_move_to_destination(); // Lower Z and update current_position
hop_amount = 0.0; // Clear hop 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 // A retract multiplier has been added here to get faster swap recovery

Loading…
Cancel
Save