Skip to content

Commit

Permalink
Merge pull request MarlinFirmware#3787 from gudnimg/PFW-1439
Browse files Browse the repository at this point in the history
PFW-1448 Fix underextrusion + compensate load to nozzle extruder sequence for Extra Loading Distance
  • Loading branch information
leptun authored Dec 22, 2022
2 parents 775cabb + 62ea78d commit 8414c27
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
17 changes: 11 additions & 6 deletions Firmware/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ static_assert(EXTRUDERS==1);

namespace MMU2 {

void execute_extruder_sequence(const E_Step *sequence, int steps);

template<typename F>
void waitForHotendTargetTemp(uint16_t delay, F f){
while (((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5)) {
Expand Down Expand Up @@ -251,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 - (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 - logic.ExtraLoadDistance());
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())
Expand Down Expand Up @@ -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();
} break;
}

Expand Down Expand Up @@ -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();
Sound_MakeSound(e_SOUND_TYPE_StandardConfirm);
}
lcd_update_enable(true);
Expand Down Expand Up @@ -839,6 +837,13 @@ 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() - 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]));
}

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
Expand Down
1 change: 1 addition & 0 deletions Firmware/mmu2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/// Reports an error into attached ExtUIs
/// @param ec error code, see ErrorCode
Expand Down
10 changes: 6 additions & 4 deletions Firmware/mmu2/variants/config_MMU2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>(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
Expand Down Expand Up @@ -64,7 +66,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
};
10 changes: 6 additions & 4 deletions Firmware/mmu2/variants/config_MMU2S.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8_t>(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
Expand Down Expand Up @@ -64,7 +66,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
};

0 comments on commit 8414c27

Please sign in to comment.