Block | A single line of G-Code |
Canned Cycle | Complex cycle defined by a single block of code |
Dwell | Program pause with a duration defined by “P” in seconds |
EOB | End of block. Required at the end of every block of G-Code. In Mach4 this is a carriage return |
Feedrate | Velocity, set by F, at which an axis will move |
Group | Collection of G-Codes that control the same function or mode, i.e. G90 and G91 positioning modes |
Modal | Active until a code from the same group is called |
Normal | A line perpendicular to a plane, pointing in the positive direction. |
Origin | Point in a coordinate system where X, Y and Z are zero |
RPM | Revolutions per minute |
UPM | Units per minute (inches, millimeters, degrees, etc.) |
Word | A single word of G-Code is a letter followed by a number. G01, X1.0, etc. are words |
G | Preparatory function, G followed by a numerical code, specifies machining modes and functions |
M | Miscellaneous function, M followed by a numerical code, defines program flow and can control auxiliary functions such as coolant. Can also perform machine specific functions and macros user or builder. |
X, Y, Z, C | Absolute movement commands followed by a numerical value, define the end point of a motion command in the user coordinate system. |
U, V, W, H | Incremental movement commands followed by a numerical value, define the distance and direction to the end point of a motion command. |
S | Spindle speed, followed by numerical value of desired rpm or surface speed |
T | Tool call, followed by next tool number and offset to be used |
F | Followed by a numerical value to define the feedrate. The magnitude and value of which will be determined by the feed mode setting |
P | Followed by a numerical value, specifies dwell time in seconds. (also used in other functions) |
N | Sequence numbers. Used for program organization and go to commands |
**Code** | **Group** | **Description** | **Modal** |
G00 | 1 | Rapid Move | Y |
G01 | 1 | Linear Feed Move | Y |
G02 | 1 | Clockwise Arc Feed Move | Y |
G03 | 1 | Counter Clockwise Arc Feed Move | Y |
G04 | 0 | Dwell | N |
G09 | 0 | Exact stop | N |
G10 | 0 | Fixture and Tool Offset Setting | N |
G18 | 2 | ZX Plane Select | Y |
G20 | 6 | Inch | Y |
G21 | 6 | Millimeter | Y |
G28 | 0 | Zero Return | N |
G30 | 0 | 2^{nd}, 3^{rd}, 4^{th} Zero Return | N |
G31 | 1 | Probe function | N |
G32 | 1 | Threading\* | N |
G40 | 7 | Tool Radius Compensation Cancel | Y |
G41 | 7 | Tool Radius Compensation Left | Y |
G42 | 7 | Tool Radius Compensation Right | Y |
G50 | 0 | Max Spindle Speed | Y |
G52 | 0 | Local Coordinate System Shift | Y |
G53 | 0 | Machine Coordinate System | N |
G54 | 12 | Fixture Offset 1 | Y |
G54.1 | 12 | Additional Fixture Offsets | Y |
G55 | 12 | Fixture Offset 2 | Y |
G56 | 12 | Fixture Offset 3 | Y |
G57 | 12 | Fixture Offset 4 | Y |
G58 | 12 | Fixture Offset 5 | Y |
G59 | 12 | Fixture Offset 6 | Y |
G61 | 13 | Exact Stop Mode | Y |
G64 | 13 | Cutting Mode (Constant Velocity) | Y |
G76 | 0 | Thread Cutting Cycle | N |
G80 | 16 | Canned Cycle Cancel | Y |
G83 | 16 | Face Drilling | Y |
G84 | 16 | Face Tapping | Y |
G85 | 16 | Face Boring | Y |
G87 | 16 | Side Drilling | Y |
G89 | 16 | Side Boring | Y |
G90.1 | 4 | Arc Center Absolute Mode | Y |
G91.1 | 4 | Arc Center Incremental Mode | Y |
G93 | 5 | Inverse Time Feed | Y |
G96 | 14 | Constant Surface Speed\* | Y |
G97 | 14 | Constant Speed | Y |
G98 | 5 | Feed Per Minute | Y |
G98.1 | 10 | Initial Point Return | Y |
G99 | 5 | Feed Per Revolution\* | Y |
G99.1 | 10 | R Point Return | Y |
**G0 G54 G18 G40 G80** | Safe start line |
**T1 M6** | Tool change |
**S2500 M3** | Start spindle |
**G0 X1.0 Z3.0** | Rapid to XZ position |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T1 M6** | Tool change |
**S2500 M3** | Start spindle |
**G98** | Feed per minute mode |
**G0 X1.0 Z3.0** | Rapid to XZ position |
**G1 X10.0 Z-1.0 F15.0** | Move to XZ position at feedrate |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T0101** | Tool change |
**S2500 M3** | Start spindle |
**G0 X1.0 Z0.0** | Position to X and Y start point |
**G99** | Feed per revolution mode |
**G3 X1.4 Z-0.2 I0.0 K-0.2 F0.006** | Arc move |
**G0 G53 X0.0** | Return X to home |
**G0 G53 Z0.0** | Return Z to home |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T0101** | Tool change |
**S2500 M3** | Start spindle |
**G0 X1.0 Z0.0** | Position to X and Y start point |
**G99** | Feed per revolution mode |
**G3 X1.4 Z-0.2 R0.2 F0.006** | Arc move |
**G0 G53 X0.0** | Return X to home |
**G0 G53 Z0.0** | Return Z to home |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T0101** | Tool change |
**S2500 M3** | Start spindle |
**G0 X0.0 Y.5** | Position to X and Y start point |
**G0 Z.5** | Activate tool offset 1 and move to Z rapid plane |
**G98** | Feed per minute mode |
**G1 Z0.0 F10.0** | Z plunge at feedrate |
**G2 X-.5 Y0.0 Z-1.0 I0.0 J-.5 F10.0** | Helical interpolation |
**G0 Z.5** | Retract Z to rapid plane |
**G0 G53 Z0.0** | Return Z to home |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T0101** | Tool change |
**S2500 M3** | Start spindle |
**G0 X1.0 Z1.0** | Rapid to XZ position |
**G4 P5.** | Dwell for 5 seconds |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T0101** | Tool change |
**S2500 M3** | Start spindle |
**G99** | Feed per revolution mode |
**G0 X0.0 Z1.0** | Rapid to XY position |
**G1 Z0.0 F0.008** | Move to position at feedrate |
**X1.0** | Move to position at feedrate |
**Z-2.0** | Move to position at feedrate |
**G9 X1.5** | Move to position at feedrate, exact stop active |
**Z-4.0** | Move to position at feedrate |
**G0 G53 X0 Z0** | Return X and Z to home position |
**M30** | Program end and rewind |
Fixture offset (G\_\_) | P\_\_ |
54 | 1 |
55 | 2 |
56 | 3 |
57 | 4 |
58 | 5 |
59 | 6 |
X(U) | X axis offset |
Y(V) | Y axis offset |
Z(W) | Z axis offset |
C(H) | C axis offset |
**G0 G54 G18 G40 G80** | Safe start line |
**G10 L2 P3 X-8.0 Y-3.0 Z-5.0 C45.0** | Set G56 fixture offset values |
**M30** | Program end and rewind |
**G54.1 P\_\_** | **G10 L20 P\_\_** | **Legacy G59 P\_\_** | **Legacy G10 L2 P\_\_** |
1 | 1 | 7 | 7 |
2 | 2 | 8 | 8 |
3 | 3 | 9 | 9 |
- | - | - | - |
- | - | - | - |
- | - | - | - |
248 | 248 | 254 | 254 |
**G0 G54 G18 G40 G80** | Safe start line |
**G10 L20 P5 X3.0 Y3.4 Z-10.0** | Set G54.1 P5 fixture offset values |
**M30** | Program end and rewind |
X(U) | X offset |
Y(V) | Y offset |
Z(W) | Z offset |
R(C) | Tool nose radius |
T | Tool tip direction |
**G0 G54 G18 G40 G80** | Safe start line |
**G10 L1 P5 X-5.0** | Set X axis offset #5 to -5.0 |
**G10 L3 P2 W.05** | Add .05 to Z wear for offset #2 |
**M30** | Program end and rewind |
**G0 G90 G54 G18 G40 G80** | Safe start line |
**G0 X1.0 Z1.0** | Rapid position to point |
**G28 Z0.0** | Send Z axis home via point Z0 |
**M30** | Program end and rewind |
Axis | P2 # Variables | P3 # Variables | P4 # Variables |
X | 5301 | 5311 | 5321 |
Y | 5302 | 5312 | 5322 |
Z | 5303 | 5313 | 5323 |
A | 5304 | 5314 | 5324 |
B | 5305 | 5315 | 5325 |
C | 5306 | 5316 | 5326 |
Axis | G31 # Variables | G31.1 # Variables | G31.2 | G31.3 |
X | 5061 | 5071 | ||
Y | 5062 | 5072 | ||
Z | 5063 | 5073 | ||
A | 5064 | 5074 | ||
B | 5065 | 5075 | ||
C | 5066 | 5076 |
**G0 G54 G18 G40 G80** | Safe start line |
**G0 X1.0 Z0.1** | Rapid position |
**G97 S1000 M3** | Start spindle at 1000 RPM |
**G0 X0.22** | Move to start position for rough |
**G32 X0.22 Z-1.0 F.05** | Cut straight thread |
**G0 X0.3** | Retract X axis |
**Z0.1** | Retract Z axis |
**X0.21** | Move to start position for finish |
**G32 X0.21 Z-1.0 F.05** | Cut straight thread |
**G0 X0.3** | Retract X axis |
**Z0.1** | Retract Z axis |
**G53 X0.0 Z0.0 M5** | Return home and stop spindle |
**M30** | Program end and rewind |
**G0 G90 G54 G18 G40 G80** | Safe start line |
**G0 X1.0 Z0.1** | Rapid position |
**G97 S1000 M3** | Start spindle at 1000 RPM |
**G0 X0.22** | Move to start position for rough |
**G32 X0.25 Z-1.0 F.05** | Cut tapered thread |
**G0 X0.3** | Retract X axis |
**Z0.1** | Retract Z axis |
**X0.21** | Move to start position for finish |
**G32 X0.24 Z-1.0 F.05** | Cut tapered thread |
**G0 X0.3** | Retract X axis |
**Z0.1** | Retract Z axis |
**G53X0.0 Z0.0 M5** | Return home and stop spindle |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**G0 X4.0 Y0.0 Z1.0** | Rapid position to point (X position is 4.) |
**G51 X2.0** | Activate scaling on X axis (scale factor = 2) |
**G0 X5.0** | Rapid position to point (X position is 10.) |
**G50** | Cancel Scaling |
**G0 X5.0** | Rapid position to point (X position is 5.) |
**M30** | Program end and rewind |
**G0 G90 G54 G18 G40 G80** | Safe start line |
**G0 X4.0 Y0.0 Z1.0** | Rapid position to point (X position is 4.) |
**G51 X-1.0** | Mirror X axis (scale factor = 1) |
**G0 X5.0** | Rapid position to point (X position is -5.) |
**G50** | Cancel Scaling |
**G0 X5.0** | Rapid position to point (X position is 5.) |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**G0 X-4.0 Y0.0 Z1.0** | Rapid position to point |
**G12 I2.0 F30.0** | Cut circle with radius 2.0 |
**G52 X7.0** | Local Coordinate system active, X offset = 7 |
**G0 X-4.0 Y0.0 Z1.0** | Rapid to same start point |
**G12 I2.0 F30.0** | Cut same circle with radius 2.0 |
**G52 X0.0** | Local coordinate system cancelled |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**G0 X4.0 Y0.0 Z1.0** | Rapid position in G54 |
**…** | Body of program |
**G53 Z0.0** | Return directly to Z home position |
**G53 X10.0 Y0.0** | Move to load/unload position |
**M30** | Program end and rewind |
Axis | \# Variable |
X | 5440 |
Y | 5441 |
Z | 5442 |
A | 5443 |
B | 5444 |
C | 5445 |
**G0 G54 G18 G40 G80 G99** | Safe start line |
**G0 X1.0 Z0.1** | Rapid position |
**G97 S1200 M03** | Start spindle at 1200 RPM |
**G76 P040060 Q0.001 R0.001 K1** | Threading line 1 |
**G76 X0.4931 Z-0.75 P0.0651 Q0.025 F0.0909** | Threading line 2 |
**G0 X1.0** | Retract X axis |
**Z0.1** | Retract Z axis |
**M05** | Stop Spindle |
**M30** | Rewind Program |
**Standard Hole Machining Cycles** | ||
G80 | Canned Cycle Cancel | G80 |
G83 | Deep Hole Peck Drilling | G83 X\_ Y\_ Z\_ R\_ Q\_ F\_ |
G84 | Tapping | G84 X\_ Y\_ Z\_ R\_ F\_ |
G85 | Boring, Retract at Feed, Spindle On | G85 X\_ Y\_ Z\_ R\_ F\_ |
G87 | Back Boring | G87 X\_ Y\_ Z\_ R\_ I\_ J\_ F\_ |
G89 | Boring, Dwell, Retract at Feed, Spindle On | G89 X\_ Y\_ Z\_ R\_ P\_ F\_ |
**G0 G54 G18 G40 G80** | Safe start line |
**G91.1** | Incremental arc center mode |
**T0101** | Tool change |
**S2500 M3** | Start spindle |
**G0 X3.0 Y0.0** | Position to X and Y start point |
**G43 h3 Z.5** | Activate tool offset 1 and move to Z rapid plane |
**G1 Z0.0 F10.0** | Z plunge at feedrate |
**G3 X1.0 Y2.0 I-2.0 J0.0 F10.0** | Arc move |
**G0 Z.5** | Retract Z to rapid plane |
**G0 G53 Z0.0** | Return Z to home |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**G90.1** | Absolute arc center mode |
**T0101** | Tool change |
**S2500 M3** | Start spindle |
**G0 X3.0 Y0.0** | Position to X and Y start point |
**G43 h3 Z.5** | Activate tool offset 1 and move to Z rapid plane |
**G1 Z0.0 F10.0** | Z plunge at feedrate |
**G3 X1.0 Y2.0 I1.0 J0.0 F10.0** | Arc move |
**G0 Z.5** | Retract Z to rapid plane |
**G0 G53 Z0.0** | Return Z to home |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**G0 X4.0 Y0.0 Z1.0** | Rapid move, current position X4, Y0, Z1 |
**G92 X1.0 Y2.0 Z3.0** | Set local coordinate system, current position X1, Y2, Z3 |
**G92.1** | Cancel local coordinate system, current position X4, Y0, Z1 |
**M30** | Program end and rewind |
**Standard Hole Machining Cycles** | ||
G80 | Canned Cycle Cancel | G80 |
G83 | Face Drilling | G83 X\_ Z\_ R\_ Q\_ P\_ F\_ |
G84 | Face Tapping | G84 X\_ Z\_ R\_ P\_ F\_ |
G85 | Face Boring | G85 X\_ Z\_ R\_ P\_ F\_ |
G87 | Side Drilling | G87 Z\_ X\_ R\_ Q\_ P\_ F\_ |
G89 | Side Boring | G89 Z\_ X\_ R\_ P\_ F\_ |
cc | Number of the desired canned cycle (i.e. 83, 84, 85, etc). |
xx | X position of the center point of the first hole with respect to the current work zero point |
uu | Distance and direction along X axis to center point of first hole from the current position |
zz | Z position of bottom of hole with respect to the current work zero point |
ww | Distance and direction along Z axis, from point R, to bottom of hole |
Peck increment if deep hole drilling, always positive | |
rr | Retract plane, always programmed in incremental and always in radius values |
pp | Dwell, in seconds, at bottom of hole |
ll | Number of repetitions |
ff | Feedrate |
xn | Position of nth hole X axis, same rules as applied to xx |
yn | Position of nth hole Y axis, same rules as applied to yy |
**G0 G54 G18 G40 G80** | Safe start line |
**T0101** | Tool change |
**S2500 M3** | Start spindle |
**G0 Z1.0** | Move to Z initial point |
**X0.0** | Move to X position |
**G81 G99.1 X0.0 Z-1.0 R.25 F0.01** | Drill cycle start |
**G80** | Canned cycle cancel |
**G0 G53 X0.0 Z0.0** | Return to home |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T0101** | Tool change |
**S2500 M3** | Start spindle |
**G0 Z1.0** | Move to Z initial point |
**X0.0** | Move to X position |
**G83 G99.1 X0.0 Z-0.1 R.25 F0.01** | Drill cycle start |
**G80** | Canned cycle cancel |
**G0 G53 X0.0 Z0.0** | Return to home |
**G0 G54 G18 G40 G80** | Safe start line |
**T0202** | Tool change |
**S3000 M3** | Start spindle |
**G0 Z1.0** | Move to Z initial point |
**X0.0** | Move to X position |
**G83 G99.1 X0.0 Z-1.0 R0.25 Q0.20 F0.008** | Drill cycle start |
**G80** | Canned cycle cancel |
**G0 G53 X0.0 Z0.0** | Return to home |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T0101** | Tool change |
**S2500 M3** | Start spindle |
**G0 Z-1.97** | Move to Z initial point |
**X3.0 C0.0** | Move to X and C position |
**G87 G99.1 Z1.97 C0.0 X2.30 R3.0 F0.01** | Drill cycle start |
**C180.0** | Drill 2^{nd} hole |
**G80** | Canned cycle cancel |
**G0 G53 X0.0 Z0.0** | Return to home |
**G0 G54 G18 G40 G80** | Safe start line |
**T0202** | Tool change |
**S3000 M3** | Start spindle |
**G0 Z-1.97** | Move to Z initial point |
**X3.0 C0.0** | Move to X and C position |
**G87 G99.1 Z-1.97 C0.0 X1.50 R3.0 Q0.20 F0.008** | Drill cycle start |
**C180.0** | Drill 2^{nd} hole |
**G80** | Canned cycle cancel |
**G0 G53 X0.0 Z0.0** | Return to home |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T0202** | Tool change |
**S1000 M3** | Start spindle |
**G0 Z1.0** | Move to Z initial point |
**X0.0** | Move to X position |
**G98** | Feed per minute mode |
**G84 G99.1 X0.0 Z-0.5 R.25 F50.0** | Tap cycle start |
**G80** | Canned cycle cancel |
**G0 G53 X0.0 Z0.0** | Return to home |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T0303** | Tool change |
**S750 M3** | Start spindle |
**G0 Z1.0** | Move to Z initial point |
**X0.0** | Move to X position |
**G85 G99.1 X0.0 Z-0.250 R.25 F0.003** | Bore cycle start |
**G80** | Canned cycle cancel |
**G0 G53 X0.0 Z0.0** | Return to home |
**M30** | Program end and rewind |
**G0 G54 G18 G40 G80** | Safe start line |
**T0303** | Tool change |
**S750 M3** | Start spindle |
**G0 Z-1.97** | Move to Z initial point |
**X3.0 C0.0** | Move to X and C position |
**G89 G99.1 Z1.97 C0.0 X2.00 R3.0 F0.003** | Bore cycle start |
**C180.0** | Bore 2^{nd} hole |
**G80** | Canned cycle cancel |
**G0 G53 X0.0 Z0.0** | Return to home |
**M30** | Program end and rewind |
**Code** | **Description** |
M00 | Mandatory Program Stop, with optional message display |
M01 | Optional Program Stop |
M02 | Program End |
M03 | Spindle Forward/Clockwise |
M04 | Spindle Reverse/Counterclockwise |
M05 | Spindle Stop |
M07 | Mist Coolant On |
M08 | Flood Coolant On |
M09 | All Coolant Off |
M19 | Spindle Orient |
M30 | Program End and Rewind |
M48 | Enable Feed/Speed Overrides |
M49 | Disable Feed/Speed Overrides |
M98 | Subprogram Call |
M99 | Return From Subprogram / Rewind |
M??? | Custom Macro M-Codes |
**G0 G90 G54 G18 G40 G80** | Safe start line |
**G0 X4.0 Y0.0 Z1.0 T1** | Rapid move, pre call tool 1 |
**M6** | Tool change to tool 1 |
**G0 X10.0 Y-5.0 Z1.0** | Rapid move |
**T2 M6** | Tool change to tool 2 |
**M30** | Program end and rewind |
**(MAIN PROGRAM)** | Main program header |
**G0 G90 G54 G18 G40 G80** | Safe start line |
**G0 X4.0 Y0.0 Z1.0** | Rapid move |
**T1 M6** | Tool change to tool 1 |
**G0 X10.0 Y-5.0 Z1.0** | Rapid move |
**M98 P1000** | Call subprogram number 1000 |
**M30** | Program end and rewind |
**O1000 (SUB PROGRAM BEGIN)** | Subprogram number |
**G12 I-0.25** | Cut circle |
**M99** | Return to main program |