G01 CNC Code Explained: An Easy Intro for Beginners [Linear Interpolation]

Welcome to our comprehensive guide to using the G01 CNC code. Whether you’re a beginner learning CNC programming or an experienced machinist, understanding the G01 CNC code is extremely important.

In this guide, we’ll break down everything you need to know about this linear interpolation command, including how, when, and why to use it.

What does a G01 code do?

G01 sets the CNC movement mode to straight line movement, otherwise known as linear interpolation. 

The G01 code is used to move the CNC axes (X, Y, & Z) around in a straight line around at a feed rate specified with the F command

an illustration that shows the X, Y and Z axes on a CNC machine

G01 is a modal command which means it will stay on until switched to another code in the same movement group of codes such as G00 – Rapid travel or G02 – Clockwise circular interpolation.

Ready to master CNC programming?

Try the free 30 minute intro course to see how simple and easy G code can be. Take the shortcut to becoming a G Code Master today!

G01 vs G1: Clearing the Confusion

Some people get confused about whether the 0 is required to be included in a G01 code.

To clear this up, there is no need to include the extra zero in the code. The CNC machine will read the code the same. It really is just a matter of preference.

Often you will see the full G01 code used in textbooks or other reference materials. In practice though, many prefer the shortened G1 code in their programs.

If you are working on your own, then go with whichever format you prefer. If you work in a bigger shop, make sure to stick to the format that the business has been using.

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.

Format for using a G01 code

G01 X1.0 Y2.0 Z3.0 F40

Once the G01 code is used, the machine will move to any XYZ locations given in a straight line at the set feed rate. 

Because G01 is a modal code, you don’t need to specify it on every line of code. 

If the next line of code after the one above was:

X4.0 Y5.0 Z6.0

then the machine would still move to the location in a straight line at the set feed rate. Because it’s modal, it stays on until switched to another mode.

The feed rate will also remain the same until it is changed and isn’t required to be on every line. This means that the feed rate can be set before the G01 code is used as well.

How to turn off the G01 code

There isn’t a specific cancel command for G01 like there is for canned cycles. Instead, to turn G01 off you will need to switch it to another code in the same group of movement codes.

The other codes in the movement group are:

Using any of these codes will turn G01 linear interpolation off and switch to the new movement mode.

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.

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

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, all locations are relative to the machine’s current location.

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[linear interpolation] vs G00[rapid travel]

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 machine’s maximum speed. G00 is not affected by the feed rate command (F).

G01 is used for cutting motions. G00 is not.

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.

Ready to master CNC programming?

Try the free 30 minute intro course to see how simple and easy G code can be. Take the shortcut to becoming a G Code Master today!

Leave a Comment