Beginner’s Guide To Reading Machine Shop Numbers & Values

Confused? If you’re reading this page then I’m pretty sure you are. Dealing with numbers, values and calculations when machining or 3d printing can be hard for those just starting. 

The lingo and terminology used by many people both online or at a new job can be hard to understand. My hope is that after this quick lesson in dealing with machine shop numbers, you will not only be comfortable reading your numbers and measurements but also will know how to perform some simple calculations using them. 

math on chalkboard

Let’s begin

First we need to understand what the numbers we are working with represent.

Whether they are a reading on a micrometer, a spec on a blueprint or a stack of gage blocks, the goal is the same.

We need to know how to read them and work with them. 

Below is a graphic that shows the name (including machine shop lingo) for different values.

Pay attention to how far each number is from the decimal place when looking at the chart.

Please note that not everyone will be working down to millionths of an inch but I included them for reference. Many will only work down to the the values shown in this table. 

Value

Machinist Lingo

Technical Math Term

0.001″

Thousandth or Thou

Thousandth of an Inch

0.0001″

Tenth

Ten Thousandth of an Inch

Keep in mind that all these numbers and terms apply to imperial units (inches).

machine shop terminology for numbers

How to say the value

Machine shops usually speak in terms of thousandths of an inch. Because of this when we describe the value to someone else we will read it a little different than you might expect.

As noted above, if we give the example of 7.489136″ a machinist would describe the value as 7 inch, 489 thousandths, 1 tenth, 36 millionths. 

Read that last sentence over a couple times to really understand the terms your typical machine shop speaks in.

As a note, not all machine shops or hobbyists will deal in millionths of an inch and some might not even work with tenths but I have included them for reference.

Note: Thousandths of an inch is often abbreviated as “thou” especially when discussing values verbally. 

Machine shop number reading examples

Below are some more examples to show how machinists communicate values:

Value

Machinist Lingo

1.325″

1 inch 325 thousandths

0.5001″

500 thousandths 1 tenth

0.021

21 thousandths

0.6532″

653 thousandths 2 tenths

9.792345″

9 inch 792 thousandths 3 tenths 45 millionths

Gage blocks

A common scenario for someone new in a machine shop is learning how to set up a stack of gage blocks.

I’m not going to show you how to pick the right gage blocks for your stack here. If you need those instructions then head over to Starrett’s website. They have great instructions that show you how to select your gage blocks and make a stack of a specific height. 

The link also contains information related to the use and care of your gage blocks. Take care of your gage blocks people, those things are expensive.

How to setup calculations

Now I said I would show you how to work with these numbers, so let’s demonstrate how to do that.

The important part when dealing with numbers or values in a machine shop context is to line up the decimal point. Below you will see some examples of addition and subtraction of numbers:

Simple calculation examples

addition and subtraction of values

For practice, let’s list out how to say those answers!

Value

Machinist Lingo

1.610″

1 inch 610 thousandths

0.7206″

720 thousandths 6 tenths

0.6249″

624 thousandths 9 tenths

There aren’t any other special tricks here. Once you line up the decimal places everything else is just like you learned early in school. Also consider yourself lucky we have calculators.

That’s it. Now you should know how to speak in terms that a machinist would understand and use the values in simple calculations. 

If you need more in depth training when it comes to machine shop math, check out the training linked below. It breaks all the hard subjects down into bite sized pieces to make them easy to understand.

Ready to master machining math?

Get the tips and tricks you need to master the math needed for CNC and manual machining. Includes easy-to-follow guidance to make learning the math you need to succeed a breeze!

Related articles

Complete Guide to Comments in G Code

a cnc machine running with g code overlaid

What are g code comments?

Comments in CNC g code are portions of the program that are ignored by the CNC controller and/or help the machine operator understand the program.

There are many different machine manufacturers and they can each have their own format for handling and identifying comments. In other words, what works on one machine may not work on another.

When in doubt try to find a manual or research your specific brand of CNC. We have outlined some of the most common CNC manufacturers and how they call out comments in the table below.

You can see that the two most common ways to identify a comment are by enclosing it in parentheses () or placing a semicolon symbol ; before the comment.

How to insert a comment into a g code program

The table below lists the symbol or character that is used to identify g code comments on a specific line of the program.

Take note that when parentheses () are used, everything between the open and closed parentheses will be ignored.

When the semicolon ; is used, all code after the semicolon on that line will be ignored and treated as a comment. Placing a semicolon inside a parentheses will not make the machine ignore the rest of the line, only what is inside the parentheses in this case will be ignored.

Remember, there are dozens or possibly hundreds of machine tool manufacturers and some may not adhere to these rules but this guidance will work for the majority of machines.

Machine Control Manufacturer

G Code Comment Character

Fanuc

Parentheses ()

Haas

Parentheses ()

Heidenhain

Semicolon ;

Hurco

Parentheses ()

Mitsubishi

Parentheses ()

Sinumerik (Siemens)

Semicolon ;

Yasnac

Parentheses ()

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!

What should be included in a g code comment?

Comments can include anything that can help to operator or setup person to better understand how the program is operating.

Placing comments at key moments in the program can be a great way to help an operator. Letting them know if they need to perform an action or if the program is about to start a new operation (switching from roughing to finishing or starting to drill a set of holes) can be extremely helpful.

The best practice is to be brief but provide enough info. You don’t want to write a book and clutter up the program, but too little information can leave a person guessing or assuming what is happening in the program.

Creating good comments can help someone who isn’t highly trained in reading g code but they can also help you when you go to troubleshoot the program or try to edit or improve it later on down the road.

Where should you put comments in your CNC program?

In general, g code comments should be placed at the end of the program line to describe the current action. Some machines allow comments, specifically ones in parentheses (), to be added in the middle of the line.

I recommend avoiding this practice as much as possible. It can cause issues with some machines. Sticking with a semicolon or parentheses at the end of the line will help ensure your program is the most compatible with a wider assortment of machines.

