Beginning and Ending Gcode


You can customize the beginning and ending code that your slicer adds to the gcode files it produces to automate certain tasks or produce a more desired behavior.  Below are suggestions for these codes.  Feel free to use them and modify them to fit your usage.  For a list of gcode commands and their usage, see this page:


Beginning Gcode

G28 ;home all axes

Ending Gcode

The following ending gcode will lift the Z axis slightly, retract filament to reduce oozing when pre-heating for the next print, move the bed to the front, and run the extruder cooling fan at 100% for 2 minutes before turning it off.

M104 S0                       ;extruder heater off
M140 S0                       ;bed heater off
G91                           ;relative positioning
G1 E-1 F300                   ;retract the filament 1mm
G1 Z+0.5 E-3 X-20 Y-20 F6000  ;move Z up and retract filament 3mm
M106 S255                     ;fan at 100% to cool nozzle
G90                           ;absolute positioning
G28 X0 Y0                     ;home X and Y
G1 Y190                       ;move bed forward
M84                           ;steppers off
G4 P120000                    ;wait 2 minutes (120 seconds)
M106 S0                       ;fan off


Skip to toolbar