Want to be a better CNC'er? Get our weekly newsletter plus a package of greatest hits, special tips, and more, all for free. I'm Ready to Be a Better CNC'er, Hook Me Up!
 Programming Tapping in GCode Rigid Tapping, Tapping Heads, and Tension Compression Tap Holders CNCCookbook's G-Code Tutorial

Introduction: Tapping on CNC Machines

Tapping is a common operation used to thread holes on CNC Machines. For more on the Feeds and Speeds as well as the different kinds of taps and tap holders, see our companion Tapping Feeds and Speeds article. In this article, we'll be looking at two ways of programming tapping on a CNC:

- Tapping Cycles that can use the Rigid Tapping capabilities of your CNC Machine.

- Long Form (no canned cycle is needed or used) programming when a Tapping Head or Tension-Compression Tap Holder is to be used on machines that do not have Rigid Tapping.

How to Program Rigid Tapping With a Canned Cycle

To use Rigid Tapping, your machine must support the synchronization of feed motion with the spindle speed. This is typically an extra-cost option for CNC Machines and is harder to come by on older machines. The most common GCodes for Rigid Tapping Cycles are:

- G84: Tapping of right hand threads to be done with M3 spindle rotation.

- G74: Tapping of left hand threads to be done with M4 spindle rotation.

With some machines and controls, just simply using these cycles is sufficient for Rigid Tapping. On others, you must trigger a Rigid Tapping motion mode using another code. M29 is the common way to do this on Fanuc controls, for example.

Let's say we want to tap a 1/4-20 thread 0.500" deep at 0, 0. Here's the code to do that with G84:

M03
M8

( Speed and Feedrate )
S400
F20

( Tapping )
Z1.0
G00 X0.0 Y0.0
G01 M29
G84 Z-0.5 R0.2

Let's go through line by line:

M03 to get the spindle moving in the right direction and M8 to turn coolant on. Next we set spindle speed to 400 RPM and feedrate to 20. With this particular cycle, it expects feedrate in threads per inch (or mm in metric mode).

Next we move down to Save Z and XY. We switch to G01 and we use M29 to turn on Rigid Tapping. Lastly, we run the G84 with Z indicating the bottom of hole coordinate and R indicating the retract coordinate.

If we had more holes to tap we could list their XY coordinates immediately following like this:

G84 Z-0.5 R0.2

X0.0 Y1.0

X0.0 Y2.0

etc.

G84 is modal like most canned cycles. When we're done with it, we use G80 to cancel or simply switch to an alternate motion mode such as G00, G01, another canned cycle, or an arc.

Pretty simple with a canned cycle, right?

That code is straight from G-Wizard Editor's Conversational CNC Tapping Wizard, which can generate the gcodes for such cycles very easily. Here's what the Wizard's popup looks like with the settings for this example:

Answer a few simple questions and G-Wizard Editor's Conversational CNC will generate your tapping code for you...

How to Program Tapping on Machines that Lack Rigid Tapping

If your machine can't do Rigid Tapping, you'll need to use a special tap holder. There are two common types described in our companion article on tapping: a Tapping Head or a Tension-Compression Holder. There are pros and cons for each described in the other article.

The purpose of the special holder is to allow some up/down motion of the tap in case the spindle speed isn't precisely right for the feedrate. This lets the threading process itself regulate the true feedrate and it works well. A tapping head has some other functions that enable it to tap faster too.

Programming these is fairly straightforward. Here is some basic code:

M03
M8

( Speed and Feedrate )
S400
F20

( Tapping )
Z1.0
G00 X0.0 Y0.0
G01 Z-0.5
Z0.2
G00 Z1.0

Same sort of thing but in this case, it is done long-form with no tapping cycle. You could use one of the canned cycles to shorten the code, but it's so simple to use the long-form, why not?

There are some embellishments to the code that may be helpful depending on the equipment you're using:

1. A Tapping Head may have a gear ratio that allows it to retract faster. You'll want to change the feedrate when retracting if yours does.

2. A Dwell at the bottom of the hole may be helpful as the spindle reverses to even out the amount of spring adjustment being used.

3. For a lot of these devices, it can be helpful to drag the feedrate a bit. About 5% should do it. This is due to many of them performing better in tension than compression.

You can see all of those options are available on the G-Wizard Editor Conversational screen above.

Conclusion

Tapping is a very commonly used function. Peter Smid says it is second only to drilling holes. It's easy to program either by hand or using a tool like G-Wizard Editor's Conversational CNC. Don't be afraid to program it on your machines now that you know how.

Exercises

1. Use GW Editor's Conversational CNC Tapping Wizards to generate code for the different kinds of tapping so you can see how it should work.

Try the Free Trial Version of G-Wizard CNC Program Editor...

No credit card required--just your name and email.

Next Article:

CNCCookbook's G-Code Course

GCode is complicated.
G-Wizard Editor
makes it easy.

Feeds and Speeds:

Do you want to be a better CNC'er in 37 Seconds?

Get Better Tool Life, Surface Finish, and Material Removal Rates Fast.

It's that easy. You can install and get results in a matter of minutes.