G codes

There are four main types of information you need to enter into the computer:

Types of information

Information
Example
Code

Mechanical
The mechanical actions required.

Turning on the spindle or the vacuum pump.

M codes (machine functions)

eg M93, M06

Direction
The direction of each movement.

Movement left or right, back or forward, up and down.

Cartesian (rectangular) co-ordinates expressed as axes (X,Y,Z)

Dimensions
The distance each movement travels.

Appears after every axis designation

Expressed as millimetres and contain a decimal point eg X345.67

Movements
The way movements take place.

A straight line, clockwise and anti-clockwise curves and rapid feed.

G codes (preparatory functions)

eg G01, G02, G03, G00

In this section we will look at Movements.

There are many possible programmable movements using a CNC machine. Generally, they are either linear (straight line) or rotary (circular). G codes are used to determine the way movements take place.

Below is a sample list of G codes. You can also find a more detailed list of G codes here.

G code

Group

Function

G00

G01

G02

G03

01

Rapid positioning

Linear interpolation (straight line)

Circular interpolation CW (clockwise)

Circular interpolation CCW (counter clockwise)

G04

G09

00

Dwell

Exact stop check

G17

G18

G19

02

XY plane selection

XZ plane selection

YZ plane selection

G28

00

Return to reference point

G40

G41

G42

07

Cutter compensation cancel

Cutter compensation left

Cutter compensation right

G43

G44

G49

08

Tool length compensation + direction

Tool length compensation – direction

Tool length compensation cancel

G61

G62

G64

15

Exact stop check mode

Automatic corner over-ride effective

Cutting mode

G90

G91

03

Absolute programming

Incremental programming

G92

00

Programming of absolute zero point

 

Hint icon
Each G code has three characters, so usually G1 must be expressed as G01. However, newer controllers will accept two characters such as G0, G1, G2, G3.

No two codes from the same group can be used on the same program line. For example, the codes G90 and G91 are for identifying absolute and incremental measurements and only one type can be selected. One code tells the computer to measure from a fixed point (G90, absolute) and the other code tells the computer to measure from the tool's current position (G91, incremental).

Remember icon
Whether using absolute or incremental modes, it is necessary to begin each program cycle with the table and carriage in the home (or zero) position on the CNC machine.

G codes may differ on each CNC machine. It is vital that you become familiar with the list specific to the machine you are working with. Below is a brief explanation of each group

G00 to G03

tool movement codes

G04 and G09

pause codes

G17 to G19

plane selection codes

G28

a return code used at the end of program

G40 to G42

tool radius codes

G43, G44 and G49

tool length codes

G61 and G64

allow for continuous or “stop each line” movement

G90 and G91

identify absolute and incremental measurements

G92

will set a zero or start point

 

Hint icon
You should always refer to your machine manual as G codes may vary on different machines.