The Machine Daily
CNC Programming & G-Code

Essential CNC Machine G Code List: Technical Specs & Execution

Explore the essential CNC machine G code list with technical specs, controller execution logic, canned cycle mechanics, and servo troubleshooting.

Published Diana Kowalski

G-code (formally defined by the RS-274D and ISO 6983 standards) operates as the foundational instruction set for computer numerical control (CNC) machining. Rather than functioning as a simple list of commands, G-code dictates the exact kinematic behavior, servo response, and logic sequencing of the machine tool. Understanding the technical specifications behind these codes—how the controller parses blocks, manages look-ahead buffers, and interpolates axis movements—is critical for optimizing cycle times and preventing catastrophic collisions.

The Architecture of G-Code Execution: Modal vs. Non-Modal Groups

CNC controllers do not read G-code line-by-line in isolation; they process it through modal groups. A modal command remains active until explicitly canceled or replaced by another command within the same group. For example, G01 (linear interpolation) belongs to Modal Group 01. Once activated, the controller applies linear interpolation to all subsequent coordinate blocks until a different Group 01 command (like G00, G02, or G03) is invoked.

Conversely, non-modal (or 'one-shot') commands, such as G04 (Dwell) or G28 (Return to Home), belong to Group 00. These execute only within the specific block where they are programmed. Advanced controllers, such as the FANUC 31i-B5 or Haas NGC, utilize sophisticated look-ahead algorithms that pre-read hundreds of upcoming blocks to calculate acceleration/deceleration profiles, preventing servo lag during high-speed contouring.

⚠️ WARNING: G00 Non-Linear Rapids on Multi-Axis Machines

On standard 3-axis mills, G00 (Rapid Traverse) moves all axes simultaneously, resulting in a non-linear, dog-leg toolpath. On 5-axis machines with RTCP (Rotary Tool Center Point) enabled, executing G00 between extreme rotary angles can cause the tool tip to plunge violently into the workpiece or fixture. Always use G01 with a programmed feedrate for large angular transitions in 5-axis simultaneous machining.

Core Motion Commands: Technical Specifications & Interpolation

The core motion commands dictate the physical trajectory of the cutting tool. The controller's interpolator breaks these commands down into micro-movements, typically updating the servo drives every 1 to 4 milliseconds.

Command Modal Group Controller Execution Logic Jerk / Acceleration Control
G00 01 (Motion) Positions axes at maximum rapid traverse rate (parameter-defined). Ignores F-word. Max jerk; uses rapid acceleration time constants.
G01 01 (Motion) Linear interpolation. Calculates intermediate points to maintain exact F-word velocity. Corner deceleration applied based on angle deviation and tolerance parameters.
G02 01 (Motion) Clockwise circular interpolation. Requires I, J, K (center vectors) or R (radius). Centripetal acceleration limits cap the maximum feedrate based on arc radius.
G03 01 (Motion) Counter-clockwise circular interpolation. Mathematically identical to G02 with reversed vector logic. Identical centripetal limits; NURBS interpolation may override for smooth blending.

Canned Cycles: Chip Evacuation & Dwell Mechanics

Canned cycles condense complex, multi-block drilling and tapping sequences into a single line of code. The technical distinction between similar cycles often dictates tool life and surface finish quality, particularly in deep-hole drilling and rigid tapping.

  • G81 (Standard Drill): Executes a simple plunge to the Z-depth and rapid retracts to the R-plane (initial clearance) or G98 initial Z-level. No dwell is applied at the bottom of the hole.
  • G82 (Drill with Dwell): Identical to G81 but includes a P-word dwell (e.g., P500 for 0.5 seconds) at the Z-depth. Critical for spot facing and counterboring to ensure a flat, clean bottom surface before retraction.
  • G73 (High-Speed Peck Drill): Uses a micro-retraction (typically 0.010" to 0.020", defined by parameter) inside the hole to break chips without fully withdrawing the tool. Ideal for stringy materials like aluminum or mild steel where chip breaking is the primary concern.
  • G83 (Deep Hole Peck Drill): Fully retracts the tool out of the hole to the R-plane on every peck. This allows coolant to flood the cavity and completely clears chips. The Q word defines the peck depth (e.g., Q0.150), and subsequent pecks can be programmed to decrease in depth to account for increased tool deflection and heat.
  • G84 (Rigid Tapping): Synchronizes the spindle encoder (S-word) with the Z-axis servo to cut threads. The Z-axis feedrate must exactly equal the spindle RPM multiplied by the thread pitch. Reversal at the bottom of the hole is handled automatically by the controller's rigid tap logic.

Data Highlight: Controller Processing Speeds

Modern CNC controls process G-code blocks at varying speeds, which directly impacts surface finish during 3D contouring. A standard Haas NGC control processes up to 1,000 blocks per second with its High-Speed Machining option. FANUC's AI Contour Control II (AICC II) can process up to 1,200 blocks ahead, dynamically adjusting axis acceleration to maintain within a programmed tolerance band (e.g., 0.0002"), effectively eliminating dwell marks at sharp vector transitions.

Work Offsets and Coordinate Mapping Logic

The relationship between the physical machine and the programmed part is governed by Work Coordinate Systems (WCS), primarily G54 through G59. The controller calculates the absolute machine position using a strict mathematical hierarchy:

Machine Coordinates = Part Zero (Work Offset) + Tool Length Offset (H-word) + Programmed Coordinate (X, Y, Z)

When setting a G54 offset, the operator is defining the distance from the machine's absolute home position (established via G28 on startup) to the part's X, Y, Z zero datum. Advanced setups utilize G54.1 P1 through P300 for extended coordinate systems, allowing a single setup to machine multiple identical vises or tombstone faces without recalculating absolute coordinates in the CAM software. As noted in CNC Cookbook's G-Code Basics, failing to cancel a tool length offset (G49) or work offset shift (G92) before a tool change is one of the most common causes of Z-axis crashes in multi-tool programs.

Execution Failures: Troubleshooting Servo Lag and Alarms

Even perfectly formatted G-code can trigger machine alarms if the programmed kinematics exceed the physical capabilities of the servo drives. Understanding these failure modes is essential for advanced programmers.

Following Errors (e.g., FANUC Alarm 411 / Haas Alarm 107):
A following error occurs when the actual axis position lags behind the commanded G-code position beyond the acceptable parameter threshold. This frequently happens during G01 linear moves at high feedrates or G02/G03 arcs with tight radii. The controller demands a velocity change that the servo motor's torque cannot physically achieve. Fix: Reduce the F-word feedrate, increase the arc radius, or verify that the machine's guideways are properly lubricated to reduce static friction.

Over-Travel Alarms (e.g., Alarm 500/501):
Triggered when a G-code coordinate commands an axis beyond the physical limit switches or the soft limits defined in the controller's parameters. This often occurs when a programmer forgets to account for the tool length in the Z-axis, or when a G28 (Return to Home) command is executed without first retracting the Z-axis to a safe clearance plane, causing the X or Y axis to drag the tool through the fixture.

Format and Syntax Errors (e.g., Alarm 010):
Controllers are unforgiving regarding syntax. Missing decimal points in imperial mode (G20) can cause catastrophic scaling errors. For instance, programming Z-100 instead of Z-1.00 in G20 mode commands the machine to move 100 inches, not 1 inch. Modern controllers often include a parameter setting to assume a trailing decimal if omitted, but relying on this is a dangerous practice in aerospace and medical machining where tolerances are measured in tenths (0.0001").