As we noted above, it is also a good idea to include comments at the start of a new section of your program.

Tooling descriptions, offset information and descriptions of the operations being performed are all great info to include in the comments at the start of a new section.

A block of comments at the start of your program is a welcome addition that many CAM programs will automatically insert with information such as the program creators name, a date or revision of the program and miscellaneous other information.

When should you use comments in your g code?

Comments add to the size of the CNC program (not as much of an issue with newer machines) and also clutter up the code.

Use them sparingly and in the important places. You don’t need to comment ever move.

Comments work great at the start of program sections to help operators know what to expect or what is expected of them.

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!

How to Learn CNC Programming [Best Resources]

What is CNC programming?

CNC programming is the process of creating and running a program consisting of G code in a CNC machine to move the machine and control its functions.  

There are a large range of CNC machine types available, from industrial mills and lathes to home machines such as 3d printers, laser engravers and CNC routers.

All of these CNC machines use the same G code language to control the machine.

How difficult is it to learn CNC programming?

Learning basic CNC programming is fairly easy. It involves learning how the CNC machine will react to a series of codes. Most of the codes are easy to remember with a little practice (F for feedrate, S for spindle speed) and for any of the harder to remember codes, cheat sheet type references are usually not too far away.

Learning advanced CNC programming will take more time. Practice and repetition help, as does attending local training programs or completing an online training course.

When learning CNC programming expect to apply math skills, learn to read manufacturing blueprints and work with specialized computer programs.

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!

What are the steps involved in CNC programming?

infographic that shows three steps to making a cnc program

Plan the program

The first step in CNC programming is planning out your program. In this step you will choose the machine and tools that will use to make your part. The operations to create the part (shape part, drill hole, mill slot, etc.) as well as the order of those steps will be determined.

Write the program

Now that you know what you will use to make the part (machine and tools) and how you will make the part (the order of operations), the program can be written.

When writing the program, you will create code either by hand or with the help of software to create the instructions for the machine to run.

In this step, documentation is usually created that lists any special requirements for running the program such as the tooling to be used, offset information, and fixturing information.

Setup the CNC machine

The role of the CNC programmer will sometimes end once the program is written and documented. However, in many machine shops programmers are also responsible for setting up and/or operating the machines too.

Setting the CNC machine up will involve loading the correct tools, setting offsets, loading the program and running a first piece to verify everything is running as planned.

Types of CNC programming

Manual programming

Manual programming is when the programmer creates the G code by hand. This involves controlling all of the machine’s functions and movements through the use of code.

Manual programming of CNC programs is usually only done with very simple programs.

Conversational programming

Conversational programming involves giving the machine specific parameters or dimensions that are required and the CNC machine generates the code for you based on the input.

Conversational programming is a middle point between manual programming and programming with CAD/CAM systems. Conversational programming simplifies the programming of features that may be difficult to program manually.

Conversational programming can allow quicker programming times when compared to CAD/CAM programming options. It also generally requires far less training than what is required to work with CAD/CAM packages.

Programming with CAD/CAM

two computer monitors with CAD-CAM software running
Example CAD/CAM software

The majority of CNC programming today is done with the use of various computer aided drafting (CAD) and computer aided manufacturing (CAM) software packages. These software programs allow the creation of long, complex CNC programs with much less work when compared to manual or conversational programming.

CAD/CAM programs are capable of programming things that wouldn’t be possible with manual or conversational programming. There are many different CAD/CAM software programs available with some of the most common being AutoCAD, Fusion 360, SolidWorks, Mastercam & EDGECAM.

How to start learning CNC programming

Local college/training

One of the best ways to start learning CNC machining is to look for local education resources such as colleges, community colleges, training programs and your state’s manufacturing extension partnership (MEP).

These resources often provide unequaled instruction and hands on use of equipment.

In some areas, companies have created their own training programs which they operate to help educate their local workforce.

Self-guided training

If you don’t have local training options available, there are a large number of resources that allow you to learn CNC machining and programming on your own schedule.

YouTube has a wealth of informative instructional videos and there is an abundance of information available on other online resources such as MachinistGuides.com.

We recommend reviewing our list of the Best CNC and Machining Books to find the best reference material available.

Learning on your own can be daunting, especially when you don’t know where to start. For this reason, we have put together A Roadmap to Learn CNC Programming to help guide you and make sure you focus on the important stuff first.

Online training

For those looking for a more structured approach, there are online CNC training resources and courses available such as GCodeTutor.

The biggest benefit of online training is that it allows you to work at your own pace. The best online training programs will have help resources available as well as quizzes and projects to test your knowledge.

Types of CNC machines

CNC machines used to be extremely expensive machines that only large companies were capable of purchasing.

In recent years, the cost of CNC machines has come down quite a bit. Large scale industrial machines are still available, but they are accompanied by a new generation of machines aimed at hobbyists and makers.

Home/hobbyist machines

cnc wood router
CNC router
  • CNC routers
  • CNC plasma cutters
  • CNC laser engravers
  • 3d printers

Industrial level machines

a cnc mill with multiple fixtures and coolant lines
Industrial CNC
  • Mills
  • Lathes
  • Electrical discharge machines (EDM)

Frequently asked questions

Do you need a degree to get a job in CNC programming?

No degree is needed to become a CNC programmer, although previous training or certifications are looked at very favorably by employers.

Many employers are willing to provide on the job training to teach new employees the skills needed to perform the job.

How long does it take to learn CNC programming?

The basics of CNC programming can be learned in a short amount of time.  Learning the basics will only take a few short months.

However, CNC programming is a wide field, and it will take much longer to have a solid understanding of everything that goes into CNC programming.

