Quick Guide to the G40 CNC Code [Cutter Comp Cancel]

a graphic of a cnc machine with text that says learn g code today G40 cutter compensation cancel

What does a G40 code do?

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

Cutter compensation is turned on with either the G41, for cutter compensation left or G42, for cutter compensation right.

Want to learn more about CNC G Code?

What is cutter compensation?

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

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.

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 using cutter compensation right with the G42 code

Where does G40 show up in a program?

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

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

G40 is one of the off commands.

Safety lines are also used at the start of a new section of code. For example, you 

Things to know when using the G40 code

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

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

Canceling cutter compensation when off the part enough keeps the machine from running back into the part. A good practice is to move the machine in the Z axis so that it is away from the part before canceling cutter compensation.

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

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

Other cancel commands

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

Code

Description

G40

Cancel cutter compensation

G49

Cancel tool length compensation

G50

Cancel scaling

G67

Cancel custom macro call

G69

Cancel rotation

G80

Cancel canned cycles

Want to learn more about CNC G Code?

Quick Guide to the G41 CNC Code [Cutter Comp]

a graphic of a cnc machine with text that says learn g code today G41 cutter compensation left

What does a G41 code do?

G41 is a modal command called cutter compensation left. This code adjusts the path of the cutting tool based on the diameter of the cutter.

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

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

Want to learn more about CNC G Code?

What is cutter compensation

illustration that shows how a CNC will act when using cutter compensation left with the G41 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.

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 there is no cutter compensation mode active
illustration that shows how a CNC will act when using cutter compensation right with the G42 code

When to use a G41 code

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

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

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

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

Cutter sizes and D offsets

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

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

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

Because we are talking about cutter compensation with G41, we are going to focus on D offsets. D offsets are stored in your machine’s controller, and they store the diameter of your cutting tool.

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

Telling the machine the size of the cutters with your D offsets allows it to account for them and run the same program with different tools and get the same size part. If you didn’t have cutter compensation, then you would need to create a new version of the program every time you wanted to use a new tool.

Using the tool offset table for cutter compensation

mach 3 tool offset table

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

Tool offset tables vary and some machines will only store one type of offset. This means you may need to store both your diameter and tool length offsets in a D offset.

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

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

G41 programming format

There are multiple ways of formatting a G41 command:

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

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

G41 vs G42

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

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

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

G41 is used when climb milling, which is the most common type of milling used. G42 is used when conventional milling. Conventional milling sounds like it would be the standard but in reality, it is rarely used.

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

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

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

Which code cancels cutter compensation?

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

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

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

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

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

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

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

Other types of compensation

The other main form of compensation is tool length compensation.

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

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

Tool length compensation is canceled with the G49 code.

Want to learn more about CNC G Code?

Quick Guide to the X, Y, & Z CNC Codes [Coordinates]

a graphic of a cnc machine with text that says learn g code today XYZ coordinate locations

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. 

Want to learn more about CNC G Code?

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. On the other end of the axis are larger and larger positive numbers.

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.

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
Axes on a lathe
an illustration that shows the X, Y and Z axes on a CNC machine

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.

How to establish Cartesian coordinates in CNC machines

Usually, an easy way to establish 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.

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.

How are coordinates used in CNC machining?

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

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.

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.

Want to learn more about CNC G Code?

Quick Guide to the S CNC Code [Spindle Speed]

a graphic of a cnc machine with text that says learn g code today S spindle speed

What is the S CNC code used for?

The S code is a command used to set the speed of the spindle on a CNC machine.

A number value is used together with the S code to set the required spindle speed. 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.

Want to learn more about CNC G Code?

When to use the S code?

S codes show up at many spots in a CNC program.

At the beginning of the program, after setting spindle 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.

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

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

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

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 stop - M05

The code M05 is used to stop the spindle speed. It is normally used when there is a tool change or at 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.

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

  • S – spindle speed
  • F – cutting feedrate
  • G96 (lathe) – constant surface speed
  • G97 (lathe) – constant RPM
  • M03 – spindle on, clockwise
  • M04 – spindle on, counterclockwise
  • M05 – spindle stop
  • M06 – tool change
  • M19 – spindle orient

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.

