G84 CNC Code: The Ultimate Guide to Tapping (Milling) and Face Tapping (Turning)
Introduction:
The G84 G-code is a fundamental canned cycle used for creating internal threads in CNC machining. Like other canned cycles, G84 simplifies programming by automating a complex sequence of movements. However, there’s a crucial distinction: G84 functions differently on a CNC lathe (turning center) versus a CNC machining center (mill). On lathes, G84 is often a Face Tapping Cycle, used for threading on the face of a rotating part. On mills, it’s a general Tapping Cycle, used for creating threads in a stationary workpiece. This comprehensive guide explains both variations, covering their function, syntax, differences, implementation across major control systems (Fanuc, Siemens, Haas, Mazatrol, Mitsubishi, Heidenhain, and others), best practices, troubleshooting, and advanced techniques. This guide is suitable for CNC users of all skill levels.
1. What is the G84 Canned Cycle?
G84 is a G-code command that initiates a canned cycle for tapping – the process of cutting internal threads into a pre-drilled hole. The key characteristic of G84 is the synchronized movement of the spindle (rotation) and the feed axis (Z-axis in most cases). This synchronization is absolutely essential for creating accurate threads without damaging the tap (the threading tool) or the workpiece. The feed rate must match the spindle speed and the thread pitch.
2. Key Differences: G84 Face Tapping (Turning) vs. G84 Tapping (Milling)
The core difference lies in the machine configuration and how the workpiece and tool interact:
Feature | G84 Face Tapping (Turning) | G84 Tapping (Milling) |
---|---|---|
Machine Type | CNC Lathe (Turning Center) | CNC Machining Center (Mill) |
Workpiece | Rotating | Stationary |
Tool | Stationary (except with live tooling) | Rotating |
Purpose | Creating internal threads on the face of a rotating workpiece, typically on the center axis. | Creating internal threads in a stationary workpiece. |
Primary Axis | Z-axis (movement of the tool along the spindle axis) | Z-axis (movement of the tool into the workpiece), X and Y for positioning. |
Spindle | Controls the workpiece rotation. | Controls the tool rotation. |
Example Use | Creating a threaded hole on the end of a shaft. | Creating threaded holes for fasteners in a plate or block. |
In simple terms:
- Turning (G84 Face Tapping): The workpiece spins, and the tap (usually) moves only in the Z-axis to create threads on the end face of the part.
- Milling (G84 Tapping): The workpiece is stationary, and the rotating tap moves in X, Y, and Z to create threads in a hole.
3. Rigid Tapping vs. Floating Tapping (Primarily Milling)
Before diving into syntax, it’s important to understand the two main types of tapping used with G84 on machining centers:
- Rigid Tapping (G84.2 or M29 S… on Fanuc): This is the preferred method when your machine supports it. The machine’s control system electronically synchronizes the spindle rotation and the Z-axis feed with extreme precision. This allows for faster tapping speeds, better thread quality, and longer tool life. Requires a machine with a rigid tapping capability.
- Floating Tapping (Standard G84): This method uses a special tap holder with a built-in “float.” This float allows the tap to compensate for slight discrepancies between the programmed feed rate and the actual spindle speed. It’s more forgiving, but generally slower and can result in slightly lower thread quality compared to rigid tapping. Used on machines without rigid tapping capability, or when very precise synchronization isn’t achievable.
Turning Note: On lathes, the concept of “rigid tapping” in the same sense doesn’t apply because the workpiece rotation is inherently synchronized with the tool’s Z-axis movement. However, the precision of that synchronization can still vary depending on the machine’s capabilities.
4. Why Use G84?
- Automation: Simplifies the programming of tapping operations.
- Synchronization: Ensures the correct relationship between spindle speed and feed rate, preventing tap breakage and ensuring accurate threads.
- Consistency: Produces consistent threads from hole to hole.
- Efficiency: Faster than manually programming the tapping operation.
5. G84 Tapping Cycle (Milling) - Syntax and Parameters
This section focuses on the G84 tapping cycle used on machining centers (mills).
General Syntax (Milling):
G84 X[Hole X] Y[Hole Y] Z[Hole Depth] R[Return Plane] F[Feed Rate] S[Spindle Speed]
- G84: The G-code for the tapping cycle.
- X[Hole X]: The X-coordinate of the hole center.
- Y[Hole Y]: The Y-coordinate of the hole center.
- Z[Hole Depth]: The final Z-depth of the threaded portion of the hole (negative value if Z-zero is at the workpiece surface).
- R[Return Plane]: The Z-coordinate of the retract plane. This is a safe position above the workpiece.
- F[Feed Rate]: The feed rate. Crucially, this MUST be calculated based on the spindle speed (S) and the thread pitch. Feed Rate (F) = Spindle Speed (S) x Thread Pitch
- S[Spindle Speed]: The spindle speed in revolutions per minute (RPM).
Example (Milling - Fanuc/Haas/Mitsubishi - Standard G84, Floating Tapping):
O0001 (G84 Tapping - Milling)
G90 G21 G17 G40 G80 ; Safety line
T01 M06 ; Select Tool 1 (Tap - e.g., M6 x 1.0)
G54 ; Select Work Coordinate System
G00 X10.0 Y10.0 ; Rapid to first hole position
G43 H01 Z5.0 ; Activate tool length compensation, rapid to safe Z
M03 S500; Spindle on clockwise, 500 RPM
; --- G84 Tapping Cycle ---
G84 X10.0 Y10.0 Z-20.0 R2.0 F500 ; Tap to Z-20 (Pitch = 1.0mm)
X20.0 Y10.0 ; Second hole
X30.0 Y20.0 ; Third hole
X40.0 Y20.0 ; Fourth hole
G80 ; Cancel the G84 cycle
G00 Z50.0 ; Rapid retract to safe Z
M05 ; Stop Spindle
M30 ; Program end
Explanation:
- M6 x 1.0 Tap: This example assumes a common M6 tap with a 1.0mm pitch.
- S500: Spindle speed is set to 500 RPM.
- F500: Feed rate is calculated as 500 RPM * 1.0 mm/rev = 500 mm/min.
- Z-20.0: The threaded depth is 20mm. You must pre-drill the hole to a suitable diameter and depth before using G84.
Example (Milling - Fanuc/Haas - Rigid Tapping - G84.2 or M29 S…):
O0002 (G84 Rigid Tapping - Milling)
G90 G21 G17 G40 G80 ; Safety line
T01 M06 ; Select Tool 1 (Tap - e.g., M6 x 1.0)
G54 ; Select Work Coordinate System
G00 X10.0 Y10.0 ; Rapid to first hole position
G43 H01 Z5.0 ; Activate tool length compensation, rapid to safe Z
M29 S500; Enable rigid tapping mode and set spindle speed
; --- G84 Tapping Cycle (Rigid) ---
G84 X10.0 Y10.0 Z-20.0 R2.0 F1.0 ; Tap to Z-20 (Pitch = 1.0mm)
X20.0 Y10.0 ; Second hole
X30.0 Y20.0 ; Third hole
X40.0 Y20.0 ; Fourth hole
G80 ; Cancel the G84 cycle
G00 Z50.0 ; Rapid retract to safe Z
M05; Stop Spindle
M30 ; Program end
Explanation (Rigid Tapping):
- M29 S500: This command (or G84.2 on some controls) enables rigid tapping mode and sets the spindle speed. The exact command and syntax vary between control manufacturers and even machine models. Consult your machine’s manual.
- F1.0: In rigid tapping, you typically specify the thread pitch directly as the feed rate (F). The control system handles the synchronization.
6. Control System Variations (Milling - G84 Tapping)
- Fanuc, Haas, Mitsubishi: The basic G84 syntax is as described above. The key difference is how rigid tapping is enabled (M29 S… or G84.2).
- Siemens (SINUMERIK):
- CYCLE84: Siemens uses
CYCLE84
for tapping. - Parameters:
CYCLE84
has numerous parameters for fine control:RTP
: Retract planeRFP
: Reference planeSDIS
: Safety distanceDP
: Final drilling depthDPR
: Final drilling depth relative to reference planeDTB
: Dwell time at thread depthSDAC
: Spindle direction after cycle endMPIT
: Metric thread pitch (as a value)PIT
: Thread pitch (as a value)POSS
: Spindle position for oriented spindle stopSST
: Spindle speedSST1
: Spindle speed for retract- And others… **Example (Siemens - Rigid Tapping):**CYCLE84(5, 0, 1, -20, , 0, 3, 1.0, , , 500, , , , 0) ; Rigid tap, M6x1.0, 500 RPM ```
- CYCLE84: Siemens uses
- Mazatrol (Mazak):
- Conversational Programming: Tapping is typically defined within the conversational programming interface (often a “TAP” unit).
- EIA/ISO (G-code): Mazak machines can run standard G-code; G84 would function similarly to Fanuc.
- Heidenhain:
- CYCL DEF 206 (TAPPING) / CYCL DEF 207 (RIGID TAPPING): Heidenhain uses
CYCL DEF 206
for standard tapping (with a floating tap holder) andCYCL DEF 207
for rigid tapping. - Example (Heidenhain - Rigid Tapping):
- CYCL DEF 206 (TAPPING) / CYCL DEF 207 (RIGID TAPPING): Heidenhain uses
CYCL DEF 207 RIGID TAPPING NEW CYCLE
Q200=2 ;SET-UP CLEARANCE
Q201=-20 ;THREAD DEPTH
Q239=1 ;THREAD PITCH
Q203=+0 ;SURFACE COORDINATE
Q204=50 ;2ND SET-UP CLEARANCE
- Other Controls: Always consult the programming manual.
Key Differences (Milling):
- Syntax: While G84 is common, Siemens uses
CYCLE84
, and Heidenhain usesCYCL DEF 206/207
. - Rigid Tapping: The method for enabling rigid tapping varies (M-codes, G-codes, or cycle parameters).
- Parameter Names: The names and availability of parameters for fine-tuning the cycle differ significantly.
7. G84 Face Tapping Cycle (Turning) - Syntax and Parameters
This section focuses on the G84 tapping cycle used on lathes (turning centers).
General Syntax (Turning):
G84 Z[Hole Depth] R[Return Plane] F[Feed Rate]
Or, if tapping off-center with live tooling:
G84 X[Hole Depth] Z[Hole Position] R[Return Plane] F[Feed Rate] C[C-axis position]
- G84: The G-code for the face tapping cycle.
- X[Hole Depth]: The final X-depth for the off center tapping operation.
- Z[Hole Depth]: The final Z-depth of the threaded portion of the hole (negative value).
- R[Return Plane]: The Z-coordinate (or X coordinate, for off-center) of the retract plane.
- F[Feed Rate]: The feed rate. On a lathe, this is typically specified in feed per revolution (e.g., mm/rev or inch/rev). The feed rate must equal the thread pitch.
- C[C-axis position]: The angular position of the C-axis for off-center tapping (using live tooling).
Example (Turning - Fanuc-style, Center Tapping):
O0002 (G84 Face Tapping - Turning)
T0101 ; Select Tool 1 (Tap - e.g., M8 x 1.25)
G97 S400 M03 ; Constant RPM, spindle on, 400 RPM
G00 X0 Z5.0 ; Rapid to starting position (center of the face)
M08 ; Coolant on
; --- G84 Face Tapping Cycle ---
G84 Z-15.0 R2.0 F1.25 ; Tap to Z-15 (Pitch = 1.25mm)
G80 ; Cancel the G84 cycle
G00 Z5.0 ; Rapid retract
M09; Coolant off
M05 ; Stop the spindle
M30 ; Program end
Explanation:
- M8 x 1.25 Tap: This example assumes an M8 tap with a 1.25mm pitch.
- S400: Spindle speed is set to 400 RPM.
- F1.25: The feed rate must be equal to the thread pitch (1.25 mm/rev). The control system handles the synchronization.
- Live Tooling: For using live tooling, you need to use M codes for activating it.
8. Control System Variations (Turning - G84 Face Tapping)
The implementation of face tapping cycles can vary significantly between CNC lathe controls:
-
Fanuc and Similar (Haas, Mitsubishi):
- G84: The G84 command is commonly used for face tapping, as shown in the examples above.
- Rigid Tapping: While not strictly “rigid tapping” in the same sense as a machining center (since the workpiece is rotating), the lathe’s control must still synchronize the Z-axis feed with the spindle rotation. Modern lathes have very precise spindle control that effectively achieves this.
- Live Tooling: For off-center tapping, live tooling and C-axis control are required. G84 is still used, but with appropriate plane selection (G17/G19) and C-axis positioning.
-
Siemens (SINUMERIK):
- CYCLE84: Siemens uses
CYCLE84
for all tapping operations, including face tapping on a lathe. The parameters withinCYCLE84
define the specifics of the operation. - Parameters:
CYCLE84
has a comprehensive set of parameters, including options for specifying the thread pitch, depth, retract plane, dwell time, and whether to use a floating tap holder or rigid tapping (if the machine supports it).
- CYCLE84: Siemens uses
-
Mazatrol (Mazak):
- Conversational Programming: Face tapping is defined within the conversational programming interface (often a “TAP” unit within a turning process). You would specify the thread parameters, location, and depth, and the control would automatically generate the necessary movements.
- EIA/ISO (G-code): Mazak lathes can run standard G-code, and G84 would be used as described for Fanuc-style controls.
- TAP UNIT: Mazak uses this unit.
-
Heidenhain:
- CYCL DEF 207 (Rigid Tapping - Left-Hand): Or CYCL DEF 206 (TAPPING) Heidenhain uses
CYCL DEF 206
for standard tapping.
- CYCL DEF 207 (Rigid Tapping - Left-Hand): Or CYCL DEF 206 (TAPPING) Heidenhain uses
-
Other Controls: Always consult your machine’s programming manual. Okuma, Fagor, and other controls will have their own specific cycles or methods for face tapping.
9. Best Practices for Using G84 (Turning and Milling)
- Correct Tap: Use a tap of the correct size, thread form, and material for the workpiece. For face tapping on a lathe, ensure the tap is suitable for the limited space and potential chip clearance issues. For left-hand threads, use a left-hand tap.
- Correct Feed Rate: The feed rate must be calculated correctly based on the spindle speed and thread pitch. For rigid tapping, the feed rate is often simply equal to the thread pitch.
- Pre-Drilled Hole: Always pre-drill the hole to the correct tap drill size before tapping. Refer to a tap drill chart.
- Spindle Speed: Choose an appropriate spindle speed for the tap size, material, and thread pitch. Tapping speeds are generally much lower than drilling speeds.
- Coolant: Use generous amounts of appropriate cutting fluid designed for tapping.
- Rigid Tapping (if available): Use rigid tapping whenever possible for better thread quality and faster cycle times (primarily on machining centers).
- Verify the Toolpath: Always simulate your program.
- Spindle Orientation (Turning): Use M19 for positioning.
10. Troubleshooting Common G84 Problems
- Broken Tap:
- Cause: Incorrect feed rate, dull tap, inadequate cutting fluid, incorrect pre-drill size, material too hard, or rigid tapping not properly synchronized (machining centers).
- Solution: Verify feed rate, use a new/sharper tap, ensure adequate cutting fluid, check pre-drill size, choose a tap designed for the material, and verify rigid tapping settings.
- Oversized/Undersized Threads:
- Cause: Incorrect feed rate, worn tap, incorrect pre-drill size, or machine not properly calibrated.
- Solution: Recalculate feed rate, replace the tap, check the pre-drill size, and verify machine calibration.
- Poor Thread Quality:
- Cause: Incorrect parameters.
- Solution: Check parameters.
- Machine Alarms:
- Cause: Syntax errors, incorrect parameters, exceeding machine limits, or problems with the spindle or axes.
- Solution: Consult the machine’s manual for alarm codes, check your program, and inspect the machine.
11. Conclusion: Precise and Efficient Threading
The G84 Tapping Cycle (both for face tapping on lathes and general tapping on machining centers) is a fundamental and powerful tool in CNC machining. It automates the complex process of creating internal threads, ensuring accuracy, consistency, and efficiency. By understanding the differences between its application on lathes and mills, the specific parameters for different control systems, and best practices for programming and troubleshooting, CNC machinists and programmers can significantly improve their threading operations and produce high-quality parts.