start-and-end-gcode

This is an old revision of the document!


e4444

Starting & Ending GCode

In your slicer you will have a section for GCode commands that are run at the very start and end of every print. In Cura/JGCreat, these are found in the machine settings.

There are several good videos on this topic that are linked at the bottom of this article. These will give you a great introduction into what is possible to achieve with starting and ending gcode commands.


Starting GCode

Typically this contains several functions:

  • Home and reference all axis
  • Set position to zero
  • Prime the extruder
  • Wipe the nozzle on the bed (not enabled by default - you need to add your own commands)
  • Enable auto-bed or mesh-bed levelling (if configured)

Default Start Script

  • G28 ; Home all axis
  • G1 Z15.0 F6000 ; Move up 15mm at 6000mm/min (note: more than the max speed set in the printer firmware)
  • ; Wait for temperature (Slic3r-only notation):
    • M190 S[first_layer_bed_temperature] ; Set bed temp.
    • M140 S[first_layer_bed_temperature] ; Wait for bed temp.
    • M109 S[first_layer_temperature_0] ; Wait for all used extruders to reach temperature.
  • ; Wait for temperature (Cura-only notation) https://github.com/Ultimaker/Cura/issues/1131#issuecomment-378851858:
    • M190 S{print_bed_temperature} ; Set bed temp.
    • M140 S{print_bed_temperature} ; Wait for bed temp.
    • M109 S{print_temperature} ; Wait for all used extruders to reach temperature.
  • G92 E0 ; Reset extruder length to zero
  • G1 F200 E10 ; Extrude 10mm at 200mm/min
  • G92 E0 ; Reset extruder length to zero

The lift up and extrude is the β€œpurge and prime” to ensure that filament is flowing correctly. If the filament is left at home position for too long while the nozzle is hot, the filament can ooze out. Then the nozzle will not be ready for printing. The purge and prime gets the filament flowing again ready for printing.

You can add a β€œwipe” step to the starting gcode after the β€œpurge”. Replace the start gcode listed above with the lines below - or watch the videos below.

Start Script With Wipe

  • G28 ; Home all axis
  • G1 Z15.0 F6000 ; Move up 15mm at 6000mm/min (note: more than the max speed set in the printer firmware)
  • G92 E0 ; Reset extruder length to zero
  • G1 X0.0 Y0.0 F1000.0 ; go to edge of print area
  • G1 Z0.200 F1000.0 ; Go to Start Z position
  • G1 X60.0 E9.0 F1000.0 ; intro line
  • G1 X100.0 E21.5 F1000.0 ; intro line
  • G92 E0.0 ; reset extruder distance position

Thanks to DaHai for the wipe script. :edit 2019-11-15 Poikilos: Wait for temperature.


Ending GCode

  • G91; Set relative positioning mode
  • G1 E-5 F600; retract filament slightly
  • M140 S0; Turn off the bed heater
  • M104 S0; Turn off the nozzle heater
  • G28 X; Home the X axis
  • G0 Y280 F600; Bring the bed to the front for easy print removal
  • M84; Turn off the motors

As the home positions on the A5 has the bed towards the back of the printer, one useful command to add to the end GCode, is a command to bring the Y-axis forward to the front once the print is finished. e.g. β€œG0 Y280 F600”

Thanks to Rich Haubert for the suggestion to insert a small filament retraction.

Wait for Temperature

After slicing, if you check the GCode file, you will see that the slicer has added additional lines to your start gcode. You do not need to add these lines to your start gcode, they are automatically added. 1. Your 3D printer must wait to get to temperature before trying to prime the extruder. Without doing so, it will do nothing but grind the gears on the filament (or crush flexible filament) unless it is still hot enough from a print immediately beforehand. However, the three lines below only have software-specific notation. For Slic3r:

  • M190 S[first_layer_bed_temperature] ; Set bed temp.
  • M140 S[first_layer_bed_temperature] ; Wait for bed temp.
  • M109 S[first_layer_temperature_0] ; Wait for all used extruders to reach temperature.

For Cura (See here):

  • M190 S{print_bed_temperature} ; Set bed temp.
  • M140 S{print_bed_temperature} ; Wait for bed temp.
  • M109 S{print_temperature} ; Wait for all used extruders to reach temperature.

Videos

start-and-end-gcode.1573869257.txt.gz Β· Last modified: 2020/12/25 02:13 (external edit)