Want to learn more about CNC G Code?

Ultimate Guide to CNC Codes

Here is our Ultimate Guide to CNC Codes. Below is a list of CNC codes with a description of what they are.

Click on the code if you want to find out more including multiple examples to help you understand how to use them in your programs.

A - Rotation Around the X Axis

Rotates around the 4th axis of the machine if equipped.

B - Rotation Around the Y Axis

Rotates around the 5th axis of the machine if equipped.

C - Rotation Around the Z Axis

Rotates around the 6th axis of the machine if equipped.

D - Diameter Offset

Specifies the tool diameter offset to be used for cutter compensation (G41 and G42).

Sets the feed rate to be used for movement. The feed rate is used when moving using codes such as G01, G02 & G03.

The feed rate is not used when using rapid travel (G00).

Learn more about the F code

Sets various modes in the machine or prepares the machine to perform a function such as a canned cycle.

Learn more about G codes

H CNC Code

H - Height Offset

Specifies the height offset to be used when turning tool length compensation on (G43) or off (G49)

I CNC Code

I - Radius Center in X Axis

Identifies the location of the center of a radius for a circular move relative to the current X axis location. 

J CNC Code

J - Radius Center in Y Axis

Identifies the location of the center of a radius for a circular move relative to the current Y axis location. 

K CNC Code

K - Radius Center in Z Axis

Identifies the location of the center of a radius for a circular move relative to the current Z axis location. 

L CNC Code

L - Number of Subprogram Repetitions

Used with the M98 subprogram call command. L lists how many times the subprogram will be repeated.

M codes turn on and off various machine functions such as the spindle or coolant. 

They are also used for program start and stop functions.

Learn more about M codes

N CNC Code

N - Program Line Number

Identifies the sequence or line number of the program. They are not required but they can help make a CNC program easier to follow. 

O CNC Code

O - Program Number

The program number is the first CNC word in the program.

P CNC Code

P - Subprogram Number/Dwell Time

When used with an M98 code, P identifies the subprogram number.

When used with G04 or canned cycles, P specifies the amount of time to dwell.

Q CNC Code

Q - Peck Drill Depth

Used with G73 and G83 peck drilling cycles. Q identifies the depth of each drilling peck before the drill backs up to break chips.

R CNC Code

R - Radius Size/Reference Plane

When used with G02 and G03, R specifies the size of the circular curve to be machined.

When used with a canned cycle such as G73, R specifies the location of the rapid plane.

Sets the speed of the spindle.

Units are in revolutions per minute (RPM)

Learn more about the S code

T CNC Code

T - Tool Number

Selects a tool to prepare it for tool change. M06 will cause the CNC to swap the currently loaded tool with the one selected with the T code.

Some machines do not require the use of a M06 code and will swap tools by simply using the T code.

Specifies the location to be moved to in the X axis. 

The distance will be affected by whether the machine is in absolute (G90) or incremental (G91) mode.

Learn more about the X code

Specifies the location to be moved to in the Y axis. 

The distance will be affected by whether the machine is in absolute (G90) or incremental (G91) mode.

Learn more about the Y code

Specifies the location to be moved to in the Z axis. 

The distance will be affected by whether the machine is in absolute (G90) or incremental (G91) mode.

Learn more about the Z code

; - End of Block

Signifies the end of a block of code. A single block will usually consist of one line of code.

Useful when testing code by stepping through the blocks in single block mode.

Slash Block Skip CNC Code

/ - Block Skip

Used together with a switch on the CNC control. 

When the switch is on the machine will read and execute lines that start with the / character. When the switch is off, these lines will be ignored.

Quick Guide to the CNC F Code [Feedrate]

a graphic of a cnc machine with text that says learn g code today F feedrate

What is the F code used for in CNC programming?

The F code, or feedrate command controls how fast the tool advances in a machining process.

It controls the speed at which the tool will remove material while cutting.

Every G code program needs to control the feed rate by setting an F value. This includes milling, drilling, lathes, routers, and so on.

The feed rate needs to be adjusted depending on the needs of the cutting process. For example, the feed rate for machining aluminum will be different form the feed rate needed for hardened steel and so on.

