Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced MMU2 S Mode spins the BMG gears during C0 #19429

Merged
merged 36 commits into from
Sep 26, 2020
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3725784
PRUSA_MMU2_S_MODE_ENHACEMENT
isanval Jul 11, 2020
d434a56
some clean up
isanval Jul 11, 2020
4f1d965
more cleanup
isanval Jul 11, 2020
da9edfb
some little more cleanup
isanval Jul 11, 2020
f498917
cleanup
isanval Jul 11, 2020
af45d06
renaming functions
isanval Jul 11, 2020
3035b78
new conditionals
isanval Jul 11, 2020
cdededc
bugfix
isanval Jul 11, 2020
039c802
more bugfixing
isanval Jul 12, 2020
d875e5f
striping debug
isanval Jul 12, 2020
62af9f2
cleanup
isanval Jul 12, 2020
73cee48
mooore cleanup
isanval Jul 12, 2020
d6304ca
"final" cleanup
isanval Jul 12, 2020
3a23012
bugs fixed or introduced?
isanval Jul 12, 2020
52fc637
more testing
isanval Jul 12, 2020
35d9ebc
PRUSA_MMU2_S_MODE_ENHACEMENT
isanval Jul 11, 2020
70bd365
some clean up
isanval Jul 11, 2020
971a7c1
more cleanup
isanval Jul 11, 2020
aa84ba1
some little more cleanup
isanval Jul 11, 2020
70ad7f0
cleanup
isanval Jul 11, 2020
5c71e5a
renaming functions
isanval Jul 11, 2020
86b0003
new conditionals
isanval Jul 11, 2020
7cdc164
bugfix
isanval Jul 11, 2020
9d32064
more bugfixing
isanval Jul 12, 2020
2257bd5
striping debug
isanval Jul 12, 2020
51f2373
cleanup
isanval Jul 12, 2020
52ae2a2
mooore cleanup
isanval Jul 12, 2020
05b8a06
"final" cleanup
isanval Jul 12, 2020
ee0d70f
bugs fixed or introduced?
isanval Jul 12, 2020
01e5ada
more testing
isanval Jul 12, 2020
ad9d50f
Merge branch 'bugfix-2.0.x' of https://github.com/isanval/Marlin into…
isanval Jul 24, 2020
b04fcd2
removed some unneded code
isanval Jul 24, 2020
dd42670
remove unneded code
isanval Jul 24, 2020
b2410fe
blank space...
isanval Jul 24, 2020
d67a4b6
Clean up
thinkyhead Sep 26, 2020
ee331df
Add MMU2_COMMAND
thinkyhead Sep 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 44 additions & 23 deletions Marlin/src/feature/mmu2/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ MMU2 mmu2;
#define MMU_CMD_TIMEOUT 45000UL // 45s timeout for mmu commands (except P0)
#define MMU_P0_TIMEOUT 3000UL // Timeout for P0 command: 3seconds

#define MMU2_COMMAND(S) tx_str_P(PSTR(S "\n"))

#if ENABLED(MMU_EXTRUDER_SENSOR)
uint8_t mmu_idl_sens = 0;
static bool mmu_loading_flag = false;
Expand Down Expand Up @@ -152,7 +154,7 @@ void MMU2::reset() {
safe_delay(20);
WRITE(MMU2_RST_PIN, HIGH);
#else
tx_str_P(PSTR("X0\n")); // Send soft reset
MMU2_COMMAND("X0"); // Send soft reset
#endif
}

