Quick Guide to the G84 CNC Code [Tapping]

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

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?

Leave a Comment