Anyone can use a 3D printer, thanks to how easy it is to download free object models online. So long as you have a basic knowledge of how to send G-Code to a 3D printer, you can get the physical created magically from a digital file.
As it turns out, there’s more to 3D printing than that. Once you understand a bit more about g-code and what makes 3D printers tick, you will have the power to customize g-code and create even more awesome projects and have the skills to troubleshoot problems easily.
After creating or downloading your project as an STL file, you will then proceed to feed it into a slicer software which will then generate the g-code file. Sending this file to the 3D printer is the last step of the process before you begin printing, which you can do by:
One of the best free software to help do all this is Repetier Host, but we will cover that later. For now, let’s start with g-code.
G-code is short for geometric code, a type of low-level programming language used by machines such as CNC (Computer Numerical Control) and 3D printers. The language is used to provide commands to control the movement of the machine head, provide initialization protocols, and other essential instructions.
G-code language is presented in cleartext format, which means that humans can understand it as easily as the printer does.
There are specific commands used in g-code to pass these instructions along. They are easy to understand once you have spent some time exploring the language.
G-code lacks sophisticated constructions such as variables and loops. Instead, it uses standard commands which serve as functions with arguments. An example of a line of code would look something like this:
G1 X-5.3 Y-5.5 Z2.0 F2000.0 E0.0250
The first command, G1, tells the printer to move in a straight line towards the coordinates (X-5.3 Y-5.5 Z2.0) at a feed rate of 2000 while extruding 0.0250 of material. Thus, the command comes with its own arguments, which makes the code very easy to read.
Here are 10 common g-code commands to help you understand and read it better.
This command tells the print head to travel at maximum speed to the coordinates specified. It will typically do so without extrusion, traveling through the three axes simultaneously. Another example of a rapid motion command could be G0 X8 Y15.
Unlike the command for rapid motion, this one provides arguments as parameters to control the coordinates for movement as well as the feed rate and volume of extrusion. The main example above, G1 X-5.3 Y-5.5 Z2.0 F2000.0 E0.0250, is one example of a G1 command.
This command instructs the printer head to return to the farthest edges of its travel until it contacts the end-stops. This “home” position gets the head out of the way when you’re ready to remove your finished product. You can also specify which axis you want the homing command to get out of the way.
These two commands instruct the 3D printer on which units to use. G20 tells it to use inches (imperial system), while G21 is for millimeters (metric system). As you can imagine, it is very important to be sure of which units you are referring to when you send direct commands to your 3D printer. For example,
G1 X-5.3 Y-5.5 Z2.0
Tells the printer to move 5.3 inches along the X-axis, 5.5 inches along the Y-axis, and 2 inches up.
These three commands are used to set the plane in which the printer head should move. T
G17 – this is a default for the X/Y plane
G18 – represents the Z/X plane
G19 – it represents the Y/Z plane
The printer head can use both absolute and relative positioning to move. Absolute positioning references the neutral point (X=0, Y=0, Z=0) to move to the exact Cartesian coordinates indicated, while relative positioning tells it to move in reference to its current position. Here are examples.
G1 X-5.3 Y-5.5 Z2.0 F2000.0 E0.0250
G1 X-5.3 Y-5.5 Z2.0 F2000.0 E0.0250
In both cases, you can instruct the printer to use either system of units.
This command tells the printer head to move clockwise starting from its current position. X/Y parameters specify the endpoint of the resultant arc, while the center of rotation is specified by the parameter I – this is the X offset of the head’s current position from the center of rotation. You can also set the Y offset of the center of rotation using the parameter J.
G20 G90 G17
G1 X5 Y15
G2 X150 Y50 I0 J-200
G3 commands follow the same format, only that the printer head moves anticlockwise.
G20 G90 G17
G1 X5 Y15
G2 X-150 Y50 I0 J-200
In either command, the second line of code gets the printer head to the starting point, while the third line defines the kind of motion, the endpoint, and center points respectively.
In reality, any g-code file will contain a lot of plaintext English comments to help ease understanding. This code also provides information such as the software version, printer type, filament characteristics, and more.
Code comments in g-code always start with a semicolon, which tells the printer not to execute them. For example:
G1 X5 Y15 ; Linear movement in a straight line to the coordinates X5 and Y15
M or “miscellaneous” commands are used to control printer settings. These can be anything from setting the temperature of the bed to putting the printer ON or OFF. For example:
M104 ; starts heating the extruder, but you can carry out more commands in the meantime
M109 ; instructs the printer to wait until the set temperature is attained
The arguments for this command are used to tell the machine what units are to be used. S is for degrees Celsius, T value is used when you have more than one extruder to specify which one you are referring to. For example:
M104 S230 T0 ; start heating the extruder T0 to 230 degrees Celsius
G28 X0 ; home the extruder on the X-axis while it continues heating
M109 S230 T0; wait for T0 to reach 230 degrees before executing the next command
For printers with only one printer head, you can eliminate the T arguments. M140 and M190 are used in the same way to heat the printer bed, but only the S argument is needed.
F-values specify the feed rate – that’s the rate at which the extruder traveling. These values are usually set in mm/min, so a value of F300 means a rate of 5mm/s. E values are used to signify the amount of material extruded so far on filament 3D printers. It’s much easier to just let the slicer program handle this automatically.
Now that you understand the technical part of g-code, actually sending the completed .gcode file to the printer should be easy. There are three ways to do it:
This is the easiest and most common way to send the .gcode file to your 3D printer. Every printer has an SD card slot and comes with an adapter, and you can use almost any decent size SD card for the job.
Once you have the file loaded on the card, simply insert it into your printer, initialize it, and select the file name under which you saved the .gcode file for the particular project. Your printer’s manual should have information on how to do this.
A direct cable connection is one way to send g-code from a computer to a 3D printer. You will need a software terminal that can use the PC’s COM port to make this possible, one of which is Repetier Host. More about Repetier in a bit.
Most people don’t favor this method because the PC will need to stay connected to the printer for the entire time the print is in progress, which could be hours or days. If on a laptop, even going into sleep mode can interrupt or ruin the printing process.
Some of the best 3D printers out there actually come with inbuilt wireless connectivity using WIFI. It is an easy way to send raw g-code to a 3D printer and even edit it manually in the process.
If you have one of those budget 3D printers, you can even upgrade the controller or use a Raspberry Pi or Arduino module to give it wireless connectivity.
In this case, you will also need a software host such as Repetier to create a send path for the file to the printer. As with the direct connect method, any interruption in your WLAN connectivity can ruin the printing process. Repetier uses a more reliable method of caching the model onto its servers.
Repetier Host is a free program combining a slicer and g-code editor as well as object placement, basic design, and communication functionalities into one convenient program.
Using Repetier Host is easy enough. You simply load your STL file by selecting “Object Placement.” After this, select “Slice with Slic3r” or “curaEngine”, which will generate the g-code file. You can then save this file to your computer and copy it to an SD card.
Connecting over WIFI or cabled connection is a bit more technical, but Repetier as a full how-to guide on the process here.
3D printing has now become simple and easy, but it is still a pretty technical process. If you’re just getting started, you should read through the book 3D Printing for Dummies to get acquainted with the fundamentals. The book covers things like types of 3D printers, materials, assembly, calibration, web-based printing, and more.
In reality, learning how to send g-code to a 3D printer is only the first step of the process. If you want to get better and gain more control, contrive to understand how g-code works and what the g-code file actually looks like. After all, 3D printing isn’t really for dummies.