Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Firmware/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ void proc_commands();

void M600_load_filament();
void M600_load_filament_movements();
void M600_wait_for_user(float HotendTempBckp);
bool M600_wait_for_user(float HotendTempBckp);
void M600_check_state(float nozzle_temp);
void load_filament_final_feed();
void marlin_wait_for_click();
Expand Down
49 changes: 37 additions & 12 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3706,7 +3706,7 @@ static T gcode_M600_filament_change_z_shift()
#endif
}

static void gcode_M600(bool automatic, float x_position, float y_position, float z_shift, float e_shift, float /*e_shift_late*/)
static void gcode_M600(bool automatic, bool runout, float x_position, float y_position, float z_shift, float e_shift, float /*e_shift_late*/)
{
st_synchronize();
float lastpos[4];
Expand All @@ -3720,6 +3720,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
int feedmultiplyBckp = feedmultiply;
float HotendTempBckp = degTargetHotend(active_extruder);
int fanSpeedBckp = fanSpeed;
bool cooldown = false;

lastpos[X_AXIS] = current_position[X_AXIS];
lastpos[Y_AXIS] = current_position[Y_AXIS];
Expand All @@ -3728,7 +3729,7 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float

//Retract E
current_position[E_AXIS] += e_shift;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_RFEED);
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EFEED_RETRACT);
st_synchronize();

//Lift Z
Expand All @@ -3742,14 +3743,28 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
plan_buffer_line_curposXYZE(FILAMENTCHANGE_XYFEED);
st_synchronize();

//Beep, manage nozzle heater and wait for user to start unload filament
if(!mmu_enabled) M600_wait_for_user(HotendTempBckp);
if(!mmu_enabled)
{
//Beep, manage nozzle heater and wait for user to start unload filament
cooldown = M600_wait_for_user(HotendTempBckp);
}

lcd_change_fil_state = 0;

// Unload filament
if (mmu_enabled) extr_unload(); //unload just current filament for multimaterial printers (used also in M702)
else unload_filament(true); //unload filament for single material (used also in M702)
if (mmu_enabled)
{
// unload just current filament for multimaterial printers (used also in M702)
extr_unload();
}
else
{
// unload filament for single material (used also in M702)
unload_filament(runout? UnloadType::Runout:
cooldown? UnloadType::Purge:
UnloadType::Swap);
}

//finish moves
st_synchronize();

Expand Down Expand Up @@ -3798,8 +3813,8 @@ static void gcode_M600(bool automatic, float x_position, float y_position, float
//Feed a little of filament to stabilize pressure
if (!automatic)
{
current_position[E_AXIS] += FILAMENTCHANGE_RECFEED;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EXFEED);
current_position[E_AXIS] += FILAMENTCHANGE_PRIMEFEED;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EFEED_PRIME);
}

//Move XY back
Expand Down Expand Up @@ -8133,7 +8148,8 @@ SERIAL_PROTOCOLPGM("\n\n");
float e_shift_init = 0;
float e_shift_late = 0;
bool automatic = false;

bool runout = false;

//Retract extruder
if(code_seen('E'))
{
Expand Down Expand Up @@ -8191,8 +8207,13 @@ SERIAL_PROTOCOLPGM("\n\n");

if (mmu_enabled && code_seen_P(PSTR("AUTO")))
automatic = true;
if (code_seen('R'))
{
// Code 'R' is supported internally to indicate filament change due to a runout condition
runout = true;
}

gcode_M600(automatic, x_position, y_position, z_shift, e_shift_init, e_shift_late);
gcode_M600(automatic, runout, x_position, y_position, z_shift, e_shift_init, e_shift_late);

}
break;
Expand Down Expand Up @@ -11728,7 +11749,7 @@ void restore_print_from_ram_and_continue(float e_move)
//then move Z
plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], saved_pos[Z_AXIS], saved_pos[E_AXIS] - e_move, homing_feedrate[Z_AXIS]/13, active_extruder);
//and finaly unretract (35mm/s)
plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], saved_pos[Z_AXIS], saved_pos[E_AXIS], FILAMENTCHANGE_RFEED, active_extruder);
plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], saved_pos[Z_AXIS], saved_pos[E_AXIS], FILAMENTCHANGE_EFEED_RETRACT, active_extruder);
st_synchronize();

