## G-Code Cheatsheet

### From PROBOTIX :: wiki

## Contents

## G Codes

G Code | Description |
---|---|

G0 | Rapid Linear Motion |

G1 | Linear Feed |

G2 | CW Arc Feed |

G3 | CCW Arc Feed |

G4 | Dwell |

G5.1 | Quadratic B-Spline |

G5.2 G5.3 | NURBs Block |

G7 | Diameter Mode (lathe) |

G8 | Radius Mode (lathe) |

G10 L1 | Set Tool Table Entry |

G10 L10 | Set Tool Table, Calculated, Workpiece |

G10 L11 | Set Tool Table, Calculated, Fixture |

G10 L2 | Coordinate System Origin Setting |

G10 L20 | Coordinate System Origin Setting Calculated |

G17 | XY Plane |

G18 | ZX Plane |

G19 | YZ Plane |

G17.1 | UV Plane |

G18.1 | WU Plane |

G19.1 | VW Plan |

G20 | Inch Units |

G21 | Millimeter Units |

G28 | Go to Predefined Position |

G28.1 | Store Current Absolute Position for G28 |

G30 | Go to Predefined Position |

G30.1 | Store Current Absolute Position for G30 |

G33 | Spindle Synchronized Motion |

G33.1 | Rigid Tapping |

G38.2 – G38.5 | Probing |

G38.2 | Probe toward workpiece, stop on contact, signal error if failure |

G38.3 | Probe toward workpiece, stop on contact |

G38.4 | Probe away from workpiece, stop on loss of contact, signal error if failure |

G38.5 | Probe away from workpiece, stop on loss of contact |

G40 | Cutter Compensation Cancel |

G41 | Cutter Compensation Left of Path |

G42 | Cutter Compensation Right of Path |

G41.1 | Dynamic Cutter Compensation Left of Path |

G42.1 | Dynamic Cutter Compensation Right of Path |

G43 | Tool Length Offset |

G43.1 | Dynamic Tool Length Offset |

G49 | Cancel Tool Length Offset |

G53 | Motion in Machine Coordinate System |

G54 | Select Coordinate System 1 |

G55 | Select Coordinate System 2 |

G56 | Select Coordinate System 3 |

G57 | Select Coordinate System 4 |

G58 | Select Coordinate System 5 |

G59 | Select Coordinate System 6 |

G59.1 | Select Coordinate System 7 |

G59.2 | Select Coordinate System 8 |

G59.3 | Select Coordinate System 9 |

G61 | Exact Path Mode (Path Control Mode) |

G61.1 | Exact Path Mode (Path Control Mode) |

G64 | Path Control Mode with Optional Tolerance |

G73 | Drilling Cycle with Chip Breaking |

G76 | Multi-pass Threading Cycle (Lathe) |

G80 | Cancel Canned Cycle |

G81 | Drilling Cycle |

G82 | Drilling Cycle with Dwell |

G83 | Peck Drilling Cycle |

G85 | Boring Cycle, Feed Out |

G86 | Boring Cycle, Spindle Stop, Rapid Out |

G89 | Boring Cycle, Dwell, Feed Out |

G90 | Absolute Distance Mode |

G91 | Incremental Distance Mode |

G90.1 | Absolute Distance Mode for Arc (I, J & K offsets) |

G91.1 | Incremental Distance Mode for Arc (I, J & K offsets) |

G92 | Coordinate System Offset |

G92.1 | Cancel Coordinate System Offsets |

G92.2 | Cancel Coordinate System Offsets |

G92.3 | Restore Axis Offsets |

G93 | Inverse Time Mode |

G94 | Units per Minute Mode |

G95 | Units per Revolution Mode |

G96 | Constant Surface Speed |

G97 | RPM Mode |

G98 | Retract to Start Position (Canned Cycle Z Retract Mode) |

G99 | Retract to R Position (Canned Cycle Z Retract Mode) |

## M Codes

M Code | Description |
---|---|

M0 M1 | Program Pause |

M2 M30 | Program End |

M60 | Pallet Change Pause |

M3 M4 M5 | Spindle Control |

M6 | Tool Change |

M7 M8 M9 | Coolant Control |

M48 M49 | Feed / Spindle Overrides Enable/Disable |

M50 | Feed Override Control |

M51 | Spindle Override Control |

M52 | Adaptive Feed Control |

M53 | Feed Stop Control |

M61 | Set Current Tool Number |

M62-M65 | Output Control |

M66 | Input Control |

M67 | Analog Output Control |

M68 | Analog Output Control |

M100-M199 | User Defined M codes |

## Binary Operators

Operator | Description |
---|---|

Addition | |

Subtraction | |

* | Multiplication |

/ | Division |

OR | Non-exclusive or |

XOR | Exclusive or |

AND | Logical and |

MOD | Modulus operation |

** | Power operation |

EQ | Equality (EQ) |

NE | Inequality (NE) |

GT | Strictly greater than |

GE | Greater than or equal to |

LT | Strictly less than |

LE | Less than or equal to |

## Functions

Function Name | Function Result |
---|---|

ATAN[Y]/[X] | Four quadrant inverse tangent |

ABS[arg] | Absolute value |

ACOS[arg] | Inverse cosine |

ASIN[arg] | Inverse sine |

COS[arg] | Cosine |

EXP[arg] | e raised to the given power |

FIX[arg] | Round down to integer |

FUP[arg] | Round up to integer |

ROUND[arg] | Round to nearest integer |

LN[arg] | Base-e logarithm |

SIN[arg] | Sine |

SQRT[arg] | Square Root |

TAN[arg] | Tangent |

EXISTS[arg] | Check named Parameter |

## Words Letters

Letter | Meaning |
---|---|

A | A axis of machine |

B | B axis of machine |

C | C axis of machine |

D | Tool radius compensation number |

F | Feed rate |

G | General function (See table Modal Groups) |

H | Tool length offset index |

I | X offset for arcs and G87 canned cycles |

J | Y offset for arcs and G87 canned cycles |

K | Z offset for arcs and G87 canned cycles.Spindle-Motion Ratio for G33 synchronized movements. |

M | Miscellaneous function (See table Modal Groups) |

N | Line number |

P | Dwell time in canned cycles and with G4.Key used with G10. |

Q | Feed increment in G73, G83 canned cycles |

R | Arc radius or canned cycle plane |

S | Spindle speed |

T | Tool selection |

U | U axis of machine |

V | V axis of machine |

W | W axis of machine |

X | X axis of machine |

Y | Y axis of machine |

Z | Z axis of machine |

/ | Block delete |

() | Comments |

; | Comments |

MSG, | Messages |

## Common Error Messages

### G code out of range

A G code greater than G99 was used, the scope of G codes in LinuxCNC is 0 – 99. Not every number between 0 and 99 is a valid G code.

### Unknown g code used

A G code was used that is not part of the LinuxCNC G code language.

### i,j,k word with no Gx to use it

i, j and k words must be used on the same line as the G code.

### Cannot use axis values without a g code that uses them

Axis values can not be used on a line without either a modal G code in effect or a G code on the same line.

### File ended with no percent sign or program end

Every G code file must end in a M2 or M30 or be wrapped with the percent sign %.