To become a highly skilled CNC programmer will likely take years. Training programs vary in length from 1-4 years on average. In addition, hands on experience will be needed to truly become a master of the craft. Certainly, anyone who applies themselves and works hard to learn will shorten that timeframe considerably especially when working in a good training program.

Is CNC programming a good career?

CNC programming is a great potential career. There is a high level of demand for skilled CNC workers across the globe. Many experienced CNC programmers and machinists are expected to retire in the coming years and a lower rate of younger workers entering the field has created a high demand for skilled CNC workers.

The demand for skilled CNC workers is so large that many in the CNC industry refer to it as “the skills gap”.

This skills gap has created a good opportunity for anyone seeking a well-paying job in the industry.

What is the salary for a CNC programmer?

According to GlassDoor.com, the average CNC programmer makes about $85,000 per year.

That comes out to about $40 an hour.

CNC programming is similar to other skilled trade jobs and can pay quite well without the need for a college degree. Getting training or certifications will help improve your chances of landing that well-paying position.

What skills does a CNC programmer need?

Because most CNC programming positions require the use of specialized CAD/CAM software, the best programmers have solid computer skills.

CNC programming positions often require math skills as well. Trigonometry, geometry and algebra are all commonly used when programming. Often the computer software will perform the necessary calculations but there are many times where calculations must be verified by hand.

Luckily, most of the math skills only use a limited number of formulas. To get a better idea of the type of math skills involved, check out our Beginner’s Guide to Machine Shop Math.

title image that shows a triangle drawn on a paper with pencil next to it

What other jobs take similar skills to CNC programming?

CNC and machine operators are the closest related job to CNC programming. Often, operators are the ones who will be running the CNC programs.

It is quite common for operators to gain some experience in their machine shop and work their way up to a position in CNC programming.

CNC and machine operator positions are typically much less demanding when it comes to computer and math skills and are a great starting point for anyone interested in learning CNC machining.

Quick Guide to CNC Safety Lines [Common Codes]

What are CNC program safety lines?

Safety lines, sometimes called a safety block, are a section of code within a CNC program which are used to protect the machine, the workpiece, and the operator.

Safety lines are used to make sure the machine is in the proper mode/state which means that the machine will understand all the commands we give it correctly.

If you need the machine to work in inches (or mm in some parts of the world), it is important to frequently set the machine to work in those units. 

This is especially true if you will be switching between units when machining.

While many won’t switch between imperial and metric units, it is common to switch between absolute and incremental positioning modes.

The safety lines used will vary by machine, however there are many which are common between the majority of machines.

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!

Types of codes found in a safety line

Safety lines can contain G codes for coordinate systems, measurement units, tool compensation, and cancel functions. 

Each one of these commands is necessary to move the tool safely. 

Modal commands and cancel commands are two of the most common codes used in CNC safety lines.

Below are the most common safety codes found in CNC programs:

Positioning mode – G90/G91

The first code normally found in a safety line will be the machine’s positioning mode.

There are two positioning modes available to use. Absolute and incremental positioning.

Absolute positioning uses the G90 command. 

Absolute positioning mode tells the machine to interpret all locations it is given as measured from a fixed zero location (origin).

graph paper example of absolute positioning with multiple points as examples

Incremental positioning uses the G91 command.

Incremental positioning modes tells the CNC that the zero location is wherever the machine currently is. 

Once the CNC makes a move in incremental mode, the new location becomes the zero location.

graph paper example of incremental positioning with multiple points as examples

Units mode – G20/G21

Selecting the system of units you will be working in is important. This is why the units mode is found in the safety lines of the program.

Imperial units are set with G20 (inches) and metric units are set with G21 (mm).

You don’t want to move 4 inches when you meant to 4 millimeters.

Setting the units mode is critical to running your CNC.

comparison of units of measurement for cnc programming

Plane selection – G17/G18/G19

Selecting the plane you will be working with is necessary. Not because you will often switch between planes, but because it’s possible.

Most people will never use anything other than the standard XY plane with G17, but setting it will make sure that it is set correctly.

The alternatives to G17 are G18 for the ZX plane and G19 for the YZ plane.

Canned cycle cancel – G80

G80 is the g code used to cancel any active canned cycle.

Canned cycles are used to perform repetitive machining. This includes drilling, reaming, boring, counterboring and other operations.

Canned cycles are modal which means they are on until they are switched or turned off. 

In the case of a drilling canned cycle, once it is turned on every new location the machine reads will be a spot where it drills a hole.

Obviously, you need to stop drilling holes eventually. Using G80 cancels the drilling canned cycle or another other canned cycles that might be active.

Cutter compensation cancel – G40

Cutter compensation is when the CNC machine control changes how it reads the program. With cutter compensation on, the machine will shift a set distance based on the size of the cutting tool when running the program.

illustration that shows how a CNC will act when using cutter compensation left with the G41 code

Cutter compensation is turned on with either G41 or G42. G41 shifts the tool left and G42 shifts it right.

illustration that shows how a CNC will act when using cutter compensation right with the G42 code

The G40 code turns cutter compensation off.

illustration that shows how a CNC will act when there is no cutter compensation mode active

Tool length compensation cancel – G49

Cutter compensation is accounts for the diameter of the cutting tool.

Tool length compensation accounts for the length of the cutter from the CNC spindle.

G49 is the code used to cancel tool length compensation.

Both compensation modes adjust for the size of your cutter. This allows you to run the same program with different tools.

Other safety codes

Codes will vary by machine. Check your instruction manual for the specific codes you need to use in the safety lines.

The codes listed here are certainly a good start.

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

Safety lines for starting up your CNC

Setting the initial modes for your machine is an important part of every CNC program. If the modes are not set then the machine will stay in it’s initialized state.

Modes such as the unit system (mm/inch) can be set in the machine parameters. If no code is specifically given in the program then the machine will remain in the initialized state.

This is not a good programming practice because there is plenty of opportunity for errors to occur. Use safety lines to make absolutely sure your CNC is in the correct mode.

