Fix Z home movement when XY already at TLS position

When X and Y coordinates are already at the tool length sensor (TLS)
position during tool change restore, Z was incorrectly not moving to
the home position after probing.

The issue was in the restore() function where Z movement was only
executed inside a conditional block that checked if XY needed to move.
This caused Z to remain at the probed position when starting from the
TLS XY location.

Fixed by decoupling Z home movement from XY position comparison,
ensuring Z always returns to home after probing (unless $346
disables full position restore).
This commit is contained in:
Greg Cormier
2025-12-20 11:39:46 -05:00
parent aaa7b6e73e
commit c5d888fdee
+8 -6
View File
@@ -139,18 +139,20 @@ static void reset (void)
// Restore coolant and spindle status, return controlled point to original position.
static bool restore (void)
{
bool ok;
bool ok = true;
plan_line_data_t plan_data;
plan_data_init(&plan_data);
plan_data.condition.rapid_motion = On;
if(!(ok = (target.values[plane.axis_0] == previous.values[plane.axis_0] &&
target.values[plane.axis_1] == previous.values[plane.axis_1]))) {
// Always move Z to home position first (unless full restore is disabled)
target.values[plane.axis_linear] = sys.home_position[plane.axis_linear];
ok = mc_line(target.values, &plan_data);
target.values[plane.axis_linear] = sys.home_position[plane.axis_linear];
if((ok = mc_line(target.values, &plan_data)) && !settings.flags.no_restore_position_after_M6) {
// Then move XY to previous position if needed and full restore is enabled
if(ok && !settings.flags.no_restore_position_after_M6) {
if(target.values[plane.axis_0] != previous.values[plane.axis_0] ||
target.values[plane.axis_1] != previous.values[plane.axis_1]) {
memcpy(&target, &previous, sizeof(coord_data_t));
target.values[plane.axis_linear] = sys.home_position[plane.axis_linear];
ok = mc_line(target.values, &plan_data);