Skip to content

Start the extruder retract of a coordinated unload at once (unload fails mid-print) - #47

Open
marcelozani wants to merge 1 commit into
Kobra-S1:devfrom
marcelozani:fix/start-coordinated-extruder-retract
Open

marcelozani wants to merge 1 commit into
Kobra-S1:devfrom
marcelozani:fix/start-coordinated-extruder-retract

Conversation

@marcelozani

@marcelozani marcelozani commented Oct 30, 2026 •

Copy link
Copy Markdown

Problem

During a print, toolchange unloads (and the unload in PRINT_END) fail with

⚠ WARNING - Toolhead sensor still triggered after <N>mm retraction
Unload failed for T<n>

The same unload works when the printer is idle or paused, and Retry from the pause dialog always succeeds.

Root cause

In the coordinated retract of _smart_unload() (the non-transfer branch), the extruder retract is queued with _extruder_move(..., wait_for_move_end=False), which only calls toolhead.move(). The driver then starts the ACE retract and waits on it. While a print runs, Klipper keeps that move in its look-ahead until more moves arrive, and none arrive while the driver waits. So the extruder does not retract: its gears keep gripping the filament while the ACE pulls the whole length. Idle or paused, the toolhead flushes the move right away, which is why the retry works.

Evidence from klippy.log during a 27 s ACE retract mid-print: the Stats lines show print_time frozen at the same value and buffer_time=0.000, so the extruder move never reached the MCU.

Fix

Call _start_queued_toolhead_moves() right after queuing the extruder retract, before the ACE retract starts. That is the helper the intake-gated transfer already uses in _extruder_stretch() for the same reason. The move still runs concurrently with the ACE retract and is waited for with _wait_toolhead_move_finished() as before.

Tests

  • New test_coordinated_retract_starts_the_extruder_before_the_ace_pulls in tests/test_manager_unload_paths.py: checks the order extruder retract → start queued moves → ACE retract. It fails without the fix.
  • Three existing tests that drive this branch with a mocked _extruder_move now mock _start_queued_toolhead_moves too (tests/test_manager.py, tests/test_unload_rdm_guard.py).
  • bash tests/run_all_tests.sh: 2106 passed, 9 skipped, flake8 clean.

Hardware

Voron 2.4 with mainline Klipper, ACE Pro gen 1 (fw V1.3.863), Stealthburner + Clockwork 2 + FilamATrix cutter, toolhead sensor in front of the extruder gears.

I validated the fix on dev @ 7cf0d73 with the equivalent flush (toolhead.get_last_move_time()) inside _extruder_move(). A mid-print test G-code (heat, a few XY moves, Tn, more moves) failed 3 of 3 times before the fix. After it, the toolhead sensor cleared after 1.8 s, and unload, load, purge and the rest of the print were fine. This PR applies the same flush on top of current dev through the existing helper.

After that I still had a few unload failures with a different signature (the extruder moved, but the filament stayed at the gears). They were mechanical on my side, and since I fixed the mechanics the unload has not failed again. One more thing helped on a cutter toolhead: a short push forward right before the cut. The pressure keeps the filament from creeping up, so the cut tip stays clean and the next filament seats easily. I did that in my CUT_TIP macro, not in the driver, and this PR does not touch it.

🤖 Generated with Claude Code

The coordinated unload queues the extruder retract without waiting for
it and then waits on the ACE retract. While a print runs, Klipper keeps
that move in its look-ahead until more moves arrive, and none do while
the driver waits: the ACE pulls against the stationary extruder gears
and the unload ends with "Toolhead sensor still triggered". Idle or
paused the same unload works, so Retry from the pause always succeeds.

Hand the queued move to the steppers right away, as the intake-gated
transfer already does for its extruder stretches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant