O CNC Code Explained: An Easy Intro for Beginners [Program Number]

Welcome to the exciting world of CNC programming!

If you’re curious about the O CNC code and want to learn how to use it, you’ve come to the right place.

In this easy-to-follow guide, we’ll teach you everything you need to know. Don’t worry if you’re new to this, because the O code is super easy to learn.

So, let’s jump in to discover the O CNC code together!

What does the O code do?

The O code lists the CNC program number. 

It is found on the first line of a CNC program.

Example program numbers

Code BlockProgram Number
O00011
O12341234
O0555555

What range of numbers can you use with the O code?

Most controllers allow the use of program numbers O0001 through O9999.

Some newer machines allow a larger range of program numbers, but they would rarely be used or needed.

O code program example

Code BlockCode Description
O0001(Program number: O0001)
G90 G80(Absolute positioning mode, cancel canned cycles)
G54 G0 X0 Y0 (Select coordinate system G54, rapid move to X0 Y0)
M3 S1000(Start spindle clockwise at 1000 RPM)
G43 H1 Z0.1(Tool length compensation active, move Z to 0.1)
G1 Z-0.5 F100(Linear move to Z-0.5 at a feed rate of 100)
X1 Y1(Linear move to X1 Y1)
X0 Y0(Linear move back to X0 Y0)
G0 Z1(Rapid move to Z1, retracting the tool)
M30(End of program and rewind)

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!

Using the O code when running subprograms with M97 and M98

Subprograms are reusable pieces of code that are often used for repetitive tasks such as drilling holes or changing a tool.

There are two codes used to call subprograms; M97 & M98.

When using M98, the P code is used to choose the subprogram to be run.

For example, M98 P5678 will tell the CNC to run subprogram O5678.

M98 Code Flow

M98 calls a separate program.

The M97 code calls a subprogram by line number in the current program.

Important: M97 and M98 call subprograms differently. M97 jumps to another line in the current program. M98 moves to a completely separate program.

An example of this is M97 P500 will tell the machine to jump to line number 500 in the current program. The N code notes the line number.

illustration that shows the flow of a cnc program when using the m97 command to call a subprogram

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!

Q CNC Code Explained: An Easy Intro for Beginners [Peck Depth]

What does the Q CNC code do?

The Q code is used to specify the depth of each peck when peck drilling with either the G73 or G83 code.

The “peck” is how much farther down the machine will drill on each pass.

When peck drilling, the machine drills down, backs up, drills further down, backs up, drills even further down and repeats until the cycle has been completed.

Difference between peck and standard drilling

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

The main difference between peck and standard drilling is that the peck drilling process removes the material in multiple steps, while standard drilling is a one-step process.

Both commands are intended to make holes, but the peck drilling cycle allows more control over how the hole is drilled.

Peck drilling is the first option for CNC programmers when making blind holes. The pecking process helps break chips as well as remove them and any other debris from the hole during the drilling process.

Trouble removing chips from the hole when drilling can cause size and/or surface finish issues.

Standard drilling is far more common when dealing with simple through (thru) holes.

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 peck drilling

There are two peck drilling cycles, G73 and G83.

They are both canned cycles with one key difference. 

Using the G83 code will retract completely out of the hole after each peck to the retract plane. 

Using the G73 code will only retract to the start of each peck.

an illustration that shows the difference between the G73 and G83 CNC codes

The G73 canned cycle is a peck drilling cycle but with a shorter retract intended for relatively shallow holes. 

Meanwhile, the G83 command is peck drilling with a full retract intended for deep holes.

Both commands are meant to help break and clear chips. 

G83 does a better job of this by fully retracting out of the hole but with the added expense of a longer cycle time.

On the other hand, G73 is designed to break up stringy chips, while G83 is intended to pull chips up and out of deep holes.

Other codes used with the Q code

The Q code is used in peck drilling canned cycles G73 and G83. 

You can also expect to find the following codes used in those canned cycles:

Format for using the Q code

The format for using a Q code is shown below:

G98 G83 R1.0 Z-5.0 Q1.0 F25.0

This example shows a peck depth (Q) of 1.0.

This means that the machine will drill the hole in 1.0 unit steps. This would be 1 inch or 1mm depending on which unit mode you currently have active.

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!

R CNC Code Explained: An Easy Intro for Beginners [Multi Use Code]

What does the R CNC code do?

There are two main functions for the R code when CNC programming, radius size and setting the retract (R) plane.

When combined with the G02 or G03 circular interpolation commands, the R code specifies the size of the radius to be machined.

When combined with canned cycles such as G73 through G89, the R code specifies the location of the R plane or clearance height to be used.

Radius size with G02 or G03

There are two types of circular movement (interpolation) that can be used when CNC machining.

They are G02 for clockwise movement and G03 for counterclockwise movement.

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

The format for using both codes is:

G02 (or G03) X10 Y15 R5 F30

The X and Y locations are the end point of the circular movement. 

The R value is the radius size of the circle and F is the feedrate.

illustration that compares a circles radius and diameter

Circular movement can also be performed using IJK codes instead of XY locations and an R value.

Both methods are common, so be on the lookout for either type.

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!

R plane with canned cycles

The R plane is a specific height that the CNC will reference when performing a canned cycle.

First it is the height that the machine will rapid travel to and begin the machining part of the canned cycle.

It is also the height that the machine will return to if the G99 [return to R plane] command is active.

If the G99 [return to initial plane] command is active then the machine will return to the start of the canned cycle instead.

visualization of how a cnc machine moves using g98 and g99 codes shows motion of travel for the machine

