G41 CNC Code Explained: An Easy Intro for Beginners [Cutter Comp Left]

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

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

What does a G41 code do?

G41 is a modal command called cutter compensation left.

This code adjusts the path of the cutting tool based on the diameter of the cutter.

If you are looking towards the direction that the cutter is moving, the tool path is shifted to the left.

In the animation below, the tool path in the program is represented by the line with arrows.

an animation showing how the cnc machine will move with cutter compensation left on

There are also codes for using no cutter compensation (G40) as well as using cutter compensation right (G42).

What is cutter compensation

Cutter compensation is a CNC mode that allows the CNC controller to adjust for the size of the cutting tool.

Setting the size of the cutting tool allows you to use the same program with multiple different cutting tools.

Turning cutter compensation on tells the machine to shift the cutting tool either left with G41 or right with G42. The shift is half of the diameter of cutting tool, otherwise known as the radius.

a cnc cutting tool with it's diameter, radius, and center point identified

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

Visualizing which way the machine will shift can be a little tricky. The shift happens as if you are looking towards the direction that the cutter is moving.

The two animations below show how the CNC will move when the other cutter compensation modes are active.

When cutter compensation is off (G40), the cutter will follow the tool path given in the program.

an animation showing how a cnc machine will move when cutter compensation is off

With cutter compensation right on (G42), the cutter will be shifted right and the left edge of the cutting tool will follow the tool path.

an animation showing how the cnc machine will move with cutter compensation right on

When to use a G41 code

The G41 command is useful in many milling operations such as contouring, pocketing, facing, and engraving.

Every operation that involves facing the cutter’s tip against the workpiece needs to account for the diameter of the cutting tool to avoid overcutting.

The G41 command is commonly found at the beginning of a program or subprogram and should remain activated until the machining operation ends. This doesn’t mean the entire program, but instead the individual sections of the program.

When using G41 or G42, the toolpath runs the cutter’s edge along the tool path instead of the centerline of the cutter.

Cutter sizes and D offsets

Even if you were to buy two of the same cutters, it is likely that there is a small difference in size between them. This difference in size is accounted for using offsets.

There are H offsets and D offsets that can be used when CNC machining.

illustration of a cnc cutting tool that shows what an D offset is

Because we are talking about cutter compensation with G41, we are going to focus on D offsets.

D offsets are stored in your machine’s controller, and they store the diameter of your cutting tool.

Now usually when the machine reads the coordinates given in the program, it moves the center of the cutting tool to that position. This can make it difficult to get the correct size especially when using different or multiple cutters.

Telling the machine the size of the cutters with your D offsets allows it to account for them and run the same program with different tools and get the same size part.

If you didn’t have cutter compensation, then you would need to create a new version of the program every time you wanted to use a new tool.

Using the tool offset table for cutter compensation

mach 3 tool offset table

The Tool Offset Table, sometimes called Tool Table or Offset Library, is simply a table that the operator uses to store the offset values. This can include both diameter (D) and tool length (H) offsets.

Tool offset tables vary and some machines will only store one type of offset.

This means you may need to store both your diameter and tool length offsets in a D offset.

Some other machines may allow you to store the diameter and length of a cutting tool in the same offset number. The setup varies by machine so check yours out to make sure you know how it works.

The purpose of the Tool Table is to tell the CNC machine what the dimensions of the cutting tool are. This includes radius and length.

G41 programming format

There are multiple ways of formatting a G41 command:

  1. G41 D1. When the G41 code is used with a D offset it is meant to be used on a machine with a built-in tool table in the controller. G41 turns on cutter compensation left and D1 tells the machine to adjust the tool path based on the size stored in the first D offset.
  2. G41 P2. The P value is the radius of the tool used in the operation. This format is used more often on hobby level machines.
  3. G41 X2. This format is the same as using the P value.

Focus on learning the first format unless you plan to only ever use simple home level machines.

G41 vs G42

There are two different cutter compensation modes that can be used:

  • G41 for cutter compensation left
  • G42 for cutter compensation right

