From 70356b71df8e8e53273dd64b9836fc074e769bc0 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Mon, 19 Dec 2022 23:41:43 +0100 Subject: [PATCH] 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 70a217c6b..1a28579f6 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 6942df889..dfcfb7e60 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 fdd7972bf..46d55c404 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