Here is an example of a safety line to use at the beginning of a program:

O1000
(Start of safety code)
G20 G17 G40 (G20 inch, XY plane, cancel cutter compensation)
G49 G64 G80 (cancel tool length compensation, normal cutting mode, cancel canned cycles)
G90 G94 G98 (absolute mode, feed per minute, initial plane for canned cycles)
(end of safety code)

Frequently asked questions about CNC safety lines

Can you put all of your safety codes on the same line?

The number of codes that can fit in the same line depends on the CNC machine.

Many machines have limitations for how many M-codes you can put on one line. G codes are generally only limited to one code from each group.

For example, G00, G01, G02 and G03 are all in the same group (movement). Only one of the codes from this group should be used on any particular line.

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!

CNC Spindle Controls Explained [M03, M04, M05 and More]

Getting started with CNC spindle controls

The most basic codes to control your CNC spindle are:

But there is more to controlling your CNC spindle than simply turning it on and off.

For instance, most CNC machines have multiple ways to turn the spindle off and each way has it’s own use case. 

Controlling the spindle speed is another function that has multiple modes. Choosing the wrong one could potentially be disastrous. 

Learn the ins and outs of controlling your spindle below.

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

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!

Codes for turning your spindle on

There are two CNC commands for turning the spindle on, M03 and M04.

The S code is used together with these codes to set the speed of the spindle.

Spindle direction

M03 [spindle on, clockwise]

The M03 code turns the spindle on in a clockwise direction at a set speed.

The speed is set with the most recent S code.

Clockwise rotation with M03 is the most common spindle rotation direction when CNC machining. 

Clockwise rotation is used with right hand cutting tools.

M04 [spindle on, counterclockwise]

The M04 code turns the spindle on in a counterclockwise direction at a set speed. 

Just like M03, the set speed is the value used with the most recent S code.

M04 is used with left hand cutting tools.

Counterclockwise spindle rotation is much less common than clockwise. 

This is especially true for machining centers (mills). For lathes, M03 is still more common but M04 gets more use.

Codes for turning your spindle off

The M05 code is the only code that just turns the spindle off.

However, there are other codes listed below that turn off multiple machine functions and the spindle is included in those functions.

M05 [spindle off]

The M05 code is used to stop the spindle.

It is normally used when there is a tool change or other change in the machining process.

When the spindle is turned back on with an M03 or M04 code after being stopped, the spindle will return to the same speed it was previously set at with the last S code.

M00 [program stop]

The M00 code is called a program stop. It stops the current program in the middle of running.

Using the M00 code turns off the following functions:

  • Movement of all axes
  • Spindle rotation
  • Coolant flow
  • The machine pauses reading the program

When the M00 code is used, nothing is reset. In other words, any active modes or parameters will stay as they are.

The program is merely paused when it reads the M00 code.

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

The machine will resume reading the program when the cycle start button is pressed after the program stop has occurred.

One thing to keep in mind is that the machine doesn’t turn on functions when cycle start is pushed. 

If the M00 code turns something off such as the spindle, it will need to be turned back on in the program.

M01 [optional stop]

The M01 code is called an optional stop. 

It stops the current program in the middle of running, but only if the optional stop switch or button is on.

If the optional stop switch is not on, then the machine will ignore any M01 codes it reads and continue running the program like normal.

haas cnc control panel with optional stop button highlighted
Optional stop button on a Haas CNC

When the machine reads an M01 code and the optional stop switch is on, it will turn off the following functions:

  • Movement of all axes
  • Spindle rotation
  • Coolant flow
  • The machine pauses reading the program

When the M01 code is used, nothing is reset. Same as with the M00 code.

In other words, any active modes or parameters will stay as they are. The program is merely paused when it reads the M01 code.

The machine will resume reading the program when the cycle start button is pressed after the program stop has occurred.

One thing to keep in mind is that the machine doesn’t turn on functions when cycle start is pushed. 

If the M01 code turns something off such as the spindle, it will need to be turned back on in the program.

M30 [program end]

The M30 code ends the program. 

This makes it different from M00, M01 or M05.

M00 and M01 shut down various machine functions and pause the program.

M30 shuts down machine functions and ends it. 

Pressing cycle start after an M30 code will start the entire program over again.

How to set spindle speeds

CNC spindle speeds are set using the S code.

S code

Using the S code sets the spindle speed that will be used whenever the spindle is turned on. The units are revolutions per minute (RPM).

The same spindle speed value will be maintained until it is changed.

Below is a small section of code with comments in parentheses that show what will happen as the machine reads the code.

M03 S3000   (Spindle On CW, Speed = 3,000 RPM)
M05              (Spindle Off)
M04              (Spindle On CCW, Speed = 3,000 RPM)

Notice how the spindle turns back on at the same set speed. This happens even if the spindle rotation direction is changed from clockwise to counterclockwise or vice versa.

S codes show up frequently in programs at the beginning of a new section of code. This can be switching tools or switching machining operations such as going from cutting the outside profile of the part to drilling holes.

Some other notes about the S code:

  • Must be a whole number (no decimals such as 3000.5)
  • Most machines have a limit to the range of spindle speeds that can be used. 1-9999 is common but 1-99999 is also used by some machines

Spindle speed modes

In CNC programming there are two codes that control the spindle speed mode, G96 and G97.

G97 is the most common and sets the spindle mode to RPM.

G96 sets the spindle mode to constant surface speed which adjusts the speed of the spindle based on the size of the part being machined.

G97 [speed in RPM]

When the G97 mode is active, the machine will maintain a constant spindle speed based on the RPM value set with the most recent S code.

If G97 is active, spindle speed will only change when the S code is changed.

G96 [constant surface speed]

When the G96 mode is active, the machine will maintain a constant surface speed.

Imagine a monster truck tire. Now picture rolling the monster truck tire one complete revolution in one minute. In that one minute, you might move 20 feet.

