1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-27 13:56:24 +00:00

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.
This commit is contained in:
Scott Lahteine 2018-03-29 18:42:31 -05:00
parent ac7e97f4fe
commit 53f0c7522a

View File

@ -125,7 +125,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
@ -144,22 +143,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