The direction of the shift is relative to the cutting tools direction of movement.

G41 is used when climb milling, which is the most common type of milling used.

G42 is used when conventional milling. Conventional milling sounds like it would be the standard, but in reality it is rarely used.

When climb milling, the cutter moves in the same direction as the stock feeds, which means that the workpiece produces less resistance to the cutting as the chips fall behind the cutter.

This type of milling helps prolong the life of the cutters and create a better surface finish. This is the most commonly used milling method CNC machines.

On the other hand, with conventional milling the cutter runs in the opposite direction of the stock feed, which means that the cutter will have more resistance against the workpiece and cause more tool wear resulting in a shorter tool life.

Which code cancels cutter compensation?

Cutter compensation with G41 is canceled by using the G40 code which cancels all active cutter compensation modes.

Alternatively, G41 can be canceled by switching to cutter compensation right by using the G42 code.

The two main things to pay attention to when using G40 to cancel cutter compensation are:

  • Cancel cutter comp when you are off the part more than half the diameter of the cutter
  • Make a move when canceling cutter compensation

Canceling off the part enough keeps the machine from running back into the part.

Making a move forces the machine to move in a consistent way. Some machines can react unexpectedly if no move is made when canceling cutter compensation. The machine basically thinks it has teleported locations.

Don’t teleport your CNC. Make a move when canceling cutter compensation.

Other types of compensation

The other main form of compensation is tool length compensation.

Tool length compensation is turned on with either G43 or G44. Although G44 is almost never used. G43 is by a super wide margin the most often used tool length compensation.

Tool length compensation accounts for the length of the cutting tool relative to the end of the spindle.

Tool length compensation is canceled with the G49 code.

Ready to master CNC programming?

Join our simple, easy-to-follow course, ‘G Code Made Easy: CNC Programming for Beginners’ and take the shortcut to becoming a G Code Master today!

Master G Code Today

G40 CNC Code Explained: An Easy Intro for Beginners [Cutter Comp Cancel]

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

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

What does a G40 code do?

G40 is the CNC G code to turn off cutter compensation. 

When cutter compensation is turned off, the center of the cutter will follow the tool path given in the program.

In the animation below, the tool path in the program is shown by the lines with the arrow.

What is cutter compensation?

Cutter compensation is a CNC mode that allows the CNC controller to adjust for the size of the cutting tool.

Setting the size of the cutting tool allows you to use the same program with multiple different cutting tools.

Turning cutter compensation on tells the machine to shift the cutting tool either left with G41 or right with G42 based on the size of the D offset chosen using the D code.

The shift is half of the diameter of the cutting tool, otherwise known as the radius.

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

Visualizing which way the machine will shift can be a little tricky. The shift happens as if you are looking towards the direction that the cutter is moving.

The two animations below show how the CNC will move when the other cutter compensation modes are active.

With cutter compensation left on (G41), the cutter will be shifted left and the right edge of the cutting tool will follow the tool path.

an animation showing how the cnc machine will move with cutter compensation left on

With cutter compensation right on (G42), the cutter will be shifted right and the left edge of the cutting tool will follow the tool path.

an animation showing how the cnc machine will move with cutter compensation right on

Things to know when using the G40 code

The two main things to pay attention to when using G40 to cancel cutter compensation are:

  • Cancel cutter comp when you are off the part more than half the diameter of the cutter
  • Make a move when canceling cutter compensation

Canceling cutter compensation when off the part enough keeps the machine from running back into the part.

A good practice is to move the machine up above the part in the Z axis so that it is away from the part before canceling cutter compensation.

Making a move forces the machine to move in a consistent way. Some machines can react unexpectedly if no move is made when canceling cutter compensation. The machine basically thinks it has teleported location.

Don’t teleport your CNC. Make a move when canceling cutter compensation.

Where does G40 show up in a program?

The G40 command can be found at any point within the program, but the most common place to find one is in safety lines of the program.

Safety lines are a set of codes used to put the CNC machine into the correct mode(s) prior to running the program. Sometimes this means turning modes on, sometimes it means turning them off.