Now imagine you have a normal car tire. If you roll the car tire one revolution in one minute, you might only travel 4 feet.

You covered a lot less distance in that one minute, which means you traveled at a slower speed.

When things are spinning based on an RPM speed, the actual speed that the cutting edge of the tool is traveling can change.

Using constant surface speed with the G96 code tells the machine to change the spindle speed over time as the size of the part changes so that the speed where the cutting action is happening remains the same.

This is a simplified explanation of how G96 works. For more information about G96 see our full guide to the G96 command.

How to change the tool in your spindle

Most machining centers have automatic tool changers that can switch tools into and out of the CNC spindle.

an automatic tool changer on a dmg mori cnc machine
Automatic tool changer holding multiple tools in a DMG Mori CNC

The tool to be placed into the spindle is called up with the T code. This places the new tool in location so that it is ready to be switched.

The M06 command is then used to perform the tool change.

Here is an example section of code:

T01    (Tool 1 is readied for change)
M06    (Tool 1 is placed in the spindle)
T02    (Tool 2 is readied for change)
T03    (Tool 3 is readied for change)
M06    (Tool 3 is placed in the spindle)

Notice that even though tool 2 was readied for change, it never actually was put in the spindle. Instead, tool 3 was readied before the tool change occurred and it was placed in the spindle instead.

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!

CNC Offsets Explained [D, H and Work Offsets]

What is a CNC offset?

Offsets are the adjustments that the CNC machine will make based on different features of the machine.

There are three types of offsets:

  • Diameter offsets
  • Height offsets
  • Work offsets

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!

Types of CNC offsets

Each of the three offset types has a specific purpose. 

They each allow for flexibility when running your program. This includes allowing you to use the same program even if you need to change cutting tools.

Height (H) offsets

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

The height offset refers to the location difference between the spindle and the cutting tool.

This difference in location is stored in the machines offset library. Height offsets are usually stored in the same number location as the tool.

mach 3 tool offset table
Example offset library

For instance, T01 (tool 1) and H01 (height offset 1) or T05 (tool 5) and H05 (height offset 5).

This makes it easier to match up the necessary offset with the correct tool.

The G43 code is used to turn on tool length compensation using an H offset.

For example, G43 H01 turns on tool length comp with the first H offset.

Once tool length compensation is turned on with the G43 code, it will stay on until it is turned off with the G49 cancel code or switched to a new H offset such as H02 or H05.

Diameter (D) offsets

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

While H offsets adjust for the length of the cutter, D offsets compensate for the diameter of the cutting tool.

D offsets are also stored in the machines offset library. D offsets are usually stored in the same number location as the tool they are used with.

T04 (tool 4) and D04 (diameter offset 4) would usually be matched together.

G41 and G42 are the two cutter compensation modes that are used with D offsets.

They tell the machine to adjust the path of the cutter so that the edge of cutter follows the path given in the CNC program. G41 shifts the cutter left and G42 shifts the cutter right.

illustration that shows how a CNC will act when using cutter compensation left with the G41 code
illustration that shows how a CNC will act when using cutter compensation right with the G42 code

With cutter compensation off using the G40 code, the machine will move the center of the cutter along the path in the program. 

This can make it difficult to get the correct size, especially when using different or multiple cutters.

illustration that shows how a CNC will act when there is no cutter compensation mode active

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 ang 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.

Just like tool length compensation with G43, cutter comp with G41 and G42 are modal commands so those adjustments will stay on until switched or turned off with the G40 code.

Work offsets (G54-G59)

Work offsets are basically the stored location of your part in the machine. 

You use them to set the XYZ zero location when working in absolute positioning mode.

There are multiple work offsets available. 

The six most common are G54 through G59. Most machines will also have others available, but the format varies from machine to machine.

visual to show cnc work offsets G54-G59 with the zero locations shown
Multiple work offsets being used in one CNC machine

Fanuc controls are one of the most common controllers. If they allow additional work offsets, the Fanuc format for using them is G54.1 P1, G54.1 P2 and so on. The P number is the additional offset.

In most cases the six offsets of G54 through G59 that are common on all machines will be more than enough.

One benefit of having multiple work offsets is how easy they make it to run multiple parts at once. You can set the work offset for multiple parts and run the same program with a new work offset each time.

This works well when you a fixture that holds multiple parts in your CNC.

Where are offsets stored?

Offsets are stored in the tool offset table or library.

This tool table allows you to describe the different dimensions of the tool that will affect the program.

This includes the tool radius or diameter (D offset) and its length (H offset).

Offset Library
Tool offset library on an Okuma CNC machine

Some machines allow you to store the H and D offsets together in one offset. In this example, tool T01 would use both H01 and D01 as offsets. 

Other machines may require the offsets to be stored individually. 

When the offsets are stored individually, the programmer should maintain a system so that the offset numbers used are consistent. 

In other words, the first H offset would always be stored in the 01 location and the first D offset would always be stored in the 51 location.

Having a system like this will help prevent errors in your program.

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!

First CNC G Codes to Learn [Where to Start for Beginners]

What is a G code?

G code is the programming language used by CNC machines of all types.

This includes everything from mills and lathes to 3D printers and laser engravers.

G code consists of commands made up of letters and numbers that tell the CNC machine what to do. Most letters in the alphabet are used as codes to make the machine do something.

This can be a little confusing because while G code refers to the programming language used by CNC machines, there is also a large group of codes that are frequently used which start with the letter G. This group of codes is often referred to as simply “G codes”.

This post will cover the most common group of codes that start with the letter G, but we also have resources to help with the other letter codes if you need it.

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!

What types of codes are used in CNC programming?

M CNC Code

The two largest groups of codes are G codes and M codes.

G codes are preparatory functions. 

These codes prepare the machine to perform an action by setting various machine modes such as working in inches vs millimeters.