Choosing the correct feed rate can mean the difference between a perfect part and a pile of scrap.

Want to learn more about CNC G Code?

F code structure

The format for an F command is F3.0

Unlike some other commands, the feed rate code allows the use of decimal points.

The F code should be used with a G code that sets the units of the feed rate.

This will be either G94 or G95 for milling machines or G98 or G99 for lathes.

Codes for setting feedrates

There are two types of feed rates that can be selected and the codes used vary between machine types.

On milling machines:

G94 code: Sets the feedrate to inches or millimeters per minute.

G95 code: Sets the feedrate to inches or millimeters per revolution.

a cnc mill with multiple fixtures and coolant lines
CNC Mill

On lathe machines:

G98 code: Sets the feedrate to inches or millimeters per minute.

G99 code: Sets the feedrate to inches or millimeters per revolution.

cnc lathe cutting threads on part
CNC Lathe

Feedrate units

Feedrate per minute (mm/min or in/min)

This type of feed rate sets the distance that the cutting tool will travel in 60 seconds. It is especially useful in milling operations and does not depend on the spindle speed.

For imperial (inch) system units, the feed rate value contains one decimal place. For example, a feedrate of 12.5 inches per minute would be F12.5.

For metric (mm) system units, the feed rate value contains one decimal place, even if it is a whole number. For example, a feed rate of 200 mm per minute would be F200.0

Feedrate per revolution (mm/rev or in/rev)

This type of feed rate sets the distance the cutting tool will travel in one spindle revolution (rotation).

In imperial units, the feed rate number allows four decimals, while in metric units it allows only three decimals.

For example, a feed rate of 0.32945 mm/rev will be programmed as F0.329 and a feed rate of 0.08457 in/rev will be programmed as F0.0846 on most controls.

Most CNC machines can work with both types of feed rate. However, feed rate per revolution is commonly used when working with a lathe and machining centers (mills) tend to stick with feed rate per minute. 

Which other codes does the F command affect?

F codes affect the feed rates used when using various movement G codes such as G01, G02 and G03. Rapid travel with G00 is not affected.

Feed rates also affect canned cycles such as G81, G83 and G85.

Factors that affect the optimal feedrate

Cutting tool material and shape

assorted cutting inserts for cnc machines with text that reads various inserts for cutting

The tool material and shape are determining factors when setting the feedrate in your CNC machine. The size of the tool will directly affect the milling, turning, or drilling process in terms of motion and machining time.

Also, the tool material affects cutting speeds and feed rates.

High-speed steel tools support less friction, which means they generally don’t allow high feed rates and speeds.

Carbide and ceramic tools have better resistance and can be used at high speeds to increase machining efficiency.  

The shape of the cutter and the angle of the tool also affect the cutting efficiency, and therefore the feed rate and speed.

Sharpened tools are ideal for reducing friction and chip load formation during cutting processes.

Workpiece material

Workpiece material has a similar affect to cutting tool material on feed rates. The harder the material is, the more difficult it would be to cut it. Softer materials allow the fastest speeds and rates.

Machine condition

a white and black cnc machine
Not everyone works with a machine this nice

Backlash or wear are common in older machines which can require decreased feed rates and spindle speeds for safety reasons.

Spindle speeds

The speed of the spindle plays an important role in determining the best feed rate. They don’t call it speeds and feeds for nothing.

There are many tables available online that suggest good starting points for picking the best spindle speed for different materials and machining processes.

Depth of cut

illustration showing the depth of cut on a cnc machine

It should go without saying but if the depth of the cut and the feed rate are large, then the friction will increase causing tool damage.

In these cases, the cutting speed should be reduced. A careful balance needs to be maintained between cutting tool life and total machining time.

Width of cut

The width of the cut affects chip thinning during the machining process. Usually, increasing feed rates can decrease this effect and promote user safety. 

How to calculate the feedrate

Figuring out your feed rate might mean doing other calculations first depending on what information you know.

You might need to switch between feed rate units or calculate the feed rate using the spindle speed.

Formulas for switching between units

In the formulas below, the following abbreviations are used:

  • mm/min = millimeters per minute
  • rev/min = revolutions per minute
  • Nt = number of teeth on the tool