G40 is one of the off (cancel) commands.

Safety lines are often used at the start of a new section of code to make sure the CNC is set to the correct modes before running the section of code.

Other cancel commands

There are multiple G code cancel commands. The table below shows the most common codes for turning modes off:

Code

Description

G40

Cancel cutter compensation

G49

Cancel tool length compensation

G50

Cancel scaling

G67

Cancel custom macro call

G69

Cancel rotation

G80

Cancel canned cycles

Ready to master CNC programming?

Join our simple, easy-to-follow course, ‘G Code Made Easy: CNC Programming for Beginners’ and take the shortcut to becoming a G Code Master today!

Master G Code Today

G21 CNC Code Explained: An Easy Intro for Beginners [Metric Mode]

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

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

What does a G21 code do?

A G21 code will switch the CNC into metric mode.

Once the G21 code is used, all sizes and locations in the program will be treated as millimeter values until the mode is changed.

This type of G code is called a modal command.

Modal commands remain in effect until they are canceled or changed to another code in the same group.

This holds true even if you restart your program.

Many, but not all modal codes have a cancel command to turn the mode off.

Note: There is no cancel command for unit modes. One of the unit mode codes must be active.

For this reason, most CNC programs will be created with start-up or safety commands. The safety commands make sure that the machine is always in the correct modes.

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

G21 [mm mode] vs G20 [inch mode]

It should be pretty obvious from the names but the other unit mode to consider is G20 – Inch mode.

When G20 is the active units code, the machine will read all locations and values as in inches.

comparison of CNC unit mode codes G20 and G21

Neither code can be canceled. The only way to turn on off is to switch to the other.

It is not advised to switch units in your program.

When to use a G21 code?

A G21 code can be found at any point within the program but the most likely location is at the start of the program or at the start of a new section of code.

For instance, you might switch the CNC into metric mode by using the G21 command immediately before starting to cut a slot in the part.

The machine may already be in metric mode or it could be in inch mode, but placing the G21 command immediately before the new block of code for the slot operation will make sure you are working in the correct units.

All kinds of things can happen when machining and it isn’t uncommon for the machine to crash or some part of a program to need to be re-run.

Placing the safety commands (G21 in this case) at the start of the new block of code makes sure your machine does exactly what was intended.

What to think about when using a G21 code?

When you use a G21 code you simply need to be aware of what type of units you are working in.

Most machine shops will work in either inches or mm.

There are definitely some shops out there that will use mixed units, but in most cases CNC programs will be written in one or the other for every program they make.

Know whether your parts are in inches or millimeters.

CNC codes that are similar to G21

All of the codes listed in the table below are modal commands that affect the way the CNC machine interprets size and location values that are entered.

Ready to master CNC programming?

Join our simple, easy-to-follow course, ‘G Code Made Easy: CNC Programming for Beginners’ and take the shortcut to becoming a G Code Master today!

Master G Code Today

G20 CNC Code Explained: An Easy Intro for Beginners [Inch Mode]

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

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

What does the G20 code do?

A G20 code switches the CNC into inch mode.

Once the G20 code is used, all sizes and locations in the program will be treated as inch values until the mode is changed. This includes canned cycles and subprograms.

This type of G code is called a modal command.

Modal commands remain in effect until they are canceled or changed to another code in the same group.

This holds true even if you restart your program.

Many, but not all modal codes have a cancel command to turn the mode off.

Note: There is no cancel command for unit modes. One of the unit mode codes must be active.

For this reason, most CNC programs will be created with start-up or safety commands. The safety commands make sure that the machine is always in the correct modes.

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

G20 [inch mode] vs G21 [mm mode]

It should be pretty obvious from the names but the other unit mode to consider is G21 – Metric mode.

When G21 is the active units code, the machine will read all locations and values as in metric (mm).

Neither code can be canceled. The only way to turn on off is to switch to the other.

It is not advised to switch between units in your program.

When to use a G20 code?

A G20 code can be found at any point within the program, but the most likely location is at the start of the program or at the start of a new section of code.