The G98 and G99 codes are used to switch between the two types of clearance modes available when running canned cycles.

The G98 code moves the cutter further up and away because in most instances the canned cycle is started at a higher Z height location further away from the part. This increases the time that it takes the machine to run the program.

The G99 command is used to keep the machine closer to the part being machined. It should only be used when you are sure that there are no obstacles in the way such as the part itself, clamps or fixtures.

Format for using the R code with canned cycles

The format for using canned cycles is:

G81 X0 Y0 R5 Z1 F5 G98

G81 is the canned cycle. This can be replaced with any other canned cycle as needed.

The R code sets the retract plane height. 

The X, Y and F codes are not required. 

X and Y are the location where the canned cycle will be run. F is the feedrate of the cutter.

Often, the X and Y codes will be placed on the previous line.

It is good practice to include the feedrate (F) 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!

S CNC Code Explained: An Easy Intro for Beginners [Spindle Speed]

What is the S CNC code used for?

The S code is used together with a number value to set the speed of the spindle on a CNC machine.

The number value can have up to four digits and cannot have a decimal point. 100.5 is not an acceptable value to use when setting the spindle speed. 100 or 101 would be acceptable alternatives.

The number value is in revolutions per minute (RPM).

For example, to set the machines spindle to 3000 RPM use “S3000”.

The majority of machines will allow four digits to be used to set the spindle RPM. So anything from 1 to 9,999 RPM. Some machines will allow five digits which allows them to go from 1 to 99,999 RPM

The required spindle speed will vary and can be higher or lower depending on the material of the workpiece, surface finish requirements and the limitations of the CNC machine itself.

When to use the S code?

S codes show up in CNC programs at many locations including at the beginning of the program, after setting the spindle rotation direction (clockwise/counterclockwise) and also whenever there is a change of material, surface, or tool.

Setting the spindle speed at the start of each new section of the program ensures that the spindle is running at the correct RPM if part of the program needs to be rerun for any reason.

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 spindle control

The spindle is a very important part of any CNC machine. It doesn’t matter if you are working with a mill or a lathe.

Almost everything you do with your CNC will involve the spindle in some way or another.

Below are the types of control that you have over the spindle and some of it’s related functions as well as the codes they use.

Direction of rotation – M03 & M04

Spindle direction

The direction of rotation of the spindle can be set in the CNC program by using either the M03 code (clockwise rotation) or the M04 code (counterclockwise rotation).

Using either of these codes turns the spindle on in the direction chosen.

Most machines use tooling that requires using clockwise rotation of the spindle (M03).

Spindle stop – M05

The M05 code is used to stop the spindle.

M05 is normally used when there is a tool change or at the start of a new section of the program.

The spindle will also stop after the tool goes to the home position at the end of the program when using the M30 code.

The emergency stop button can also be used to stop the spindle in the case of emergencies.

Speed

There are two types of speed control for a CNC spindle. 

CNC mills mainly work in RPMS and you usually will not need to specify this in your program.

CNC lathes on the other hand use G96 and G97 to switch between the two speed modes.

Revolutions per minute – G97

Using this spindle speed mode, the spindle will turn at a constant rate as specified by the S code.

For example if you set the speed with S5000, the machine spindle will rotate at 5,000 RPMs until it is changed with another S code or the spindle is stopped using the M05 code.

Constant surface speed – G96

The other spindle speed mode is constant surface speed using the G96 command.

This code instructs the machine to maintain a constant cutting speed at the tip of the tool.

A smaller diameter workpiece will need to spin faster to maintain the same surface speed as a larger part.

The picture below shows how if both parts make one revolution, then the larger part will have traveled faster because it needs to cover a larger distance in the same amount of time.

illustration that shows the difference between the cutting speed of a smaller and larger diameter for cutting speed

Using the constant surface speed mode will cause the machine to change the RPMs of the spindle as the size of the part changes so that the cutting speed is constant.

This way of programming can provide a better surface finish and extend tool life.

Spindle orientation – M19

The M19 command is used to precisely load a tool into the spindle. 

This is more critical with certain canned cycles such as boring.

Tool change – M06

Most machining centers allow the swapping of tools in and out of an automatic tool changer.

Automatic tool changers increase the productivity of the machine by decreasing the amount of time needed to swap cutting tools.

Common codes used with the S command

Spindle speed vs cutting speed

Both spindle speed and cutting speed are commonly used together, but they mean different things.

The cutting speed given by the F code controls how fast the tool advances in a given machining process. The cutting speed controls the forward movement at which the tool will remove material while cutting.

Meanwhile, spindle speed (S code) is the number of turns the spindle can do in one minute (revolutions per minute). Both are really important factors to be aware of when you are programming.

Speeds and feeds. Take note because this will be referred to often.

Proper speeds and feeds prevent tool breakage and increase tool life while also allowing for a higher quality surface finish.  

How should you change your spindle speed based on the workpiece?

Small pieces usually require less speed than workpieces of big diameters.

However, it also depends on the process and the material you are machining.

If the material is very rigid, it is recommended to use a low spindle speed at first and low feed rates, later you use a higher spindle speed for an optimal end finish of the workpiece and higher feedrate.

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!

T CNC Code Explained: An Easy Intro for Beginners [Tool Selection]

What does the T CNC code do?

On most CNC machines, the T code tells the machine the tool to place in the tool changer to prepare it for a tool change.

The M06 command will then perform the tool change.

On some CNC machines, the T code will actually switch to the tool called out.

The T command is a very important CNC code because most programs will use multiple tools during the execution of a program.

