Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sjasonsmith committed Nov 19, 2020
1 parent 1ed67ab commit bab460e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 56 deletions.
14 changes: 3 additions & 11 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3612,17 +3612,9 @@
#define MMU2_CAN_LOAD_INCREMENT 0.2 // (mm) To reuse within MMU2 module
#define MMU2_CAN_LOAD_INCREMENT_SEQUENCE \
{ -MMU2_CAN_LOAD_INCREMENT, MMU2_CAN_LOAD_FEEDRATE }

/**
* The original prusa firmware has parameters to make sure there is no
* filament when switching tools, if so, keep unloading until no filament
* is detected. I noticed this wasn't implemented in the mmu2.cpp of marlin
* since it assumes no filament was ever loaded if a different tool was used
* or load to nozzle was used. It relies on the filament ramming parameters
* which can be unreliable for flexible materials because it could sometimes
* keep it loaded in the gears. Uncomment to enable this feature
*/
//#define MMU_IR_UNLOAD_MOVE // Enable unloading with IR sensor

// Continue unloading if sensor detects filament after the initial unload move
//#define MMU_IR_UNLOAD_MOVE
#endif

//#define MMU2_DEBUG // Write debug info to serial output
Expand Down
94 changes: 49 additions & 45 deletions Marlin/src/feature/mmu/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,28 +508,32 @@ static void mmu2_not_responding() {

set_runout_valid(false);

if (index != extruder) {
if (index != extruder)
{
#if ENABLED(MMU_IR_UNLOAD_MOVE)
if(FILAMENT_PRESENT()){
DEBUG_ECHOLNPGM("Unloading\n");
//filament_ramming(); //unloading from printer side
ENABLE_AXIS_E0();
while (FILAMENT_PRESENT()){ //if filament is still present, keep unloading
current_position.e -=0.25; //this is a guessed value, adjust to your preference
line_to_current_position(MMM_TO_MMS(120));
planner.synchronize();
}
DISABLE_AXIS_E0(); //disable E stepper when unloading finished
//command(MMU_CMD_U0); //unloading from mmu side but not printer
if (FILAMENT_PRESENT())
{
DEBUG_ECHOLNPGM("Unloading\n");
//filament_ramming(); //unloading from printer side
ENABLE_AXIS_E0();
while (FILAMENT_PRESENT())
{ //if filament is still present, keep unloading
current_position.e -= 0.25; //this is a guessed value, adjust to your preference
line_to_current_position(MMM_TO_MMS(120));
planner.synchronize();
}
DISABLE_AXIS_E0(); //disable E stepper when unloading finished
//command(MMU_CMD_U0); //unloading from mmu side but not printer
// ^commented out because command(MMU_CMD_T0 + index); manages the current loaded tool
manage_response(true,true);
}
else { //filament was unloaded from idler, no additional movements needed
DISABLE_AXIS_E0();
}
#else // !MMU_IR_UNLOAD_MOVE - default
DISABLE_AXIS_E0();
#endif // MMU_IR_UNLOAD_MOVE
manage_response(true, true);
}
else
{ //filament was unloaded from idler, no additional movements needed
DISABLE_AXIS_E0();
}
#else // !MMU_IR_UNLOAD_MOVE - default
DISABLE_AXIS_E0();
#endif // MMU_IR_UNLOAD_MOVE

ui.status_printf_P(0, GET_TEXT(MSG_MMU2_LOADING_FILAMENT), int(index + 1));

Expand Down Expand Up @@ -958,33 +962,33 @@ bool MMU2::load_filament_to_nozzle(const uint8_t index) {
return false;
}

#if ENABLED(MMU_IR_UNLOAD_MOVE)
// custom THIS IS FOR LOAD TO NOZZLE FUNCTION ONLY
if (index != extruder){
if(FILAMENT_PRESENT()){
DEBUG_ECHOLNPGM("Unloading\n");
ENABLE_AXIS_E0();
filament_ramming(); //unloading from printer side ! EXCLUSIVE FOR THIS FUNCTION
while (FILAMENT_PRESENT()){ // if filament is still present, keep unloading - WARNING I'm not sure
// if this is a recommended coding style in marlin
current_position.e -=1; //this is a guessed value
line_to_current_position(MMM_TO_MMS(120));
planner.synchronize();
}
DISABLE_AXIS_E0(); //disable E stepper when unloading finished
command(MMU_CMD_U0); //unloading from mmu side but not printer
#if ENABLED(MMU_IR_UNLOAD_MOVE)
// custom THIS IS FOR LOAD TO NOZZLE FUNCTION ONLY
if (index != extruder){
if(FILAMENT_PRESENT()){
DEBUG_ECHOLNPGM("Unloading\n");
ENABLE_AXIS_E0();
filament_ramming(); //unloading from printer side ! EXCLUSIVE FOR THIS FUNCTION
while (FILAMENT_PRESENT()){ // if filament is still present, keep unloading - WARNING I'm not sure
// if this is a recommended coding style in marlin
current_position.e -=1; //this is a guessed value
line_to_current_position(MMM_TO_MMS(120));
planner.synchronize();
}
DISABLE_AXIS_E0(); //disable E stepper when unloading finished
command(MMU_CMD_U0); //unloading from mmu side but not printer
// ^ needed because if startup, printer might not know current tool loaded
// this helps flag both mmu to know nothing is loaded
manage_response(true,true);
}
else { //filament was unloaded from idler, no additional movements needed
DISABLE_AXIS_E0();
}
}
#endif // MMU_IR_UNLOAD_MOVE

command(MMU_CMD_T0 + index);
manage_response(true, true);
manage_response(true,true);
}
else { //filament was unloaded from idler, no additional movements needed
DISABLE_AXIS_E0();
}
}
#endif // MMU_IR_UNLOAD_MOVE

command(MMU_CMD_T0 + index);
manage_response(true, true);

const bool success = load_to_gears();
if (success) {
Expand Down

0 comments on commit bab460e

Please sign in to comment.