For instance, you might use the G20 command immediately before starting a drilling cycle.

The machine may already be in inch mode, but placing the G20 command immediately before the drill cycle will ensure the program is in inch mode.

All kinds of things can happen when machining and it isn’t uncommon for the machine to crash or some part of a program to need to be re-run.

Placing the safety commands (G20 in this case) at the start of the new block of code makes sure your machine is in the correct unit mode when running that block of code.

With this example, the customer won’t be happy if you give them holes that are 1mm instead of 1 inch. If it goes the other way and you make a hole that is 1 inch instead of 1mm, just tell them that the extra work is on the house.

What to think about when using a G20 code?

When you use a G20 code you simply need to be aware of what type of units you are working in.

Most machine shops will work in only one unit mode, either inches or mm.

There are definitely some shops out there that will use mixed units, but in most cases CNC programs will be written in one or the other for every program they make.

Know whether your parts are in inches or mms.

Codes that are similar to G20

All of the codes listed in the table below are modal commands that affect the way the CNC machine interprets size and location values that are entered.

Ready to master CNC programming?

Join our simple, easy-to-follow course, ‘G Code Made Easy: CNC Programming for Beginners’ and take the shortcut to becoming a G Code Master today!

Master G Code Today

G04 CNC Code Explained: An Easy Intro for Beginners [Dwell]

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

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

What does a G04 code do?

The G04 code tells the CNC machine to dwell (stay) in place for specified amount of time.

It’s a code that tells the machine to pause for a bit.

After the specified amount of time is done, the machine will proceed to read the next line of code.

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

When to use a G04 code?

G04 codes are used for multiple reasons.

They are used on lathes specifically, to break the chips. This way you don’t end up with one super long, razor-sharp chip.

Those chips are sharp!

They are also used to improve surface finishes on both lathes and mills. Dwelling at the bottom of a hole for instance may create a better finish on the bottom of the hole.

Another main reason that the G04 dwell code is used is to allow the machine time to perform an action. CNC machines tend to be very fast but sometimes all of their function can’t keep up. 

Sometimes you may need to tell your machine to pause so the coolant can get flowing enough or allow the machine enough time to finish a pallet change.

Format for using a G04 code

There is some variation to how G04 codes are called out. The difference is how the dwell times are listed.

Depending on what brand/controller your machine is, the following can change:

  • Letter used in callout to list time. Common letters are F, P, U, and X.
  • Seconds vs milliseconds. 1 second = 1000 milliseconds. Some machines work in seconds, others work in milliseconds.
  • Decimal or no decimal. Some controllers require a decimal. Some don’t allow a decimal. Some allow either way, but treat the number different based on whether you use the decimal or not.

Real standardized stuff ain’t it?

For example, these three lines below could all do the same thing:

G04 P3

G04 U3.0

G04 U3000

Still, these differences should help you troubleshoot any program issues you have related to a G04 dwell code. 

Consult your machine manual or machine manufacturer to make sure you know how your individual machine handles dwell commands.

G04 vs G4

Some people get confused about whether the 0 is required to be included in a G04 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 G04 code used in textbooks or other reference materials. In practice though, many prefer the shortened G4 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.

CNC codes that are similar to G04

If G04 pauses the CNC machine, what other codes are somewhat similar?

First you have stops.

Both of these codes pause the machine, but unlike G04 they also turn off machine functions such as the spindle and coolant flow.

When using stops, the machine won’t resume the program without hitting the cycle start button either.

fanuc cnc control panel with cycle start button highlighted
Cycle start on a Fanuc control

When using G04, the machine will wait the required amount of time and then resume on it’s own.

There are also some canned cycles that have dwell times baked into the code. These include:

Ready to master CNC programming?

Join our simple, easy-to-follow course, ‘G Code Made Easy: CNC Programming for Beginners’ and take the shortcut to becoming a G Code Master today!

Master G Code Today

G03 CNC Code Explained: An Easy Intro for Beginners [Counterclockwise Circular Interpolation]

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

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

What does a G03 code do?

