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

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?

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

a graphic of a cnc machine with text that says learn g code today G84 right hand tapping cycle

What is a G84 CNC code?

A G84 command activates the tapping canned cycle.

Tapping is threading the female portion of a mating pair. Basically, this means you are creating the thing that will be screwed into.

three different taps used for creating internal threads with a CNC machine

Tapping is done by rotating the spindle which holds the tap down through the hole until it reaches the desired depth (bottom of the hole). Once at the bottom of the hole, the spindle will change directions and reverse out of the hole.

The G84 code is also used for peck tapping. 

Peck tapping is similar to peck drilling where the machine will tap in steps. For instance, if your peck depth was 0.1” then the machine would feed down 0.1” and then back up. Then the machine would feed down to 0.2” and back up. Rinse and repeat going 0.1” lower with each peck.

Want to learn more about CNC G Code?

When to use a G84 code?

The G84 code is used when you want to tap (thread) an existing hole in a part.

Never use the G84 command to drill a hole. This operation is only meant to remove the material that will form the threads of the holes, not create the hole as well.

Parameters used with a G84 code

When using a G84 code you need to consider all the aspects that control the tapping process, these are:

  • G98 (or G99): Specifies the plane the machine will return to after running the cycle
  • X: Hole location in X-Axis
  • Y: Hole location in Y-Axis
  • R: The distance from the initial level to point retract (R) plane
  • Z: Final tapping depth
  • Q: Depth of cut for each peck
  • F: Cutting feedrate, this will be the pitch of your thread
  • K (or L): The number of repetitions of 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.

G84 code format

The format for using a G84 command is shown below:

G98 (or G99) G84 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 hole tapping movement.

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

In most programs you will see them in this format:

X2.0 Y3.0

G98 G84 R1.0 Z-5.0 F25.0

The program first identifies the coordinates of the hole and then starts the tapping process.

G84 code example

G00 X50.0 Y50.0

G84 Z-40.0 R5.0 F20

X25.0

Y25.0

G80 Z10.0

M30

In this example, the tool approaches the coordinates of the first hole (X50 Y50), then starts the tapping process.

The tapping operation is set to reach a depth of 40 mm and has a retraction plane of 5 mm above the workpiece. This procedure is repeated in 2 more holes in the positions (X25, Y50) and (X25, Y25).

The program stops the tapping cycle by using the G80 command.

Finally, the tool moves away from the part in the Z axis and the M30 command ends the program.

G84 rigid tapping

Rigid tapping means that the tap can remain rigid throughout the cycle. The machine spindle locks in with the feedrate similar to the screw cutting process.

There are tapping heads specially designed for this process.

To perform Rigid Tapping, the machine should be able to synchronize feed motion and spindle speed. This option may not be available on all machines, especially older ones. Check your machine manual to make sure you are capable of rigid tapping.

However, Rigid Tapping mode can cause issues due to chips sticking to the tool or increased cutting resistance. That’s why it is important to consider peck tapping.

G84 peck tapping

Including the Q parameter in the G84 command line will immediately set the machine to a peck tapping cycle.

This means that the spindle will rotate to a specified depth (Q value) in each tapping peck and then repeat the process, one step or “peck” at a time until reaching the bottom of the hole.

Peck tapping allows chips to exit the hole, making the tapping process easier and safer. 

The downfall of peck tapping is that it increases machining time when compared to standard tapping.  

The picture below is for drilling but it is the same concept. The pecks do not need to come all the way back up either.

You can drill down 0.200″ and then retract 0.100″ and then repeat the process going down 0.100″ at a time.

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

What to think about when using a G84 code?

Speeds and feeds

You will need to set the spindle speed before using the G84 cycle. When using G84, the spindle should always be moving clockwise through the use of an M03 command.

The feed rate of code G84 will be the pitch of your thread.

Various holds or overrides for speeds and feeds will not work when tapping. This is for safety purposes.

Hole size and location

Before using the G84 there must be a previous drilling cycle.

The correct hole diameter for a tapping operation will be the final diameter of the screw minus the pitch. For example, the diameter of the hole for an M10 x 1.5 mm hole will be 8.5 mm.

Keep in mind that the X and Y coordinates of the hole are not usually in the same line as the G84 command. The standard format for selecting your hole location and calling the G84 tapping cycle is shown below:

X50.0 Y50.0

G84 Z-40.0 R5.0 F20

The machine is moved to the location of the hole to be threaded and then the hole cycle is used.

Retract planes

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

The G84 command is usually followed by G98 in the same line of code, in which case the machine will use the Z coordinate (height of the first hole) to move between holes. Keeping in mind this aspect can prevent redundant coding and machining errors.

When tapping it is advisable to set your R plane higher than usual.

