Welcome! Log In Create A New Profile

Advanced

Marlin Pause Management

Posted by kangarooJack 
Marlin Pause Management
April 03, 2014 10:55PM
I’ve got a home-built printer running Marlin firmware and ramps electronics. I have an SD card module but no LCD. I always print from SD, initiated using Repetier Host.

There are two things about this set-up that bother me… 1: I can’t use longFileNames on the SD Card, and 2: When pausing mid-way through a print to change filament (or whatever), there’s no real management.

I haven’t had any luck with longFileNames yet, but I have come up with a solution for pause management that seems to work. It’s controlled by code and therefore can be inserted in a print file to have the printer pause at a chosen position. The pause code is “M25” followed by “M601” (next line). The M25 is the standard Marlin pause code, the M601 records the current position X,Y,Z,E and the current feed rate. It then retracts the filament and moves X, Y, Z to a park location. While in this pause mode, filament can be changed and axes can be jogged or homed.

To continue printing use “M602” followed by “M24” (next line). The M602 returns X,Y,Z,E back to their original paused positions, and reinstates the feed rate. The M24 is the standard Marlin resume.

Most of the code used is borrowed from the existing M600 command (which only works with an LCD). To implement, code needs to be added to both Marlin_Main.cpp and Configuration_adv.h See below.

If anyone has thoughts regarding issues or improvement please let me know. Any thoughts on how longFileNames on SD printing through a host could work, would also be appreciated.

Jack

***************************************************************************************************************
In Marlin_Main.cpp add…
***************************************************************************************************************
(Approximately Line 168 – Implemented Codes)

// M601 - Move to pause park position XYZE - after pause (M25) – stores XYZE position and feed rate.
// M602 - Return to pause park position XYZE post M601 – Use M24 to resume printing.


(Approximately Line 208 – Public Variables)

float target[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
float lastpos[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
int lastfeedrate=1500;


(Approximately Line 2947 – After case 600)

#ifdef PAUSEMANAGEMENT
case 601: // Move to pause park position XYZE - after pause (M25)
{
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];
lastfeedrate=feedrate;

target[E_AXIS]+= PAUSEMANAGEMENT _RETRACT ;
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
target[Z_AXIS]+= PAUSEMANAGEMENT _ZADD ;
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);
target[X_AXIS]= PAUSEMANAGEMENT _XPOS ;
target[Y_AXIS]= PAUSEMANAGEMENT _YPOS ;
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], feedrate/60, active_extruder);

uint8_t cnt=0;
cnt++;
manage_heater();
manage_inactivity();
}
break;
#endif // Move to pause position XYZE - after pause (M25)
#ifdef PAUSEMANAGEMENT
case 602: // Return to pause park position XYZE post M601
{

feedrate=lastfeedrate;
next_feedrate=lastfeedrate;
saved_feedrate=lastfeedrate;

target[E_AXIS]+=(-1)* PAUSEMANAGEMENT _RETRACT ;
current_position[E_AXIS]=target[E_AXIS];
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); //untretract
}
break;
#endif // Return to pause park position XYZE post M601

***************************************************************************************************************
In Configuration_adv.h add…
***************************************************************************************************************
(Approximately Line 427 – Buffers)

#define PAUSEMANAGEMENT // Used in M601 / M602 commands

#ifdef PAUSEMANAGEMENT
#define PAUSEMANAGEMENT_XPOS 150 // X park position (mm)
#define PAUSEMANAGEMENT_YPOS 25 // Y park position (mm)
#define PAUSEMANAGEMENT_ZADD 10 // Z park position (mm) – added to current Z position
#define PAUSEMANAGEMENT_RETRACT -2 // Filament retract distance (mm)
#endif
Sorry, only registered users may post in this forum.

Click here to login