Expand All @@ -175,9 +177,7 @@ void MMU2::mmu_loop() {
DEBUG_ECHOLNPGM("MMU => 'start'");
DEBUG_ECHOLNPGM("MMU <= 'S1'");

// send "read version" request
tx_str_P(PSTR("S1\n"));

MMU2_COMMAND("S1"); // Read Version
state = -2;
}
else if (millis() > 3000000) {
Expand All @@ -192,7 +192,7 @@ void MMU2::mmu_loop() {

DEBUG_ECHOLNPAIR("MMU => ", version, "\nMMU <= 'S2'");

tx_str_P(PSTR("S2\n")); // read build number
MMU2_COMMAND("S2"); // Read Build Number
state = -3;
}
break;
Expand All @@ -208,13 +208,13 @@ void MMU2::mmu_loop() {
#if ENABLED(MMU2_MODE_12V)
DEBUG_ECHOLNPGM("MMU <= 'M1'");

tx_str_P(PSTR("M1\n")); // switch to stealth mode
MMU2_COMMAND("M1"); // Stealth Mode
state = -5;

#else
DEBUG_ECHOLNPGM("MMU <= 'P0'");

tx_str_P(PSTR("P0\n")); // read finda
MMU2_COMMAND("P0"); // Read FINDA
state = -4;
#endif
}
Expand All @@ -228,7 +228,7 @@ void MMU2::mmu_loop() {

DEBUG_ECHOLNPGM("MMU <= 'P0'");

tx_str_P(PSTR("P0\n")); // read finda
MMU2_COMMAND("P0"); // Read FINDA
state = -4;
}
break;
Expand Down Expand Up @@ -266,14 +266,14 @@ void MMU2::mmu_loop() {
else if (cmd == MMU_CMD_C0) {
// continue loading
DEBUG_ECHOLNPGM("MMU <= 'C0'");
tx_str_P(PSTR("C0\n"));
MMU2_COMMAND("C0");
state = 3; // wait for response
}
else if (cmd == MMU_CMD_U0) {
// unload current
DEBUG_ECHOLNPGM("MMU <= 'U0'");

tx_str_P(PSTR("U0\n"));
MMU2_COMMAND("U0");
state = 3; // wait for response
}
else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E4)) {
Expand All @@ -286,7 +286,7 @@ void MMU2::mmu_loop() {
else if (cmd == MMU_CMD_R0) {
// recover after eject
DEBUG_ECHOLNPGM("MMU <= 'R0'");
tx_str_P(PSTR("R0\n"));
MMU2_COMMAND("R0");
state = 3; // wait for response
}
else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F4)) {
Expand All @@ -303,8 +303,7 @@ void MMU2::mmu_loop() {
cmd = MMU_CMD_NONE;
}
else if (ELAPSED(millis(), prev_P0_request + 300)) {
// read FINDA
tx_str_P(PSTR("P0\n"));
MMU2_COMMAND("P0"); // Read FINDA
state = 2; // wait for response
}

Expand Down Expand Up @@ -332,19 +331,32 @@ void MMU2::mmu_loop() {
#if ENABLED(MMU_EXTRUDER_SENSOR)
if (mmu_idl_sens) {
if (FILAMENT_PRESENT() && mmu_loading_flag) {
DEBUG_ECHOLNPGM("MMU <= 'A'\n");
tx_str_P(PSTR("A\n")); // send 'abort' request
DEBUG_ECHOLNPGM("MMU <= 'A'");
MMU2_COMMAND("A"); // send 'abort' request
mmu_idl_sens = 0;
DEBUG_ECHOLNPGM("MMU IDLER_SENSOR = 0 - ABORT\n");
DEBUG_ECHOLNPGM("MMU IDLER_SENSOR = 0 - ABORT");
}
}
#endif

if (rx_ok()) {
DEBUG_ECHOLNPGM("MMU => 'ok'");
ready = true;
state = 1;
last_cmd = MMU_CMD_NONE;
// response to C0 mmu command in PRUSA_MMU2_S_MODE
bool can_reset = true;
if (ENABLED(PRUSA_MMU2_S_MODE) && last_cmd == MMU_CMD_C0) {
if (!mmu2s_triggered) {
can_reset = false;
// MMU ok received but filament sensor not triggered, retrying...
DEBUG_ECHOLNPGM("MMU => 'ok' (filament not present in gears)");
DEBUG_ECHOLNPGM("MMU <= 'C0' (keep trying)");
MMU2_COMMAND("C0");
}
}
if (can_reset) {
DEBUG_ECHOLNPGM("MMU => 'ok'");
ready = true;
state = 1;
last_cmd = MMU_CMD_NONE;
}
}
else if (ELAPSED(millis(), prev_request + MMU_CMD_TIMEOUT)) {
// resend request after timeout
Expand Down Expand Up @@ -862,9 +874,18 @@ void MMU2::filament_runout() {

void MMU2::check_filament() {
const bool present = FILAMENT_PRESENT();
if (present && !mmu2s_triggered) {
DEBUG_ECHOLNPGM("MMU <= 'A'");
tx_str_P(PSTR("A\n"));
if (cmd == MMU_CMD_NONE && last_cmd == MMU_CMD_C0) {
if (present && !mmu2s_triggered) {
DEBUG_ECHOLNPGM("MMU <= 'A'");
tx_str_P(PSTR("A\n"));
}
// Slowly spin the extruder during C0
else {
while (planner.movesplanned() < 3) {
current_position.e += 0.25;
line_to_current_position(MMM_TO_MMS(120));
}
}
}
mmu2s_triggered = present;
}
Expand Down