G-code dictionary

Useful G-code dictionary


Contents

What are G-Codes


More and more often we need to surf across the web to find the correct Gcode for some task. Gcode is a very basic language and allows us to control our machines and to make them perform in any matter. We can change the greetings text or add a low bit photo, send manual commands, and change printer settings. The interface that allows you to create Gcodes suitable for our 3d printers is a special software called Slicer. They are
particular programs dedicated to the transformation of a model in machine language, the GCODE. This software translates the path that the nozzle will have to carry out and determine how much material to deposit, in total autonomy, creating our object. These commands that we use for 3D printers are the same that are used for CNC mils.

Surely the machine knows how to calculate and determine the most efficient path, and the way of doing its job, but human intervention is crucial for various settings, we have to manually add some information that the machine doesn’t know, pieces of information as material type, speed, supports, etc.
Once this is done, however, the software proceeds autonomously to form the Gcode, which is the set of movements combined with an extrusion that is performed in a precise order and perfect timing. Finally resulting in our printer object. This is the basics

Why do we need to know Gcode commands then?


The answer to this question is one and simple:
Customizing marlin code

There are cases when we need to alter the Start code or finish g code

For example, if we want a lower electrical consumption, we could tell our machine to turn off the nozzle, the build plate, and the motors at the end of the job, in this way we may not be present at the end of the print, avoiding current consumption and overall risk, or another case, if we have a leveling probe, we need to alter the start code to level the plate before each print.

How to modify G-codes

These changes can be made in 2 ways:

Using the slicer

Any slicer has a special space where is configured the head and the tail of the overall generated Gcode. Once we find this space, we just need to add the lines of code corresponding to the commands we want to add and the machine will automatically complete them in every print. An example of a rather common start and end Gcode is the following:

Start G-code

 G28 X0 Y0 Z0 - Home all axes
 M107 - Turns off the layer fan if is turned on
 G1 F200 E3 - Extrudes a small amount of filament to ensure that the extruder is loaded.

END G-code

G28 X0 Y0 - Return to zero on x and y-direction
M104 S0 - Turn off the extruder
M140 S0 - Turn off the hot build plate
G1 E1 F200 - Retracts a little filament
M84 - Disables stepper motors

Notepad /Text Editor

As a second method, less common than the first, we can have our favorite slicer process the code and then open the file with notepad. Through notepad, we will see all the commands and we can intervene by adding or removing commands to our pleasure. With this method, you can create a filament change script, and add it at a specific layer each time you need it.But be aware altering g-codes by hand is not easy and if you are not very sure of the process it’s better to avoid it. A simple and nice experiment to post-process a Gcode is to add music emitted by the motherboard buzzer, which could be used as a signal.

After this brief introduction, as promised, here is the list of Gcode commands, a comprehensive dictionary for every kind of person.
Just as for languages, ​​it is not enough to know the words but you will have to compose real sentences, you will have to follow the correct order of the commands if you want to be understood by your interlocutor: the machine.

GCODE DICTIONARY


G codes Base of the G code iso

G0 Rapid movement


example: G0 X11 rapid movement in X = 11mm.

G1 Controlled Movement X Y Z E

example: G1 X80 Y10 E10 moves from the current position (X0, Y0) to (80.10) and extrudes 10mm of materials

G2 Clockwise arc controlled movement

example of code g2: G2 X80 Y10 I5 J10 E10 goes from the current position (X, Y) with a clockwise arc movement to the position (80.10) keeping a constant distance from the point (5 10) by extruding the material from the current position to on arrival extruding 10 mm of material

G3 Counterclockwise arc-controlled movement 

example of the g code g3: the same as the previous command but the arc movement is counterclockwise

G4 Break for S or P


example: G4 P200 does nothing for 200 msec.


Inserts a pause of the indicated number of milliseconds. During this time the machine maintains the parameters but remains stationary.

G28 Returns to the point of origin of the axes
G29 Bed Leveling. Use a three-point test.
G30 Z probe test. Use a single test point
G31 It reports the current test status.
G90 Set all axes to absolute
G91 Set all axes to relative
G92 Set the coordinates


example G92 code: allows programming the absolute zero, to reset the current position to the specified values. No physical movement will occur. Without any specification, the command will reset all axes to zero. g code set zero.