It is not uncommon for dozens of tool changes to be performed in the process of running a more complex program.

When does the T code get used?

The T code is used at the start of a program to make sure the correct tool is loaded before any machining is performed.

After this initial setup, the T code is used every time the machine switches to a new tool.

If tool #1 is currently in the CNC spindle, calling tool #2 with the T02 command will ready it in the tool changer. Using the M06 command will swap tools.

Readying the tool before the switch saves precious machining time, something that is more important for high volume production machining.

Even though the tool is already loaded in the tool changer, it is advised to still call the T02 command in this instance to make sure that the correct tool is loaded.

The code would look like this:

T02

<machining code here>

T02 M06

Again, this format is used to ensure that the correct tool is placed in the CNC spindle during the tool change.

Without using the T02 command right before the M06 tool change command, it is possible that another is loaded in the tool change position and will be swapped in.

Imagine if you needed to re-run a portion of the code and started your program after the initial T02 code. If you didn’t repeat the T02 code right before the tool change then the machine would use the last tool number from its memory.

There is a good chance that it isn’t swapping the correct tool which can mean a machine crash.

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 change tools

CNC cutting tools are changed using the M06 command. On some machines (usually older CNCs), the T code will cause the machine to perform a tool change.

Check your machine manual to know how your machine will react.

If your machine is equipped with an automatic tool changer, then it is likely that you will be using the M06 command to change tools.

an automatic tool changer on a dmg mori cnc machine
Automatic tool changer carousel

Where should you document your tools?

Information about your tools should be stored in two locations, on your machine setup sheet and in your tool offset library.

The setup sheet is used to communicate to the machine operator what tools are expected to be loaded in the machine while running the program.

The tool offset library, sometimes called the tool offset table stores information related to the size of your cutting tools. This includes both the diameter (D offset) and tool length or height (H offset).

Offset Library
Offset library with H offsets on the left and D offsets on the right

The D offset and H offset values allow the machine to compensate for the size of the cutting tool and accurately machine the part.

Offsets and your cutting tools

Two of the most important characteristics of your cutting tools are their length and diameter. 

These two characteristics are stored as H (height) and D (diameter) offsets.

Knowing these two values and storing them in your offset library allows the machine to adjust for the size of the cutter when running the program. 

Without these adjustments using height (H) and diameter (D) offsets, the program would need to be rewritten for each new tool. Not the most efficient way to machine parts.

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

The value of the H offset is the distance between the end of the spindle and the end of the cutting tool.

The H code is used to select the H offset stored in the offset library when tool length compensation is turned on with the G43 code.

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

The D code is used to choose the D offset to be used when cutter compensation is turned on with either the G41 – Cutter compensation left or G42 – Cutter compensation right codes are used.

The D offset value is a number stored in the offset library that tells the CNC the size (diameter) of the cutting tool. 

Once the machine knows the size of the cutter it can adjust how it runs the program based on that size.

Frequently asked questions about the T code

How is the T code used differently on mills vs lathes

As stated above, most CNC milling programs will use more than one tool to complete the machining of a workpiece.

Therefore, using the T code for tool changes is necessary.

On lathes, the T change is used less often because the same cutter can perform many turning operations.

However, operations such as parting-off, threading, and drilling require specific tools. The number of tools allowed on a CNC lathe depends on the number of cutters that fit in the machine’s turret.

What does T0X.0X mean?

You may see some codes that have two numbers separated by a dot along the T code (e.g. T01.01).

This formatting exists because some controllers such as Fanuc allow different offsets to be assigned to the same tool.

Depending on the type of operation performed by the tool, you may need to change its offset values. T01.01 is tool #1, offset 1. T01.02 would be tool #1, offset 2.

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!

X, Y, & Z CNC Codes Explained: An Easy Intro for Beginners [Coordinates]

What kind of coordinate system is used in CNC machining?

Almost every CNC machine uses a Cartesian coordinate system based on an X, Y, and Z-axis.

The coordinate system allows the machine to identify locations, move in specific directions and establish positions in a three-dimensional space.  

Coordinate systems are formed by the axes (X, Y & Z), planes, and an origin where the three axes meet. 

Using an X, Y or Z code in a CNC program tells the machine to go to a specific location along those axes. Location changes can be in one or more axes. 

If only a Z axis coordinate is given then the machine will only move in the Z axis. This is the same for the other axes as well.

XY Plane
The grid in the picture shows the XY plane. The XZ and YZ axes combine to make planes as well.

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!

Terms to know

To understand the coordinate system used by CNC machines, you need to first understand a few terms and concepts.

Coordinates

a number line that shows positive and negative numbers as well as the origin location

A coordinate is a location given in one or more axes.

Axis or plural axes

An axis is a straight line.

Along this straight line, each axis has a positive and a negative side.

The negative side continues on forever with larger and larger negative numbers. -1, -10, -99, -20,346 on til negative infinity.

On the other end of the axis are larger and larger positive numbers. 1, 5, 24, 578, 356,728 and on til positive infinity.

The two sides of the axis are separated by a center point.

At the center point the value of the axis is 0. This is called the origin.

Where the X and Y axes cross is the XY origin

Origin

The origin is the zero location of one or more axes. 

Typically, when talking about origins we are referring to the zero location of multiple axes.

CNC mills are usually 3 axis machines and lathes are 2 axis. Both types of machines can have more axes but let’s keep things simple.

the X and Y axes shown on graph paper with the origin identified.

Less axes are usually easier to understand so let’s start with 2 axis coordinates.