G03 sets the CNC movement mode to counterclockwise circular movement, otherwise known as circular interpolation.

illustration showing how a cnc machine moves from the start to end point when using counterclockwise circular interpolation

G03 is used to move the CNC around along a specified radius set with the R code in a counterclockwise direction and at a feed rate set with the F code.

illustration showing the radius in a circular interpolation move

G03 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 travelG01 – Linear interpolation or G02 – Clockwise circular interpolation.

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

What is circular interpolation?

You know how when you zoom in real far on a photo, it starts to look all pixelated?

Circular interpolation is kind of like that. When we zoom in real close and look at how the machine is moving, we see it isn’t so smooth.

illustration showing how a CNC machine makes steps when using circular interpolation

While it may look like your CNC machine is moving in a perfect circle, it is actually moving in a series of small steps that look like a circle. This is called interpolation.

Basically, your CNC is doing the best it can to mimic a perfect circle.

You don’t need to do anything differently, it’s just good to know what we mean by interpolation.

G03 [counterclockwise circular interpolation] vs G02 [clockwise circular interpolation]

Everything that applies to the G03 code applies to the G02 code as well.

The only difference between the two is the direction of movement. 

illustration showing how a cnc machine moves from the start to end point when using clockwise circular interpolation

G02 moves clockwise and G03 moves counterclockwise.

G03 vs G3

Some people get confused about whether the 0 is required to be included in a G03 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 G03 code used in textbooks or other reference materials. In practice though, many prefer the shortened G3 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 G03 code?

G03 codes will usually be in the lines of the program that are used to cut the part.

The G03 code allows the programmer to cut a full circle or portion of a circle.

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

An R code is used as well to tell the machine what size radius to move along. Some CNC programs will use IJK codes instead of an R code to describe the circular move.

Other codes used with G03

The codes below are used with the G03 code or commonly found very close to a G03 command in a CNC program:

Format for using a G03 code

G03 X7.5 Y1.5 R0.5

Once the G03 code is used the machine will move to any XYZ locations given in a circular movement going counterclockwise along the given radius size and the set feed rate. 

Because G03 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:

X7.0 Y1.0 R0.5

then the machine would still move to the location in a circle 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 G03 code is used as well.

How to turn off a G03 code

There isn’t a specific cancel command for G03 like there is for canned cycles. Instead to turn G03 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 G03 counterclockwise circular interpolation off and switch to the new movement mode.

What to think about when using a G03 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 should identify the units you are working in before your G03 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 G03 code will move the machine in a circular arc 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.

CNC codes that are similar to G03

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?

Join our simple, easy-to-follow course, ‘G Code Made Easy: CNC Programming for Beginners’ and take the shortcut to becoming a G Code Master today!

Master G Code Today

G02 CNC Code Explained: An Easy Intro for Beginners [Clockwise Circular Interpolation]

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

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

What does a G02 code do?

G02 sets the CNC movement mode to clockwise circular movement, otherwise known as circular interpolation.

G02 is used to move the CNC around along a specified radius set with the R code in a clockwise direction and at a feed rate set with the F code.

illustration showing the radius in a circular interpolation move

G02 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, G01 – Linear interpolation or G03 – Counterclockwise circular interpolation.

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

What is circular interpolation?

You know how when you zoom in real far on a photo, it starts to look all pixelated?

Circular interpolation is kind of like that. When we zoom in real close and look at how the machine is moving, we see it isn’t so smooth.

illustration showing how a CNC machine makes steps when using circular interpolation

While it may look like your CNC machine is moving in a perfect circle, it is actually moving in a series of small steps that look like a circle. This is called interpolation.

Basically, your CNC is doing the best it can to mimic a perfect circle.

You don’t need to do anything differently, it’s just good to know what we mean by interpolation.

G02 [clockwise circular interpolation] vs G03 [counterclockwise circular interpolation]

Everything that applies to the G02 code applies to the G03 code as well.

The only difference between the two is the direction of movement. 

illustration showing how a cnc machine moves from the start to end point when using counterclockwise circular interpolation

