2.2.14. PrusaSlicer Start G-Code for the Prusa i3 Mk3
The default g-code that ships with PrusaSlicer works just fine, but I found myself wanting to tweak a few things to my liking. I have updated my startup g-code to incorporate several functions that I want to use on every print:
A 2-step “no ooze” nozzle warmup routine to speed up the heating process, but avoid dots and strings caused by molten filament dripping out during mesh bed leveling and bed warmup. 1
Position the nozzle away from the PEI print surface during nozzle heating and startup movement to avoid damaging the print surface.
A modified prime line print routine to catch errant nozzle ooze, test extrusion and perform a final wipe action to avoid stringing between the prime line and start of the print.
PINDA warmup to ensure a consistent 35C PINDA temperature before performing mesh bed leveling to ensure consistent results. This is only necessary for printers with PINDA v2.0 probes as shipped on the original Mk3. 2 It is optional for PINDA v2.1+ and SuperPINDA configurations. For more information, check out the PINDA warmup notes page.
Important
Prusa has recently released the SuperPINDA sensor for bed leveling. SuperPINDA works differently than the previous generations of PINDA sensors. If the M860 gcode command is used, printers with the SuperPINDA mounted will simply hang.
I have updated this page and the referenced gcode to detect whether the user is using a Mk3S or Mk3S+ printer profile. Lines of gcode will inserted or left out based on this setting. If you are runnning a SuperPINDA on a Mk3 (not Mk3*S*) printer profile, this gcode may not work. I do not believe there is a way to detect a SuperPINDA configuration in the slicer at this time. Please let me know via the contact links at the bottom of this page if you encounter any problems.
I’ve incorporated these features into my own customized g-code settings for PrusaSlicer.
Note
These notes are based on my experiences with the Prusa i3 Mk3 and Artillery/Evnovo Sidewinder X1 printers. If you are using a different printer, please verify the hardware details are similar.
Here’s a line-by-line breakdown:
Caution
Please be sure that you’ve calibrated your printer, and particularly your Live-Z settings before using any of the following examples. These routines move the nozzle around close to the bed, and could cause damage if your printer is not adjusted properly.
2.2.14.1. Version control
The first lines are simple date, firmware, and hardware setting checks.
Line 3 chirps the printer speaker. I’m not a fan of loud piezo beeps, much less music, but I have inserted several chirp sounds (
M300 S100 P10
) to indicate progress throughout the print.Line 4 does a printer model check. If you generated gcode using PrusaSlicer configured for a different printer, you’ll receive a warning.
Line 5 does a nozzle diameter check. If you generated gcode using PrusaSlicer for a different nozzle size than you’ve set in your printer settings menu, you’ll receive a warning. Note that the firmware currently only supports 0.25, 0.40 and 0.60mm nozzle sizes.
Line 6 does a firmware version check. If you print generated gcode on a printer running an older firmware version, you’ll get a warning message to update. You can press the front knob to continue and ignore this warning, but updating to recent firmware is always recommended to take full advantage of enhanced features that Prusa is continually adding to the printer firmware and PrusaSlicer.
1; PrusaSlicer start gcode for Prusa i3 Mk3
2; Last updated 20210316
3M300 S60 P10 ; chirp
4M862.3 P "[printer_model]" ; printer model check
5M862.1 P[nozzle_diameter] ; nozzle diameter check
6M115 U3.9.0 ; tell printer latest fw version
Note
I am not a fan of the printer and nozzle checks since I am the only user of my printer. I have disabled these checks in the printer menu.
2.2.14.2. Initialize movement and extrusion coordinates
The next stanza sets the initial movement and extrusion coordinates. These aren’t technically required, but if they’re improperly set, they can cause problems with a print.
Line 9 sets absolute move coordinates for movement.
Line 10 sets relative extruder coordinates.
7M117 Initializing
8; Set coordinate modes
9G90 ; use absolute coordinates
10M83 ; extruder relative mode
2.2.14.3. Initialization
The next block resets printing parameters that can persist after an aborted job.
Line 12 disables volumetric e (autospeed) printing.
Line 13 resets the print speed to 100% on the printer in case it was previously changed by using the front knob or an aborted print.
Line 14 resets the extrusion multiplier to 100% on the printer in case it was previously changed by using the front knob or an aborted print.
11; Reset speed and extrusion rates
12M200 D0 ; disable volumetric e
13M220 S100 ; reset speed
14M221 S100 ; reset extrusion rate
2.2.14.4. Initialize warmup temperatures
The next block sets initial “two step” extruder warmup temperatures to avoid oozing during mesh bed leveling.
Note
I have modified this section significantly as of January 2021:
Versions of the PINDA probe since the original v1 version do not require the PINDA warmup routine to ensure consistent results. However, warming up the printer is still recommended, particularly on cold days. The “PINDA warmup” is a good way to accomplish this.
The SuperPINDA sensor used on the Mk3S+ printer is not compatible with (and does not need) the PINDA temperature check.
I have added checks for a Mk3s/Mk3s+ printer. PINDA temperature checks will be skipped if you are running this gcode with one of these printers. Unfortunately, this also means you will lose the benefit of warming the entire printer up before the first print of the day. I am working on a solution to still provide a reasonable warmup.
Line 17 sets the extruder (nozzle) temperature to 160C (
S160
), a good “no ooze” temp that will soften most filament, but not hot enough to cause filament to trickle out of the nozzle. This will prevent dots of filament and stringing during mesh bed leveling.Line 18 sets the bed temperature.
If you are using this gcode on a Mk3s/Mk3s+ printer, the bed will be set to the temperature set in the filament settings profile.
If you are not running a Mk3s/Mk3s+ printer, the bed temperature will be set to the higher of the specified bed temperature or 80C. This is to ensure that the bed is hot enough to warm up the PINDA even on cold days.
Note
I set the bed to 80C due to cold weather. See the PINDA warmup notes for details.
Line 20 waits for the nozzle to hit the no-ooze temp before proceeding. This ensures any filament stuck to the nozzle will be soft enough to squish if it hits the PEI print surface.
15; Set initial warmup temps
16M117 Nozzle preheat
17M104 S160 ; set extruder no-ooze temp
18M140 S{if printer_model=~/.*MK3S.*/}[first_layer_bed_temperature]{else}{max(first_layer_bed_temperature[0],80)}{endif} ; set bed PINDA warmup temp
19; Nozzle warmup before home to avoid driving hardened ooze into PEI surface
20M109 S160 ; wait for extruder no-ooze warmup temp before mesh bed leveling, cool hot PINDA
2.2.14.5. Initial homing
The next stanza prepares for initial homing. On startup, the printer has no way of knowing where the extruder is in 3D space, so homing is necessary for it to establish a known position. This is to ensure that any filament hanging from the nozzle is sufficiently soft to either break off or bend when the nozzle is lowered in the next line. This avoids creating dents in the PEI sheet at the lower-left corner.
Line 24 performs homing (
G28 W
), moving the printer to the lowest (Z 0
) left (X 0
) front (Y 210
) coordinates to establish the current position.
21; Home
22M300 S40 P10 ; chirp
23M117 Homing
24G28 W ; home all without mesh bed level
2.2.14.6. Bed presentation
This stanza presents the bed for inspection and cleaning while waiting for the bed to come up to final printing temperature. The nozzle is moved to the center-rear portion of the bed, positioned slightly forward so the extruder is warmed by the bed.
Line 26 raises the nozzle 3mm to avoid possibly damaging the PEI sheet during nozzle movement in the steps that follow.
Line 27 moves the nozzle to the center (
X 125
) back (Y 180
) to allow access to the bed for final inspection and cleaning while waiting for the PINDA warmup in the following steps.
Note
I recently moved the resting Y position closer to the bed center to improve PINDA warming.
Line 28 lowers the nozzle and PINDA probe close to the bed (
Z 0.15mm
) to aid in warming up the PINDA probe.
25; Present bed for final cleaning
26G0 Z3; Raise nozzle before move
27G0 X125 Y180 F10200; Move nozzle to PINDA warming position
28G0 Z0.15 F10200; Lower nozzle to PINDA warming position
2.2.14.7. PINDA warmup
The next stanza conditionally performs a PINDA warmup routine. If you are running a Mk3s/Mk3s+, this procedure will be skipped. This procedure will only be run if you not using this gcode as part of a Mk3s/Mk3s+ printer profile.
The PINDA warmup procedure waits for the PINDA probe to reach a consistent temperature before automatic mesh bed leveling (MBL). For more info on the PINDA warmup procedure, refer to the about PINDA warmup notes.
Note
This procedure has become considerably more complex due to the need to do additional checks for the printer type. It is a good example of using the PrusaSlicer conditional code checks.
Line 31 starts a block of gcode that will be inserted if the printer_model placeholder contains the text “MK3S”.
Line 32 sends a message to the printer display (
M117
). You can insert lines to be inserted only for a Mk3s/Mk3s+ printer here.Line 33 starts the block of gcode that will be inserted if the printer_model placeholder does not contain the text “MK3S”.
Line 34 sends a message to the printer display (
M117
).Line 35 inserts the command (
M860 S35
) to wait for the PINDA probe to reach at least 35C, an all-around good temperature for mesh bed leveling. Note that this can take a long time (5-10 minutes) on the first print on a cold day. For subsequent prints, it should warm up much more quickly.Line 36 ends the block of gcode that will be inserted if the printer_model placeholder does not contain the text “MK3S”.
Line 37 sets the bed temp specified in the filament settings. This is done here before mesh bed leveling to let the bed cool down to close to the final print temperature as MBL completes.
Line 38 raises the nozzle 3mm (
Z3
) for movement as a precaution before rapid moves close to the print surface.
29; Wait for PINDA warmup
30M117 PINDA warmup
31{if printer_model=~/.*MK3S.*/}
32M117 Mk3S detected, no warmup required
33{else}
34M117 Mk3 Waiting for PINDA warmup
35M860 S35 ; wait for PINDA temp to stabilize
36{endif}
37M140 S[first_layer_bed_temperature] ; set target bed temp
38G0 Z3; Raise nozzle before move
2.2.14.8. Mesh bed leveling and final warmup
Now that any preparation is complete, we can perform mesh bed leveling.
Line 42 performs the actual leveling (
G80
). With the latest firmware releases, this will do either 3X3 or 7X7 grid leveling as configured in the printer setup menu. After leveling, the nozzle will return automatically to the home position.Line 44 stores the leveling results for use with the Octoprint Prusa mesh bed leveling plugin.
39; Mesh bed leveling
40M300 S40 P10 ; chirp
41M117 Mesh bed leveling
42G80 ; mesh bed leveling
43M117 Saving results
44G81 ; save mesh leveling results
2.2.14.9. Final temperature settings
After all calibration and settings are done, we set final temperatures in preparation for starting the actual print.
Line 47 raises the nozzle 5mm (
Z5
) while we wait for the nozzle to come up to full print temperature. This both avoids possibly damaging the PEI sheet under the nozzle, and also provides a clean prime line in the steps that follow.Line 48 sets (
M140
) the first layer bed temperature set in the filament settings profile.Line 49 sets (
M104
) the first layer print temperature set in the filament settings profile.Line 50 waits for (
M109
) the first layer print temperature set in the slicer settings.Line 51 waits for (
M190
) the first layer bed temperature to settle before printing.
45; Final warmup routine
46M117 Final warmup
47G0 Z5; Raise nozzle to avoid denting bed while nozzle heats
48M140 S[first_layer_bed_temperature] ; set bed final temp
49M104 S[first_layer_temperature] ; set extruder final temp
50M109 S[first_layer_temperature] ; wait for extruder final temp
51M190 S[first_layer_bed_temperature] ; wait for bed final temp
52; Prime line routine
2.2.14.10. Prime line
Once the nozzle and bed come up to temperature, a custom prime line is printed. I’ve made some tweaks to the bog-standard line.
Line 55 lowers the nozzle (
Z0.15
) to initial printing position.Line 56 disables Linear Advance (
M900 K0
) for printing the prime line. With LA enabled, I often get distracting extruder clicks and skips when printing the initial thick line.Line 57 resets the current extruder position. This is done periodically when extruder moves are set to relative. It ensures that the amount of filament extruded does not drift over time.
Line 58 moves to the initial prime line position at the left (
X=0
) front (Y=-3
) bed position.Line 59 extrudes an initial 2mm “blort” of filament without moving (
G1 E2
with no X or Y movement) to trap any ooze or string remaining on the nozzle.Line 60 extrudes 6mm of filament (
E6
) while moving 20mm along the X axis (X20.0
).Line 61 extrudes 3.2mm of filament (
E3.2
) while moving another 40mm along the X axis (X60
).Line 62 extrudes 6mm of filament (
E6
) while moving another 40mm along the X axis (X100
). I like another fat run at the end of the prime line to make it adhere better and avoid loose prime strips floating around.Line 63 retracts 0.8mm of filament (
E-0.8
) to reduce stringing.Line 64 performs a wipe action back over the printed line along the X axis (
X99.5
) without extruding (E0
).Line 65 moves another 10mm along the X axis (
X110.0
) without extruding (E0
) to complete the wiping action and eliminate any stringing.Line 66 de-retracts (pushes) 0.6mm of filament (
E0.6
) to re-prime after the previous retraction. Note that this is slightly less than was retracted in line 63 to avoid ooze as the nozzle moves into final printing position. If filament doesn’t flow at the start of a print, either use a skirt to prime the flow, or increase this to 0.8mm.
52; Prime line routine
53M300 S40 P10 ; chirp
54M117 Printing prime line
55G0 Z0.15 ; Restore nozzle position - (thanks tim.m30)
56M900 K0; Disable Linear Advance for prime line
57G92 E0.0 ; reset extrusion distance
58G1 Y-3.0 F1000.0 ; go outside print area
59G1 E2 F1000 ; de-retract and push ooze
60G1 X20.0 E6 F1000.0 ; fat 20mm intro line @ 0.30
61G1 X60.0 E3.2 F1000.0 ; thin +40mm intro line @ 0.08
62G1 X100.0 E6 F1000.0 ; fat +40mm intro line @ 0.15
63G1 E-0.8 F3000; retract to avoid stringing
64G1 X99.5 E0 F1000.0 ; -0.5mm wipe action to avoid string
65G1 X110.0 E0 F1000.0 ; +10mm intro line @ 0.00
66G1 E0.6 F1500; de-retract
67G92 E0.0 ; reset extrusion distance
2.2.14.11. Final print adjustments
Finally, we do any last minute print adjustments. I’m not doing anything here. Adjust for your printer.
Line 72 is commented out. It can be used to adjust the extrusion rate (
M221
). In this example, I set the rate to 90% for layer heights over 0.32mm. I find this is helpful when using large nozzles with very high layers. Generally, you want to set this in the extrusion multiplier for each filament profile. See my notes on the PrusaSlicer system preset for the Mk3-series for more detail.
68; Final print adjustments
69M300 S40 P10 ; chirp
70M117 Preparing to print
71; Adjust extrusion rate if desired
72; M221 S{if layer_height >= 0.32}90{else}100{endif} ; compensate for thick layer heights
73M117 Print in progress
At this point, the print will proceed normally.
2.2.14.12. Full startup g-code example
Here’s the full start g-code:
1; PrusaSlicer start gcode for Prusa i3 Mk3
2; Last updated 20210316
3M300 S60 P10 ; chirp
4M862.3 P "[printer_model]" ; printer model check
5M862.1 P[nozzle_diameter] ; nozzle diameter check
6M115 U3.9.0 ; tell printer latest fw version
7M117 Initializing
8; Set coordinate modes
9G90 ; use absolute coordinates
10M83 ; extruder relative mode
11; Reset speed and extrusion rates
12M200 D0 ; disable volumetric e
13M220 S100 ; reset speed
14M221 S100 ; reset extrusion rate
15; Set initial warmup temps
16M117 Nozzle preheat
17M104 S160 ; set extruder no-ooze temp
18M140 S{if printer_model=~/.*MK3S.*/}[first_layer_bed_temperature]{else}{max(first_layer_bed_temperature[0],80)}{endif} ; set bed PINDA warmup temp
19; Nozzle warmup before home to avoid driving hardened ooze into PEI surface
20M109 S160 ; wait for extruder no-ooze warmup temp before mesh bed leveling, cool hot PINDA
21; Home
22M300 S40 P10 ; chirp
23M117 Homing
24G28 W ; home all without mesh bed level
25; Present bed for final cleaning
26G0 Z3; Raise nozzle before move
27G0 X125 Y180 F10200; Move nozzle to PINDA warming position
28G0 Z0.15 F10200; Lower nozzle to PINDA warming position
29; Wait for PINDA warmup
30M117 PINDA warmup
31{if printer_model=~/.*MK3S.*/}
32M117 Mk3S detected, no warmup required
33{else}
34M117 Mk3 Waiting for PINDA warmup
35M860 S35 ; wait for PINDA temp to stabilize
36{endif}
37M140 S[first_layer_bed_temperature] ; set target bed temp
38G0 Z3; Raise nozzle before move
39; Mesh bed leveling
40M300 S40 P10 ; chirp
41M117 Mesh bed leveling
42G80 ; mesh bed leveling
43M117 Saving results
44G81 ; save mesh leveling results
45; Final warmup routine
46M117 Final warmup
47G0 Z5; Raise nozzle to avoid denting bed while nozzle heats
48M140 S[first_layer_bed_temperature] ; set bed final temp
49M104 S[first_layer_temperature] ; set extruder final temp
50M109 S[first_layer_temperature] ; wait for extruder final temp
51M190 S[first_layer_bed_temperature] ; wait for bed final temp
52; Prime line routine
53M300 S40 P10 ; chirp
54M117 Printing prime line
55G0 Z0.15 ; Restore nozzle position - (thanks tim.m30)
56M900 K0; Disable Linear Advance for prime line
57G92 E0.0 ; reset extrusion distance
58G1 Y-3.0 F1000.0 ; go outside print area
59G1 E2 F1000 ; de-retract and push ooze
60G1 X20.0 E6 F1000.0 ; fat 20mm intro line @ 0.30
61G1 X60.0 E3.2 F1000.0 ; thin +40mm intro line @ 0.08
62G1 X100.0 E6 F1000.0 ; fat +40mm intro line @ 0.15
63G1 E-0.8 F3000; retract to avoid stringing
64G1 X99.5 E0 F1000.0 ; -0.5mm wipe action to avoid string
65G1 X110.0 E0 F1000.0 ; +10mm intro line @ 0.00
66G1 E0.6 F1500; de-retract
67G92 E0.0 ; reset extrusion distance
68; Final print adjustments
69M300 S40 P10 ; chirp
70M117 Preparing to print
71; Adjust extrusion rate if desired
72; M221 S{if layer_height >= 0.32}90{else}100{endif} ; compensate for thick layer heights
73M117 Print in progress
Thanks /Urban for catching the paste error!
Contact and feedback
You can find me on the Prusa support forums or Reddit where I lurk in many of the 3D printing-related subreddits. I occasionally drop into the Official Prusa 3D discord server where I can be reached as bobstro (bobstro#9830). You can email me directly at projects@ttlexceeded.com.
Footnotes
- 1
The earliest reference to the “2 step” warmup procedure for the Mk3 that I have found is a post by @PJR on the Prusa forums back in 2017.
- 2
There is a lot of confusion about PINDA numbering. I’ve based these version numbers on the info in the Prusa knowledgebase and aprocryphal information here.
Last edited on Sep 22, 2021. Last build on Oct 22, 2021.