With two axes, the origin would be the (0,0) location.

The is the location where the two straight line axes cross. This could be any two axes (XY, YZ, XZ) but generally we are referring to the X and Y axes. (0,0) is (X=0, Y=0).

Note that the two axes are perpendicular, or at 90 degrees to each other.

When talking about three axes, we are referring to the X, Y and Z axes.

When working with three dimensional coordinates, the origin is the spot where all three axes meet.

This is the (0,0,0) location.

Each of the axes are still perpendicular to each other. The order of axes is the same as before with the Z axis added on so (0,0,0) is (X=0, Y=0, Z=0).

a lathe with the X and Z axis shown and the spindle identified
A 2 axis lathe
an illustration that shows the X, Y and Z axes on a CNC machine
A 3 axis mill

Plane

XY Plane

A plane is a two-dimensional flat surface. 

The most common one when talking about CNC machines is the XY plane. The XY plane is shown as the grid in the picture above.

The plane consists of all the possible coordinate location combinations possible in the X and Y axes.

There are three different types of plane combinations: XY, YZ, and XZ, and each plane has four quadrants with corresponding negative and positive values, two axes and an origin.

Quadrant

coordinates on a graph paper background that shows the different X and Y quadrants

A quadrant is an area of the coordinate system plane. The four quadrants are shown below.

Quadrant 1 has positive X and positive Y values.

Quadrant 2 has negative X and positive Y values.

Quadrant 3 has negative X and negative Y values.

Quadrant 4 has positive X and negative Y values.

CNC machinists will want to pay attention to what happens when their machines switch quadrants. 

Often changing the direction of travel from one direction to another will result in small defects or unintended features on the workpiece depending on the quality of the CNC machine.

Understanding Cartesian coordinates on a CNC machine

Usually, an easy way to understand the coordinate system for your CNC machine is to follow the Right-Hand Rule.

Hold your hand out palm up with your thumb and index finger pointed outwards, and your middle finger pointed upwards. 

Place your hand in front of your CNC machine, aligned with the machine’s spindle, and you’ll see the axes line up perfectly.

  • The thumb is the X-axis.
  • The index finger is the Y-axis.
  • The middle finger is the Z-axis.

The three fingers point to the positive side of each axis. The negative side is in the opposite direction.

Right Hand Rule
The thumb and index finger make an L shape and the middle finger is pointed straight up

Let’s compare that to our 3 axis mill to see how they line up.

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

How are coordinates used in CNC machining?

Most CNC machines use a conventional cartesian coordinate system and assign the order of axes movement as follows:

  • X-axis allows movement “left” and “right”
  • Y-axis allows movement “forward” and “backward”
  • Z-axis allows movement “up” and “down”

However, there are a few exceptions to this rule, that will depend on the machine model or manufacturing company.

Some machines can switch the Z and Y axis, which can lead to confusion. Be sure to check all these details in your machine’s manual.

Movement in the coordinate system is related to the movement of your cutting tool. Many times, the cutting tool may not move in one or more axes but instead the control will move the table to act as if the tool moved.

Machine reference point

Every CNC machine has its own origin point or Home location that will serve as the machine’s coordinate system’s origin.

The machine reference point is a known point for the CNC machine.

You might move the zero location using a work offset such as G54, but the machine is calculating everything based off the reference point.

The CNC control allows you to do this to make the program easier to create and understand.

Work coordinate system

A work coordinate system sets a new origin location for the machine to use when running the CNC program.

You wouldn’t want to program to random coordinate locations in your machine. You also wouldn’t want to make a new program every time you wanted to make the same part on a different CNC machine.

The solution is a work coordinate system.

We touched on it earlier but using a work offset such as G54, G55 or one of the others commonly available on CNC controllers allows you to set your part or a fixture as the origin location.

Once the part or fixture is set as the X, Y and Z zero location, the program can be run.

Using a work coordinate system or work offset allows the CNC programmer and operator more flexibility in their programs and setup.

Often the work offset origin location will be either be where a corner of the part or the center of the part intersects the top surface.

Absolute vs incremental coordinates

Everything we have talked about so far has been discussing absolute coordinates.

Absolute coordinates are a type of coordinates that are based on a fixed origin (zero) location.

In CNC machines, absolute coordinates are set using the G90 code.

There are exceptions but most CNC programs are mainly written using absolute coordinates.

The other type of coordinates that can be used are incremental coordinates.

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

Incremental coordinates have a constantly changing origin location. Each time the CNC machine moves to a new location, that location becomes the origin. 

In other words, each new move is relative to the machine’s current location.

Incremental coordinates are set using the G91 code in a CNC program. They are usually reserved for specific, repetitive features such as a series of holes that need to be drilled or something similar.

The pictures above show the same machine movement in the two different positioning modes. The locations given to the machine are given in parentheses ( ).

Polar coordinates

Credit “ToolNotes.com © 2021, used by permission”

Most beginners don’t need to be too concerned with polar coordinates, but it is still helpful to be aware that they exist.

Polar coordinates are another way of specifying machine locations, like Cartesian coordinates.

Instead of X, Y and Z locations, polar coordinates use a radius, an angle, and a Z location.

Polar coordinates vs cartesian coordinates

Polar coordinates make calculations easier with circular motion, arcs, and circular paths.

On the other hand, Cartesian coordinates make linear movement easier to comprehend, and it is far more commonly used.

CNC machines are set to operate with a cartesian system by default. However, most CNC machines and controls include the option to use polar coordinates if needed.

CNC machines with multiple axes

