Synopsis of the tool/technology
The nuances of GCODE as related to the Dremel 3D45 3D printing devices.
G-code is a programming language that is utilized to tell machines how to do something. In regards to 3D printing, g-code contains a series of commands that move parts of the printer.[1]
G-Code Commands
G-code stands for geometric code, where the variation of the alpha numeric patterns are communicating to the machine specific commands (N## G## X## Y## Z## F## S##).
Codes that are Relevant to the Dremel 3d45 3D printers at the GSD are:
G: Motion
X: Horizontal position
Y: Vertical position
Z: Depth
F: Speed of the print head movement in mm/min (millimeters per minute)
S: Value input for temperature in Celsius or value input for fan speed indicated in increments of 255, where S255 = full speed and S0 = turned off
E: Length of material to be extruded in mm
P: Value of time in ms (milliseconds)
Most machines speak variations of the g-code, making the code vary depending on type, make, and model of the printer. Machine specific commands are those that start with an M. M-codes tell the printer how to perform an action, such as the start/end of the program and what temperature to heat the extruder to.[2]
How to Read G-code Commands
Here is a typical example of a line of code:
G1 X-10 Y-4.3 Z0.5 F4000.0 E0.089
This line is telling the printer to move along a straight line toward the coordinates X=-10, Y=-4.3, and Z=0.5 with the print head moving at 4000 mm/min. The code is also telling the printer to extrude 0.089 mm of filament while it is moving.
Every line begins with a command, in this case the command is G1. The initial command does not always begin with a G. Geometric commands are not enough to control every aspect of a printer. If one needs to raise the bed temperature or turn the fan off an M code will need to be used. Here is a typical example of an M code:
M140 S100
This line is telling the printer to set the bed temperature to 100 degrees.
The portions of code that follow the initial command are referred to as arguments. Each argument tells the printer how to execute the command. For example, Y-4.3 means a destination Y coordinate of -4.3.
Movement Commands
G1 is the command for linear movement, telling the printer where to move along a straight line to the specified location. The command may be used to move a single axis or multiple axes simultaneously. A majority of 3D printing occurs during the execution of this command, allowing for the extrusion of material during execution.
G0 is the command for rapid movement, which tells the printer to move at its maximum travel speed to the specified coordinates. The nozzle will not extrude any material during the execution of this command.
Watch the Dremel 3D45 moving along the X axis, video taken from the front of the machine and video taken from above the machine.
Extrusion Commands
A printer may extrude as specified by the extrusion argument E. An example of a typical line of code with an extrusion command is:
G1 E10 F800
This line is telling the printer to extrude 10mm of filament, as the E value is 10, while the print head is moving 800 mm/min.
Watch the Dremel 3D45 as it extrudes filament at a speed corresponding to the speed at which it travels.
Heating Commands
There are two types of extruder heating commands used to set the temperature of the printer’s extruder. The first is M104, which starts heating the extruder, but allows the printer to run other commands immediately after. The second, M109, will instruct the printer to wait until the desired extruder temperature is reached before starting any other commands.
Here is an example line of code showing the usage of the extruder heating commands:
M104 S170 Start heating the extruder to 170 degrees Celsius
G28 X0 Home X axis while extruder is still heating
M109 S170 Wait for the extruder to reach 170 degrees Celsius before continuing
The argument following heating commands are indicated by the value S. This specified the extruder temperature in Celsius.
There are also two types of bed heating commands, used to set the temperature of the heated build platform. The first command is M140, which starts to heat the build platform to a specified temperature while allowing other commands to be run immediately after. The second, M190, will instruct the printer to wait until the build platform is heated to a specified temperature before continuing with other commands.
Here is an example line of coding showing the usage of the bed heating commands:
M140 S35 Start heating the bed to 35 degrees Celsius
G28 Home all axes
M190 S35 Wait for the bed to reach 35 degrees Celsius before continuing
Homing Commands
Homing is the process by which the printer determines the extruder’s location.
G28 is the command for the printer to run its homing sequence. In this process the toolhead is moved to the far edges of the bed until it comes into contact with endstops at the specific locations. Most prints begin with this command so that printing commences at a known location.
Here are some examples of the code:
G28 Home all axes (X Y Z)
G28 X Y Home X and Y axes
G28 Z Home Z axis only
Start Commands
Start g-code script prepares the printer for producing a given file. At a minimum, start codes must tell the printer what temperature the extruder and heated bed need to be set to and the toolhead needs to be homed. It will also contain code information to set the units of the printer, which will always be in millimeters.
Here is the start.gcode script produced by 3DPrinterOS:
G21 Sets the units to millimeters
G90 Sets an absolute positioning or an “absolute zero”
M82 Sets the extruder to absolute positioning
G28 Z0.000 Home Z axis
G1 Z10.000 F1800 Move toolhead to Z=10.00 with the print head moving at 1800 mm/min
G28 X0.000 Y0.000 Home X and Y axes
M140 S35 Heat the bed to 35 degrees Celsius and continue
M190 S35 Wait until the bed is heating to 35 degrees Celsius before continuing
M104 S220 T0 Heat extruder to 220 degrees Celsius and continue
M6 T0 Stabilize extruder
M106 Set Fan Speed
G1 X0.000 Y0.000 Z0.000 Move toolhead to X=0 Y=0 and Z=0
G92 E0 Set current filament position to E=0 mm
G4 P2000 Dwell (do nothing) for 2000 milliseconds
M106 S255 Set fan to full speed
Stop Commands
Stop g-code script prepares the printer for completing all specified functions and finishing off the print. This also includes command for stopping all functions when the print has been completed. The most important commands are those than turn of heating and motor functions.
Here is the end.gcode script produced by 3DPrinterOS:
M106 S0 Turn off fan completely
M104 S0 T0 Reduce heat of the extruder to 0 degrees Celsius
M84 Disable all stepper motors
[1] https://www.autodesk.com/industry/manufacturing/resources/manufacturing-engineer/g-code
[2] https://www.autodesk.com/industry/manufacturing/resources/manufacturing-engineer/g-code
The Fabrication Lab is intended for the use of the faculty, staff, and students enrolled in courses at the Graduate School of Design pursuing academic work. Please see our Policies page for more information.