Added a feature to have filament change by gcode or display trigger.
[default off for now] syntax: M600 X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] if enabled, after a M600, the printer will retract by E, lift by Z, move to XY, retract even more filament. Oh, and it will display "remove filament" and beep like crazy. You are then supposed to insert a new filament (other color, e.g.) and click the display to continue. After having the nozzle cleaned manually, aided by the disabled e-steppers. After clicking, the printer will then go back the whole shebang, and continue printing with a fancy new color.
This commit is contained in:
@@ -126,6 +126,7 @@
|
||||
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
||||
// M503 - print the current settings (from memory not from eeprom)
|
||||
// M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
||||
// M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
|
||||
// M907 - Set digital trimpot motor current using axis codes.
|
||||
// M908 - Control digital trimpot directly.
|
||||
// M350 - Set microstepping mode.
|
||||
@@ -1506,6 +1507,130 @@ void process_commands()
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef FILAMENTCHANGEENABLE
|
||||
case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
|
||||
{
|
||||
float target[4];
|
||||
float lastpos[4];
|
||||
target[X_AXIS]=current_position[X_AXIS];
|
||||
target[Y_AXIS]=current_position[Y_AXIS];
|
||||
target[Z_AXIS]=current_position[Z_AXIS];
|
||||
target[E_AXIS]=current_position[E_AXIS];
|
||||
lastpos[X_AXIS]=current_position[X_AXIS];
|
||||
lastpos[Y_AXIS]=current_position[Y_AXIS];
|
||||
lastpos[Z_AXIS]=current_position[Z_AXIS];
|
||||
lastpos[E_AXIS]=current_position[E_AXIS];
|
||||
//retract by E
|
||||
if(code_seen('E'))
|
||||
{
|
||||
target[E_AXIS]+= code_value();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FILAMENTCHANGE_FIRSTRETRACT
|
||||
target[E_AXIS]+= FILAMENTCHANGE_FIRSTRETRACT ;
|
||||
#endif
|
||||
}
|
||||
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
|
||||
|
||||
//lift Z
|
||||
if(code_seen('Z'))
|
||||
{
|
||||
target[Z_AXIS]+= code_value();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FILAMENTCHANGE_ZADD
|
||||
target[Z_AXIS]+= FILAMENTCHANGE_ZADD ;
|
||||
#endif
|
||||
}
|
||||
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
|
||||
|
||||
//move xy
|
||||
if(code_seen('X'))
|
||||
{
|
||||
target[X_AXIS]+= code_value();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FILAMENTCHANGE_XPOS
|
||||
target[X_AXIS]= FILAMENTCHANGE_XPOS ;
|
||||
#endif
|
||||
}
|
||||
if(code_seen('Y'))
|
||||
{
|
||||
target[Y_AXIS]= code_value();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FILAMENTCHANGE_YPOS
|
||||
target[Y_AXIS]= FILAMENTCHANGE_YPOS ;
|
||||
#endif
|
||||
}
|
||||
|
||||
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
|
||||
|
||||
if(code_seen('L'))
|
||||
{
|
||||
target[E_AXIS]+= code_value();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FILAMENTCHANGE_FINALRETRACT
|
||||
target[E_AXIS]+= FILAMENTCHANGE_FINALRETRACT ;
|
||||
#endif
|
||||
}
|
||||
|
||||
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
|
||||
|
||||
//finish moves
|
||||
st_synchronize();
|
||||
//disable extruder steppers so filament can be removed
|
||||
disable_e0();
|
||||
disable_e1();
|
||||
disable_e2();
|
||||
delay(100);
|
||||
LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
|
||||
uint8_t cnt=0;
|
||||
while(!LCD_CLICKED){
|
||||
cnt++;
|
||||
manage_heater();
|
||||
manage_inactivity();
|
||||
lcd_update();
|
||||
|
||||
#if BEEPER > -1
|
||||
if(cnt==0)
|
||||
{
|
||||
SET_OUTPUT(BEEPER);
|
||||
|
||||
WRITE(BEEPER,HIGH);
|
||||
delay(3);
|
||||
WRITE(BEEPER,LOW);
|
||||
delay(3);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//return to normal
|
||||
if(code_seen('L'))
|
||||
{
|
||||
target[E_AXIS]+= -code_value();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef FILAMENTCHANGE_FINALRETRACT
|
||||
target[E_AXIS]+=(-1)*FILAMENTCHANGE_FINALRETRACT ;
|
||||
#endif
|
||||
}
|
||||
current_position[E_AXIS]=target[E_AXIS]; //the long retract of L is compensated by manual filament feeding
|
||||
plan_set_e_position(current_position[E_AXIS]);
|
||||
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //should do nothing
|
||||
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move xy back
|
||||
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder); //move z back
|
||||
plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], feedrate/60, active_extruder); //final untretract
|
||||
}
|
||||
break;
|
||||
#endif //FILAMENTCHANGEENABLE
|
||||
case 907: // M907 Set digital trimpot motor current using axis codes.
|
||||
{
|
||||
#if DIGIPOTSS_PIN > -1
|
||||
|
Reference in New Issue
Block a user