No products in the cart.
Just as humans use language to interpret and understand actions and commands, 3D printers have their own language: Gcode demands.
Gcodes instruct 3D printers on every action the printer must take, including movements, speed, temperatures, and much more. Having a basic understanding of what gcodes are will help you in your 3D printing processes by allowing you to work more efficiently and possibly even more creatively.
We’ll review all the basics you need to know about gcodes: how they work, how to read a line of gcodes, and a gcode cheat sheet.
Basic Guide to 3D Printer GCodes
Simply put, a gcode is a programming language that tells the printer what to do. These actions can include where the printer head goes, extruder temperature, bed temperature, pauses, printer head speed, and more.
Gcodes are actually used for a variety of machines, not just 3D printers! Cutting tools likes lathes and mills also rely on Gcodes.
On your computer, a g-ode will be a .gcode file. You can view the line by line code of the gcode by opening it in a text editor.
Gcodes are typically hundreds of pages long since they are directing every single action the printer is taking. Although gcodes are considered a fairly easy coding language, it is not recommended to write your own gcode: they are very complex, long, and if done incorrectly they can damage your printer. This leads us to our first question:
How are GCodes created?
Gcodes are created when you import an STL file into a slicing software. The slicing software will then configure a code based on the specificities of your 3D print’s design. The code is then sent to your 3D printer to bring the digital file to life.
Gcodes come in towards the end of the 3D printing workflow, but they are crucial for the success of your 3D print coming to life. A 3D design is made in a CAD software and exported as an STL, the STL file is then imported into a slicer software, like BCN3D Cura. Within the slicer software, you set your parameters, and then the software will create and export the .gcode. That file is then sent to the 3D printer through an SD card or wifi. The printer then uses each line of code for every action that it will take.
How to Read GCode
Gcode is a fairly simple and easy to understand code language. Each line of code tells the printer to perform one specific action, which is why there can be thousands of lines for just one print!
Although called gcode, it is actually made up of several different letters and numbers that have specific meanings or instructions. Also, gcodes don’t always start with the letter G. Geometric commands, or commands that deal directly with printing the object, start with a G. Non-geometric commands start with an M. An example of a non-geometric command could be setting the bed temperature or extruder temperature.
Here is an example of what a Gcode could look like:
56 G1 F2200 X22.3 Y56.4 E5.9
Let’s dive into the specific meaning of each letter and number you see:
- The first number: The first number you will see on a line of gcode is just specifying which number line you are on. Gcodes all exist on their own line, with the first line being 1.
- G or M followed by a number: A G or M with its corresponding number indicates a specific action that the printer must take. For most printers, these letter-number combinations are universal. Think of this as the “what” of the printer’s action, and the following numbers and letters as the “how.”
- X followed by a number, and Y followed by a number: These letter-number combinations indicate the x and y coordinates of where the printer head must go. Some gcodes may also include a Z coordinate.
- F followed by a number: The F in the gcode indicates the feed rate. Essentially, this tells the printer how fast or slow to move the printhead.
- E followed by a number: This tells the printer how much filament will be discharged from the extruder.
There are some additional letters and numbers that are used for M codes. For example, T indicates which extruder is being used, starting with T0 and moving up based on the number of extruders. S indicates the degree in celsius for an extruder.
Gcode Cheat Sheet
Now that you know what the letters stand for, let’s take a look at some common Gcode commands and their meanings.
G0 and G1: Move
This commands the print head to move in a straight direction. The print head will move to the indicated X and Y coordinates. The difference between G0 and G1 is filament extrusion, as G1 commands the printer to push out filament while G0 moves the print head without filament extrusion.
The E and F in the code will tell the printer how quickly it needs to move to that location and how much filament should be extruded during this time. This is the most commonly used gcode command.
G90 and G91: Absolute and Relative Position
Absolute position (G90) means that the printer head must move to the exact position indicated by the x and y coordinates.
Relative position (G91) means that the print head must move using the numerical values of the x and y coordinates, but not necessarily to those spots.
For example, if a line of code reads G90 G1 X40, then the print head must move to the X=40 position on the bed. But, if the line reads G91 G1 X40, then the print head must move 40mm from where the print head is currently located.
This command sends the print home back to its “home”, the X0 andY0 coordinates.
M104 and M109: Heat Extruder
Both M104 and M109 will heat the extruder to a specific temperature, the only difference is that an M104 command will allow the printer to take other actions while the extruder is heating and an M109 command will pause all activity until the final temperature is reached.
M140 and M190: Heat Print Bed
M140 and M190 work similarly to the above M commands except they deal with the temperature of the printing bed. An M140 command means the printer can take other actions while the bed is heating, and an M190 command will pause all actions until the bed is fully heated.
Some professionals may go their entire career without ever dealing with Gcodes, but having a basic understanding of how they work can actually aid you in your 3D printing workflow. Understanding how your 3D printer interprets commands and takes actions can help you if any problems occur with your printer and can even help you come up with new creative ideas for print projects.