From 6bdc3c5cfb17c8168e11bb58d1df5dd8c389dace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 25 Mar 2023 09:08:14 +0000 Subject: [PATCH 1/3] Improve MMU toolchange when E-cool mode is enabled Currently we are queuing many small 2 mm E-moves until the filament sensor triggers. We do this because we never abort any queued moves, so making small 2 mm moves ensures we do not move the E-motor more than 2 mm past the filament sensor. Unfortunately, when E-cool mode is enabled, the E-motor will create audible clicking sounds (similar one hears during jam or a loose grub screw). A workaround for this is to queue one or more very long moves. Where very long is something of the order of hundreds of millimeters. I have it set to 350 mm but it's just a random constant really. Keep in mind the firmware will block too large E-moves, if I recall correctly it was anything above > 450 mm (see PREVENT_LENGTHY_EXTRUDE) In order to use very long moves, we must somehow stop the E-motor from moving once the filament sensor triggers. In other words, throw away what's left of the current E-motor move. For this simple purpose we can use planner_abort_hard() but we must set planner_aborted to false afterwards because the code architecture does not allow the main loop() to run until the Toolchange command is done processing. Change in memory: Flash: +18 bytes SRAM: 0 bytes --- Firmware/mmu2.cpp | 8 +++++++- Firmware/mmu2_marlin.h | 1 + Firmware/mmu2_marlin1.cpp | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 62b46375e..8c07a3f6a 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -922,10 +922,12 @@ void MMU2::ReportError(ErrorCode ec, ErrorSource res) { switch (logic.Progress()) { case ProgressCode::UnloadingToFinda: unloadFilamentStarted = false; + planner_abort_queued_moves(); // Abort excess E-moves to be safe break; case ProgressCode::FeedingToFSensor: // FSENSOR error during load. Make sure E-motor stops moving. loadFilamentStarted = false; + planner_abort_queued_moves(); // Abort excess E-moves to be safe break; default: break; @@ -1040,6 +1042,10 @@ void MMU2::OnMMUProgressMsgSame(ProgressCode pc) { case FilamentState::AT_FSENSOR: // fsensor triggered, finish FeedingToExtruder state loadFilamentStarted = false; + + // Abort any excess E-move from the planner queue + planner_abort_queued_moves(); + // After the MMU knows the FSENSOR is triggered it will: // 1. Push the filament by additional 30mm (see fsensorToNozzle) // 2. Disengage the idler and push another 2mm. @@ -1048,7 +1054,7 @@ void MMU2::OnMMUProgressMsgSame(ProgressCode pc) { case FilamentState::NOT_PRESENT: // fsensor not triggered, continue moving extruder if (!planner_any_moves()) { // Only plan a move if there is no move ongoing - MoveE(2.0f, MMU2_LOAD_TO_NOZZLE_FEED_RATE); + MoveE(350.0f, MMU2_LOAD_TO_NOZZLE_FEED_RATE); } break; default: diff --git a/Firmware/mmu2_marlin.h b/Firmware/mmu2_marlin.h index 199de649e..0877a60f8 100644 --- a/Firmware/mmu2_marlin.h +++ b/Firmware/mmu2_marlin.h @@ -26,6 +26,7 @@ void MoveE(float delta, float feedRate); float MoveRaiseZ(float delta); +void planner_abort_queued_moves(); void planner_synchronize(); bool planner_any_moves(); float planner_get_machine_position_E_mm(); diff --git a/Firmware/mmu2_marlin1.cpp b/Firmware/mmu2_marlin1.cpp index 07f3c01b5..c197d2b01 100644 --- a/Firmware/mmu2_marlin1.cpp +++ b/Firmware/mmu2_marlin1.cpp @@ -18,6 +18,11 @@ float MoveRaiseZ(float delta) { return raise_z(delta); } +void planner_abort_queued_moves() { + planner_abort_hard(); + planner_aborted = false; +} + void planner_synchronize() { st_synchronize(); } From 4342217159d8c3a4f02783936b8338550d084073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 26 Mar 2023 08:54:47 +0000 Subject: [PATCH 2/3] Add comment about planner_aborted = false --- Firmware/mmu2_marlin1.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Firmware/mmu2_marlin1.cpp b/Firmware/mmu2_marlin1.cpp index c197d2b01..58ce99171 100644 --- a/Firmware/mmu2_marlin1.cpp +++ b/Firmware/mmu2_marlin1.cpp @@ -20,6 +20,12 @@ float MoveRaiseZ(float delta) { void planner_abort_queued_moves() { planner_abort_hard(); + + // Unblock the planner. This should be safe in the + // toolchange context. Currently we are mainly aborting + // excess E-moves after detecting filament during toolchange. + // If a MMU error is reported, the planner must be unblocked + // as well so the extruder can be parked safely. planner_aborted = false; } From 138654e207de678aaca01ef0831dbb79220dc8be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 26 Mar 2023 09:16:07 +0000 Subject: [PATCH 3/3] Add comment Note we cannot use too long extrusions --- Firmware/mmu2.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 8c07a3f6a..e047643ef 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -1054,6 +1054,11 @@ void MMU2::OnMMUProgressMsgSame(ProgressCode pc) { case FilamentState::NOT_PRESENT: // fsensor not triggered, continue moving extruder if (!planner_any_moves()) { // Only plan a move if there is no move ongoing + // Plan a very long move, where 'very long' is hundreds + // of millimeters. Keep in mind though the move can't be much longer + // than 450mm because the firmware will ignore too long extrusions + // for safety reasons. See PREVENT_LENGTHY_EXTRUDE. + // Use 350mm to be safely away from the prevention threshold MoveE(350.0f, MMU2_LOAD_TO_NOZZLE_FEED_RATE); } break;