There are dozens of G codes which are used, and they vary somewhat from machine to machine.

The most common G codes are listed below. 

For the most part, the commonly used G codes are consistent across the different machine makes but check your machine manual to be sure.

M codes are miscellaneous functions. 

These are easier to remember as “machine functions” because this group of codes controls different parts of the CNC machine such as turning the spindle or coolant on and off.

The rest of the CNC codes consist of the remaining letters A through Z.

G and M codes are the only ones to worry about that have multiple codes within the same letter. In other words, there is a G01 and a G02 code. This isn’t true for other codes such as F, S, X, Y or Z.

Working with G Codes

G codes set various machine modes including turning them on and off.

Only one G code can be active at a time from each group. 

If you use the G20 code to turn on inch mode then the machine will basically turn off metric (mm) mode. You can’t have both codes active at the same time. 

These are called modal commands.

Some modal commands can be canceled (turned off) without setting another mode. For example, cutter compensation can be set to adjust left with G41 or right with G42. It can also be turned off (canceled) with G40 so there is no cutter compensation.

Inch/metric mode on the other hand can not be turned off. One of the two codes must be active at all times. There is no G code for turning the units the machine is working with off.

The most common G code groups are listed below:

Common G Codes

Movement G Codes

Movement codes are some of the most often used G codes in CNC programming. They are used to move the cutting tool around the machine.

The G codes for movement are:

G00 is used for quickly moving the machine around when not cutting. The machine will move at the max allowed speed. This helps reduce the time it takes to run a program.

G01 through G03 are for cutting movements. They will move at the most recently listed feedrate specified with the F code.

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

Unit Modes

There are two unit modes that can be used when CNC machining.

G20 is used for working with imperial (inch) units and G21 is used for working with metric (mm) units.

You want to pay attention to your unit mode because 1 inch is 25.4 times bigger than 1mm so being in the wrong unit mode could be disastrous!

Positioning Modes

There are two types of positioning that can be used by the CNC.

Absolute positioning with G90 treats every new location that the machine reads as a location relative to a fixed point in the machine.

Incremental positioning using G91 reads every new location as a distance from its current location. Every time the machine moves to a new location in incremental mode, the new location becomes the new zero location.

The main body of most CNC programs is written in absolute positioning mode and smaller sections of the program are often written in incremental positioning mode. 

Incremental positioning is usually used for repetitive features such as drilling a number of holes.

The pictures below show how the locations given to the machine differ between the two positioning modes. The numbers in parentheses ( ) are the coordinates that the CNC is given for each new move.

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

Compensation Modes and Offsets

Offsets and compensation modes allow the CNC machine to be more flexible. Using them allows you to use the same program with multiple machines as well as different cutting tools.

Offsets and compensation modes also make CNC programs easier to read and understand.

Tool Length Compensation

Tool length compensation is how the CNC machine accounts for the length of the cutting tool.

G43 turns tool length compensation on and G49 turns it off. G44 also turns tool length compensations on, but it is almost never used.

Using tool length compensation allows you to tell the CNC machine how long your cutter is. This lets you use the same program across multiple different tools. Each tool will have its own adjustment, or offset value, stored in the machine’s memory.

Tool length compensation uses H offset values stored in the machine.

H offsets are selected using the H code.

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

Cutter Compensation

Just like tool length compensation adjusts for the length of the cutting tool, cutter compensation adjusts for the diameter of the cutter.

If cutter compensation is off with G40 then the machine will move the center of the cutting tool along the path in the CNC program.

If cutter comp is on with either G41 – left compensation, or G42 right compensation then the machine will adjust the location so that the edge of the cutter follows the path given in the CNC program.

Like tool length compensation, this allows multiple different cutters to be used with the same program. Without cutter compensation, the program would need to be rewritten each time you wanted to use a new tool.

Cutter compensation is in the XY direction and tool length compensation is in the Z direction.

Cutter compensation uses D offset values stored in the CNC controller.

D offsets are selected using the D code.

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

Work Offsets

While tool length and cutter compensation modes adjust for the cutting tool, work offsets adjust for the CNC machine itself in the program.

There are many different sized CNC machines available. Because machines vary in size, the location within the machine for a part can change.

Using a work offset such as G54 allows you to set a zero location for the program. This allows a much simpler and easier to read program. Also, work offsets let you use the same program in different machines.

Without work offsets you would need to write a new program for each CNC machine you want to run it on.

Most CNC machines have multiple work offsets available. G54-G59 are the most common.

Using multiple work offsets can be used to run more than one part at a time. The zero location gets switched and the same program is run again.

Multiple work offsets can even be used in a single program.

visual to show cnc work offsets G54-G59 with the zero locations shown
Multiple work offsets used in a single machine

Canned Cycles

Canned cycles are a single code that allows you to perform common, repetitive machining functions such as tapping or peck drilling.

For example, peck drilling involves drilling into the part, backing up, drilling deeper, backing up again and repeat. 

Using canned cycles allows you to have a simple, easy to read line code that gives the machine instructions for what can be a long process.

illustration that shows the difference between peck drilling and standard drilling in a CNC machine

Using canned cycles can change the length of your program by a large amount. Smaller programs are usually easier to read and programs that are easier to read are usually easier to troubleshoot as well.

Next Steps

That covers the most common G codes, but what about the other letter codes?

Once you’ve mastered the G codes listed above, dive into the list of M codes

There are a lot less M codes that get used and almost all of them are essential to know.

After that, check out the Complete List of CNC Letter Codes. You will likely know some of the common ones such as F for setting feed rates or S for setting spindle speeds through learning about the various G & M codes.

Our complete list of codes rounds them all up and puts them all in one place to make learning easy.

Check out our comprehensive CNC G code training:

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!

First M Codes to Learn [Where to Start for Beginners]

What is an M code in CNC programming?

