Custom g-code is something of a dark art amongst the 3D printing community. After using several slicers and comparing a variety of profiles, I realized a lot of the magic behind the best profiles was happening in the g-code. Many of the best embedded hardware parameters in a section of settings not fully understood by many.
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 and jerk 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 things you’re likely to want to do at the start and finish of each print. Custom G-code is the right place to insert these functions.
If you run into a printing challenge that can’t be handled with your slicer settings, a bit of custom g-code may be the fix you’re looking for. There may be printer options you want to enable, or setup procedures you want to run before, during or after a print. The Prusa i3 Mk3 is controlled using g-code, a rudimentary language used to instruct the printer to move, extrude or otherwise create a printed part. Fortunately, most slicers allow inserting custom g-code at several points during a print to work-around some slicer software limitations.
- 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, but can also be tweaked to move the extruder and bed after a print.
- Between layer changes, gcode is useful for adjusting hardware settings like nozzle temperatures and other settings based on the current layer number or height.
While moving these commands to the slicer GUI is a big improvement, there are still several things you’re likely to want to do at the start and finish of each print. Custom G-code is the right place to insert these functions.
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.
Contact and feedback
Last updated on 20190517