G-Codes

🔧 G-Code Reference Guide

Comprehensive CNC & 3D Printing Command Reference

Motion Commands

G0 - Rapid Positioning

Moves the machine to a specified position at maximum speed. Not intended for cutting operations. Example: G0 X100 Y50 Z10 moves to position X100, Y50, Z10 at rapid speed.

G1 - Linear Interpolation

Moves the machine in a straight line at a controlled feed rate. Used for cutting and printing operations. Example: G1 X50 Y30 F1500 moves to X50, Y30 at 1500 mm/min feed rate.

G2 - Clockwise Circular Interpolation

Creates a clockwise arc or circle. Requires endpoint and center point or radius. Example: G2 X20 Y20 I10 J10 F500 creates a clockwise arc.

G3 - Counter-Clockwise Circular Interpolation

Creates a counter-clockwise arc or circle. Similar to G2 but in opposite direction. Example: G3 X30 Y10 I5 J-5 F500 creates a counter-clockwise arc.

G4 - Dwell/Pause

Pauses all machine motion for a specified duration. Example: G4 P500 pauses for 500 milliseconds or G4 S2 pauses for 2 seconds.

Coordinate System

G17 - XY Plane Selection

Selects the XY plane for arc movements. This is the default plane for most operations and is standard for 2D machining and 3D printing.

G18 - XZ Plane Selection

Selects the XZ plane for arc movements. Commonly used for lathe operations or vertical milling.

G19 - YZ Plane Selection

Selects the YZ plane for arc movements. Used for specialized machining operations on the YZ face.

G20 - Inch Units

Sets the measurement units to inches. All subsequent coordinates are interpreted as inches. Example: G20 then G1 X1.5 moves 1.5 inches.

G21 - Millimeter Units

Sets the measurement units to millimeters. This is the standard for most 3D printers and modern CNC machines. Example: G21 then G1 X50 moves 50mm.

G28 - Return to Home Position

Moves all axes to their home/reference position. Example: G28 homes all axes, or G28 X Y homes only X and Y axes.

G90 - Absolute Positioning

All coordinates are relative to the origin (0,0,0). This is the default mode. Example: G90 G1 X10 moves to position X=10 from origin.

G91 - Relative Positioning

All coordinates are relative to the current position. Example: G91 G1 X10 moves 10 units from the current X position.

G92 - Set Position

Sets the current position to specified values without moving. Example: G92 X0 Y0 Z0 defines the current position as origin.

3D Printing Specific

G10 - Retract

Retracts the filament to prevent oozing during travel moves. Used in firmware retraction. Example: G10 retracts filament by preset amount.

G11 - Unretract

Reverses the retraction, pushing filament back for printing. Example: G11 unretracts filament to resume printing.

G29 - Bed Leveling

Initiates automatic bed leveling/probing sequence. Creates a mesh of the bed surface for compensation. Example: G29 starts auto bed leveling.

Spindle/Tool Control

G43 - Tool Length Offset

Applies tool length compensation. Example: G43 H1 applies the offset stored in H1 to the Z-axis for the current tool.

G53 - Machine Coordinate System

Temporarily uses machine coordinates instead of work coordinates for one command. Example: G53 G0 Z0 moves to machine Z zero.

G54-G59 - Work Coordinate Systems

Selects one of six different work coordinate systems. G54 is the default. Example: G55 switches to work coordinate system 2.

Feed Rate & Speed

G93 - Inverse Time Feed Mode

Feed rate is specified as the inverse of time required to complete the move. Rarely used in standard operations.

G94 - Units Per Minute Feed Mode

Feed rate is in units per minute (default mode). Example: G94 then F500 means 500 mm/min or inches/min.

G95 - Units Per Revolution Feed Mode

Feed rate is in units per spindle revolution. Used in lathe operations. Example: G95 F0.1 feeds 0.1mm per revolution.