CNC machines are capable of switching between modes very quickly, but the change is not instantaneous. The higher R plane gives the machine time to stabilize and ensure it is working at the correct feedrate before starting the cut.

How to cancel a G84 code?

The G84 code is canceled with the G80 command.  

If the G84 code is not canceled, the machine will try to tap a hole at every new location given in the program.

The G80 command cancels all canned cycles.

G84 vs G74

The G74 cycle is the left-hand tapping cycle, sometimes called the reverse tapping cycle.

It performs the same operation as the G84 command but with the difference that the spindle rotates counterclockwise instead of clockwise.

The G74 left hand tapping cycle creates left hand internal threads while the G84 canned cycle creates standard or right-hand internal threads. Left hand threads are the opposite of your standard threads.

If G84 creates threads that are lefty-loosey, righty tighty then G74 creates threads that are righty-loosey, lefty tighty. In other words, G74 creates threads that would be screwed in the opposite way of normal.

The G74 command also has the ability to peck tap.

Both the G74 and G84 commands are modal which means they will stay on and in effect until they are either changed or canceled.

The cancel code to use with both cycles is G80.

Want to learn more about CNC G Code?

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

a graphic of a cnc machine with text that says learn g code today G83 peck drilling cycle

What is a G83 CNC code?

G83 is a modal command that sets the CNC machine to run a peck drilling cycle.

The practice of peck drilling refers to drilling a hole in a series of steps (pecks) instead of drilling the complete depth of the hole in a single pass.

Want to learn more about CNC G Code?

Differences between peck drilling and standard drilling

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.

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

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.

When to use a G83 code?

When you need to drill deep holes in a workpiece, that would need more than one step to avoid jamming or tool breakage.

G83 is especially useful for drilling blind holes when you want to achieve a clean finish.

When not to use a G83 code?

If you want to make a shallow hole, you won’t probably need the G83 code.

There is no need for the tool to take on several pecks if the depth of the hole is less than an inch (depending on the material and tool).

The G83 command works best when you follow a general rule: if the depth of the hole is 3 to 4 times greater than its diameter, use G83. 

G83 code format

The format for using a G83 command is shown below:

G98 (or G99) G83 X2.0 Y3.0 R1.0 Z-5.0 Q1.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 hole drilling movement.

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

In most programs you will see the G81 code in this format:

X2.0 Y3.0

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

The program first identifies the coordinates of the hole and then starts the drilling process.

Parameters used with a G83 code

  • F – Feedrate
  • R – Position of the R plane (clearance level)
  • X – Hole position in X-Axis
  • Y – Hole position in Y-Axis
  • Z – Position of the Z Axis at the bottom of hole
  • Q – Depth to increase on each depth
  • P – Dwell time at the bottom of the hole
  • K or L – Number of cycle repetitions

The feed rate (F) is dependent on the material that is being cut and the diameter of the drilling tool that you are using.

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.

Also, some machines might use L instead of K for cycle repetition (depending on the model and machine type). If you are the programmer, remember to check the machine’s manual for further details.

What to think about when using a G83 code?

Peck depth

The bigger the peck distance is, the fastest the drilling operation will be. So, in this sense, choosing an appropriate peck distance can speed up machining time.

Usually, when using G83, the maximum peck distance recommended will be equal to the hole’s diameter. However, you must be careful with hard materials and heavy chips that can come out of the hole during the process. 

Some CNC models have variable-depth peck controllers, and you could play with them to decrease peck distance in each pass by taking a big peck in the first step and then taking shorter ones to avoid plugging up the tool.

Be sure to check the machine’s manual first to see the available options for controllers.

Positioning mode

When using the G83 drilling cycle, you will need to be aware of the positioning mode that is currently active.

If G90 is active, the machine will read all locations as relative to a single zero location.

If G91 is active, the machine will read all locations as relative to its current position.

Pay careful attention to your current positioning mode because using the wrong one can easily result in a machine crash.

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

The difference between the two modes is shown above. When in absolute mode, the machine will move relative to a fixed zero location.

When in incremental mode, the machine will move relative its current location.

Look at the first move in the pictures above. They both start at (0,0). They both move up one block in the Y axis.

On the second move, in absolute mode the machine the machine is still reading the new location as from the fixed zero location. 

In incremental mode the move is from the machines current location which is why the move is 1 block shorter in the Y axis.

Retract planes

The retract plane is the location that the machine will return to after each canned cycle.

There are two codes that affect retract planes. G98 will cause the machine to return to the Z location at the start of the canned cycle. G99 will

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

Selecting a retract plane that is above any potential obstacles in the machine such as fixtures, clamps, or the part itself will allow the machine to safely move between each hole drilling location.

If the R plane is too low it could cause damage on the workpiece and lead to disaster. However, if an R plane is too high above the workpiece’s surface, it could increase machining time, due to the extra time needed to go all the way up to the R value after each drilling. 

