|
|
@ -91,6 +91,9 @@ MMU2 mmu2;
|
|
|
|
#define mmuSerial MMU2_SERIAL
|
|
|
|
#define mmuSerial MMU2_SERIAL
|
|
|
|
|
|
|
|
|
|
|
|
bool MMU2::enabled, MMU2::ready, MMU2::mmu_print_saved;
|
|
|
|
bool MMU2::enabled, MMU2::ready, MMU2::mmu_print_saved;
|
|
|
|
|
|
|
|
#if ENABLED(PRUSA_MMU2_S_MODE)
|
|
|
|
|
|
|
|
bool MMU2::mmu2s_triggered;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
uint8_t MMU2::cmd, MMU2::cmd_arg, MMU2::last_cmd, MMU2::extruder;
|
|
|
|
uint8_t MMU2::cmd, MMU2::cmd_arg, MMU2::last_cmd, MMU2::extruder;
|
|
|
|
int8_t MMU2::state = 0;
|
|
|
|
int8_t MMU2::state = 0;
|
|
|
|
volatile int8_t MMU2::finda = 1;
|
|
|
|
volatile int8_t MMU2::finda = 1;
|
|
|
@ -106,8 +109,14 @@ char MMU2::rx_buffer[MMU_RX_SIZE], MMU2::tx_buffer[MMU_TX_SIZE];
|
|
|
|
feedRate_t feedRate; //!< feed rate in mm/s
|
|
|
|
feedRate_t feedRate; //!< feed rate in mm/s
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static constexpr E_Step ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE };
|
|
|
|
static constexpr E_Step
|
|
|
|
static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { MMU2_LOAD_TO_NOZZLE_SEQUENCE };
|
|
|
|
ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE }
|
|
|
|
|
|
|
|
, load_to_nozzle_sequence[] PROGMEM = { MMU2_LOAD_TO_NOZZLE_SEQUENCE }
|
|
|
|
|
|
|
|
#if ENABLED(PRUSA_MMU2_S_MODE)
|
|
|
|
|
|
|
|
, can_load_sequence[] PROGMEM = { MMU2_CAN_LOAD_SEQUENCE }
|
|
|
|
|
|
|
|
, can_load_increment_sequence[] PROGMEM = { MMU2_CAN_LOAD_INCREMENT_SEQUENCE }
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
#endif // MMU2_MENUS
|
|
|
|
#endif // MMU2_MENUS
|
|
|
|
|
|
|
|
|
|
|
@ -228,6 +237,7 @@ void MMU2::mmu_loop() {
|
|
|
|
|
|
|
|
|
|
|
|
enabled = true;
|
|
|
|
enabled = true;
|
|
|
|
state = 1;
|
|
|
|
state = 1;
|
|
|
|
|
|
|
|
TERN_(PRUSA_MMU2_S_MODE, mmu2s_triggered = false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
@ -291,6 +301,8 @@ void MMU2::mmu_loop() {
|
|
|
|
tx_str_P(PSTR("P0\n"));
|
|
|
|
tx_str_P(PSTR("P0\n"));
|
|
|
|
state = 2; // wait for response
|
|
|
|
state = 2; // wait for response
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TERN_(PRUSA_MMU2_S_MODE, check_filament());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 2: // response to command P0
|
|
|
|
case 2: // response to command P0
|
|
|
@ -309,6 +321,7 @@ void MMU2::mmu_loop() {
|
|
|
|
else if (ELAPSED(millis(), last_request + MMU_P0_TIMEOUT)) // Resend request after timeout (3s)
|
|
|
|
else if (ELAPSED(millis(), last_request + MMU_P0_TIMEOUT)) // Resend request after timeout (3s)
|
|
|
|
state = 1;
|
|
|
|
state = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TERN_(PRUSA_MMU2_S_MODE, check_filament());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 3: // response to mmu commands
|
|
|
|
case 3: // response to mmu commands
|
|
|
@ -327,6 +340,7 @@ void MMU2::mmu_loop() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
state = 1;
|
|
|
|
state = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TERN_(PRUSA_MMU2_S_MODE, check_filament());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -437,6 +451,33 @@ void MMU2::check_version() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool mmu2_not_responding() {
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING);
|
|
|
|
|
|
|
|
BUZZ(100, 659);
|
|
|
|
|
|
|
|
BUZZ(200, 698);
|
|
|
|
|
|
|
|
BUZZ(100, 659);
|
|
|
|
|
|
|
|
BUZZ(300, 440);
|
|
|
|
|
|
|
|
BUZZ(100, 659);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(PRUSA_MMU2_S_MODE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool MMU2::load_to_gears() {
|
|
|
|
|
|
|
|
command(MMU_CMD_C0);
|
|
|
|
|
|
|
|
manage_response(true, true);
|
|
|
|
|
|
|
|
LOOP_L_N(i, MMU2_C0_RETRY) { // Keep loading until filament reaches gears
|
|
|
|
|
|
|
|
if (mmu2s_triggered) break;
|
|
|
|
|
|
|
|
command(MMU_CMD_C0);
|
|
|
|
|
|
|
|
manage_response(true, true);
|
|
|
|
|
|
|
|
check_filament();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const bool success = mmu2s_triggered && can_load();
|
|
|
|
|
|
|
|
if (!success) mmu2_not_responding();
|
|
|
|
|
|
|
|
return success;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Handle tool change
|
|
|
|
* Handle tool change
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -452,18 +493,15 @@ void MMU2::tool_change(uint8_t index) {
|
|
|
|
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
|
|
|
|
ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
|
|
|
|
|
|
|
|
|
|
|
|
command(MMU_CMD_T0 + index);
|
|
|
|
command(MMU_CMD_T0 + index);
|
|
|
|
|
|
|
|
|
|
|
|
manage_response(true, true);
|
|
|
|
manage_response(true, true);
|
|
|
|
|
|
|
|
|
|
|
|
command(MMU_CMD_C0);
|
|
|
|
if (load_to_gears()) {
|
|
|
|
extruder = index; //filament change is finished
|
|
|
|
extruder = index; // filament change is finished
|
|
|
|
active_extruder = 0;
|
|
|
|
active_extruder = 0;
|
|
|
|
|
|
|
|
ENABLE_AXIS_E0();
|
|
|
|
ENABLE_AXIS_E0();
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
|
|
|
|
SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder));
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
}
|
|
|
|
SERIAL_ECHOLNPAIR(STR_ACTIVE_EXTRUDER, int(extruder));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui.reset_status();
|
|
|
|
ui.reset_status();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -500,12 +538,13 @@ void MMU2::tool_change(const char* special) {
|
|
|
|
DISABLE_AXIS_E0();
|
|
|
|
DISABLE_AXIS_E0();
|
|
|
|
command(MMU_CMD_T0 + index);
|
|
|
|
command(MMU_CMD_T0 + index);
|
|
|
|
manage_response(true, true);
|
|
|
|
manage_response(true, true);
|
|
|
|
command(MMU_CMD_C0);
|
|
|
|
|
|
|
|
mmu_loop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ENABLE_AXIS_E0();
|
|
|
|
if (load_to_gears()) {
|
|
|
|
extruder = index;
|
|
|
|
mmu_loop();
|
|
|
|
active_extruder = 0;
|
|
|
|
ENABLE_AXIS_E0();
|
|
|
|
|
|
|
|
extruder = index;
|
|
|
|
|
|
|
|
active_extruder = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
|
|
case 'c': {
|
|
|
|
case 'c': {
|
|
|
@ -579,12 +618,7 @@ void MMU2::manage_response(const bool move_axes, const bool turn_off_nozzle) {
|
|
|
|
|
|
|
|
|
|
|
|
if (turn_off_nozzle) thermalManager.setTargetHotend(0, active_extruder);
|
|
|
|
if (turn_off_nozzle) thermalManager.setTargetHotend(0, active_extruder);
|
|
|
|
|
|
|
|
|
|
|
|
LCD_MESSAGEPGM(MSG_MMU2_NOT_RESPONDING);
|
|
|
|
mmu2_not_responding();
|
|
|
|
BUZZ(100, 659);
|
|
|
|
|
|
|
|
BUZZ(200, 698);
|
|
|
|
|
|
|
|
BUZZ(100, 659);
|
|
|
|
|
|
|
|
BUZZ(300, 440);
|
|
|
|
|
|
|
|
BUZZ(100, 659);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (mmu_print_saved) {
|
|
|
|
else if (mmu_print_saved) {
|
|
|
@ -632,6 +666,39 @@ void MMU2::filament_runout() {
|
|
|
|
planner.synchronize();
|
|
|
|
planner.synchronize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(PRUSA_MMU2_S_MODE)
|
|
|
|
|
|
|
|
void MMU2::check_filament() {
|
|
|
|
|
|
|
|
const bool runout = READ(FIL_RUNOUT_PIN) ^ (FIL_RUNOUT_INVERTING);
|
|
|
|
|
|
|
|
if (runout && !mmu2s_triggered) {
|
|
|
|
|
|
|
|
DEBUG_ECHOLNPGM("MMU <= 'A'");
|
|
|
|
|
|
|
|
tx_str_P(PSTR("A\n"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
mmu2s_triggered = runout;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool MMU2::can_load() {
|
|
|
|
|
|
|
|
execute_extruder_sequence((const E_Step *)can_load_sequence, COUNT(can_load_sequence));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int filament_detected_count = 0;
|
|
|
|
|
|
|
|
const int steps = MMU2_CAN_LOAD_RETRACT / MMU2_CAN_LOAD_INCREMENT;
|
|
|
|
|
|
|
|
DEBUG_ECHOLNPGM("MMU can_load:");
|
|
|
|
|
|
|
|
LOOP_L_N(i, steps) {
|
|
|
|
|
|
|
|
execute_extruder_sequence((const E_Step *)can_load_increment_sequence, COUNT(can_load_increment_sequence));
|
|
|
|
|
|
|
|
check_filament(); // Don't trust the idle function
|
|
|
|
|
|
|
|
DEBUG_CHAR(mmu2s_triggered ? 'O' : 'o');
|
|
|
|
|
|
|
|
if (mmu2s_triggered) ++filament_detected_count;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (filament_detected_count <= steps - (MMU2_CAN_LOAD_DEVIATION / MMU2_CAN_LOAD_INCREMENT)) {
|
|
|
|
|
|
|
|
DEBUG_ECHOLNPGM(" failed.");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG_ECHOLNPGM(" succeeded.");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if BOTH(HAS_LCD_MENU, MMU2_MENUS)
|
|
|
|
#if BOTH(HAS_LCD_MENU, MMU2_MENUS)
|
|
|
|
|
|
|
|
|
|
|
|
// Load filament into MMU2
|
|
|
|
// Load filament into MMU2
|
|
|
@ -656,20 +723,19 @@ void MMU2::filament_runout() {
|
|
|
|
LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD);
|
|
|
|
LCD_ALERTMESSAGEPGM(MSG_HOTEND_TOO_COLD);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
command(MMU_CMD_T0 + index);
|
|
|
|
|
|
|
|
manage_response(true, true);
|
|
|
|
|
|
|
|
command(MMU_CMD_C0);
|
|
|
|
|
|
|
|
mmu_loop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command(MMU_CMD_T0 + index);
|
|
|
|
|
|
|
|
manage_response(true, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const bool success = load_to_gears();
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
|
|
|
|
mmu_loop();
|
|
|
|
extruder = index;
|
|
|
|
extruder = index;
|
|
|
|
active_extruder = 0;
|
|
|
|
active_extruder = 0;
|
|
|
|
|
|
|
|
|
|
|
|
load_to_nozzle();
|
|
|
|
load_to_nozzle();
|
|
|
|
|
|
|
|
|
|
|
|
BUZZ(200, 404);
|
|
|
|
BUZZ(200, 404);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|