Hobbyist CNC machines usually work with three axes (X, Y, & Z) as explained above.

Industrial grade machines can often be found with one or more additional axes. The most common is the addition of a rotary 4th axis.

4th, 5th and 6th axis machines are not uncommon.  

Each of these axes rotates around one of the first 3 axes. The 4th axis rotates around X. The 5th around Y. The 6th around Z.

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 Coolant Codes [M07, M08 & M09]

Which codes control coolant use on a CNC machine?

There are three main CNC M codes which control coolant use:

M07, M08 and M09.

M08 and M09 are the most common codes used. 

In addition, many machines have special coolant functions available such as through spindle coolant.

Special coolant codes tend to vary from machine to machine so make sure to check your individual machine for specialty coolant function.

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!

M07 [mist coolant]

The M07 code is a modal command which turns on mist coolant.

Mist coolant is compressed air and coolant (usually oil). 

It can be more efficient than flood coolant and in some situations be better at clearing chips than flood coolant, but it is used far less often than flood coolant with the M08 command.

M08 [flood coolant]

cnc machine table with coolant lines and spindle shown
Flood coolant on a workpiece

M08 turns on the coolant for the main spindle.

In general, you will find this coolant aimed directly at the cutting edge of the tool.

Flooding the area with coolant has multiple benefits. The coolant reduces the heat build up from the cutting action, lubricates the cutter and helps to clear chips from the cutting area.

These three benefits of using flood coolant all work to reduce any heat that is caused by the cutting action which helps extend the life of your cutting tool.

M09 [coolant off]

The M09 code is used to turn off both types of coolant flow.

You never want to turn off coolant while the cutter is still cutting. On the opposite end of things, you should never turn coolant on if the cutter is already cutting.

Always start and stop coolant flow when the cutter is not actively engaged with the part.

What is coolant used for in CNC machining?

Coolant for CNC machines is used to keep the workpiece and cutting tool at a lower temperature during the cutting process.

Both the cutter and the part tend to get hotter because of the friction created cutting.

Coolant is also used to clear chips from the cutting area. If chips are not cleared from the cutting area then you can end up recutting chips. Built up chips can also lead to built up heat which can damage your cutter or part.

Recutting chips also has a tendency to create poor surface finishes.

Types of coolant that can be used

The main types of coolant used on CNC machines are:

  • Air: This type of coolant reduces heat and clears the chips, but it does not lubricate the workpiece. This type of coolant is used more often with sensitive materials.
  • Mist: With mist coolant, the pressure of the coolant is kept low and less coolant is used. This can be beneficial if your CNC doesn’t have a coolant capture system. Mist coolant lubricates the cutter and clears chips.
  • Flood: This is also a low-pressure form of coolant. Flood coolant lubricates, removes chips and reduces heat buildup.
  • High pressure: High pressure coolant is similar to flood coolant. The only difference is that it hits the workpiece at greater than 1000psi. The higher pressure and higher quantity of coolant helps cool the cutter better and remove more chips.
  • Through spindle: Through spindle coolant delivers the coolant directly where it is needed. It is better at clearing chips in many cases because the coolant from the spindle pushes the chips out of a hole or pocket.

What is CNC coolant made of?

Coolants are categorized into four groups depending on the material that they are made of:

  • Synthetic fluids: They are made of lubricants and rust inhibitors usually dissolved in water. It is basically soluble oil mixed with water to create coolant.
  • Semi-synthetic fluids: These coolants are a mix between synthetic polymer and oil.
  • Soluble oils: They contain a mix of 40 percent or more of oil and the rest is water.
  • Straight oils: These ones are derived from petroleum, they are not diluted with water.

List of common CNC coolant brands

There are many different brands of CNC coolant available. Some of the most commonly used ones are:

  • Castrol
  • Chem Arrow
  • ChemTool
  • Fuchs
  • Hangsterfers
  • Master Fluid Solutions
  • Quaker Houghton
  • Qualichem
  • Tower Coolant
  • Yushiro

Frequently asked questions

Does every CNC machine have coolant capabilities?

Yes and no.

You can expect that industrial level CNC machines will have coolant capabilities.

Home or hobbyist level machines such as CNC routers often do not have coolant capabilities, but they can usually be added on if needed.

cnc wood router
CNC router without coolant capability

Which code turns CNC coolant off?

The M-code to turn coolant off is M09.

However, there are other stopping commands that also turn off coolant such as:

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 Compensation Modes [Cutter Comp, Tool Length Comp and Offsets]

Types of compensation


CNC machines have three main types of compensation:

  • Cutter compensation/tool diameter compensation
  • Tool length compensation
  • Work/fixture offsets

These compensation modes allow the machine to accommodate for things such as the location of a part in the machine or the size of a cutting tool.

Compensation allows the machine to adjust how it reads the CNC G code so that the same program can be used in multiple ways.

Using compensation modes allows the CNC to run the same program and get the same results even if the factors we mentioned above (cutting tool, workpiece location) are changed between runs.

The machine will have no problem adjusting for a new cutter as long as we tell the machine the diameter and length of the new cutting tool.

The values that tell the machine how long the tool is or what its diameter is are called offsets.

There are multiple compensation codes and offset codes.

Luckily, the list isn’t long. Let’s go through them one by one.

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!

Cutter compensation/tool diameter compensation


The first type of compensation is compensation that accounts for the size or diameter of the cutting tool. This is often referred to as simply cutter compensation.

There are two types of cutter compensation.

Before we talk about what cutter compensation does when it is on, let’s talk about how to turn it off.