How to cancel a G83 code?

The G80 command is used to cancel a G83 code as well as all other canned cycles.

If the G83 command is not canceled, then the machine will continue to drill holes in every location given in the program.

G83 vs G73

The most similar code to G83 is G73.

They are both peck drilling cycles with one key difference. G83 will retract completely out of the hole after each peck to the retract plane. G73 will only retract to the start of each peck.

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.

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

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.

G83 vs similar codes

Besides G73 there are a few other G-codes for drilling holes with slight variations in the drilling process which make them better to use in certain circumstances.

Code

Name

Function

Standard drilling

Drill simple, shallow holes and center drilling

Spot drilling

Standard drilling cycle with a dwell at the bottom of the hole

Peck drilling - full retract

Drill into the part in steps (pecks) and after each peck, fully retract from the hole

Peck drilling - stepped drilling

Similar to G83, but instead of retracting completely out of the hole, the machine will pull back a specified amount and then resume drilling

Want to learn more about CNC G Code?

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

a graphic of a cnc machine with text that says learn g code today G81 standard drilling cycle

What does a G81 code do?

G81 calls a standard drilling cycle. It is a modal function that allows the machine (lathe or mill) to perform a one-pass drilling operation and retraction.

The machine will drill the hole in one straight shot and then retract out of the hole. There is no dwell or movement of the cutter away from the surface of the hole.

Just like other modal functions, you will need to deactivate it by calling another G code of the same type (canned cycle) or by using the G80 canned cycle cancel command to stop drilling.

Want to learn more about CNC G Code?

When to use a G81 code?

The G81 command is useful when you want to drill holes that are not too deep and can be drilled in just one step. G81 is the most common drilling canned cycle used.

G81 can be used for spot drilling, counterboring, reaming, boring, center drilling and other drilling operations. It is a very simple drilling cycle.

The G81 canned cycle does not include any retract steps (pecks) when drilling. For this reason, if you want to drill a deep hole, the best option would be to use the G83 peck drilling deep hole canned cycle. Peck drilling will help clear chips.

G81 code format

The format for using a G81 command is shown below:

G98 (or G99) G81 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 hole drilling movement.

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

In most programs you will see the G81 code in this format:

X2.0 Y3.0

G98 G81 R1.0 Z-5.0 F25.0

The program first identifies the coordinates of the hole and then starts the drilling process.

G81 code parameters

  • X – Hole location in X-Axis
  • Y – Hole location in Y-Axis
  • Z – Z axis location of the bottom of drilling motion
  • R – Position of the retract plane (for movement clearance)
  • F – Feed rate for drilling

What to think about when using a G81 code?

Positioning mode

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

When using the G81 drilling cycle, you will need to be aware of the positioning mode that is currently active.

If G90 is active, the machine will read all locations as relative to a single zero location.

If G91 is active, the machine will read all locations as relative to its current position.

Pay careful attention to your current positioning mode because using the wrong one can easily result in a machine crash.

Retract planes

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

The retract plane is the location that the machine will return to after each canned cycle.

There are two codes that affect retract planes. G98 will cause the machine to return to the Z location at the start of the canned cycle. G99 will

Selecting a retract plane that is above any potential obstacles in the machine such as fixtures, clamps, or the part itself will allow the machine to safely move between each hole drilling location.

If the R plane is too low it could cause damage on the workpiece and lead to disaster. However, if an R plane is too high above the workpiece’s surface, it could increase machining time, due to the extra time needed to go all the way up to the R value after each drilling. 

How to cancel a G81 code?

The G80 command is used to cancel a G81 code as well as all other canned cycles.

If the G81 command is not canceled, then the machine will continue to drill holes in every location given in the program.

G81 vs similar canned cycles

The G81 command is the simplest drilling canned cycle.

Besides G81 there are a few other G-codes for drilling holes with slight variations in the drilling process which make them better to use in certain circumstances.

Code

Name

Function

Standard drilling

Drill simple, shallow holes and center drilling

Spot drilling

Standard drilling cycle with a dwell at the bottom of the hole

Peck drilling - full retract

Drill into the part in steps (pecks) and after each peck, fully retract from the hole

Peck drilling - stepped drilling

Similar to G83, but instead of retracting completely out of the hole, the machine will pull back a specified amount and then resume drilling

Want to learn more about CNC G Code?

How to Learn CNC Programming [Best Resources]

What is CNC programming?

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

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

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

How difficult is it to learn CNC programming?

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

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

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

What are the steps involved in CNC programming?

infographic that shows three steps to making a cnc program

Plan the program

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

Write the program

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

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

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

Setup the CNC machine

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

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

Types of CNC programming

Manual programming

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

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

Conversational programming

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

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

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

Programming with CAD/CAM

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

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

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

How to start learning CNC programming

