G-code is a dark art amongst the 3D printing community. You can work for years without touching it, yet it can be used to solve very specific problems when needed. After comparing a variety of “magic” slicer profiles, I realized a lot of the magic in the g-code. In many cases, a bit of embedded g-code sets printer values that provide most of the benefit with little or no explanation.
The high-tech Prusa i3 Mk3 is controlled using g-code, a decadesold rudimentary control language used to instruct the printer to move, extrude or otherwise create a printed part. The printer has no real intelligence or decision-making capabilities. Everything the printer does is based on g-codecommands.
These notes are based on my experiences with the Prusa i3 Mk3 printer. If you are using a different printer, please verify the hardware details are same. These pages may be a bit rough as I revise them and add new material. Please check back regularly for updates.
Until recently, tuning accleration, jerk and other hardware settings required tweaking and inserting gcode commands by hand. More recent versions of slicers – notably PrusaSlicer and Ultimaker Cura – have begun exposing these settings in the printer, print and filament profiles, making them much more accessible and easy to adjust between prints. While moving these commands to the slicer GUI is a big improvement, there are still several refinements to print start and stop sequences that are useful to do at print start and finish and various points in between. Custom g-code is the right place to insert these functions.
- At the start of a print, startup gcode can insert printer initialization commands, warmup routines and nozzle priming.
- At the end of a print, end g-code is responsible for turning off heaters, motors and fans. It can also be modified to move the extruder and bed after a print, make noises or otherwise tidy things up.
- Between layer changes, gcode is useful for adjusting hardware settings like nozzle temperatures and other settings based on the current layer number or height.
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 can cause damage if your printer is not adjusted properly.
Contact and feedback
Last updated on 20190729