G40 – Cutter compensation cancel


The two cutter compensation modes are both modal commands

This means that they stay on and in effect until they are changed or cancelled.

Selecting G41 or G42 switches between the two modes. If you want to turn off cutter compensation you will need to use the cancel command.

G40 is the off button for cutter compensation

Calling it in your program will cancel any active cutter compensation.  

Because modal commands stay on until changed or turned off, you often see cancel commands used in safety blocks of code found at the beginning of the program or a new section of the code such as when changing tools.

The illustration below shows how the CNC will move when cutter compensation is off.

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

G41 – Cutter compensation left


G41 is the most common cutter compensation. It is used when climb milling.

The G41 code tells the CNC to shift the cutter to the left of the cutting path to account for the size of the cutter.

See the pic below for help understanding what that means in practice.

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

G42 – Cutter compensation right


G42 is used when conventional milling.

The G42 code tells the CNC to shift the cutter to the right of the cutting path to account for the size of the cutter.

G42 is not used nearly as often as the G41 code. 

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

D offsets


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

Diameter (D) offsets are the location where the size (diameter) of the tool is stored in the CNC control.

D01 will be the offset where the size information is stored for tool #01. D02 will be for tool #02 and so on.

D offsets are set with the D code.

Tool length compensation


G43 – Tool length compensation +


G43 is the command to turn on tool length compensation. 

Just like G40-G42, G43 is modal which means it will stay on until changed or canceled.

G43 is for positive tool length compensation. You should be aware there is also a negative tool length compensation mode (G44) but it is rarely used and not something that beginners should be worried about.

G43 is used frequently and you can expect to see it used in 99.9% of the CNC programs you will come across.

G49 – Tool length compensation cancel


Just like G40 cancels cutter compensation based on the diameter of the tool, G49 does the same for tool length compensation.

Like many other cancel commands, G49 can be found at the beginning or ending of different sections of code to ensure the machine is in the correct mode as tools are changed and different operations are performed.

H offsets


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

Height (H) offsets are the location where the length of the tool is stored in the CNC control.

This value is the difference in location between the end of the spindle and the end of the cutting tool.

H01 will be the offset where the length of tool #01 is stored. H05 will be for tool #05 and so on.

Height offsets are set with the H code.

Fixture/work offsets


Work offsets are used to tell the machine where it should reference all program values from.

For example, imagine if you wanted to machine four separate parts to be all the same. You could load all four parts into your CNC machine and set a work offset location for each separate part.

Once the work offsets are stored, you could call out the first work offset and then run your program.

Next you could call out the next work offset and run the same program again. This would run the same program in a new location resulting in two of the same part. And rinse and repeat as much as needed.

visual to show cnc work offsets G54-G59 with the zero locations shown
Example of a CNC machine set with 4 work offsets

G54-G59 – Work offsets


G54 through G59 are the standard work offsets that you can expect to find on just about any CNC machine.

Work offsets identify an X, Y & Z coordinate zero location. Work offsets go by many other names such as program zero, part zero, zero location, etc.

Some machines may be capable of storing many more work offset locations, but it is best to concentrate on the most common codes first. Check your individual machine documentation to learn how to program with more work offsets.

If you are very new to CNC programming with G code then be on the lookout for a G54 code. 

This is the first work offset and as a result is the most common one used. Often shops will only have a need for this single work offset. As shops and machine become more advanced you can expect to see more usage of additional work offsets.

Just like the other offset modes we have talked about; work offsets are also modal commands.

Expect to find them in the safety blocks of code and because they are important enough to be included in the safety block section, you should be very careful about making sure you have identified the correct work offset at all times in the 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!

Beginner’s Guide to Micrometers – Get Started

A standard outside measuring micrometer

What is a micrometer?

A micrometer is a precision measuring tool. 

They are used in manufacturing, machine shops, automotive work and the construction industry. 

“Mic” is shorthand for micrometer.

Mics are very accurate measuring devices. 

Micrometers are used to take measurements with an accuracy of ~.0001″ or better in inches. 

Measurements in millimeters can be made down to .01mm or .001mm.

How accurate are micrometers?

Most micrometers have an accuracy of +/- 0.0001″, commonly referred to as a tenth of an inch in machining.

The standard metric versions would come as +/- 0.001mm or +/- 0.002mm.

They can be found with worse or better accuracy but what is usually seen .

When to use a micrometer

Three of the most common precision measuring devices used by a hobbyist or a machine shop are calipers, micrometers and dial test indicators. 

Calipers have the least accuracy of the three and the largest measuring range.

Mitutoyo digital caliper

The dial test indicator has the most accuracy and least measuring range. 

Micrometers are in the middle for both accuracy and measuring range. 

While still very accurate, one downfall of the micrometer is that they usually come with a 1″ measuring range (3-4″, 4-5″, etc.).

Because of this they are often sold in sets to cover a larger measuring range. 

A 0-6″ micrometer set will cover the needs of most applications while a 0-12″ set is more than most people, especially hobbyists will need. 0-3″ sets are also common.

Parts of a micrometer

How to use a micrometer

Before using your micrometer, ensure that the measuring tool and surface to be measured are free of dirt, debris, chips, etc.

Everything should be clean.

The micrometer thimble should spin freely. No hangs up or anything similar.

Open the thimble to place the part you want to measure between the anvil and spindle.

Spin the thimble until it closes on the part. 

You aren’t trying to clamp down on the part. 

Use a gentle, consistent amount of force when spinning the thimble. Using the ratchet on your micrometer can make this easier. Try spinning the thimble until you get three clicks on your ratchet.