Local college/training

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

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

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

Self-guided training

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

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

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

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

Online training

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

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

Types of CNC machines

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

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

Home/hobbyist machines

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

Industrial level machines

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

Frequently asked questions

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

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

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

How long does it take to learn CNC programming?

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

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

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

Is CNC programming a good career?

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

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

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

What is the salary for a CNC programmer?

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

That comes out to about $40 an hour.

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

What skills does a CNC programmer need?

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

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

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

What other jobs take similar skills to CNC programming?

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

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

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

Quick Guide to the G91 CNC G Code [Tips and Tricks]

a graphic of a cnc machine with text that says learn g code today G91 incremental positioning mode

Code

G91

Name

Incremental Positioning

Type


Modal - stays on until changed

Description

The machine will read all locations as relative to its current location

What does a G91 code do?

A G91 code sets the CNC to incremental positioning mode. This means that the CNC will interpret all location values as relative to the position of the machine before making the move.

The zero location of the machine will move each time the machine moves. This can be good for repetitive work such as drilling a series of holes.

G90 vs G91: CNC positioning modes

For a CNC machine there are two positioning modes available. They are absolute (G90) and incremental (G91) positioning.

As noted above, incremental positioning with G91 will take all locations relative to the machines current location.

With absolute positioning (G90), the machine will interpret all locations as relative a static location. This will usually be the work offset zero location as set by G54 or the machines home location if no work offset is active.

Both codes are modal which means that the code will stay active until it is either canceled or changed. For G90 and G91, there is no cancel code so the only way to change them is to call the opposite code.

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

The images above show the difference between the absolute and incremental positioning modes. The numbers in parentheses are the locations given to the the machine to make the move.

Notice how in absolute mode, all locations are relative to a single location, usually either the workpiece zero or machine home location. 

In incremental mode, all locations are relative to the machine’s current location.

When to use a G91 code

The main portion of most programs will be in absolute mode (G90). Incremental mode (G91) is usually only used to create repetitive features such as drilling a set of holes.

G91 is a much less frequently used code compared to G90.

G90 codes are used frequently. This is because they get used as part of safety lines of code sometimes called safety block.

Safety lines are a chunk of code that is used to ensure that the machine is in the correct modes before executing a section of the CNC program.

They are used at the start of new sections of code such as when changing tools.

Why using a G91 code is important

Both G90 and G91 are modal commands which means that they will stay in effect until changed or canceled.

It is important to set your positioning mode in your program with either G90 (absolute mode) or G91 (incremental mode).

Imagine if you had an operation where you were going to drill a set of holes. Before you drill those holes, it would be wise to set all the necessary modes you will need to have active.

Setting the positioning mode (absolute or incremental), setting the type of units you are in (inches or mm) and turning on various compensation modes are just some of the modes that you might want to have set.

If these modes are already active, then nothing will change. No harm, no foul.

If they weren’t active and you didn’t turn them on, you might crash your machine.

When writing your CNC programs, it is critical to be in the correct positioning mode at all times. For this reason, a G90 or G91 code should be used at the start of a new section of the program.

What to think about when using a G91 code

Know where you are at and where you want to move the machine.

In other words, you need to know where the start and stop location of each move is.

The main body of most programs will be written in absolute mode (G90). This is because it is easier to visualize a part based on absolute coordinates.

Portions of a program get written in incremental mode. Often incremental mode is used when dealing with canned cycles or subprograms.

You can make your whole program in incremental mode if you wish, most people don’t though.

G91 code example

N0010 G90 F100 S1200 T01

N0020 G00 X36 Y10

N0030 Z2

N0040 G91 G01 Z-12 M03

N0050 X10

N0060 Z12 M05

N0070 M30

Line N0010 sets the positioning mode as absolute. It also sets the feed rate to 100, spindle speed to 1200 and selects tool 01.

Line N0020 sets the movement mode as rapid travel. It then moves to the XY location listed.
Line N0030 rapid moves to the Z location.

Line N0040 sets the movement mode to incremental mode and straight-line movement. It turns the spindle on clockwise and feeds 12 units in the negative Z direction at the feed rate listed in line N0010.

Line N0050 moves 10 units in the positive X direction in a straight line at the previous feed rate.

Line N0060 moves 12 units in the positive Z direction and turns the spindle off.

Line N0070 ends the program.

CNC codes that are similar to G91

We already discussed the most common code that is similar to G91. G90 sets the machine in absolute positioning mode.

The other main codes that affect positioning are G60 and G64.

G60 sets the CNC to single direction positioning mode.

The G60 code will make force the machine to approach each new location from the same direction. This decreases location errors that can occur because of backlash in the machine.

G64 is normal positioning mode. In normal positioning mode, the machine will move all axes at the same time and will approach the workpiece form whichever side is fastest.