Marlin 3D Printer Gcode Quick Reference Guide

in #printing3d7 years ago (edited)

gcode-message.png

Previously we looked at what Gcode is and why it is important, now let's look at some of the things you can make your printer do and settings you can change.

Comments

You will have already seen me use these. ; starts a comment, a note to yourself that is not interpreted by the machine.

G0 and G1 – Straight Line Movement

With this command you are telling the print head to move to a certain coordinate, and how fast (with F AKA "Feed Rate") you want to move.

So if you wanted to move to the bottom left corner you would use:

G1 X0 Y0 F2400 ; move to 0,0 at the speed of 2000 mm/min

You can also move straight up:

G1 Z100 F1000 ; move the Z-axis up 100mm at 1000 mm/min

Extrusion also uses this command:

G1 E10; extrude 10mm of the loaded filament

So combining ...

G1 X10 Y10 E10 F2400 ; move to 10, 10 at the speed of 2000 mm/min while extruding

G2 & G3: Controlled Arc Move

G2 - Clockwise Arc
G3 - Counter-Clockwise Arc

Parameters:

X: X axis
Y: Y axis
I: X position to maintain a constant distance from
J: Y position to maintain a constant distance from
E: amount to extrude
F : The feedrate (mm per minute)

G4 Delay (dwell/pause/wait)

G4 P10 ; wait 10 milliseconds

G10 and G11 – Retract and Unretract

As well as the move/extrude, there is also retract and unretract - good for start and end moves.

G28 Home

Homing is how the printer knows where to start its coordinate system, so it is very important. Usually the front left of the build plate.

G28 ; home all axes (X, Y, and Z)
G28 X Y ; home X and Y axes
G28 Z ; home Z axis only

G29: Auto level-compensation

If you have a bed leveling sensor or probes, this will instruct the hot end to check the bed at 3 (or more) points.

Once the bed level is checked, the machine will have the z height compensated during printing to take account of the unlevel surface.

Before you run this command, the printer must already have been homed with G28.

This is commonly called "auto levelling" but that is innaccurate as the bed remains unlevel, the code is just compensating for that.

G90 and G91 – Set Positioning Mode (Absolute or Relative)

Very often you will know the precise coordinate you want to move to:

G90 ; use absolute positioning 
G1 X100 Y100 F2000 ; move to 100, 100 coordinate

But sometimes you just want to move away from wherever you are (often called "jogging"):

G91 ; use relative positioning 
G1 X100 F2000 ; move 100mm to the right

G92 – Set Current Position

This tells the machine to forget its current coordinates and set what you specify:

G92 E0 ; set the current filament position as E=0
G92 X0 Y0 Z0; Set XYZ to now be regarded as 0, 0, 0

M0/M1 - Stop and wait for LCD button

This tells the machine to wait for a button press, optionally you can provide a prompt message to show on the LCD screen. Prusa uses this to good effect with their calibration procedures.

M0 Click When Ready; will wait for a button press

M18 - Disable all stepper motors; same as M84

This is useful when you want to manually push the bed or hot end around freely.

M24 - Start/resume SD print

M25 - Pause SD print

Pausing and restarting printing off the SD card, but be aware it does *NOT happen right away - your printer has a buffer so until those commands have flowed. printing will continue.

For pausing to switch out filament, use M600.

M80 - Turn on Power Supply

M81 - Turn off Power Supply

For machines with software control of power. If the configuration is not set up then this command will, of course, be ignored.

Our old maker space Ordbot printers required this command and it caused all kinds of confusion with members thinking the machine was broken!

M104 and M109 – Extruder Heating Commands

M104 S210 T0 ; start heating 
M109 S210 T0 ; wait for the first extruder to reach 210c

(T is variously thought of as "Thermistor" or "Target", but in our use, it is which extruder you are specifying)

You can use M105 to report the current temp

M117 - display message on the LCD screen

M117 "Hello!" ; Say hello

M140 and M190: Set Bed Temperature

M140 S60

M190 waits for the temperature to be reached before continuing.

M116: Wait for temperatures stabilize

Waits for all temperatures to stabilize at set values.

M112: Emergency Stop

Unlike with 'pause', any commands are immediately canceled and everything shuts off. Only use in emergencies!

M106 – Set Fan Speed

The fan speed is a value between 0 and 255 (full).

M106 S255 ; set the fan to full speed

M106 S127 ; set the fan to roughly 50% power

M106 S0 ; turn off the fan completely

M300 - Beep

M300 SHz PMs

M300 S500 P100 ; beep!

M303 - PID relay autotune

If you find your temperature fluctuations are out of control, run the following gcode (from cold):

M303 E0 S210 C8

This heats the nozzle around the target temperature (210c) 8 times.

Set the results back into your EEPROM with M301:

M301 P20 I1 D100

Then store them away (see below):

M500

EEPROM - non-volatile memory (remembers even when powered off)

M500 - saves EEPROM values
M501 - reads values back from EEPROM
M502 - "factory reset"
M503 - report the current values

M600 - Pause for filament change

This will move the head away to allow you to change or reload filament. With nothing after the M600 it will use the defaults.

Amazing that only a few years ago this was considered experimental, and now it is taken for granted!

M600 X10 Y10 Z10 E2; pause, retract and move out of the way for filament change

Hope you found this useful!

There are many other commands but these I think are the most immediately useful!

Happy Printing :)

Sort:  

The most common thing I want to buy is the 3d printer. I buy from the gearbest or aliexpres markets to buy the small apparatuses. Cargo takes a long time. It was a very informative sharing. Thanks again. @makerhacks

I hear so many people saying ‘signed’. What does ‘signed’ mean in the context of Steem????