Quick Guide to the G01 CNC G Code [Tips and Tricks]

a graphic of a cnc machine with text that says learn g code today g01 linear interpolation

Code

G01

Name

Linear movement

Type

Modal - stays on until changed

Description

Straight line movement at a specified feed rate

G01 is a CNC g-code for straight line movement, otherwise known as linear interpolation. 

The G01 code is used to move the CNC table and/or spindle around at a feed rate specified with the F command.

When to use a G01 code?

G01 codes are found in the lines of the program where the material is being cut. 

The G01 code allows the programmer to specify the location where the tool will move to. 

Feed rate (F) and spindle speed (S) codes are used together with a G01 code to specify the feeds and speeds.

The location movement, speeds, and feeds are the main factors that influence the quality of your cut.

What to think about when using a G01 code?

Units

First, make sure you know what units you are working in

Moving 10 inches instead of 10 millimeters is a big difference. A G20 (inches) or G21 (mm) code identifies the units you are working in when making a move with your G01 code.

comparison of units of measurement for cnc programming

Absolute vs incremental mode

The second thing to know is how the machine will understand position locations.

This is determined by whether you are working in absolute (G90) or incremental (G91) coordinates. The most recent G90 or G91 code in the program will determine which mode you are in.

Absolute positioning will move from a set zero location such as your machines home location or a specified location on your part.

Incremental positioning will move relative to your current position.

The images below show the difference between the absolute and incremental positioning modes. The numbers in parentheses are the locations given to the the machine to make the move.

Notice how in absolute mode, all locations are relative to a single location, usually either the workpiece zero or machine home location. 

In incremental mode locations, all locations are relative to the machine’s current location.

graph paper example of absolute positioning with multiple points as examples
graph paper example of incremental positioning with multiple points as examples

Start and stop locations

Lastly, make sure you understand the path that the tool will take from it’s start location to the new location.

Check  where you are currently position wise (X, Y & Z location), where you will be moving to and if there is anything in between the two locations.

The G01 code will move the machine in a straight line to your new location. You don’t want anything in the way or to miscalculate your stop point. Clamps or vises can be easy to forget about and run into. Crashing your machine is never a good time.

G01 vs G00

G00 is a straight line movement code similar to G01.

There is one big difference between the two codes.

G01 uses the feed rate specified with the F command to determine how fast the machine moves. 

G00 moves at the machines maximum speed. G00 is not affected by the feed rate command (F).

6 G01 code examples and descriptions of what they do

For the examples below, we will assume your machine is in absolute mode (G90). If you are working in incremental mode (G91), the resulting movements will be different. Check out our guides to G90 and G91 G codes to understand the difference between the two movement types.

Example #1

N015 G01 X7.0 Y5.0 Z3.0

This is line number 15 of the program.

G01 sets the movement mode as linear (straight line).

X7.0 Y5.0 Z3.0 is the location the machine will move to. If the Z location of the machine was already at 3.0, then the Z axis will not move. This is the same for each axis.

Example #2

N070 G01 X6.0 Y2.0

This is line number 70 of the program.

G01 sets the movement mode as linear (straight line).

X6.0 Y2.0 is the location that the machine will move to. The Z axis of the machine will not change and remain at the location it was previously set at.

Example #3

N120 G01 Y2.5 Z1.0

This is line number 120 of the program.

G01 sets the movement mode as linear (straight line).

Y2.5 Z1.0 is the location that the machine will move to. The X axis of the machine will not change and remain at the location it was previously set at.

Example #4

N020 G00 Y4.0

This is line number 20 of the program.

G01 sets the movement mode as linear (straight line).

Y4.0 is the location that the machine will move to. The X and Z axes of the machine will not change and remain at the location they were previously set at.

Example #5

N100 G01

This is line number 100 of the program.

G01 sets the movement mode as linear (straight line).

There is no location specified on this line. The machine will not move based on this code line.

Example #6

N256 G01 X8.0

This is line number 256 of the program.

G01 sets the movement mode as linear (straight line).

X8.0 is the location that the machine will move to. The Y and Z axes of the machine will not change and remain at the location they were previously set at.

CNC codes that are similar to G01

a comparison of the type of movement created with G00, G01, G02 and G03 cnc g codes

Note that all the movement codes listed below are modal. This means they will stay in the movement mode identified by the code until switched to a different mode.

Want to learn more about G Code for your CNC?

Leave a Comment