G81 and G82 G-Code: Standard Drilling and Counterboring Cycles
Master G81 and G82 G-code drilling cycles on Fanuc, Siemens, and Mitsubishi. Learn parameters, avoid tool collision, and analyze common alarm codes.
Introduction
Commanding standard rapid traverse or linear positioning coordinates while a canned drilling cycle remains modally active drives the tool turret or spindle directly into a workpiece clamp, vise jaw, or the chuck barrier at maximum rapid speed. Instead of safely clearing the workspace, the tool plunges violently, causing a catastrophic hard collision that bends the machine spindle, shatters the solid carbide drill, and instantly transforms an expensive workpiece into a scrapped part. This severe operational hazard typically occurs during setup or manual recovery when an operator commands coordinate moves without explicitly canceling the modal cycle with a G80 instruction. Maintaining absolute modal hygiene and understanding the underlying parameter controls is the only way to prevent these uncommanded plunges and safeguard costly machine assets.
Technical Summary
| Technical Attribute | Specification / Value |
|---|---|
| Command Codes | G81, G82 (Fanuc, Mitsubishi, Siemens ISO); CYCLE81, CYCLE82 (Siemens Native) |
| Modal Group | Group 09 (M-series) / Group 10 (T-series) for Fanuc; Fixed Cycle for Siemens and Mitsubishi |
| Applicable Brands | Fanuc, Siemens, Mitsubishi |
| Critical Parameters | Fanuc (5101#0 FXY, 5101#1 EXC, 5105#4 KOD); Siemens (<_GMODE>, <_DMODE>, <_AMODE>); Mitsubishi (#1080 Dril_Z, #19417, #1265) |
| Primary Constraint | G40 (compensation cancel) and spindle rotation (M03/M04) must be active before cycle initiation; cycles must be explicitly canceled via G80 before zero returns or tool changes. |
Quick Read
- Enforce Explicit Cancellation: Always program an explicit G80 canned cycle cancellation command prior to executing zero returns (G27-G30) or tool changes to prevent automatic interpreter lockouts.
- Deactivate Cutter Compensation: Enforce G40 cutter or nose radius compensation cancellation before calling G81 or G82 to prevent alarm stops (such as Siemens Alarm 61815 or Mitsubishi P29).
- Monitor Retraction Levels: Select G98 for initial plane return when crossing mechanical clamps or fixtures, or G99 for R point return to minimize cycle time in flat, unobstructed areas.
- Audit Deceleration Checks: Configure Mitsubishi parameter #19417 or Siemens deceleration checks to ensure axes achieve proper positioning tolerances at the hole bottom before retracting.
- Check Spindle Direction: Confirm the spindle is active (M03 or M04) before initiating the drilling plunge, as starting a canned cycle without active rotation causes instant tool breakage.
- Deconflict Group 01 Commands: Be aware that issuing standard motion codes (G00 or G01) will automatically trigger implicit cancellation of G81/G82 modal data across Fanuc, Siemens, and Mitsubishi.
Basic Concepts
The standard drilling cycle G81 and counterboring cycle G82 are designed to condense complex multi-axis motion sequences into a single, automated, and modally active G-code block. A standard G81 cycle initiates a rapid traverse to the specified X and Y coordinates, plunges the tool along the designated drilling axis to the programmed Z-depth at a controlled cutting feedrate, and immediately executes a rapid traverse retraction back to either the initial plane or the reference R-plane. This automation dramatically reduces program length and eliminates the human error associated with manually writing rapid and linear interpolation lines for every single hole in a multi-hole pattern.
The G82 cycle introduces a critical modification to the standard G81 sequence by executing a programmable dwell time (P or DTB) at the absolute bottom of the drilling plunge. This brief pause allows the spindle to complete several full rotations at maximum depth, which is essential for counterboring, spot facing, or countersinking operations. The dwell ensures that the cutting edges of the tool cleanly shear away the remaining chips at the hole bottom, establishing a perfectly flat, highly accurate surface and preventing irregular finishes or dimensional errors. Both cycles rely heavily on strict modal tracking, meaning that any coordinate programmed after the cycle block will automatically execute another drilling sequence at that new location until the cycle is explicitly cancelled.
Command Structure
The syntax of standard drilling and counterboring cycles is structured around primary coordinate coordinates, feedrates, and specific auxiliary commands. The primary coordinates define the physical hole position (typically X and Y in the G17 plane) and the target depth of the hole bottom (Z-axis). The reference clearance height is designated by the R address, which represents the safe distance above the workpiece where the controller switches from rapid traverse (G00) to cutting feedrate (G01). Because these cycles are modal, once initiated, any subsequent block containing coordinate coordinates will automatically trigger another drilling sequence at the new position.
In G82 counterboring applications, the addition of the P address specifies the dwell duration at the hole bottom. This parameter is interpreted differently depending on the controller system, often representing milliseconds or seconds. Repeating a hole-making sequence is achieved through the K or L address, which tells the controller to repeat the drilling sequence a specified number of times along a grid or bolt-hole circle. For tapping applications that require corner overrides or spindle speed synchronization, refer to the G62 and G63 corner override and tapping manual sections. Programmers can force the tool to decelerate completely at the bottom of the hole by referencing G60 exact stop positioning, guaranteeing precise depth control.
The standard syntax formats across the major CNC brands are defined as follows:
- Fanuc Milling (M-Series):
G81/G82 X_ Y_ Z_ P_ R_ F_ K_ ; - Siemens Native Mode:
CYCLE81(RTP, RFP, SDIS, DP, DPR, DTB)andCYCLE82(RTP, RFP, SDIS, DP, DPR, DTB, ...) - Mitsubishi Machining Center:
G81/G82 X_ Y_ Z_ R_ F_ P_ L_ ,I_ ,J_ D_ E_ ;
The primary cycle parameters and coordinate addresses are detailed in the table below:
| Address | Description | Details |
|---|---|---|
| X, Y | Hole position coordinates | Defines coordinates in the active machining plane. |
| Z | Hole bottom coordinate | Specifies the depth along the drilling axis. |
| R | Clearance plane | The R-plane height where feedrate plunge begins. |
| P | Dwell time | Dwell duration at hole bottom (milliseconds; ignored on legacy systems). |
| DTB | Siemens Native Dwell | Dwell time at bottom specified in seconds. |
| F | Cutting feedrate | Plunge feedrate along the drilling axis. |
| K / L | Repetitions | Specifies the number of repetitions. |
| ,I / ,J | In-position width | Mitsubishi specific programmable positioning check. |
| D / E | Spindle assignment | Mitsubishi optional spindle number and chip removal frequency. |
Brand Applications
Fanuc
The Fanuc implementation focuses on rigid coordinate integration and parameter-driven behavior. Parameter 5101#0 determines the drilling axis, whereas parameter 5105#4 dictates what happens when the repetition K value is set to zero.
Programmers can invoke the cycles using standard G81 or G82 blocks followed by the coordinate positions. The G81 command can also be overloaded on specialized hobbing or electronic gear box (EGB) machines to act as a synchronization start command.
| Fanuc Configuration | Parameters | Alarms & Alarms Trigger | Version Differences |
|---|---|---|---|
| Drilling Axis & Functions | Parameter 5101#0 (FXY): 0 = Always Z-axis, 1 = plane selected; Parameter 5101#1 (EXC): 0 = Standard canned, 1 = External operation | Alarm 044 (PS0044): G27-G30 called in canned cycle; Alarm 1196 (PS1196): Illegal drilling axis or zero point missing | On M-series, G81 represents spot drilling; on hobbing/EGB machines, G81 acts as synchronization start (`G81 T_ L_ Q_ P_`). |
| Repetition & Legacy formats | Parameter 5105#4 (KOD): 0 = Memorize, 1 = Force one run on K0; Parameter 5102#6 (RAB) / 5102#7 (RDI) for legacy R interpretation | — (no source) | Legacy FS10/11 or FS15 tape formats support absolute/incremental R coordinate interpretations via parameters. |
Warning: Standard motion codes like G00 or G01 will implicitly cancel an active canned cycle, clearing all modal data instantly. Always use G80 to cancel explicitly and ensure clean program structures.
Siemens
The Siemens SINUMERIK control offers standard dual-language parsing that dynamically routes G81/G82 commands through underlying native cycles. It allows programmers to use G290 and G291 to toggle between native and ISO dialect programming modes.
Siemens programs can run standard CYCLE81 or CYCLE82 blocks natively, or execute standard G81/G82 G-code lines in ISO mode. When G81 or G82 is parsed in ISO Dialect mode, the control maps inputs to the CYCLE381M shell cycle.
| Siemens Configuration | Parameters | Alarms & Alarms Trigger | Version Differences |
|---|---|---|---|
| Native & ISO Mode Dual Parsing | <_GMODE>: Geometrical mode; <_DMODE>: Display plane G17-G19; <_AMODE>: Alternative depth/dwell mode | Alarm 61808: Depth Z or feed rate Q missing; Alarm 61815: Cutter compensation active (G41/G42) | ISO mode routes calls through shell cycles `CYCLE381M` (milling) or `CYCLE375T` (turning) to native `CYCLE81`/`CYCLE82`. |
| Hole Patterns & Nesting | DTB: Dwell time in seconds at bottom of the hole | Alarm 62100: Modal hole pattern called without active cycle; Alarm 12722: Multiple macro/cycle calls stacked in same block | Seamless on-the-fly toggling allows mixed programs using native Siemens G290 and ISO Dialect G291. |
Warning: Failure to cancel cutter radius compensation (G41/G42) via G40 before calling standard cycles will trigger an interpreter stop, halting production immediately.
Mitsubishi
The Mitsubishi control allows operators to configure positioning tolerances directly in the canned cycle block. Using parameters #1080 and #19417, the control manages axis alignment and deceleration checks.
Mitsubishi machining centers natively support standard G81/G82 fixed cycles. On lathes, the MITSUBISHI CNC Special Format must be enabled using parameter #1265 to condense operations into single blocks.
| Mitsubishi Configuration | Parameters | Alarms & Alarms Trigger | Version Differences |
|---|---|---|---|
| Positioning Tolerances & Lathe Special Format | Parameter #1080 (Dril_Z): Fixes drilling axis to Z; Parameter #1265 (ext01/bit0): Standard ISO or special format | Alarm P29: Compensation active (G41/G42); Alarm P35: Programmable in-position width out of range | Machining centers natively support G81/G82. Lathe L-systems require special format and support dynamic cross-tap PLC swaps to Y-axis. |
| Deceleration Checks | Parameter #19417: Decel checks (0 = none, 1 = command decel, 2 = in-position check sv024) | Alarm P62: Feedrate F omitted or zero | — (no source) |
Warning: Command deceleration checks and in-position check sv024 verification must be within physical ranges, or the machine will throw program errors during positioning.
Brand Comparison
| Topic | Fanuc | Siemens | Mitsubishi |
|---|---|---|---|
| Syntax Toggles | Standard G81/G82 fixed cycles | Dual interface: Native `CYCLE81`/`82` or ISO Dialect G81/G82 | Machining Center (standard) vs. Lathe (Special Format 1-block) |
| Decoupling Drilling Axis | Parameter 5101#0 (FXY) dynamically maps axis based on plane | Fixed cycle must be deselected before changing orthogonal plane | Parameter #1080 Dril_Z fixes to Z, or swappable via PLC (cross-tap) |
| Implicit Cancellation | Group 01 motion code G00/G01 instantly aborts canned cycle | Group 01 motion cancels G81/G82 modal state automatically | Group 01 (G00/G01) command in cycle block ignores cycle data entirely |
| Hole-Bottom Dwell | Programmed with `P` (milliseconds, no decimal) | Programmed with `P` in ISO mode, or `DTB` (seconds) in native mode | Programmed with `P` (milliseconds, decimal ignored) |
| Position Accuracy / Width | Handled at system parameter level globally | Standard channel parameter checks | Programmable in-position widths directly in cycle block via `,I` and `,J` |
Technical Analysis
An analytical review of G81 and G82 cycles shows significant differences in how controllers handle execution and coordinate parsing. Siemens relies on a flexible shell cycle translation backend. In ISO Dialect mode, G81 and G82 blocks do not run as hardcoded macros. The control captures addresses in system variables like `$C_x` and routes them through a shell cycle (`CYCLE381M`), calling native `CYCLE81`/`CYCLE82`. This permits deep diagnostic checks and dynamic scaling that legacy Fanuc and Mitsubishi systems cannot perform without manual parameter updates. Siemens also enables seamless on-the-fly language toggling via G290 (native Siemens) and G291 (ISO Dialect) commands, preserving active offsets and coordinate frames.
Fanuc and Mitsubishi handle modal safety and axis configuration through separate mechanisms. Fanuc allows builders to decouple the plunge axis from the Z-axis via Parameter 5101#0 (FXY). When enabled, the control dynamically selects the drilling axis based on the active G17/G18/G19 plane. Mitsubishi offers a similar but more granular axis control, using Parameter #1080 (Dril_Z) to lock drilling to the Z-axis, or cross-tap options to dynamically swap the drilling axis to the Y-axis via PLC signals. For modal cancellation, all three brands support implicit cancellation via Group 01 motion commands, but their execution differs. Fanuc and Siemens automatically abort the cycle upon reading G00/G01, while Mitsubishi ignores the cycle plunge instructions entirely and executes only the physical movement.
Hole-bottom accuracy and dwell interpretation highlight another area of brand divergence. G82 dwell time `P` is parsed as milliseconds without decimal points in Fanuc. Mitsubishi also interprets `P` in milliseconds and ignores decimal points. Siemens uses seconds for native `DTB` parameters or revolutions in CYCLE82. Direct programmable in-position width adjustments are supported on Mitsubishi controls directly in the cycle block using `,I` and `,J` addresses. This forces the control to check specific positioning tolerances on the active axes before starting the Z-axis plunge, providing a level of geometric quality control that Fanuc and Siemens support through global machine parameters.
Program Examples
Fanuc Drilling and Counterboring Examples
G90 G99 G81 X20.0 Y30.0 Z-15.0 R2.0 F150 K1 ;
G82 X40.0 Y50.0 Z-20.0 P500 R2.0 F100 ;
G80 ;
Dry Run Procedure (Fanuc):
- Use JOG mode to back the tool turret far enough from the workpiece to ensure axis acceleration.
- Input G21 to select millimeter units and verify Tool Length Compensation (G43 H1) is active.
- Run the program in Dry Run mode with the feedrate override set to a low value.
- Observe G81 plunge to Z-15.0, retract to R2.0, move to the second hole, plunge G82 to Z-20.0, dwell for 500ms, and retract.
- Verify that G80 cancels the cycle and absolute coordinates on the HMI match the programmed coordinates.
Siemens Native CYCLE81 and CYCLE82 Examples
; Siemens Native CYCLE81 and CYCLE82
G90 G17 G40 ;
CYCLE81(110.0, 100.0, 2.0, 35.0, 0.0) ;
CYCLE82(110.0, 102.0, 4.0, 75.0, 0.0, 2.0) ;
G80 ;
Dry Run Procedure (Siemens):
- Select native Siemens mode using G290 and verify cutter compensation is canceled via G40.
- Initiate the program in Single Block mode to monitor each coordinate shift.
- Observe CYCLE81 plunge to absolute depth DP=35.0 relative to reference plane RFP=100.0 with safety clearance SDIS=2.0.
- Monitor CYCLE82 dwell time DTB=2.0 seconds at the hole bottom (DP=75.0) before rapid retraction to RTP=110.0.
- Confirm that no coordinate drift occurred and the NCK registers no alarm codes.
Mitsubishi M-system and Special Format Examples
G91 G81 X-50. Z-50. R-50. L2 F2000 ,I0.2 ,J0.3 ;
G82 X100. Y100. Z-50. R25. F1000 P500 ;
G80 ;
Dry Run Procedure (Mitsubishi):
- Select incremental mode using G91 and ensure tool nose compensation is inactive.
- Set the dry run switch on the operator panel to ON to test tool path trajectories.
- Observe G81 execute two repetitions (L2) with a programmable in-position width tolerance of 0.2mm on positioning and 0.3mm on drilling.
- Monitor G82 moving to X100. Y100., plunging to incremental depth Z-50.0 relative to R25.0, and dwelling for 500ms.
- Execute G80 to cancel the canned cycle and ensure the turret moves safely to the home position.
Error Analysis
| Brand & Alarm Code | Trigger Condition | Operator Symptom | Root Cause / Practical Resolution |
|---|---|---|---|
| Fanuc Alarm 044 (PS0044) | Reference position return (G27-G30) commanded during active canned cycle. | Motion stops; screen displays PS0044 error; cycle execution is blocked. | Attempting a G28 zero return before canceling the cycle. Program an explicit G80 before zero returns or tool changes. |
| Fanuc Alarm 1196 (PS1196) | Illegal axis specified or drilling axis zero point is not specified. | Plunge fails; screen shows ILLEGAL DRILLING AXIS SELECTED; cycle stops. | Drilling axis coordinate omitted in G81/G82 block or invalid plane selection. Verify plane (G17/G18/G19) and axis coordinates. |
| Siemens Alarm 61808 | Total depth Z or feed parameter Q is missing from the initial G8x block. | Interpreter stops; active machining halts; cycle is rejected. | Missing depth definition. Program the absolute Z depth or incremental depth in the initial block. |
| Siemens Alarm 61815 | Cutter compensation G41/G42 active during cycle call. | Interpreter stop occurs; program execution is interrupted. | Active cutter compensation. Program a G40 to deactivate compensation before the fixed cycle call. |
| Siemens Alarm 62100 | Modal drilling pattern (HOLES1/HOLES2) called without an active modal drilling cycle. | Cycle terminates; machine axis remains stationary. | Calling hole patterns without a preceding G81/G82 cycle. Program a modal cycle before calling pattern macros. |
| Mitsubishi Alarm P29 | G81 or G82 called while Tool Nose Radius Compensation (G41/G42) is active. | Machine execution halts; P29 error is displayed. | Attempting fixed cycle during tool radius compensation. Issue a G40 command prior to G81/G82. |
| Mitsubishi Alarm P35 | Programmable in-position width `,I` or `,J` exceeds the range of 0.001 to 999.999 mm. | Cycle initiation is aborted; program error is thrown. | Width values out of range. Check `,I` and `,J` parameters and ensure they are within valid ranges. |
| Mitsubishi Alarm P62 | Feedrate F is omitted or programmed as F0. | Machine axis remains stationary; P62 error appears. | Omitted feedrate. Ensure a non-zero F rate is specified in or prior to the cycle block. |
Application Note
Shattering the solid carbide drill, stripping the workpiece threads, and bending the spindle bearings is the direct physical consequence of attempting to index the tool turret or execute a tool change while a G81 or G82 canned cycle remains active in the controller's memory. When an emergency stop or manual program interruption occurs during a drilling run, operators frequently try to retract the tool and perform a rapid movement to clear the workspace. If the canned cycle is not explicitly canceled via G80, any subsequent coordinate move will be interpreted by the controller as a new hole location. This causes the machine to plunge the tool at rapid feed directly into physical obstacles such as a chuck, vise jaw, or workpiece clamp. To prevent these catastrophic collisions, programmers must configure active clearance planes using G98 or G99, ensure that tool nose radius compensation (G40) is disabled prior to cycle calls, and verify that the spindle rotation (M03) is fully stabilized before the tool plunges. Manual recovery must always begin with an explicit G80 command in MDI mode before any manual axis movement is executed.
Related Command Network
- G80 canned cycle cancellation: Deactivates active canned cycles and clears modal parameters to prevent uncommanded plunges.
- G98 / G99: Defines whether the tool retracts to the initial plane level (G98) or the reference R-plane level (G99) between holes.
- G83: Implements peck drilling for deep-hole applications to facilitate chip evacuation and prevent tool overheating.
- G84: Automates tapping cycles using synchronized spindle rotation and feedrate scaling.
- G85 / G86 / G87: Executes boring cycles with varying dwell and spindle retraction behaviors.
Conclusion
Eliminating uncommanded tool plunges and optimizing drilling cycle times depends entirely on maintaining strict modal command hygiene and verifying brand-specific parameters before program execution. Enforcing the use of G80 to cancel active cycles before tool changes or zero returns removes the risk of turret collisions. Routinely auditing parameter bits, such as Fanuc 5101#0 (FXY) for drilling axis selection or Mitsubishi #19417 for deceleration checks, ensures the CNC controller executes drilling cycles with consistent accuracy and safe clearances.
Frequently Asked Questions
Why does a G81 or G82 cycle block trigger an alarm when cutter radius compensation (G41/G42) is active?
CNC controllers block canned cycle execution while G41 or G42 is active because tool compensation algorithms require continuous linear or circular interpolation vectors, which conflict with the automatic vertical plunge sequences of drilling cycles. If compensation is left enabled, the machine cannot safely calculate the tool path, resulting in Siemens Alarm 61815 or Mitsubishi P29. Practically, you must insert a G40 command to deactivate all tool nose or cutter compensation before calling G81 or G82, and re-engage G41/G42 only after the cycle is cancelled.
What happens if a standard G00 or G01 motion command is programmed while a canned drilling cycle is active?
Commanding any Group 01 motion code (like G00 or G01) triggers implicit cycle cancellation across Fanuc, Siemens, and Mitsubishi controllers. The system interprets the motion command as an instruction to abort the canned cycle, clearing all modal drilling data and executing only the programmed linear movement. While this implicit cancellation works, relying on it is bad programming practice. Programmers should always explicitly command a G80 to cancel the cycle, ensuring a clean modal state before any subsequent positioning moves.
How do you choose between G98 and G99 retraction levels when programming standard drilling cycles?
Selecting G98 forces the tool to retract to the initial z-plane height between holes, while G99 retracts the tool only to the closer R-plane clearance level. G99 reduces cycle time by minimizing tool travel, but it presents a major crash hazard if the tool must traverse over obstacles like vise jaws or clamps. Practically, you must use G98 when crossing physical obstacles and reserve G99 only for drilling contiguous holes in flat, unobstructed areas of the workpiece.
Still not resolved?
Ask our AI assistant about this topic in natural language. Grounded in verified sources, no hallucinations.

- CNC CARE Co-Founder (May 2025 - Present)
- Mitsubishi Electric NC Sales & Service Section Manager (2008 - 2025)
- Reis CNC Service Engineer (2003 - 2005)
- Ören Kalıp CNC Mold Line Team Leader (1999 - 2002)
With over 25 years of experience working in all areas of the CNC machine industry, I continue my activities as a co-founder of CNC CARE, where we offer brand-independent consulting, engineering, and original spare parts services.
Related Articles
Other articles on this topic
Siemens CYCLE800 G-Code: Swivel Planes & Tool Alignment
Master Siemens CYCLE800 for 3+2 axis machining. Learn plane swiveling, tool alignment, parameter setup, and how to troubleshoot Alarm 61190 and 61153.
Siemens CYCLE72 Contour Milling: Guide to Sinumerik Path Milling
Master Siemens CYCLE72 for contour milling on Sinumerik CNC controls. Learn parameter setup, avoid simulation alarm 61123, and prevent machine collisions.
Siemens CYCLE952 Contour Turning Cycle Programming Guide
Master Siemens CYCLE952 contour turning on Sinumerik CNC controls. Learn parameter lists, resolve Alarm 61051, and configure balance cutting.
Siemens SLOT1 and SLOT2 Slot Milling Cycles Programming Guide
Master slot milling on Siemens Sinumerik controls using SLOT1 and SLOT2 cycles. Learn parameter configurations, alarm 61000 prevention, and optimal tool paths.