This will help you get repeatable measurements. You want to be consistent in your measuring so you know your readings are good.

This is why taking multiple measurements is so important.

When possible, measure the part multiple times to be confident your readings are accurate.

A little practice on a cheap gauge block can help here. Measure that same gauge block a bunch of times and you will become more repeatable in your measurements. You’ll also see how easy it is to change your reading.

As the spindle closes on the part being measured, it can be beneficial to slightly rock the micrometer in an effort to seat the micrometer on the part.

Be careful: this technique isn’t right for surfaces that could be scratched or damaged easily.

Once you have closed the part in the micrometer, it is time to take your measurement reading.

How to read a micrometer

The most common variety of micrometers measures to one ten-thousandth of an inch (.0001″).

Measurements are taken by identifying where the lines on the micrometer line up.

You will need to take 4 readings and add them together to get your measurement.

These readings are the 0.1000″, 0.0250″, 0.0010″ and 0.0001″ readings.

Machinists refer to these as the hundred thousandths, 25 thousandths, 1 thousandths and lastly the tenths readings.

Let’s get started.

Along the sleeve of the micrometer will be graduations similar to a ruler. The graduations at every fourth interval are most often numbered 0, 1, 2 and so on. 

These numbers represent .100″ or one hundred thousandths of an inch. 

Whichever hundred thousandths reading you are past is your reading. In the pic above, the hundred thousandths reading would be 3 which equals 0.3000″.

Once you have taken your hundred thousandths reading then you will need to take the 25 thousandths reading.

Each mark along the sleeve is 0.025″ or 25 thousandths.

Next is the reading from the thimble. This is the 0.0010″ reading or one thousandth of an inch reading. 

In the pic above two lines are shown past the three so the 0.0250″ graduation value would be 0.0500″.

In the end we are going to add all of our individual measurements up for our final reading.

Note the 0.0010″ reading on the thimble and lastly take the tenths reading from the spindle.

Here we have 15 thousandths.

This makes our measurement so far 0.300″ + 0.0500″ + 0.015″ = 0.3650″.

The last reading to take is the tenths reading. If the lines matched up at the 6 tenths mark, then we would have a reading of 0.0006″ which we need to add to our previous readings.

0.3650″ + 0.0006″ = 0.3656″ or three hundred and sixty five thousandths of an inch and six tenths.

Frequently asked questions about micrometers

What kinds of micrometers are available?

There are a ton of different micrometer types available

Often specific industries have their own special type micrometers such as the auto related micrometers on our list of the most common micrometers below:

  • Outside micrometers – measures various lengths, widths, thicknesses and diameters
  • Inside micrometers – measures hole diameters, slot widths
  • Depth micrometer – measures depth of holes, step locations
  • Thread micrometers – measures various thread characteristics
  • Crankshaft micrometer – specific measuring range for measuring crankshafts
  • Disc brake micrometer – measures thickness of brake rotors
  • Blade micrometer – measures slots, keyways and grooves

Are cheaper micrometers as good as expensive ones?

The cheaper off-brand micrometers have gotten much better in recent year, but they haven’t quite caught up to the best manufacturers yet. 

Starrett and Mitutoyo still reign supreme in terms of quality and accuracy.

You can always look for used options on Craigslist or Facebook marketplace to save a buck.

What makes a good micrometer?

A good micrometer needs two things: precision and accuracy. 

Some adjustments can be made with most micrometers to account for small errors in accuracy but nothing can be done to fix a tool that isn’t precise. 

Quality micrometers will turn smoothly without any drag. This is the telltale sign of a good tool. If your micrometer ever feels like it is rubbing internally, we recommend disassembling the micrometer and cleaning per the manufacturers instructions to eliminate any possible contamination that may be causing the issue

How to adjust a micrometer

If your micrometer is in need of adjustment, most micrometers can be adjusted by using the wrench that came with your tool to spin the sleeve of the micrometer. This is usually done in the zero position. This can be especially useful for adjusting for the touch or feel of a mic when it does not include a ratchet or friction stop. 

If you no longer have a wrench or spanner for adjustment, replacement wrenches can be purchased from most manufacturers or on Amazon.

How often should my micrometer be calibrated?

How often you need to calibrate your micrometer will vary depending on a few factors such as what you are measuring with it, how often you are using it, and what type of environment it is in.

Check out our guide to micrometer calibration to get a better understanding of the how, where, when and why of calibrating your mics.

Related articles

For more information check out these related articles:

How to Read a Micrometer – Beginner’s Guide

Are you new to using a micrometer and not sure where to start? 

Don’t worry, you’re in the right place! This article will give you a step-by-step guide on how to use a micrometer correctly and with confidence. 

You’ll learn about the different parts of the micrometer, how to read the measurements, and even some tips and tricks to help you out. 

Check out the secrets to mastering micrometer measurement.

Parts of a micrometer

Before we talk about taking measurements with our micrometer, let’s have a quick refresher on the various parts of the micrometer. 

Taking a measurement with your micrometer

Alright, let’s get down to business. 

I’m assuming you’re ready to take your measurement now. 

If you need tips for getting ready to take your measurement then skip to the bottom where we have some advice laid out.

For everyone else, grab your micrometer and your part to measure.

To take the measurement we are going to take four separate readings from the micrometer and add them up for our final reading.

Put your part between the anvil and spindle

Put the part in between the anvil and spindle of the micrometer.

This might require you to spin the thimble to open the micrometer enough to get the part in there.

Close the micrometer on the part

Now spin the thimble until it closes on the part. 

