From 6ee5f0850531155c5fd1553be9007131c38022eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 27 Nov 2022 11:36:56 +0000 Subject: [PATCH 1/4] PFW-1439 Compensate load to nozzle extruder sequence for Extra Loading Distance The Extra Loading Distance is configurable by the user. We need to compensate the hardcoded sequence such that it does not extrude too much or too little. Currently the firmware extrudes too little. --- Firmware/mmu2.cpp | 13 +++++++++---- Firmware/mmu2.h | 1 + Firmware/mmu2/variants/config_MMU2.h | 6 +++--- Firmware/mmu2/variants/config_MMU2S.h | 6 +++--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index f4c31af6d269..2d5c03e38c86 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -23,8 +23,6 @@ static_assert(EXTRUDERS==1); namespace MMU2 { -void execute_extruder_sequence(const E_Step *sequence, int steps); - template void waitForHotendTargetTemp(uint16_t delay, F f){ while (((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5)) { @@ -357,7 +355,7 @@ bool MMU2::tool_change(char code, uint8_t slot) { case 'c': { waitForHotendTargetTemp(100, []{}); - execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); + execute_load_to_nozzle_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); } break; } @@ -508,7 +506,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t slot) { ToolChangeCommon(slot); // Finish loading to the nozzle with finely tuned steps. - execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); + execute_load_to_nozzle_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); Sound_MakeSound(e_SOUND_TYPE_StandardConfirm); } lcd_update_enable(true); @@ -839,6 +837,13 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) { } } +void MMU2::execute_load_to_nozzle_sequence(const E_Step *sequence, uint8_t steps) { + st_synchronize(); + // Compensate for configurable Extra Loading Distance + current_position[E_AXIS] -= logic.ExtraLoadDistance(); + execute_extruder_sequence(sequence, steps); +} + void MMU2::ReportError(ErrorCode ec, ErrorSource res) { // Due to a potential lossy error reporting layers linked to this hook // we'd better report everything to make sure especially the error states diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index a38b7f235f6d..30a7f4fc7aa1 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -239,6 +239,7 @@ class MMU2 { void filament_ramming(); void execute_extruder_sequence(const E_Step *sequence, uint8_t steps); + void execute_load_to_nozzle_sequence(const E_Step *sequence, uint8_t steps); /// Reports an error into attached ExtUIs /// @param ec error code, see ErrorCode diff --git a/Firmware/mmu2/variants/config_MMU2.h b/Firmware/mmu2/variants/config_MMU2.h index f7a4a2b655c9..6942df8897c3 100644 --- a/Firmware/mmu2/variants/config_MMU2.h +++ b/Firmware/mmu2/variants/config_MMU2.h @@ -64,7 +64,7 @@ static constexpr E_Step ramming_sequence[] PROGMEM = { { -35.0F, 2000.0F / 60.F}, }; -static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { - { 10.0F, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast until filament reach end of nozzle - { 25.0F, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament is out of the nozzle +static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { + { MMU2_EXTRUDER_PTFE_LENGTH, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast while not at heatbreak + { MMU2_EXTRUDER_HEATBREAK_LENGTH, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament reaches heatbreak }; diff --git a/Firmware/mmu2/variants/config_MMU2S.h b/Firmware/mmu2/variants/config_MMU2S.h index eea700c53ed5..fdd7972bf68f 100644 --- a/Firmware/mmu2/variants/config_MMU2S.h +++ b/Firmware/mmu2/variants/config_MMU2S.h @@ -64,7 +64,7 @@ static constexpr E_Step ramming_sequence[] PROGMEM = { { -35.0F, 2000.0F / 60.F}, }; -static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { - { 10.0F, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast until filament reach end of nozzle - { 25.0F, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament is out of the nozzle +static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { + { MMU2_EXTRUDER_PTFE_LENGTH, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast while not at heatbreak + { MMU2_EXTRUDER_HEATBREAK_LENGTH, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament reaches heatbreak }; From c72ae8a2f37ac4ae405bfe4ab5ded1b1fd034042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 18 Dec 2022 14:24:16 +0000 Subject: [PATCH 2/4] PFW-1439 Remove parameters from execute_load_to_nozzle_sequence --- Firmware/mmu2.cpp | 8 ++++---- Firmware/mmu2.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 2d5c03e38c86..70a217c6b2b7 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -355,7 +355,7 @@ bool MMU2::tool_change(char code, uint8_t slot) { case 'c': { waitForHotendTargetTemp(100, []{}); - execute_load_to_nozzle_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); + execute_load_to_nozzle_sequence(); } break; } @@ -506,7 +506,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t slot) { ToolChangeCommon(slot); // Finish loading to the nozzle with finely tuned steps. - execute_load_to_nozzle_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); + execute_load_to_nozzle_sequence(); Sound_MakeSound(e_SOUND_TYPE_StandardConfirm); } lcd_update_enable(true); @@ -837,11 +837,11 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) { } } -void MMU2::execute_load_to_nozzle_sequence(const E_Step *sequence, uint8_t steps) { +void MMU2::execute_load_to_nozzle_sequence() { st_synchronize(); // Compensate for configurable Extra Loading Distance current_position[E_AXIS] -= logic.ExtraLoadDistance(); - execute_extruder_sequence(sequence, steps); + execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); } void MMU2::ReportError(ErrorCode ec, ErrorSource res) { diff --git a/Firmware/mmu2.h b/Firmware/mmu2.h index 30a7f4fc7aa1..cf5a1aa15a30 100644 --- a/Firmware/mmu2.h +++ b/Firmware/mmu2.h @@ -239,7 +239,7 @@ class MMU2 { void filament_ramming(); void execute_extruder_sequence(const E_Step *sequence, uint8_t steps); - void execute_load_to_nozzle_sequence(const E_Step *sequence, uint8_t steps); + void execute_load_to_nozzle_sequence(); /// Reports an error into attached ExtUIs /// @param ec error code, see ErrorCode From 70356b71df8e8e53273dd64b9836fc074e769bc0 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Mon, 19 Dec 2022 23:41:43 +0100 Subject: [PATCH 3/4] Handle filament sensor position that is not 0 --- Firmware/mmu2.cpp | 6 +++--- Firmware/mmu2/variants/config_MMU2.h | 4 +++- Firmware/mmu2/variants/config_MMU2S.h | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 70a217c6b2b7..1a28579f6bb8 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -249,9 +249,9 @@ bool MMU2::VerifyFilamentEnteredPTFE() uint8_t fsensorState = 0; // MMU has finished its load, push the filament further by some defined constant length // If the filament sensor reads 0 at any moment, then report FAILURE - current_position[E_AXIS] += MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - logic.ExtraLoadDistance(); + current_position[E_AXIS] += MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - MMU2_LOAD_DISTANCE_PAST_GEARS; plan_buffer_line_curposXYZE(MMU2_LOAD_TO_NOZZLE_FEED_RATE); - current_position[E_AXIS] -= (MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - logic.ExtraLoadDistance()); + current_position[E_AXIS] -= (MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - MMU2_LOAD_DISTANCE_PAST_GEARS); plan_buffer_line_curposXYZE(MMU2_LOAD_TO_NOZZLE_FEED_RATE); while(blocks_queued()) @@ -840,7 +840,7 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) { void MMU2::execute_load_to_nozzle_sequence() { st_synchronize(); // Compensate for configurable Extra Loading Distance - current_position[E_AXIS] -= logic.ExtraLoadDistance(); + current_position[E_AXIS] -= MMU2_LOAD_DISTANCE_PAST_GEARS; execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); } diff --git a/Firmware/mmu2/variants/config_MMU2.h b/Firmware/mmu2/variants/config_MMU2.h index 6942df8897c3..dfcfb7e6044e 100644 --- a/Firmware/mmu2/variants/config_MMU2.h +++ b/Firmware/mmu2/variants/config_MMU2.h @@ -23,7 +23,9 @@ static constexpr float MMU2_LOAD_TO_NOZZLE_LENGTH = 87.0F + 5.0F; // Beware - this value is used to initialize the MMU logic layer - it will be sent to the MMU upon line up (written into its 8bit register 0x0b) // However - in the G-code we can get a request to set the extra load distance at runtime to something else (M708 A0xb Xsomething). // The printer intercepts such a call and sets its extra load distance to match the new value as well. -static constexpr uint8_t MMU2_TOOL_CHANGE_LOAD_LENGTH = 5 + 16; // mm +static constexpr float MMU2_FILAMENT_SENSOR_POSITION = 16; // mm +static constexpr float MMU2_LOAD_DISTANCE_PAST_GEARS = 5; // mm +static constexpr uint8_t MMU2_TOOL_CHANGE_LOAD_LENGTH = static_cast(MMU2_FILAMENT_SENSOR_POSITION + MMU2_LOAD_DISTANCE_PAST_GEARS); // mm static constexpr float MMU2_EXTRUDER_PTFE_LENGTH = 50.f; // mm static constexpr float MMU2_EXTRUDER_HEATBREAK_LENGTH = 17.7f; // mm diff --git a/Firmware/mmu2/variants/config_MMU2S.h b/Firmware/mmu2/variants/config_MMU2S.h index fdd7972bf68f..46d55c4040b8 100644 --- a/Firmware/mmu2/variants/config_MMU2S.h +++ b/Firmware/mmu2/variants/config_MMU2S.h @@ -23,7 +23,9 @@ static constexpr float MMU2_LOAD_TO_NOZZLE_LENGTH = 87.0F + 5.0F; // Beware - this value is used to initialize the MMU logic layer - it will be sent to the MMU upon line up (written into its 8bit register 0x0b) // However - in the G-code we can get a request to set the extra load distance at runtime to something else (M708 A0xb Xsomething). // The printer intercepts such a call and sets its extra load distance to match the new value as well. -static constexpr uint8_t MMU2_TOOL_CHANGE_LOAD_LENGTH = 5; // mm +static constexpr float MMU2_FILAMENT_SENSOR_POSITION = 0; // mm +static constexpr float MMU2_LOAD_DISTANCE_PAST_GEARS = 5; // mm +static constexpr uint8_t MMU2_TOOL_CHANGE_LOAD_LENGTH = static_cast(MMU2_FILAMENT_SENSOR_POSITION + MMU2_LOAD_DISTANCE_PAST_GEARS); // mm static constexpr float MMU2_EXTRUDER_PTFE_LENGTH = 42.3f; // mm static constexpr float MMU2_EXTRUDER_HEATBREAK_LENGTH = 17.7f; // mm From 62ea78d46e5de75e6e7cd9a9d64ae9318e103b6b Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Mon, 19 Dec 2022 23:49:12 +0100 Subject: [PATCH 4/4] Handle configurable distance past gears --- Firmware/mmu2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 1a28579f6bb8..3b66a368b732 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -249,9 +249,9 @@ bool MMU2::VerifyFilamentEnteredPTFE() uint8_t fsensorState = 0; // MMU has finished its load, push the filament further by some defined constant length // If the filament sensor reads 0 at any moment, then report FAILURE - current_position[E_AXIS] += MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - MMU2_LOAD_DISTANCE_PAST_GEARS; + current_position[E_AXIS] += MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - (logic.ExtraLoadDistance() - MMU2_FILAMENT_SENSOR_POSITION); plan_buffer_line_curposXYZE(MMU2_LOAD_TO_NOZZLE_FEED_RATE); - current_position[E_AXIS] -= (MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - MMU2_LOAD_DISTANCE_PAST_GEARS); + current_position[E_AXIS] -= (MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - (logic.ExtraLoadDistance() - MMU2_FILAMENT_SENSOR_POSITION)); plan_buffer_line_curposXYZE(MMU2_LOAD_TO_NOZZLE_FEED_RATE); while(blocks_queued()) @@ -840,7 +840,7 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) { void MMU2::execute_load_to_nozzle_sequence() { st_synchronize(); // Compensate for configurable Extra Loading Distance - current_position[E_AXIS] -= MMU2_LOAD_DISTANCE_PAST_GEARS; + current_position[E_AXIS] -= (logic.ExtraLoadDistance() - MMU2_FILAMENT_SENSOR_POSITION); execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0])); }