Skip to content

Commit 8414c27

Browse files
authored
Merge pull request MarlinFirmware#3787 from gudnimg/PFW-1439
PFW-1448 Fix underextrusion + compensate load to nozzle extruder sequence for Extra Loading Distance
2 parents 775cabb + 62ea78d commit 8414c27

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

Firmware/mmu2.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ static_assert(EXTRUDERS==1);
2323

2424
namespace MMU2 {
2525

26-
void execute_extruder_sequence(const E_Step *sequence, int steps);
27-
2826
template<typename F>
2927
void waitForHotendTargetTemp(uint16_t delay, F f){
3028
while (((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5)) {
@@ -251,9 +249,9 @@ bool MMU2::VerifyFilamentEnteredPTFE()
251249
uint8_t fsensorState = 0;
252250
// MMU has finished its load, push the filament further by some defined constant length
253251
// If the filament sensor reads 0 at any moment, then report FAILURE
254-
current_position[E_AXIS] += MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - logic.ExtraLoadDistance();
252+
current_position[E_AXIS] += MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - (logic.ExtraLoadDistance() - MMU2_FILAMENT_SENSOR_POSITION);
255253
plan_buffer_line_curposXYZE(MMU2_LOAD_TO_NOZZLE_FEED_RATE);
256-
current_position[E_AXIS] -= (MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - logic.ExtraLoadDistance());
254+
current_position[E_AXIS] -= (MMU2_EXTRUDER_PTFE_LENGTH + MMU2_EXTRUDER_HEATBREAK_LENGTH - (logic.ExtraLoadDistance() - MMU2_FILAMENT_SENSOR_POSITION));
257255
plan_buffer_line_curposXYZE(MMU2_LOAD_TO_NOZZLE_FEED_RATE);
258256

259257
while(blocks_queued())
@@ -357,7 +355,7 @@ bool MMU2::tool_change(char code, uint8_t slot) {
357355

358356
case 'c': {
359357
waitForHotendTargetTemp(100, []{});
360-
execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0]));
358+
execute_load_to_nozzle_sequence();
361359
} break;
362360
}
363361

@@ -508,7 +506,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t slot) {
508506
ToolChangeCommon(slot);
509507

510508
// Finish loading to the nozzle with finely tuned steps.
511-
execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0]));
509+
execute_load_to_nozzle_sequence();
512510
Sound_MakeSound(e_SOUND_TYPE_StandardConfirm);
513511
}
514512
lcd_update_enable(true);
@@ -839,6 +837,13 @@ void MMU2::execute_extruder_sequence(const E_Step *sequence, uint8_t steps) {
839837
}
840838
}
841839

840+
void MMU2::execute_load_to_nozzle_sequence() {
841+
st_synchronize();
842+
// Compensate for configurable Extra Loading Distance
843+
current_position[E_AXIS] -= (logic.ExtraLoadDistance() - MMU2_FILAMENT_SENSOR_POSITION);
844+
execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0]));
845+
}
846+
842847
void MMU2::ReportError(ErrorCode ec, ErrorSource res) {
843848
// Due to a potential lossy error reporting layers linked to this hook
844849
// we'd better report everything to make sure especially the error states

Firmware/mmu2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class MMU2 {
239239

240240
void filament_ramming();
241241
void execute_extruder_sequence(const E_Step *sequence, uint8_t steps);
242+
void execute_load_to_nozzle_sequence();
242243

243244
/// Reports an error into attached ExtUIs
244245
/// @param ec error code, see ErrorCode

Firmware/mmu2/variants/config_MMU2.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ static constexpr float MMU2_LOAD_TO_NOZZLE_LENGTH = 87.0F + 5.0F;
2323
// 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)
2424
// However - in the G-code we can get a request to set the extra load distance at runtime to something else (M708 A0xb Xsomething).
2525
// The printer intercepts such a call and sets its extra load distance to match the new value as well.
26-
static constexpr uint8_t MMU2_TOOL_CHANGE_LOAD_LENGTH = 5 + 16; // mm
26+
static constexpr float MMU2_FILAMENT_SENSOR_POSITION = 16; // mm
27+
static constexpr float MMU2_LOAD_DISTANCE_PAST_GEARS = 5; // mm
28+
static constexpr uint8_t MMU2_TOOL_CHANGE_LOAD_LENGTH = static_cast<uint8_t>(MMU2_FILAMENT_SENSOR_POSITION + MMU2_LOAD_DISTANCE_PAST_GEARS); // mm
2729

2830
static constexpr float MMU2_EXTRUDER_PTFE_LENGTH = 50.f; // mm
2931
static constexpr float MMU2_EXTRUDER_HEATBREAK_LENGTH = 17.7f; // mm
@@ -64,7 +66,7 @@ static constexpr E_Step ramming_sequence[] PROGMEM = {
6466
{ -35.0F, 2000.0F / 60.F},
6567
};
6668

67-
static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = {
68-
{ 10.0F, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast until filament reach end of nozzle
69-
{ 25.0F, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament is out of the nozzle
69+
static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = {
70+
{ MMU2_EXTRUDER_PTFE_LENGTH, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast while not at heatbreak
71+
{ MMU2_EXTRUDER_HEATBREAK_LENGTH, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament reaches heatbreak
7072
};

Firmware/mmu2/variants/config_MMU2S.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ static constexpr float MMU2_LOAD_TO_NOZZLE_LENGTH = 87.0F + 5.0F;
2323
// 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)
2424
// However - in the G-code we can get a request to set the extra load distance at runtime to something else (M708 A0xb Xsomething).
2525
// The printer intercepts such a call and sets its extra load distance to match the new value as well.
26-
static constexpr uint8_t MMU2_TOOL_CHANGE_LOAD_LENGTH = 5; // mm
26+
static constexpr float MMU2_FILAMENT_SENSOR_POSITION = 0; // mm
27+
static constexpr float MMU2_LOAD_DISTANCE_PAST_GEARS = 5; // mm
28+
static constexpr uint8_t MMU2_TOOL_CHANGE_LOAD_LENGTH = static_cast<uint8_t>(MMU2_FILAMENT_SENSOR_POSITION + MMU2_LOAD_DISTANCE_PAST_GEARS); // mm
2729

2830
static constexpr float MMU2_EXTRUDER_PTFE_LENGTH = 42.3f; // mm
2931
static constexpr float MMU2_EXTRUDER_HEATBREAK_LENGTH = 17.7f; // mm
@@ -64,7 +66,7 @@ static constexpr E_Step ramming_sequence[] PROGMEM = {
6466
{ -35.0F, 2000.0F / 60.F},
6567
};
6668

67-
static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = {
68-
{ 10.0F, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast until filament reach end of nozzle
69-
{ 25.0F, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament is out of the nozzle
69+
static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = {
70+
{ MMU2_EXTRUDER_PTFE_LENGTH, 810.0F / 60.F}, // feed rate = 13.5mm/s - Load fast while not at heatbreak
71+
{ MMU2_EXTRUDER_HEATBREAK_LENGTH, 198.0F / 60.F}, // feed rate = 3.3mm/s - Load slower once filament reaches heatbreak
7072
};

0 commit comments

Comments
 (0)