Skip to main content

Start and End G-code

The following snippets are used to make the start and end GCODE independent of the slicer used.

Start Print

The start print macro will first warm the bed and then perform an auto bed level while the hotend is warmed to a temperature of 160. This should be a safe enough temperature that the filament is close to operating temperature without becoming soft enough that it begins to flow out of the nozzle. As soon as the ABL is completed the hotend is set to its operating temperature, and then a purge line is done down the left side of the bed.

[gcode_macro START_PRINT]
default_parameter_BED_TEMP: 60
default_parameter_EXTRUDER_TEMP: 190
gcode:
    M140 S{BED_TEMP} # Set Heat Bed temperature
    M190 S{BED_TEMP} # Wait for Heat Bed temperature
    M104 S160 # Start warming extruder to 160
    G29 # Auto bed-level (BL-Touch)
    G92 E0 # Reset Extruder
    M104 S{EXTRUDER_TEMP} # Set Extruder temperature
    G1 X0.1 Y20 Z0.3 F5000.0 # Move to start position
    M109 S{EXTRUDER_TEMP} # Wait for Extruder temperature
    G1 X0.1 Y200.0 Z0.3 F1500.0 E15 # Draw the line
    G92 E0 # Reset Extruder
    G1 Z2.0 F3000 # Move Z Axis up little to prevent scratching of Heat Bed
    G1 X5 Y200.0 Z0.3 F5000.0 ; Move over to prevent blob squish
Calling the start macro in SuperSlicer, PrusaSlicer etc (2.6+):
  1. Printer Settings -> Custom G-code -> Start G-code
  2. Replace "Start G-code" with:
    START_PRINT BED_TEMP=[first_layer_bed_temperature] EXTRUDER_TEMP={first_layer_temperature[initial_extruder]}
Calling the start macro in SuperSlicer, PrusaSlicer etc (Pre 2.6):
  1. Printer Settings -> Custom G-code -> Start G-code
  2. Replace "Start G-code" with:
    START_PRINT BED_TEMP=[first_layer_bed_temperature] EXTRUDER_TEMP={first_layer_temperature[initial_extruder]+extruder_temperature_offset[initial_extruder]}
Calling the start macro in Cura
  1. Preferences -> Configure Cura
  2. Printers -> Select Printer -> Machine Settings
  3. Replace "Start G-code" with:
    START_PRINT BED_TEMP={material_bed_temperature} EXTRUDER_TEMP={material_print_temperature}

End Print

The end print macro will do the standard routing of moving the nozzle out of the way, presenting the print, and turning off the fan, hotend, bed and stepper motors.

[gcode_macro END_PRINT]
gcode:
    G91 #Relative positioning
    G1 E-2 F2700 #Retract a bit
    G1 E-2 Z0.2 F2400 #Retract and raise Z
    G1 X5 Y5 F3000 #Wipe out
    G1 Z10 #Raise Z more
    G90 #Absolute positionning

    G1 X0 Y{235} #Present print
    M106 S0 #Turn-off fan
    M104 S0 #Turn-off hotend
    M140 S0 #Turn-off bed

    M84 X Y E #Disable all steppers but Z
Calling the end macro in SuperSlicer, PrusaSlicer etc:
  1. Printer Settings -> Custom G-code -> End G-code
  2. Replace "End G-code" with:
    END_PRINT
Calling the end macro in Cura
  1. Preferences -> Configure Cura
  2. Printers -> Select Printer -> Machine Settings
  3. Replace "End G-code" with:
    END_PRINT