G-Code to pause & change filament

Please Login to Comment

Does anyone have some G-code they can copy and paste so I can edit to pause a print to change filament? Like pause.... go home.... (I change the filament) Resume (How would I resume?)... Go somewhere and prime the new color and start printing again. I have an X5S with Marlin firmware SHORT_BUILD_VERSION "1.1.6". I use Slic3r through Repetier Host. Thanks in advance....

I'm using this firmware is great! and have M600 without modification!

RAWR TFT Firmware Artillery X1 and Genius

M600 (For print with differents colors. PAuse, change filament and resume, with out modify or open the printer)
PID for ABS and PLA
Extrude Calibration (E Steps)
Filament Change
Baby Steps
Gcode Console
Auto Leveling and Manual Leveling (5 Points)
How to install:

RAWR TFT Firmware Artillery 3D - With M600
by wgcv

There is an easy way to do it with repetier, you can use the pause script.
This can be be set in the printer parameters/scripts/script at pause.

Then save the G-code command that you want when pause is trigger. Something like that :
G91 ; set relative positioning
G1 E-6 F500 ; retract filament slightly to avoid drips
G1 Z5 F5000; move extruder up 5mm
G90 ; return to absolute positioning
G1 X0 Y0 ;park XY

Once you've got the good commands and save them, there is one last thing to do ; go in "edit g-code", find the line when you want the print to stop, and add this command : <a href="/pause/about">@pause</a>.
While printing, Repetier will run the script and wait for you to resume the job, and it will automatically go back to the printing position.
If by mistake you move the carriage while changing filament you still can manually home X and Y axis before to resume job.

I use to add a 20mm cube as martyr part in my slice (scaled on Z if needed, 2 perimeters, 0% infill, no top layers) , and add the command <a href="/pause/about">@pause</a> at the begin of one of its layer.
It needs a bit of practice, but use Repetier is the simplest way I've tried yet.

Excellent... I copied and pasted it to the pause script. I'm going to add" M104 S90 ; cool down nozzle" and then "M109 S230 ; set temperature and wait for it to be reached" before the martyr part when I resume. I was unaware of the @pause function. Suppose I wanted to use Script1. Would I insert @Script1? Thanks... I'll test on a small piece till I get it right.

This script is only when pause is trigger, I mean this will be run before (and only before) it stop and wait for you to resume the job.
So you can add the cool down command, but I'm not sure you can add the heating back command. But you can still manually send it before to resume.

I never use the scirpts 1 to 5 so I can't say if it will work. Actually I don't think it will....let me know if you test it

Does M600 not work? I use Simplify3D to find the layer by using the slide bar in teh print preview screen then go to that line in the gcode and insert. SO far I've only used this method on my Monoprice Mini but thought it would work on my Tornado and x5s.

I hear alot of people talking about Simplify 3D, but I'm unfamiliar with it. I like your method to find the line of g-code. Find the layer and then just seach for say Z12.400 for example and insert the pause code.

M600 is the g-code command for changing filament (which works w/ marlin), but it requires the advanced_pause_feature.
This is a feature of the firmware, and so it will work only if it is enable and if it knows what to do when triggered.
If you can control the firmware, take a look at it. It will allow you to pause your prints even printing from a SD card.
Otherwise use Repetier's pause script.

That worked great. I just searched for pause in the adv config file .... found the advanced_pause_feature .... enabled it and enabled PARK_HEAD_ON_PAUSE.......then just changed a few parameters . The LCD display guides you through the process and prompts you to press the button after completing each task. After the new filament is loaded you press the button and a predetermined amount of filament gets extruded (you adjust in parameters) to prime the nozzle. When it's done it prompts you again to start the print giving you time to clean the nozzle eliminating the need for a martyr print. Here's the section from the Marlin firmware for anyone interested...


  • Advanced Pause
  • Experimental feature for filament change support and for parking the nozzle when paused.
  • Adds the GCode M600 for initiating filament change.
  • If PARK_HEAD_ON_PAUSE enabled, adds the GCode M125 to pause printing and park the nozzle.
  • Requires an LCD display.
  • This feature is required for the default FILAMENT_RUNOUT_SCRIPT.



    define PAUSE_PARK_X_POS 0 // X position of hotend

    define PAUSE_PARK_Y_POS 0 // Y position of hotend

    define PAUSE_PARK_Z_ADD 10 // Z addition of hotend (lift)

    define PAUSE_PARK_XY_FEEDRATE 100 // X and Y axes feedrate in mm/s (also used for delta printers Z axis)

    define PAUSE_PARK_Z_FEEDRATE 5 // Z axis feedrate in mm/s (not used for delta printers)

    define PAUSE_PARK_RETRACT_FEEDRATE 60 // Initial retract feedrate in mm/s

    define PAUSE_PARK_RETRACT_LENGTH 2 // Initial retract in mm

                                          // It is a short retract used immediately after print interrupt before move to filament exchange position

    define FILAMENT_CHANGE_UNLOAD_FEEDRATE 10 // Unload filament feedrate in mm/s - filament unloading can be fast

    define FILAMENT_CHANGE_UNLOAD_LENGTH 100 // Unload filament length from hotend in mm

                                          // Longer length for bowden printers to unload filament from whole bowden tube,
                                          // shorter length for printers without bowden to unload filament from extruder only,
                                          // 0 to disable unloading for manual unloading

    define FILAMENT_CHANGE_LOAD_FEEDRATE 6 // Load filament feedrate in mm/s - filament loading into the bowden tube can be fast

    define FILAMENT_CHANGE_LOAD_LENGTH 0 // Load filament length over hotend in mm

                                          // Longer length for bowden printers to fast load filament into whole bowden tube over the hotend,
                                          // Short or zero length for printers without bowden where loading is not used

    define ADVANCED_PAUSE_EXTRUDE_FEEDRATE 3 // Extrude filament feedrate in mm/s - must be slower than load feedrate

    define ADVANCED_PAUSE_EXTRUDE_LENGTH 20 // Extrude filament length in mm after filament is loaded over the hotend,

                                          // 0 to disable for manual extrusion
                                          // Filament can be extruded repeatedly from the filament exchange menu to fill the hotend,
                                          // or until outcoming filament color is not clear for filament color change

    define PAUSE_PARK_NOZZLE_TIMEOUT 45 // Turn off nozzle if user doesn't change filament within this time limit in seconds

    define FILAMENT_CHANGE_NUMBER_OF_ALERT_BEEPS 5 // Number of alert beeps before printer goes quiet

    define PAUSE_PARK_NO_STEPPER_TIMEOUT // Enable to have stepper motors hold position during filament change

                                          // even if it takes longer than DEFAULT_STEPPER_DEACTIVE_TIME.

    define PARK_HEAD_ON_PAUSE // Go to filament change position on pause, return to print position on resume

    //#define HOME_BEFORE_FILAMENT_CHANGE // Ensure homing has been completed prior to parking for filament change


Thats even better since I print from an SD card all the time. I will find advanced_pause_feature in the firmware and see what all it entails/. Thanks again.

This is what I use in Simplify3D, perhaps it could be a starting point for you. Just modify both layer numbers for the layer you want to pause on. Add multiple lines and change the layers for multiple pauses.

{REPLACE "\nM117 Layer 4, Z=" "\nG1 X10 Y5\nM0\nM117 Layer 4, Z="}