Introduction to 3D Printer GCodes

in #printing3d7 years ago (edited)

gcode.png

What is GCode?

Gcode is a language of CNC instructions, they allow us to tell our 3D printer what to do. The codes we use will mostly consist of G- and M-commands ("Geometric" and "Machine", or "Misc" commands), telling the printer how to move, heat, what to display on the screen, and settings we need to change.

Ordinarily, the code is generated by our slicer software, but we can also tweak and send gcode by hand.

In the wider CNC world, Gcode has been standardized variously as RS-274-D and also ISO 6983, but when standards and the market go head to head, the market often wins. Most 3d printers we come across will use the open source Marlin as the firmware, so while we inherited gcode from CNC, in fact, most gcode we will USE is in the Marlin flavor.

Be aware there are also 3d printer specific gcode flavors that differ even further, such as the different versions of Ultimaker.

To keep up do date with the comprehensive list of codes, there is a RepRap wiki page http://reprap.org/wiki/G-code but we will go over the most common and useful here with some examples and explanations.

Sending GCodes

The usual process of manually and interactively sending gcodes is to use your slicers machine control panel after connecting via USB. There will be a communications tab or screen, with an input box and a "send button".

s3d.jpg

Some slicers hide the feature away, or do not provide access - especially those with a goal of being for absolute beginners. Fortunately, Octoprint also has a printer terminal interface, so you don't have to switch Slicer just for this.

octoprint.png

Start and End Gcode

Let's take a look at this example move command:

G1 X75 Y75 Z1 F3000.0 E0

This means to move to 75mm x 75mm, at 1mm z height, at 3000mm/minute, with no extrusion (essentially, go to the middle of my 150mm bed, hover above the build plate, and don't extrude).

Your start gcode sets up parameters of every print you send to that printer profile. Let's take a look at an example (from my CR-10):

cr10.png

G28 ; home all axes
G1 Z5 F3000 ; lift 5mm
G1 X5 Y10 F1500 ; move to prime position
G1 Z0.2 F3000 ; get ready to prime
G92 E0 ; reset extrusion distance
G1 Y80 E10 F600 ; prime nozzle
G1 Y100 F5000 ; quick wipe

Sometimes it is nice to add a small message:

M117 BY YOUR COMMAND!

Just like you have start gcode, you will have end gcode. Again, here is my CR-10 code:

G28 X0 ; home x axis
M106 S0 ; turn off cooling fan
M104 S0 ; turn off extruder
M140 S0 ; turn off bed
M84 ; disable motors

You might want to make a beep or, if you get creative, even a little tune:

M300 S880 P300

Up next, Gcode reference guide!

Sort:  

The programmed card you are using arduino?

I've always wondered. Thank you for sharing. @makerhacks

Congratulations This post has been upvoted by SteemMakers. We are a community-based project that aims to support makers and DIYers on the blockchain in every way possible.

Join our Discord Channel to connect with us and nominate your own or somebody else's posts in our review channel.

Help us to reward you for making it ! Join our voting trail or delegate steem power to the community account.

Your post is also presented on the community website www.steemmakers.com where you can find other selected content.

If you like our work, please consider upvoting this comment to support the growth of our community. Thank you.

Nice post, it is always the big vendors who like to mess with the standard everybody else is using.

Coin Marketplace

STEEM 0.14
TRX 0.24
JST 0.032
BTC 87065.98
ETH 2149.31
SBD 0.91