#ifdef FANCHECK
Expand Down Expand Up @@ -11876,7 +11897,8 @@ void M600_check_state(float nozzle_temp)
//! If times out, active extruder temperature is set to 0.
//!
//! @param HotendTempBckp Temperature to be restored for active extruder, after user resolves MMU problem.
void M600_wait_for_user(float HotendTempBckp) {
//! @return True if the wait involved a hotend cooldown due to timeout.
bool M600_wait_for_user(float HotendTempBckp) {

KEEPALIVE_STATE(PAUSED_FOR_USER);

Expand All @@ -11885,6 +11907,7 @@ void M600_wait_for_user(float HotendTempBckp) {
uint8_t wait_for_user_state = 0;
lcd_display_message_fullscreen_P(_T(MSG_PRESS_TO_UNLOAD));
bool bFirst=true;
bool bCooldown=false;

while (!(wait_for_user_state == 0 && lcd_clicked())){
manage_heater();
Expand Down Expand Up @@ -11917,6 +11940,7 @@ void M600_wait_for_user(float HotendTempBckp) {
lcd_display_message_fullscreen_P(_i("Press the knob to preheat nozzle and continue."));////MSG_PRESS_TO_PREHEAT c=20 r=4
wait_for_user_state = 1;
setAllTargetHotends(0);
bCooldown = true;
st_synchronize();
disable_e0();
disable_e1();
Expand Down Expand Up @@ -11951,6 +11975,7 @@ void M600_wait_for_user(float HotendTempBckp) {

}
WRITE(BEEPER, LOW);
return bCooldown;
}

void M600_load_filament_movements()
Expand Down
2 changes: 1 addition & 1 deletion Firmware/fsensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ void fsensor_enque_M600(){
puts_P(PSTR("fsensor_update - M600"));
eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) + 1);
eeprom_update_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) + 1);
enquecommand_front_P((PSTR("M600")));
enquecommand_front_P((PSTR("M600 R")));
}

//! @brief filament sensor update (perform M600 on filament runout)
Expand Down
37 changes: 22 additions & 15 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4473,7 +4473,7 @@ void lcd_wizard(WizState state)
lcd_display_message_fullscreen_P(_i("Now I will preheat nozzle for PLA."));
wait_preheat();
//unload current filament
unload_filament(true);
unload_filament();
//load filament
lcd_wizard_load();
setTargetHotend(0, 0); //we are finished, cooldown nozzle
Expand Down Expand Up @@ -5573,25 +5573,32 @@ static void mmu_cut_filament_menu()


// unload filament for single material printer (used in M702 gcode)
// @param automatic: If true, unload_filament is part of a unload+load sequence (M600)
void unload_filament(bool automatic)
void unload_filament(UnloadType unload)
{
custom_message_type = CustomMsg::FilamentLoading;
lcd_setstatuspgm(_T(MSG_UNLOADING_FILAMENT));

raise_z_above(automatic? MIN_Z_FOR_SWAP: MIN_Z_FOR_UNLOAD);

// extr_unload2();
raise_z_above(unload == UnloadType::Swap? MIN_Z_FOR_SWAP: MIN_Z_FOR_UNLOAD);
if (unload == UnloadType::Purge)
{
// extrude slowly
current_position[E_AXIS] += FILAMENTCHANGE_UNLOADFEED;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EFEED_PRIME);
st_synchronize();

// relieve leftover pressure
current_position[E_AXIS] += 0.1;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EFEED_PRIME / 2);
st_synchronize();
}

current_position[E_AXIS] -= 45;
plan_buffer_line_curposXYZE(5200 / 60);
st_synchronize();
current_position[E_AXIS] -= 15;
plan_buffer_line_curposXYZE(1000 / 60);
st_synchronize();
current_position[E_AXIS] -= 20;
plan_buffer_line_curposXYZE(1000 / 60);
st_synchronize();
// retract & eject
current_position[E_AXIS] += FILAMENTCHANGE_FIRSTRETRACT;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EFEED_RETRACT);
st_synchronize();
current_position[E_AXIS] += FILAMENTCHANGE_FINALRETRACT;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EFEED_EJECT);
st_synchronize();

lcd_display_message_fullscreen_P(_T(MSG_PULL_OUT_FILAMENT));

Expand Down
12 changes: 11 additions & 1 deletion Firmware/ultralcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,17 @@ extern bool bFilamentAction;
void mFilamentItem(uint16_t nTemp,uint16_t nTempBed);
void mFilamentItemForce();
void lcd_generic_preheat_menu();
void unload_filament(bool automatic = false);


enum class UnloadType : uint8_t
{
Purge, // user-triggered unload, perform an extra purge before unload
Swap, // part of an M600 sequence (no extra purge necessary)
Runout, // triggered by runout (extra purge not possible)
};

void unload_filament(UnloadType unload=UnloadType::Purge);


void lcd_printer_connected();
void lcd_ping();
Expand Down
25 changes: 15 additions & 10 deletions Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,21 +242,26 @@
#ifdef FILAMENTCHANGEENABLE
#define FILAMENTCHANGE_XPOS 211
#define FILAMENTCHANGE_YPOS 0
#define FILAMENTCHANGE_ZADD 2
#define FILAMENTCHANGE_FIRSTRETRACT -2
#define FILAMENTCHANGE_FINALRETRACT -80
#define FILAMENTCHANGE_ZADD Z_PAUSE_LIFT