Feedrate in (mm/min) = Feedrate in (rev/min)*Nt*RPM

Feedrate in (rev/min) = Feedrate (mm/min) / (Nt*RPM)

Calculating feedrates

The formula for calculating feed rate is Fc = (*D*S)/1000

To calculate the cutting feed rate, you need to consider the variables shown below too:

  • Fc = cutting feedrate
  • D = Diameter of rotating part (job or workpiece)
  • S = spindle feed

Always be careful to stay consistent with your units.

If you choose to work with imperial units, all the parameters involved in the equation need to be in imperial units. The same with working with metric units.

How to choose the appropriate feedrate

Many machinists struggle with establishing the appropriate feedrate for given machines and materials, and rightfully so considering all the factors involved.

Many rely on online databases, manufacturing catalogs, and CNC books such as Machinery’s Handbook or FANUC control guides. 

There are also tables available online with feed rates and speeds according to the tool material, workpiece material, machine and controls used that can serve as a starting point.

Others use CAM software to get a hint of the speeds and rates needed for different machining operations.

And some experienced machinists have trained their ears to set the correct feedrate as a rule of thumb. This is a less accurate method and can easily lead to errors.

Whichever option you choose, it is important to have some guidelines for feeds. Here are a few tips:

  • Increase the cutting speed by following this sequence: carbon steel < speed steel < carbide. Carbide is the tool material that allows the highest speed.
  • Increase the cutting speed by following this sequence: steel < iron < aluminum < lead. Lead is the workpiece material that allows the highest speed.
  • Use the manufacturers specifications and charts to adjust the feed rates and speeds. The manufacturers have likely done extensive testing.
  • You will usually be given a range of speeds and feeds depending on the tool and workpiece materials. Keep in mind that most of the time slower rates will mean longer tool life and less overheating.

Ways to change the current feedrate

Feedrate override

The feedrate override is a switch that can change the programmed feed rate from 0 to 200 percent. The feed-rate override switch is located on the CNC control panel and it’s operated manually by the setup person or operator to slow (or stop) cutting motions.

Although feedrate override is useful in certain situations, you need to be careful to avoid tool overheating or breakage when using it. 

Want to learn more about CNC G Code?

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

a graphic of a cnc machine with text that says learn g code today first g codes to learn

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.

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 or right. It can also be turned off 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.

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.

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

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 feedrate or S for spindle speed 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:

Want to learn more about CNC G Code?

Quick Guide to CNC Subprograms [Tips & Tricks]

a graphic of a cnc machine with text that says learn g code today subprograms

What is a subprogram in CNC programming?

Subprograms are a separate CNC program selected to run from within another program. Subprograms can be run from the main program or other subprograms.

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.

Want to learn more about CNC G Code?

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

  • P – Selects the subprogram number to run. When used with M97, the P code selects the line in the current program to run.
  • O – Identifies the program number.
  • M97 – Jumps to a line number in the program selected with the P command.
  • M98 – Jumps to a subprogram selected with the P code.
  • M99 – Ends the subprogram, returns to the line after where subprogram was run.
  • L – Number of times to repeat the subprogram.

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

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

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.

Want to learn more about CNC G Code?

Quick Guide to CNC Compensation Modes

a graphic of a cnc machine with text that says learn g code today compensation modes

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.

Want to learn more about CNC G Code?

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.

G41 - Cutter compensation left

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

G41 shifts the cutter to the left of the cutting path to account for the size of the cutter.

G42 - Cutter compensation right

G42 is used when conventional milling.

G42 shifts the cutter to the right of the cutting path to account for the size of the cutter.

G40 - Cutter compensation cancel

The G41 and G42 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.

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.

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.

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

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.

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

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.

Want to learn more about CNC G Code?

Quick Guide to the G85 CNC Code [Tips & Tricks]

a graphic of a cnc machine with text that says learn g code today G85 boring/reaming cycle

What is a G85 CNC code?

A G85 command activates the boring and/or reaming canned cycle.

The steps the machine will take are:

  1. Rapid traverse to the R plane
  2. The machine will start boring/reaming from the R plane to the bottom of the hole (Z) at the listed feedrate (F)
  3. At the bottom of the hole, the machine will reverse directions and follow the same path back out of the hole using the same feedrate until it reaches the R plane