M codes Base of the G code iso

M0 Stop


Example: M0 – The machine stops returns to its rest position, then switches off. All engines and heaters turn off. To restart the printer you have to press Reset.

M1 Sleep.


Example: M1 – The machine stops returns to its rest position, then switches off. All motors and heaters are turned off. The machine restarts by pressing any button

M104 Sets the temperature of the selected extruder


Example: M104 S190 sets the extruder temperature to 190 ° C

M105 Reads the current temperature from the sensor 
M106 Fan on 
M107 Fan off 
M108 Sets the extrusion speed
M109 Sets the extrusion temperature and waits
M114 Displays the current position
M115 Displays the current firmware version

Advanced M codes

 M17 Turns all stepper motors on or off
 M18 Turns off the stepper motors like the M84 command
 M20 Shows the contents of the SD card
 M21 Initializes the SD card
 M22 Removes the SD card
 M23 Select a file from the SD
 M24 Starts or resumes printing of an SD file
 M25 Pause of printing from SD
 M26 Sets the position of the SD in bytes
 M27 Reports the printing status of the SD file
 M28 Start writing to SD
 M29 Ends writing to the SD
 M30 Deletes a file from the SD
 M41 Loop printing
 M42 Change pin status via gcode
 M80 Turns on the power supply(This command will work only with integrated power supply)
 M81 Turns off the power supply(This command will work only with integrated power supply)
 M82 Select the absolute codes of extruder E (default)
 M83 Select the relative codes of the extruder E
 M84 Disable the stepper motors until the next movement, or use S to specify a waiting time     before the motors are disabled. S0 is used to disable waiting.
 M85 Shutdown using a time parameter(S). To disable it, set it to zero (default)
 M92 Sets the value of the steps for each axis, useful when setting new values after calibration 


example: M92 E688.4 Set E steps for a new extruder


M114 Sends the current position to the serial port
M115 Notifies the current version of the Firmware and the capacity of the microcontroller used
M117 Displays a message


example: M117 “Printer Name”: displays the printer name on the LCD.


M119 Reports the endstop status
M140 Sets the temperature of the print bed


example: M140 S80


M190 Wait until the print bed temperature reaches the set temperature
M200 Sets the filament diameter


example: M200 D2.85


M201 Sets the maximum printing acceleration in units / second square for movements during printing (M201 X1000 Y1000)
M202 Sets the maximum acceleration in units / second squared for non-printing movements (M202 X1000 Y1000). This command is not used in the Marlin firmware.
M203 Sets the maximum extrusion speed of the machine (M203 X200 Y200 Z300 E10000) in mm / sec
M204 Sets the default speed: S for normal movements; T for movements retraction (M204 S3000 T7000) in mm / sec
M206 Sets an additional resting point
M207 Set the retraction settings for the firmware


example: M207 S10 F40 Z0 length S [positive mm] F [feedrate mm / sec] Z [additional zlift / hop]


M208 Sets the maximum movement for the axes
M209 Enable automatic retraction
M220 Sets the value of the feedrate override factor in percent
M221 Sets the value of the flow in a percentage
M240 Trigger camera to take a photo
M300 S (XXXX) P (XXXX). M300 tells the printer: "sing!". S is the pitch of the sound and P is the duration in milliseconds.
M301 Set the parameters PID, P I and D
M302 Enable cold extrusion
M303 PID relay autotune S sets the temperature (default = 150C)
M400 Ends all movements
M500 Stores the parameters in the EEPROM
M501 reads the parameters from the EEPROM
M502 Return to factory settings. Of course, these must have been previously stored in the EEPROM.
M503 Print the current settings (from memory and not from EEPROM)
M999 Restarts after an error

Conclusion

As you can see there are lots of useful codes that we can use for many purposes. Now, try to get creative and custom your start/end script to make 3D printing smarter!
If you find a useful G-code which is not on the list, feel free to comment below!

This post may contain affiliate links

Summary
Useful g-code dictionary
Article Name
Useful g-code dictionary
Description
More and more often we need to surf across the web to find the correct Gcode for some task. Here you can find the most useful ones.

Leave a Reply

Your email address will not be published. Required fields are marked *