G02 moves clockwise and G03 moves counterclockwise.

G02 vs G2

Some people get confused about whether the 0 is required to be included in a G02 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 G02 code used in textbooks or other reference materials. In practice though, many prefer the shortened G2 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 G02 code?

G02 codes will usually be in the lines of the program that are used to cut the part.

The G02 code allows the programmer to cut a full circle or portion of a circle.

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

An R code is used as well to tell the machine what size radius to move along. Some CNC programs will use IJK codes instead of an R code to describe the circular move.

Other codes used with G02

The codes below are used with the G02 code or commonly found very close to a G02 command in a CNC program:

Format for using a G02 code

G02 X7.5 Y1.5 R0.5

Once the G02 code is used the machine will move to any XYZ locations given in a circular movement going clockwise along the given radius size and at the set feed rate. 

Because G02 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:

X7.0 Y1.0 R0.5

then the machine would still move to the location in a circle 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 G02 code is used as well.

How to turn off the G02 code

There isn’t a specific cancel command for G02 like there is for canned cycles. Instead to turn G02 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 G02 clockwise circular interpolation off and switch to the new movement mode.

What to think about when using a G02 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 should identify the units you are working in before your G02 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 G02 code will move the machine in a circular arc 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.

CNC codes that are similar to G02

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?

Join our simple, easy-to-follow course, ‘G Code Made Easy: CNC Programming for Beginners’ and take the shortcut to becoming a G Code Master today!

Master G Code Today

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.

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

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.

Other codes used with G01

The codes below are used with the G01 code or commonly found very close to a G01 command in a CNC program:

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?

Join our simple, easy-to-follow course, ‘G Code Made Easy: CNC Programming for Beginners’ and take the shortcut to becoming a G Code Master today!

Master G Code Today

G00 CNC Code Explained: An Easy Intro for Beginners [Rapid Travel]

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

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

What does a G00 code do?

G00 sets the CNC movement mode to rapid traverse, sometimes called rapid travel. 

G00 controls the speed of the machine’s motion.

This code is used to move the CNC table and/or spindle around in a straight line (linearly) at the maximum speed. 

picture of the inside of a cnc machine with the spindle identified

When G00 is used, the machine ignores any feed rate set with the F code and instead goes as fast as possible.

Any combination of 1 or more of the machines axes can be moved in rapid mode. This includes the X, Y and Z axes.

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

Because G00 is a modal code, it will stay on until you switch it to another movement mode such as G01 – Linear interpolation or G02 – Clockwise circular interpolation

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

G00 vs G0: Clearing the Confusion

Some people get confused about whether the extra 0 is required to be included with an G00 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 G00 code used in textbooks or other reference materials. In practice though, many prefer the shortened G0 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 the G00 code

G00 codes are used when the CNC programmer wants to move the tool very quickly. This happens at many points throughout a program.

Rapid positioning with G00 moves the machine at full speed. This allows the program to be run faster and decreases the part cycle time which means parts can be made faster. 

G00 should only be used when there is no cutting action happening.

Using G00 while cutting your part would not give you good control over the cutting conditions and would most likely damage your part and/or your machine.

Use the G00 code to move the cutter to the location where it will start cutting or to other locations in the CNC such as the tool change position.

Other codes used with G00

The codes below are used with the G00 code or commonly found very close to a G00 command in the CNC program:

Format for using a G00 code

G00 X1.0 Y2.0 Z3.0

G00 is a simple code. You only need to specify the stop location for the movement.

Because G00 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 rapid mode. Because it’s modal it stays on until switched to another mode.

How to turn off a G00 code

There isn’t a specific cancel command for G00 like there is for canned cycles.

Instead, to turn G00 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 G00 rapid movement off and switch to the new movement mode.

What to think about when using a G00 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 should identify the units you are working in before your G00 code.

comparison of units of measurement for cnc programming

Absolute vs incremental positioning 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 zero location on your part.

Incremental positioning will move relative to the machine’s 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

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 G00 code will move the machine very quickly to the new location. You don’t want anything in the way or to miscalculate your stop point. 