M codes are miscellaneous codes. They control various functions of the CNC machine such as turning coolant flow or the spindle on and off.

M codes are the second largest group of codes after G codes.

M codes vary from machine to machine, but we have covered the most common ones below with links for more info on each code.

You can expect that these codes will work the same on most machines:

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!

Common M codes

Stops [M00, M01]

The M00 code is called a program stop.

It stops the spindle and coolant flow. 

The M00 program stop also stops all machine movement and pauses reading the program.

It is typically used when changing the tool manually or there is a need or adding tapping oil to a tap before it touches the workpiece.

The machine will continue reading the program after a program stop once the cycle start button is pushed. It doesn’t automatically restart the spindle or coolant though. Those must be turned back on in the program.

The M01 code is an optional stop. It stops everything that the M00 code does but only if the optional stop button or switch is on.

haas cnc control panel with optional stop button highlighted
Optional stop button on a Haas CNC

If the optional stop switch is off, the machine will ignore the optional stop code and keep running the program.

Program end codes [M02, M30]

While the M00 and M01 codes pause the program, the M02 and M30 codes end it.

M30 is the most common program end code. It ends the program and rewinds the program back to the start.

This means that if you press cycle start after the M30 code, the machine will run the program again.

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

M02 is a program end without rewind.

This is mostly a legacy feature from when programs were run on tape. In fact, many newer machines will treat a M02 code as if it were an M30 code.

Spindle commands [M03, M04, M05]

Spindle direction

M03 turns the spindle on in a clockwise direction.

M04 turns the spindle on in a counterclockwise direction.

M05 turns the spindle off. The spindle should be turned off first before changing the spindle direction.

Coolant commands [M07, M08, M09, M88, M89]

M08 turns flood coolant on. 

This floods the cutting area with coolant to keep heat from building up which can damage the part or the cutter.

It also helps remove chips from the cutting area which can cause issues as well.

The M09 code turns the coolant off.

Many machines will have other coolant options that can be turned on as well. M07 to turn on mist coolant is a common one and so are M88 to turn thru spindle coolant on and M89 to turn it off.

Tool change [M06]

Most machining centers (mills) have automatic tool changers.

Tools get loaded into the ready to change position with the T code.

When the M06 code is used, the machine swaps the tool currently in the spindle with the tool in the ready position.

an automatic tool changer on a dmg mori cnc machine
An automatic tool changer on a DMG Mori CNC

Subprogram codes [M97, M98, M99]

There are two ways to run subprograms: M97 and M98.

The difference between M97 and M98 is the program location they move to.

The M97 code will jump to a new line in the current program.

The M98 code will run an entirely different program.

The format for using both codes is the same. They both use the P code and the L code.

M97 P1234 L3

For a M97 code, the P number is the line number of the subprogram inside the current program.

For a M98 code, the P number is the program number for the subprogram that will be run.

The L code is the number of times that the subprogram will be repeated.

The M99 code ends both types of subprograms and jumps to the next program line after the M97 or M98 code was used. 

Subprograms are not ended with an M30 code like a normal program is.

M codes vs G codes

M codes control different machine function such as the spindle or coolant.

G codes are another type of code used in CNC programming and they are called preparatory functions. This means they prepare the machine to do something.

Usually this involves moving the machine or controlling how it moves. 

Codes such as G00 [rapid travel] or G81 [drilling canned cycle] make the machine move in a certain way. Codes such as G90 [absolute mode] or G21 [metric mode] control how the machine reads the movement.

Both G and M codes are heavily used in CNC programming. It is important to understand both types of codes. 

For this reason we have a post on the First G Codes to Learn as well. Check it out because understanding the codes in that post and this one will give you a good foundation for understanding CNC programming.

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!

Quick Guide to CNC Subprograms [Tips & Tricks]

What is a subprogram in CNC programming?

Subprograms are a separate CNC program chosen to be run from within another program. 

Subprograms can be run (called up) from the main CNC program or from within another subprogram.

They are used to perform repetitive machining operations or sequences such as drilling, counterboring and countersinking a hole.

CNC machines run the lines of code in a program in order. 

Using subprograms allows the programmer to jump around to different sections of the current program or to run a different program and come back to the current program.

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!

What is the difference between a subprogram and the main program?

The commands to end the main program and a subprogram are different.

The main CNC program ends with either M30 (most machines) or M02 (older machines) code. 

No further code will be run after either of these codes.

A subprogram ends with the M99 command

The M99 code returns the machine to the program which called the subprogram. The machine will continue to run code in this program.

CNC codes used when working with subprograms

How to call a subprogram

There are two ways to run subprograms: M97 and M98.

The difference between M97 and M98 is the program location they move to.

M97 will jump to a new line in the current program.

M98 will run an entirely different program.

Format for using M97

The format for using an M97 code is:

M97 P1234 L5

This line of code will tell the machine to move to line N1234 of the current program. The L code tells the CNC machine to run the subprogram five times. 

The L code can be left out if the subprogram will only be run once.

Line 1234 will be after the program end command (M30). Once the machine reaches the M99 command it will return to the line after the example shown above.

Format for using M98

The format for using an M98 code is:

M98 P5678 L2

This line of code will tell the machine to go run program number 5678 two times. The L code tells the CNC machine to run the subprogram twice. 

The L code can be left out if the subprogram will only be run once.

Program 5678 will perform any necessary machining functions and then end with an M99 command instead of M30. The M99 command will make the machine return to the line after the example shown above.

On the other hand, both commands (M98 and M97) use parameters K (or L) as the number of repetitions of a given subprogram. The use of the letter K or L depends on the CNC model. Always check the machine’s manual for further details.

Subprogram example

Main program