Remember you aren’t trying to clamp down on the part. 

Use a gentle, consistent amount of force when spinning the thimble. Using the ratchet on your micrometer can make this easier. Try spinning the thimble until you get three clicks on your ratchet.

We’ve done that now and we have the reading below on our micrometer.

So let’s break down the four parts of this reading.

The 0.100″ reading

The first part of the reading is the 0.1000″ reading. This is our hundred thousandths or “hundred thou” reading.

In the example above we can see that the larger lines on the sleeve of the micrometer are numbered. 

Each of these larger lines equals another 0.1000″.

We are taking our readings at the intersection of the lines on the thimble and the sleeve. Because the 3 is the last hundred thousandths graduation shown, the first part of our reading is 0.3000″.

The 0.025″ reading

Next is the 0.0250″ or 25 thousandths reading. 

This reading is also taken from the sleeve of the micrometer. 

Each of the lines on the sleeve equals another 0.0250″. In our example, we can see two lines after the 3 which equals 2x 0.0250″ = 0.0500″.

This means so far our reading is 0.3000″ + 0.0500″ = 0.3500″.

The 0.001″ reading

There are 25 lines around the thimble of an inch micrometer. 

Each of these lines equals 0.0010″ or 1 thousandth.

In our example we can see that we are on the 15 so our reading is 0.0150″.

Let’s check in on our measurement so far. 

We have 0.3000″ + 0.0500″ + 0.0150″ = 0.3650″.

The 0.0001″ reading

The last part of our reading is the tenths (0.0001″) reading.

Note: some micrometer don’t have a 0.0001″ reading. This is more common on older or very cheap micrometers.

To take the tenths measurement we look at the numbers that go around the sleeve of the micrometer.

We take the reading where the number on the sleeve lines up best with a line on the thimble. 

In the pic above you can see that it looks like the 6 on the sleeve lines up best with a number on the thimble. This would make the final part of our reading 0.0006″.

We now have all four parts of our reading. The 1, 25 and 100 thousandths readings as well as the tenths reading.

If we add them all up we get 0.3000″ + 0.0500″ + 0.0150″ + 0.0006″ = 0.3656″

Note: our measurement was taken using a 0-1″ micrometer. If we used a 1-2″ micrometer then we would add 1″ to our measurement. If we used a 4-5″ micrometer then we would add 4″ and so on.

Taking multiple measurements

One last thing to keep in mind when taking micrometer measurements is that you should take multiple readings.

These are very accurate measurements and it is easy for something to go wrong

Clamping too hard, being a little off angle or a piece of dust or lint can really throw off your measurement.

Taking multiple measurements helps build confidence that your measurements are correct.

Micrometer reading examples

To give you a little more practice let’s look at a few more readings.

All of these examples assume you are using a 0-1″ micrometer.

Example #1

a micrometer closeup with a reading of 0.1370"

Here we have 0.1000″ + 0.0250″ + 0.0120″ = 0.1370″.

The tenths reading lines up with the zero so we don’t add any tenths.

Example #2

a micrometer closeup with a reading of 0.5500"

Here we have 0.5000″ + 0.0500″ = 0.5500″.

The 1 thousandths (0.0010″) and tenths (0.0001″) readings lines up with the zeroes so we don’t add them to our measurement.

Example #3

Here we have 0.7000″ + 0.0140″ + 0.0001″ = 0.7141″.

The 25 thousandths (0.0250″) reading doesn’t have any lines shown beyond the 0.1000″ reading so we don’t add anything to our measurement for the .

If our tenths reading lined up at the 9 as shown below. Our reading would instead be 0.7000″ + 0.0140″ + 0.0009″ = 0.7149″.

Tips for preparing to take your measurement

Reading your measurement correctly is important but so isn’t preparing to take your reading.

Pay attention to these factors before taking your measurement to help make sure your readings are accurate.

Make sure everything is clean

Dust and lint might seem small but they can make a huge difference in your measurement.

A human hair measures about 0.003″. Micrometers take measurements to an accuracy of 0.0001″ which is 30 times smaller. This is why everything has to be extremely clean.

Make sure the micrometer spins freely

You want to make sure your micrometer is in good working order. 

Get a feel for it, literally!

If it feels like your micrometer is dragging or rubbing at any point when spinning the thimble, there is a good chance it could affect your measurement.

Pay attention to the angles

You want to take your measurements perpendicular (90 degrees) to the surface you are measuring. 

Measuring at an off angle will skew your measurements and tend to give you a larger reading than the actual size.

a micrometer measuring a part at 90 degrees

Verify your micrometer – checking the zero

Your micrometer should be calibrated but it also a good idea to check it right before using it.

The simplest way is to check the zero. Close the micrometer and check the reading to make sure it isn’t a tenth or two off.

If you have a larger micrometer then use a gauge block to check your zero.

Frequently asked questions about taking readings with micrometers

How to take readings with different types of micrometers

Our examples are shown using a typical outside micrometer. However, there are many different types of micrometers available.

They all get read the same way. 

Depth micrometers are probably the second most common type of micrometer. For most depth micrometer you will find that they don’t have a tenths (0.0001″) reading. Follow all of the same steps to read them but skip adding any tenths to your measurement.

What’s the difference between a micrometer and a caliper?

Generally, calipers are less accurate and more versatile. Check out the comparison below to see how they match up.

Micrometers

Calipers

Accuracy

0.0001"

0.001"

Measuring Range

1" increments

0-6"

Types of Measurements

Outside Measurements

Inside, Outside & Depth Measurements