This cycle will feed into and out of the hole at a set feedrate. Using a G85 command can lead to improved part accuracy as well as better surface finish. This isn’t guaranteed though and at times it may cause these same things to get worse.

The G85 canned cycle is very similar to G81. The difference is that G81 will rapid retract out of the hole. G85 will retract at the set feedrate.

Want to learn more about CNC G Code?

Parameters used with a G85 code

There are many different parameters used in a G85 code. They are similar to those used in other canned cycles. See the list below to understand all the different parts of the code.

  • X – X axis location of the hole
  • Y – Y axis location of the hole
  • R – retract plane or R plane, the point where the machine will stop rapid movement and begin using the specified feedrate
  • Z – the location of the bottom of the hole
  • F – the feedrate for the boring action
  • K – number of times to repeat the cycle

The retracting value (R) or clearance level refers to the plane perpendicular to the Z-axis where the tool can move safely from one hole to another. The R value should be set so the machine will clear any and all obstacles including clamps, fixtures and the part itself.

G85 code format

G85 X2.0 Y3.0 R1.0 Z-5.0 F25.0

It would be easy to assume that the Z location is the location of the start of the hole. In reality, it is the Z location for the bottom of the boring/reaming movement.

Keep in mind that the X and Y coordinates of the hole are not usually in the same line as the G85 command.

In most programs you will see them in this format:

X2.0 Y3.0

G98 G85 R1.0 Z-5.0 F25.0

The program first identifies the coordinates of the hole and then starts the boring/reaming process.

When to use a G85 code?

The G85 code is useful in programs when a hole needs to be enlarged, a hole needs to be tapered (create an inner cone shape), or when a hole needs a high-quality finish to improve accuracy.

You need to understand that although reaming and boring are operated with the same command and tool (the reamer tool), they are not the same operation. 

Reaming is just for finishing, while boring is used to change the shape of a hole by enlarging it or tapering it.

When not to use a G85 code?

The G85 command should never be used for drilling a hole because it can damage the cutting tool, the workpiece, and the operator. 

A G85 code should be used on a hole which has already been drilled.

What to think about when using a G85 code?

Hole size

The holes where the G85 cycle will be run should be drilled close to the final diameter size to ensure a good surface finish and increase the life of your cutting tool.

Speeds and feeds

The material to be machined and the required surface finish/roughness should be used to determine the appropriate speeds and feeds to use when machining.

Retract planes

G85 code is most commonly used with code G98. Retract planes are important because they control how your machine will act when moving between locations when using canned cycles such as G85.

Retract planes should be chosen so that the machine avoids any and all obstacles such as clamps, fixtures and the workpiece itself. More info about the type of retract planes that can be used is shown below.

G98 and G99 when using a G85 code

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

Before applying the G85 code, the reamer tool should move first to a safe position above the reference (R) plane.

With most canned cycles it is best that the tool moves to a starting point first and then to a reference plane with either the G98 or G99 command.

When using G98, at the end of the cycle the tool will go back to the starting point (above the R plane) in rapid movement after passing the reference plane.

When using G99, at the end of the cycle the tool will only return to the reference plane after finishing the boring/reaming cycle.

How to cancel a G85 code?

The G80 code is used to cancel the G85 boring/reaming canned cycle. G80 is the code used to cancel all canned cycles.

If the G80 code is not used, the machine will attempt to bore/ream a hole at each new location given in the program.

Canned cycles that are similar to G85

G85 vs G81

The G85 and G81 canned cycles are very similar. The difference between the two is that the G81 cycle will retract out of the hole at the machines rapid speed.

G85 will retract out of the hole at the same feedrate that it fed into the hole.

G85 vs G86

The G86 canned cycle is used for boring and is similar to G85 except that it stops the spindle before retracting the tool. The spindle is restarted when it reaches the retract (R) plane.

Because the spindle stops when using G86, the cutting tool can leave a mark on the surface of the hole. For this reason, G86 is mainly used with roughing operations.

All three commands (G81, G85, and G86) are canceled with the G80 code.  

Want to learn more about CNC G Code?