#define FILAMENTCHANGE_FIRSTFEED 70 //E distance in mm for fast filament loading sequence used used in filament change (M600)
#define FILAMENTCHANGE_FINALFEED 25 //E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701)
#define FILAMENTCHANGE_RECFEED 5
#define FILAMENTCHANGE_FIRSTRETRACT -2 // Retraction performed before parking the extruder or unloading filament
#define FILAMENTCHANGE_FINALRETRACT -80 // Full filament retraction length

#define FILAMENTCHANGE_FIRSTFEED 70 // E distance in mm for fast filament loading sequence used used in filament change (M600)
#define FILAMENTCHANGE_FINALFEED 25 // E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701)

#define FILAMENTCHANGE_PRIMEFEED 2 // E priming distance performed after resuming
#define FILAMENTCHANGE_UNLOADFEED 10 // E priming distance performed before unloading

#define FILAMENTCHANGE_XYFEED 50
#define FILAMENTCHANGE_ZFEED 15

#define FILAMENTCHANGE_EFEED_FIRST 20 // feedrate in mm/s for fast filament loading sequence used in filament change (M600)
#define FILAMENTCHANGE_EFEED_FINAL 3.3f // feedrate in mm/s for slow filament loading sequence used in filament change (M600) and filament load (M701)
//#define FILAMENTCHANGE_RFEED 400
#define FILAMENTCHANGE_RFEED 7000 / 60
#define FILAMENTCHANGE_EXFEED 2
#define FILAMENTCHANGE_ZFEED 15

#define FILAMENTCHANGE_EFEED_RETRACT (7000 / 60) // quick filament retract feedrate in mm/s
#define FILAMENTCHANGE_EFEED_EJECT (1000 / 60) // filament ejection feedrate in mm/s
#define FILAMENTCHANGE_EFEED_PRIME ( 120 / 60) // filament priming feedrate (used before unloading and after resuming a print)

#endif

Expand Down
25 changes: 15 additions & 10 deletions Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,26 @@
#ifdef FILAMENTCHANGEENABLE
#define FILAMENTCHANGE_XPOS 211
#define FILAMENTCHANGE_YPOS 0
#define FILAMENTCHANGE_ZADD 2
#define FILAMENTCHANGE_FIRSTRETRACT -2
#define FILAMENTCHANGE_FINALRETRACT -80
#define FILAMENTCHANGE_ZADD Z_PAUSE_LIFT

#define FILAMENTCHANGE_FIRSTFEED 70 //E distance in mm for fast filament loading sequence used used in filament change (M600)
#define FILAMENTCHANGE_FINALFEED 25 //E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701)
#define FILAMENTCHANGE_RECFEED 5
#define FILAMENTCHANGE_FIRSTRETRACT -2 // Retraction performed before parking the extruder or unloading filament
#define FILAMENTCHANGE_FINALRETRACT -80 // Full filament retraction length

#define FILAMENTCHANGE_FIRSTFEED 70 // E distance in mm for fast filament loading sequence used used in filament change (M600)
#define FILAMENTCHANGE_FINALFEED 25 // E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701)

#define FILAMENTCHANGE_PRIMEFEED 2 // E priming distance performed after resuming
#define FILAMENTCHANGE_UNLOADFEED 10 // E priming distance performed before unloading

#define FILAMENTCHANGE_XYFEED 50
#define FILAMENTCHANGE_ZFEED 15

#define FILAMENTCHANGE_EFEED_FIRST 20 // feedrate in mm/s for fast filament loading sequence used in filament change (M600)
#define FILAMENTCHANGE_EFEED_FINAL 3.3f // feedrate in mm/s for slow filament loading sequence used in filament change (M600) and filament load (M701)
//#define FILAMENTCHANGE_RFEED 400
#define FILAMENTCHANGE_RFEED 7000 / 60
#define FILAMENTCHANGE_EXFEED 2
#define FILAMENTCHANGE_ZFEED 15

#define FILAMENTCHANGE_EFEED_RETRACT (7000 / 60) // quick filament retract feedrate in mm/s
#define FILAMENTCHANGE_EFEED_EJECT (1000 / 60) // filament ejection feedrate in mm/s
#define FILAMENTCHANGE_EFEED_PRIME ( 120 / 60) // filament priming feedrate (used before unloading and after resuming a print)

#endif