O1234
G21                             (metric mode)
G17 G40 G80           (select XY plane, cancel cutter compensation and canned cycles)
G91 G28 Z0              (home z axis)
M03 S1200               (turn spindle on)
G90 G54 G43 H1     (incremental mode, select work offset, turn on tool length compensation)
G00 X5.0 Y5.0          (rapid to hole #1 location)
Z2.0                            (position tool above part)
M98 P5555               (run subprogram)
G28 Z0                       (home z axis)
M30                            (end program)

Subprogram

O5555
G91                             (set incremental movement mode)
G81 Z-10.0 F200     (drill hole #1)
X5.0                            (drill hole #2)
Y6.0                            (drill hole #3)
X-5.0                           (drill hole #4)
G00 Z20.0                 (rapid to safe location above part)
M99                            (return to main program)

In the example above, the machine will create a pattern of four holes. This pattern could be easily repeated by moving to the start of the pattern in a new location and running the subprogram again.

To do this the location of the repeated pattern would be listed after the subprogram call in the main program and the subprogram call of M98 P5555 would be listed again. The machine would then make the same pattern of holes in the new location.

What are subprograms used for?

Subprograms are used for repeating tasks. 

This can be machining of a part or controlling the machine itself.

Part related subprograms

Most of these subprograms include canned cycles in their lines of code to perform repetitive machining operations such as drilling, pecking, tapping, threading, bearing, and boring.  

They also help to run the same program in different parts of the workpiece, even if they don’t include canned cycles.

This can include rotating or changing the tool, contouring or finishing.

Machine related subprograms

Subprograms can also be used to control the machine.

Changing a tool in the CNC might consist of turning the coolant off, turning the spindle off and moving it to a safe location, setting or canceling a variety of modes, and finally switching the tool.

A subprogram can be created to automate the tasks and make sure it is executed the same way each time. 

This makes the operation less prone to errors or crashes.

This benefit only gets better as the amount of operations performed gets longer.

Benefits of using a subprogram

The greatest benefit of using subprograms is reducing the lines of code which makes the program easier to read and edit.

Subprograms can also reduce the number of errors in the program. Less lines of code means less possible sources of problems.

Drawbacks of using a subprogram

Subprograms are meant to make the program easier to work with for both the programmer and anyone using it. If not done correctly, they can have the opposite effect.

Programmers should remember that part of their job is making sure that the program is easy to use for the operator.

It can also be easy to have the wrong modal commands or offsets chosen when starting or ending a subprogram. Following a good program format that uses safety lines or blocks of code can protect from this happening.

If it is important that a mode or offset is needed in a specific section of your program, it is best to use the necessary code to make sure things are set correctly. Assuming your machine is in the correct mode already is dangerous.

Making subprograms inside your subprograms (nesting) also has the potential to cause confusion. Repeatedly switching between programs can be confusing for both programmers and operators.

For a more in-depth description of subprogram nesting, see additional info on the topic further down in this post.

Differences between subprograms and canned cycles

Subprograms are small blocks of code used to perform repeatable machining operations or functions.

Canned cycles are commands that give the machine instructions for a pattern of movements used to simplify code.

Canned cycles are used for operations that the majority of CNC users will need such as drilling or counterboring a hole. Subprograms can be made custom to the needs of the individual machine user.

In a way, canned cycles are like mini subprograms that can be used easily in your program without needing to create a separate subprogram.

There are often times where canned cycles are used together with subprograms to increase the efficiency of the program even further.

How do modal commands work in subprograms?

Modal commands work the same way as they do in the main program. This means they stay on until changed or turned off.

If a modal command is on when starting the subprogram, it will stay on while running the subprogram. The same is true when switching from the subprogram to the main program.

The safest thing to do is make sure your safety blocks cover the required codes for each section of code.

What is nesting in CNC programming?

So far we have concentrated on running a subprogram from our main program, but did you know you can also run a subprogram from within a subprogram?

This is called nesting.

Nesting can be a powerful tool but can quickly get out of control. 

Most CNC controllers will allow up to four level deep nesting.

This means calling a subprogram in a subprogram in a subprogram in a subprogram in your main program.

Confusing right? That is why in most cases it isn’t a good idea to nest that deep. For most applications, one level deep is enough.

Even two level nesting can be hard to follow. Three and four levels are definitely not advised if you are reading this post.

The bulleted list below shows how subprogram structure works.

bullet point list used to show nesting structure of CNC programs

Tips for numbering your subprograms

Create a system for numbering your programs and subprograms to avoid confusion.

Some choose to set aside blocks of numbers for each type of program. For example, O0001-O4999 for main programs and O5000-O9999 for subprograms.

Others make their subprograms closely follow their main program numbers. If the main program is O1000 then the subprograms will be O1001, O1002 and so on.

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!

G42 CNC Code Explained: An Easy Intro for Beginners [Cutter Comp Right]

What does a G42 code do?

G42 is a modal command called cutter compensation right.

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 right.

There are also codes for using no cutter compensation (G40) as well as using cutter compensation left (G41).

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!

What is cutter compensation?

illustration that shows how a CNC will act when using cutter compensation right with the G42 code

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.

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.

G41 vs G42

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

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 creates 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.

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

illustration that shows how a CNC will act when using cutter compensation left with the G41 code
illustration that shows how a CNC will act when there is no cutter compensation mode active
How the CNC will move when cutter compensation is off

Advantage of using cutter compensation

The advantage of cutter compensation is that you won’t need to rewrite your program continuously to adjust for the size of your tool.

Imagine you bought a new end mill, and it came in 0.001” smaller than the last one. This would mean that your parts would now come out larger than before. To account for this you can use cutter compensation and your D offsets to tell the machine how big the cutter is.

This allows you to continue using the same program even though your cutter has changed.

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 G42, 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 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.

How to turn off cutter compensation

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

Alternatively, G42 can be canceled by switching to cutter compensation right by using the G41 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 location.

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

G42 programming format

There are multiple ways of formatting a G42 command:

  1. G42 D1. When the G42 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. G42 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. G42 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. G42 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.

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?

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!