Crashing your machine is never a good time.

Machine movement

There are many different CNC machines throughout the world. Unfortunately, they don’t all behave exactly the same. For this reason you need to make sure you know your machine when it comes to how it moves, especially when it comes to rapid movement.

Some machines will move all 3 axes at once. Some will rapid one at a time.

Some machines will move the different axes at different speeds causing a “dog leg” movement where the machine doesn’t move in a single straight line.

illustration of dog leg movement on a CNC machine

Most machines will move all 3 at once, but make sure you know the path your CNC will take when using the G00 code.

It’s important to understand how you individual CNC machine will move because you need to make sure there isn’t something that the CNC will crash into in that path.

G00 [Rapid Travel] vs G01 [Linear Interpolation]

G01 is a very similar command. It also controls straight line movement, otherwise known as linear interpolation, of the CNC machine. 

The difference between the two is that G01 will not move at maximum speed and will instead move at the last feed rate listed in the CNC program using the F command.

G01 is used for cutting motions. G00 is not.

CNC codes that are similar to G00

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?

Join our simple, easy-to-follow course, ‘G Code Made Easy: CNC Programming for Beginners’ and take the shortcut to becoming a G Code Master today!

Master G Code Today

G49 CNC Code Explained: An Easy Intro for Beginners [Tool Length Compensation Cancel]

What does a G49 code do?

The G49 code cancels tool length compensation.

Once the G49 command is used, the machine will not account for any tool length (H) offsets in its movement.

This means the machine will move the end of the spindle to all new locations.

When tool length compensation is in effect by using either a G43 or G44 code, the machine will move the end of the cutting tool to all new locations.

an illustration of a cnc machine that shows how a g43 code offsets the program

What is tool length compensation?

Tool length compensation is your CNC machine accounting for the length of the cutting tool when running the program.

It does this by adjusting for the cutter by a value that is entered into the offset library. This offset is called an H offset.

mach 3 tool offset table

H offsets are assigned by using the H code with a G43 code to turn tool length compensation on. 

For example, the line

G43 H02 

tells the CNC to turn tool length compensation on using the #2 height (H) offset.

illustration of a cnc cutting tool that shows what an H offset is

Learn CNC Programming – It’s Easier Than You Think!

Learning G Code doesn’t have to be difficult…

If you know what to focus on.

Join our simple, easy-to-follow course, “G Code Made Easy: CNC Programming for Beginners“. We walk you through all the important codes – with simple explanations and real-world examples.

Want to become a super-skilled CNC programmer? Join now to take the shortcut to becoming a G Code Master today!

Make Learning G Code Easy

Where will you find G49 in a CNC program?

The G49 code is not a required part of your CNC program.

It is rare that you would want to move the tip of your spindle to an exact location. You will almost always have a cutting tool in the spindle that you will want to account for.

This means the G49 code is not used often. It is more important to make sure you have the correct tool and offset selected.

Some programmers choose to include the G49 code as part of their safety block of code.

Others skip it and just make sure to call out the correct offset for their tool at the start of a new section of code.

As long as you switch to the correct offset for the currently loaded tool, then there is no need to cancel tool length compensation with the G49 code.

What to think about when using a G49 code?

Different machines can interpret the G49 code in varying ways.

When the G49 code is used, some machines will immediately move the end of the spindle to the location the end of the cutting tool was previously in.

If you aren’t in a safe location with enough clearance, the machine could crash. That’s never good!

If you plan to use a G49 code then make sure you understand how your CNC will react. Check your manual!

Other CNC cancel commands

Code

Name

G40

Cancel Cutter Compensation

G49

Cancel Tool Length Compensation

G50

Cancel Scaling

G67

Cancel Custom Macro Call

G69

Cancel Rotation

G80

Cancel Canned Cycles

Codes that are similar to G49

There are multiple commands that will cause the machine to act very similar to when a G49 codes is used.

Using the M30 code, the reset command or an H0 offset will cause the CNC machine to cancel tool length compensation.

Want to learn more about G Code for your CNC?