Expand Down
25 changes: 15 additions & 10 deletions Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,21 +242,26 @@
#ifdef FILAMENTCHANGEENABLE
#define FILAMENTCHANGE_XPOS 211
#define FILAMENTCHANGE_YPOS 0
#define FILAMENTCHANGE_ZADD 2
#define FILAMENTCHANGE_FIRSTRETRACT -2
#define FILAMENTCHANGE_FINALRETRACT -80
#define FILAMENTCHANGE_ZADD Z_PAUSE_LIFT

#define FILAMENTCHANGE_FIRSTFEED 70 //E distance in mm for fast filament loading sequence used used in filament change (M600)
#define FILAMENTCHANGE_FINALFEED 25 //E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701)
#define FILAMENTCHANGE_RECFEED 5
#define FILAMENTCHANGE_FIRSTRETRACT -2 // Retraction performed before parking the extruder or unloading filament
#define FILAMENTCHANGE_FINALRETRACT -80 // Full filament retraction length

#define FILAMENTCHANGE_FIRSTFEED 70 // E distance in mm for fast filament loading sequence used used in filament change (M600)
#define FILAMENTCHANGE_FINALFEED 25 // E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701)

#define FILAMENTCHANGE_PRIMEFEED 2 // E priming distance performed after resuming
#define FILAMENTCHANGE_UNLOADFEED 10 // E priming distance performed before unloading

#define FILAMENTCHANGE_XYFEED 50
#define FILAMENTCHANGE_ZFEED 15

#define FILAMENTCHANGE_EFEED_FIRST 20 // feedrate in mm/s for fast filament loading sequence used in filament change (M600)
#define FILAMENTCHANGE_EFEED_FINAL 3.3f // feedrate in mm/s for slow filament loading sequence used in filament change (M600) and filament load (M701)
//#define FILAMENTCHANGE_RFEED 400
#define FILAMENTCHANGE_RFEED 7000 / 60
#define FILAMENTCHANGE_EXFEED 2
#define FILAMENTCHANGE_ZFEED 15

#define FILAMENTCHANGE_EFEED_RETRACT (7000 / 60) // quick filament retract feedrate in mm/s
#define FILAMENTCHANGE_EFEED_EJECT (1000 / 60) // filament ejection feedrate in mm/s
#define FILAMENTCHANGE_EFEED_PRIME ( 120 / 60) // filament priming feedrate (used before unloading and after resuming a print)

#endif

Expand Down
25 changes: 15 additions & 10 deletions Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,26 @@
#ifdef FILAMENTCHANGEENABLE
#define FILAMENTCHANGE_XPOS 211
#define FILAMENTCHANGE_YPOS 0
#define FILAMENTCHANGE_ZADD 2
#define FILAMENTCHANGE_FIRSTRETRACT -2
#define FILAMENTCHANGE_FINALRETRACT -80
#define FILAMENTCHANGE_ZADD Z_PAUSE_LIFT

#define FILAMENTCHANGE_FIRSTFEED 70 //E distance in mm for fast filament loading sequence used used in filament change (M600)
#define FILAMENTCHANGE_FINALFEED 25 //E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701)
#define FILAMENTCHANGE_RECFEED 5
#define FILAMENTCHANGE_FIRSTRETRACT -2 // Retraction performed before parking the extruder or unloading filament
#define FILAMENTCHANGE_FINALRETRACT -80 // Full filament retraction length

#define FILAMENTCHANGE_FIRSTFEED 70 // E distance in mm for fast filament loading sequence used used in filament change (M600)
#define FILAMENTCHANGE_FINALFEED 25 // E distance in mm for slow filament loading sequence used used in filament change (M600) and filament load (M701)

#define FILAMENTCHANGE_PRIMEFEED 2 // E priming distance performed after resuming
#define FILAMENTCHANGE_UNLOADFEED 10 // E priming distance performed before unloading

#define FILAMENTCHANGE_XYFEED 50
#define FILAMENTCHANGE_ZFEED 15

#define FILAMENTCHANGE_EFEED_FIRST 20 // feedrate in mm/s for fast filament loading sequence used in filament change (M600)
#define FILAMENTCHANGE_EFEED_FINAL 3.3f // feedrate in mm/s for slow filament loading sequence used in filament change (M600) and filament load (M701)
//#define FILAMENTCHANGE_RFEED 400
#define FILAMENTCHANGE_RFEED 7000 / 60
#define FILAMENTCHANGE_EXFEED 2
#define FILAMENTCHANGE_ZFEED 15

#define FILAMENTCHANGE_EFEED_RETRACT (7000 / 60) // quick filament retract feedrate in mm/s
#define FILAMENTCHANGE_EFEED_EJECT (1000 / 60) // filament ejection feedrate in mm/s
#define FILAMENTCHANGE_EFEED_PRIME ( 120 / 60) // filament priming feedrate (used before unloading and after resuming a print)

#endif

Expand Down
Loading