How to Configure Ender 3 (Pro/V2) Start G-Code and End G-Code?

If you open any G-code file produced by the slicer software you’re using with a text editor, you will find that the entire file consists of a long list of G-code commands, which are what your 3D printer executes in order to print the 3D model that you see on your screen.

On the other hand, your 3D printer doesn’t only use G-code commands during the printing process, as every single action, even simple ones such as turning the fans on and off, correspond to G-code commands that need to be executed before or after the printing process is underway.

In today’s article, we will be talking about automating the pre-print and post-print processes for the Ender 3 by using the the start G-code and end G-code sections you can find in slicer software, which allow you to input a set of pre-defined commands that the 3D printer automatically runs before and after each print.

So, how to configure the start G-code and end G-code optimally for the Ender 3?

To configure the start G-code optimally for the Ender 3, we recommend adding the command for pre-heating the bed in the beginning but waiting to pre-heat the nozzle until later to maximize time efficiency while ensuring that there is no oozing.

On the other hand, for the end G-code, we recommend adding the M400 (Finish Moves) to the beginning, ensuring that your Ender 3 clears up the command queue before executing the end G-code block.

Next up, we will dive deeper into the process of configuring the Ender 3 start G-code and end G-code optimally, find out how to configure the start and end G-code in popular slicers such as Cura and Prusaslicer, and finally, discuss the differences between Cura’s and PrusaSlicer’s replacement patterns that are a vital part in writing the start and end G-codes.

How to Configure Ender 3 (Pro/V2) Start G-Code?

As the start G-code sequence plays a vital role in ensuring that the 3D printer is ready for the printing process, optimally configuring it is one of the first steps to a successful print that produces a high-quality final product.

Below, you can find the start G-code block we recommend using for the Ender 3, along with explanations of each G-code command:

M140 S{material_bed_temperature_layer_0} ; Start heating the heated bed

M190 S{material_bed_temperature_layer_0} ; Wait until the heated bed reaches the desired temperature

M104 S160; Start pre-heating the extruder to 160 degrees Celsius

G92 E0 ; Reset extruder origin

M104 S{material_print_temperature_layer_0} ; Start heating the extruder

G1 X0.1 Y20 Z0.3 F5000.0 ; Move printhead to the starting position

M109 S{material_print_temperature_layer_0} ; Wait until the extruder reaches the desired temperature

G1 Z2.0 F3000 ; Move Z-Axis up to avoid scratching the build plate

G1 X0.1 Y200.0 Z0.3 F1500.0 E15 ; Draw the first line

G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to the side

G1 X0.4 Y20 Z0.3 F1500.0 E30 ; Draw the second line

G92 E0 ; Reset extruder origin

G1 Z2.0 F3000 ; Move Z-Axis up to avoid scratching the build plate

Please note that the replacement patterns (the ones in curly braces) in this G-code block are written in Cura’s syntax, and as a result, they will only work for Cura. If you want to use this G-code block in another slicer, you will need to replace these parts accordingly.

How to Configure Ender 3 (Pro/V2) End G-Code?

While not as crucial as the start G-code, configuring the end G-code correctly is still a good idea to ensure that your 3D printer powers down the components, such as the extruder and the heated bed, after the printing process.

Here is the end G-code block we recommend using for the Ender 3, along with explanations of each G-code command:

M400 ; Finish Moves

G91 ; Set positioning to relative

G1 E-2 F2700 ; Retract the filament

G1 E-2 Z0.2 F2400 ; Retract the filament and raise Z-axis

G1 X5 Y5 F3000 ; Wipe

G1 Z10 ; Raise the Z-axis

G90 ; Set positioning to absolute

G1 X0 Y{machine_depth} ; Linear move

M106 S0 ; Disable fan

M104 S0 ; Disable hotend

M140 S0 ; Disable heated bed

M84 X Y E ; Disable all steppers except Z

Please note that the replacement patterns (the ones in curly braces) in this G-code block are written in Cura’s syntax, and as a result, they will only work for Cura. If you want to use this G-code block in another slicer, you will need to replace these parts accordingly.

How to Configure Start G-Code and End G-Code in Cura?

The process of configuring the start G-code and end G-code in Cura is relatively straightforward once you know where to look, as you are presented with an input field that allows you to enter any G-code you desire.

Below, you can find a step-by-step guide that you can follow to configure the start and end G-code blocks in Cura:

  1. Click the Preferences option on the Cura menu bar.
  2. Click the Configure Cura option in the dropdown menu.
  3. Click the Printers tab from the left pane.
  4. Choose the printer you would like to change the start and end G-code blocks for, and click Machine Settings.

After following these steps, you will find the Start G-code and End G-code input areas, which you can use to perform the necessary configuration.

How to Configure Start G-Code and End G-Code in PrusaSlicer?

Similar to configuring start G-code and end G-code in Cura, you will also encounter two input areas that allow you to add the G-code of your choice once you navigate to the related section of PrusaSlicer, allowing you to perform the necessary customizations.

Here is a step-by-step guide for configuring start and end G-code in PrusaSlicer:

  1. Click the Printer Settings tab on the top of the PrusaSlicer window.
  2. Click the Custom G-code tab from the left pane.

After following these steps, you will find the Start G-code and End G-code inputs (1st and 2nd from the top), which you can utilize to apply the necessary configuration.

Differences Between the Cura and PrusaSlicer G-Code Replacement Patterns

While the G-codes themselves don’t change between slicers, as they are based on the G-code flavor of the firmware you’re running, the replacement patterns, which are essentially variables that refer to data you have configured within the slicer, show slight differences in syntax.

Since the way that the replacement patterns (placeholders) are defined entirely depends on the developer’s choices, the only way to know which placeholders you should be using is to consult the documentation for Cura and PrusaSlicer.

For instance, while the replacement pattern for the heated bed temperature in Cura is “material_bed_temperature,” it’s “bed_temperature[0]” in PrusaSlicer.

To find out more about Cura’s replacement patterns, you can follow this link. On the other hand, for more information about PrusaSlicer’s placeholders, you can refer to this page.

Wrapping Up

While you can technically perform every action that goes into the start and end G-code sections manually, utilizing these sections to automate the commands that you require the 3D printer to run before and after each print is a much more efficient method that saves time and effort.

To quickly recap, optimally configuring the start G-code for the Ender 3 is all about adding the necessary G-code commands to increase time efficiency through pre-heating and reducing oozing by waiting to heat the nozzle up to the target temperature.

On the other hand, configuring the end G-code is much simpler, as adding the M400 (Finish Moves) G-code command is the only addition you will need to make to the standard Ender 3 end G-code block you can find in Cura.

Happy printing!