Advanced G-Code • CNC Engineering • 2026

Mastering CNC Circular Interpolation: The Ultimate G02 & G03 Programming Guide

An exhaustive, shop-floor manual for vertical and horizontal machining centers. Master plane selections (G17/G18/G19), 'R' programming vs. incremental IJK vectors, cutter compensation, helical interpolation, and feed rate compensation equations.

By Nishikant Xalxo 5,500+ Words Deep Dive Updated May 25, 2026

Table of Contents

Introduction: The Evolution of Circular Motion

In the landscape of Computer Numerical Control (CNC) manufacturing, the ability to command machine tools to move along precise circular trajectories represents the divider between rudimentary component shaping and high-precision aerospace, medical, and automotive engineering. At the heart of this capability lie two primary modal G-codes: G02 (Circular Interpolation Clockwise) and G03 (Circular Interpolation Counter-Clockwise). Without these commands, machining a simple bore, thread, cylindrical boss, or o-ring groove would become an absolute programming nightmare.

Historically, in the infancy of NC systems during the 1950s and early 1960s, machine controls were unable to process complex arcs directly. Hardware constraints meant that curves had to be broken down into extremely small, discrete linear segments. A simple 2-inch diameter circle might require hundreds of lines of linear coordinate points (G01 commands) to approximate a curved surface. This method, known as linear approximation, suffered from severe critical limitations:

  • Enormous File Sizes: The storage media of the era—primarily punched paper tapes—had strictly limited memory capacities. Storing thousands of lines of linear coordinates for a single contour was physically impossible or highly impractical.
  • Data Starvation (Buffer Starvation): Early NC controllers had low processing speeds and small input buffer sizes. When running short linear segments at high feeds, the controller could not process incoming lines fast enough, leading to rapid decelerations, surface stuttering, axis dwell marks, and poor surface finishes.
  • Aesthetic & Tolerance Failures: Under magnification, linear approximations look like polygons. Meeting tight geometric tolerances (such as circularity and roundness within 0.0002 inches) was technically unachievable.
Circular Interpolation Calculator showing circular interpolation paths and coordinates
Figure 1: The SHADER7 CNC Machinist Hub features a specialized Circular Interpolation Calculator to calculate G02/G03 coordinate paths, IJK offsets, and feed rate compensation parameters.

The breakthrough came with the introduction of hardware-based circular interpolators embedded directly into the machine control unit (MCU). By supplying only the endpoint of the arc and the location of the circle's center (or the radius of the desired curve), the controller's internal algorithms took over. Using real-time differential equation solving, the controller coordinates the voltages and pulse frequencies directed to the orthogonal servo motors, executing a smooth, continuous, and mathematically perfect arc.

Today, even with modern Computer-Aided Manufacturing (CAM) systems generating millions of lines of code, a deep, manual command of G02 and G03 is a core requirement for any high-level CNC programmer, applications engineer, or setup machinist. Relying blindly on CAM software post-processors without understanding the raw G-code leads to scrap parts, broken tooling, and catastrophic spindle crashes. On a fast-paced production floor, adjusting a circular toolpath to account for tool deflection or bore tolerances is a basic task, and manually writing toolpath entries at the control panel separates elite machinists from operators.

1. Mathematical Concept & Cartesian Planes (G17/G18/G19)

Before commanding a CNC machine tool to swing an arc, we must understand the mathematical representation of circles in two-dimensional Cartesian space. A circle with center coordinate \((X_c, Y_c)\) and radius \(R\) is represented by the standard Cartesian equation:

(X − Xc)2 + (Y − Yc)2 = R2

During a circular interpolation command, the CNC controller must calculate the continuous coordinates along the arc, moving two linear axes simultaneously. For a constant linear path feed rate \(F\), the velocity vector of the tool must be dynamically resolved into individual axis velocities (\(V_x\) and \(V_y\)) at every millisecond step of the toolpath:

Vx = F × sin(θ)  •  Vy = F × cos(θ)

Where \(θ\) represents the instantaneous angle of the tool relative to the arc's center. As the tool moves along the arc, one axis is accelerating while the other is decelerating, following a sinusoidal curve. If the synchronization between the two axes is off by even a microsecond, the circle will distort, resulting in ovality.

The Critical Plane Selection: G17, G18, and G19

A standard vertical machining center operates with three primary linear axes: X, Y, and Z. However, circular interpolation is fundamentally a two-dimensional mathematical operation. Therefore, the CNC controller must know which 2D plane the circular arc is to be projected onto. If this plane is not explicitly set, the machine may execute the arc in an incorrect plane, leading to immediate tool wreckage or severe spindle collisions.

The G-code standard establishes three distinct plane selection commands:

G-Code Active Plane Interpolation Axes Incremental Center Vectors Primary Application
G17 XY Plane X and Y Axes I (for X) and J (for Y) Standard vertical mills (VMC), pocketing, profiling, face milling.
G18 ZX Plane Z and X Axes K (for Z) and I (for X) CNC Lathes, turning centers, horizontal mills (HMC), right-angle heads.
G19 YZ Plane Y and Z Axes J (for Y) and K (for Z) Side milling on VMCs with right-angle attachments, horizontal machining centers.

G17: The XY Plane (Default Standard)

On almost all vertical machining centers (VMCs), the XY plane is the startup default. In this mode, G02/G03 commands move the X and Y axes, while any specified Z motion creates a helical spiral. The incremental vectors defining the circle center are I (offset along X) and J (offset along Y).

G18: The ZX Plane (Lathes & Turning)

The G18 plane selects the ZX plane. This is the default mode for horizontal CNC turning centers (lathes), where X controls diameter and Z controls part length. It is also utilized in multi-axis milling when using 3D ball-nose cutters or specialized boring attachments. The center vector offsets are K (offset along Z) and I (offset along X).

Critical Lathe Safety Warning: On standard CNC lathes, the X-axis is programmed in diameter (double the radius). However, when calculating I offsets for G18 arcs, some control parameters require the I value to be in radius, while others require it in diameter. Consult the specific machine manual before programming, as this discrepancy is a leading cause of massive lathe setup crashes.

G19: The YZ Plane (Horizontal & Angle Machining)

When selecting G19, the active axes are Y and Z. The center vector offsets are J (offset along Y) and K (offset along Z). G19 is predominantly active in horizontal machining centers (HMCs) where the spindle axis lies parallel to the floor, or when machining side features on standard VMCs using a right-angle drive head.

2. G02 (CW) and G03 (CCW) Syntax & Commands

The direction of the circular arc must be specified as either clockwise (G02) or counter-clockwise (G03). This direction is defined from a specific viewing perspective: looking down from the positive axis of the third, non-interpolating axis onto the active plane.

  • In the G17 XY Plane: Look down from the positive Z-axis toward the Z0 plane. Clockwise is standard right-turn motion; counter-clockwise is left-turn.
  • In the G18 ZX Plane: Look down from the positive Y-axis toward the Y0 plane. Because of mathematical conventions, the direction can feel inverted to new operators. Programmers must trace the path carefully.
  • In the G19 YZ Plane: Look down from the positive X-axis toward the X0 plane.

Syntax Structuring Across Modern CNC Control Systems

While the G-code standard (EIA/ISO RS-274-D) defines standard formats, different control builders have implemented variations that programmers must match to their specific shop-floor machines.

1. Fanuc and Haas standard formats (ISO G-Code)

Fanuc and Haas controls share identical syntax. The basic circular block requires the destination endpoint coordinates, the circle center definition (via radius R or vectors IJK), and the feed rate.

G17 G90 G02 X2.0 Y3.0 R1.5 F15.0  (Standard Radius Format in G17)
G17 G90 G02 X2.0 Y3.0 I1.5 J0.0 F15.0  (Standard Vector Format in G17)

2. Siemens 840D / Sinumerik format

The Siemens 840D control is highly flexible and features advanced syntax. It supports standard ISO IJK syntax, but also provides a direct Circle Radius parameter: CR.

G2 X20 Y30 CR=15 F300 (CR is circle radius. Positive for arc <= 180°, negative for arc > 180°)
G2 X20 Y30 I=15 J=0 F300 (Note the equal sign requirements in native Siemens programming)

Siemens also supports polar coordinate commands, defining an arc endpoint using Polar Angle (AP) and Polar Radius (RP) relative to a previously defined pole.

3. Mazak (EIA/ISO vs. Mazatrol)

Mazak milling and multitasking machines run either standard EIA/ISO G-code (identical to Fanuc) or Mazatrol, their proprietary conversational language. In Mazatrol, the operator describes the geometry (such as unit shape, circle diameter, starting angle, and finish width) instead of writing physical coordinate lines. The internal machine post-processor dynamically converts these inputs to G02 and G03 motions in the background.

4. Heidenhain conversational

Heidenhain operates under a completely distinct conversational format. Instead of standard G-codes, it uses explicit verbal commands:

10 CC X+50 Y+50  ; Define Circle Center at absolute coordinates
11 C X+75 Y+50 DR+ F500 M3 ; CCW circle path to endpoint (DR+ is equivalent to G03)

The Modal Nature of Circular Commands

G02 and G03 are modal G-codes. This means once a circular command is issued, it remains active in the controller's memory. All subsequent blocks of code will be interpreted as circular moves until a different motion code (such as G00 rapid traverse or G01 linear interpolation) is commanded.

Dangerous Programming Trap: If an operator executes an arc and then plans to execute a linear exit, but forgets to insert the G01 command, the machine will interpret the next endpoint coordinates as another circular arc of the same radius. The tool will swing wildly in a circle, gouging the part, snapping the tool, and potentially overloading the spindle. Always explicitly declare G01 or G00 immediately after completing a G02/G03 sweep.

3. Radius 'R' vs. Vector 'IJK' Offsets

When programming a circular arc, the controller must calculate the circle's center to coordinate axis motors perfectly. The programmer has two choices to specify the center coordinates: the **R-Word (Radius) method** or the **IJK Incremental Vector offset method**.

The Radius (R) Programming Method

The R-word method is simple. The programmer defines the destination absolute endpoint coordinates (X, Y) and the radius of the arc (R). The machine control automatically calculates the circle's center in the background.

However, this simplicity introduces a major mathematical challenge: The Ambiguity of Two Arcs. For any given start point, end point, and radius, there are actually two mathematical arcs that can connect them. One arc spans an angle less than or equal to 180 degrees, while the other spans an angle greater than 180 degrees.

The G-Code Radius Sign Convention

To resolve this mathematical ambiguity, the CNC standard assigns signs to the R parameter:

  • Positive R (+R): Instructs the controller to execute the arc that is **less than or equal to 180 degrees** (standard profile blends).
  • Negative R (-R): Instructs the controller to execute the arc that is **greater than 180 degrees**.

The Fatal Flaw of R-Word Programming

Despite its ease of use, the R-word method has severe, dangerous drawbacks on the shop floor:

  1. No Full-Circle Support: You cannot program a complete 360-degree circle in a single block using an R-word. If the start point and the end point are identical (e.g., machining a cylindrical pocket), the machine has an infinite number of possible center points for that radius. A block like G02 X0.0 Y0.0 R1.0 will either cause the machine to stand completely still or throw a "Zero Radius Arc" alarm. The programmer is forced to split the circle into two separate 180-degree arcs, which doubles the code size and can create physical blend marks (small steps) on the finished bore.
  2. Precision and Safety Risk: If there is a rounding error in the programmed endpoint coordinates, the physical distance between the start and end points may exceed the diameter of the programmed radius. If this happens, the mathematical equation has no solution. The CNC controller will either pause with a sudden motion alarm mid-cut (leaving a mark on the part) or automatically "compensate" by shifting the center point, cutting a distorted radius, and scrapping the workpiece.

The Incremental Vector Offset Method (IJK)

The IJK vector offset method is the global industry standard for high-precision, production-grade G-code. In this mode, the programmer explicitly defines the exact coordinates of the circle's center using incremental distance vectors:

  • I: The incremental offset vector parallel to the X-axis from the arc's start point to the center.
  • J: The incremental offset vector parallel to the Y-axis from the arc's start point to the center.
  • K: The incremental offset vector parallel to the Z-axis from the arc's start point to the center.

Calculus of IJK Vector Coordinates

Under absolute programming (G90), while the destination coordinate values (X, Y) are absolute values relative to the Work Coordinate System (WCS) origin (such as G54), the I, J, and K values are strictly incremental offsets measured from the starting point of the arc.

X-Axis Center Calculation: I = Xcenter − Xstart
Y-Axis Center Calculation: J = Ycenter − Ystart

Step-by-Step Mathematical Calculation of IJK Values

Let us calculate the IJK parameters for a 90-degree clockwise (G02) circular arc in G17 (XY plane):

  • Arc Start Point: X10.000, Y20.000
  • Arc Target End Point: X25.000, Y35.000
  • Arc Center Coordinates: X25.000, Y20.000 (Radius = 15.000)

Now, let's calculate the incremental offsets:

I = Xcenter - Xstart = 25.000 - 10.000 = +15.000
J = Ycenter - Ystart = 20.000 - 20.000 = 0.000

The completed, absolute (G90) G-code block for this sweep is:

G90 G02 X25.000 Y35.000 I15.000 J0.000 F200.0

Why IJK is Highly Recommended and Safer

  • Supports 360-Degree Circles in One Block: Since IJK defines the center point explicitly, you can program a full circle by making the start and end points identical. For example, a full CW circle of 20mm radius centered 20mm to the left of the start point is written as: G90 G02 X50.0 Y50.0 I-20.0 J0.0 F300.0
  • Built-in Controller Validation: Modern CNC controls verify the accuracy of the programmed arc. The control calculates the radius from the start point to the center, then calculates the radius from the end point to the center. If these two values differ by more than a parameter-set tolerance (e.g., 0.005mm or 0.0002 inches), the control alarms out before the tool ever touches metal. This acts as a critical safety check against code errors.

4. Helical Interpolation & Thread Milling

Helical interpolation is an advanced machining process that coordinates synchronous movement across three axes. The control executes a 2D circular interpolation in the primary plane (typically XY under G17) while simultaneously executing a linear motion along the perpendicular third axis (Z-axis). The resulting physical toolpath is a precise helix.

The standard syntax for a helical move simply adds a Z-axis target endpoint parameter to the circular interpolation block:

G17 G90 G03 X50.0 Y50.0 I-15.0 J0.0 Z-5.0 F120.0

In this block, as the tool sweeps a counter-clockwise circle in the XY plane, it moves down in the Z-axis, ending exactly at Z-5.0.

Helical Ramping (Bore Entry)

In traditional vertical milling operations, entering a deep pocket or solid bore required drilling a starter hole or plunging the end mill straight down in the Z-axis. Straight plunging is extremely hard on tooling: flat-bottom end mills have no center cutting capability, resulting in massive axial cutting forces, chip packing, tool vibration, and rapid cutting edge failure.

Helical ramping solves this challenge. The tool orbits in a circular arc while ramp-down axial motion is continuously fed. The tool cuts a clean, spiral entry path, creating its own starting pocket:

  • Superior Chip Evacuation: The circular movement creates a wide channel behind the tool, allowing compressed air or high-pressure coolant to sweep chips out of the hole, preventing recutting.
  • Reduced Cutting Forces: The axial cutting loads are shifted to radial forces, utilizing the tool's side cutting edges which are structurally stronger.

Thread Milling Algorithms

For decades, threads inside machined components were cut using mechanical taps or thread cutting tools. However, high-value components (such as aerospace engine castings) run the risk of structural scrap if a tap seizes and snaps inside a deep blind hole.

Thread milling uses multi-axis helical interpolation to cut threads. A specialized thread-profile cutter (which matches the pitch angle) orbits helical sweeps along the cylinder wall.

Calculating the exact linear coordinate shifts is critical. For every 360-degree circular rotation, the Z-axis must feed axially by exactly **one lead length** (pitch) of the target thread:

For Metric Threads (Pitch is given directly in mm): Z-Shift per Rev = Thread Pitch (P)
Example M20 x 2.5: The Z-axis must move precisely 2.5mm per full circle.
For Imperial Threads (TPI - Threads Per Inch): Z-Shift per Rev = 1 / TPI
Example 1/2"-13 UNC: The Z-axis must move precisely 1 ÷ 13 = 0.07692 inches per full circle.

Internal Climb Thread Milling Directional Logic

To achieve premium surface finishes and prolong cutter life, climb milling is standard. For standard right-hand internal threads, the toolpath must start at the **bottom of the pre-drilled bore and interpolate upwards** (G03 CCW rotation + positive Z movement). This forces the tool to climb mill, pushing chips downward into the empty pocket while preventing the tool from recutting chips.

5. Cutter Compensation Dynamics (G40/G41/G42)

When writing G-code coordinates, the programmer must choose between **Centerline Programming** and **Part Profile Programming**.

  • Centerline Programming: The coordinates in the G-code represent the exact path of the tool center. This requires the programmer to offset all coordinates manually by the tool's radius. If the tool wears down by 0.05mm, or the operator switches from a 12mm end mill to an 11.8mm regrind, the entire program must be re-posted from CAM.
  • Part Profile Programming: The coordinates in the G-code match the exact dimensions on the blueprint. The CNC controller handles the tool radius offset dynamically, utilizing three modal commands:
    • G41: Cutter Compensation Left (offsets the tool to the left of the programmed path relative to the direction of travel). Used for standard climb milling of external profiles.
    • G42: Cutter Compensation Right (offsets the tool to the right). Used for conventional milling.
    • G40: Cutter Compensation Cancel. Disables dynamic tool offsets.

Critical Rules for Activating Cutter Compensation

Dynamic tool compensation requires precise programming to prevent controller errors or unexpected movements:

  1. Must Activate on a Linear Move (G01/G00): You cannot initiate G41 or G42 during a G02 or G03 arc block. The controller requires a straight line (the "startup block") to shift the tool perpendicular to the path by the radius value stored in the offset registry (D-register).
  2. Startup Vector Length: The length of the startup linear move must be **greater than the tool radius value** stored in the registry. If you attempt to activate compensation with a 10mm move while using a 12mm radius tool, the controller will trigger a motion error or collide with the part.
  3. Ensure Correct D-Register Assignment: The G41/G42 block must include a D parameter which directs the controller to the correct registry row: G01 G41 X20.0 Y10.0 D01 F150.0 (Uses Radius value from Tool 1 offset register)

Lead-In and Lead-Out Ramps

Plunging a rotating end mill directly into the finished boundary of a circle results in dynamic tool deflection. The sudden radial load causes the tool to deflect slightly, leaving a permanent gouge or witness mark on the surface.

To achieve high-quality surface finishes, programmers use **circular lead-in and lead-out arcs** to blend the tool tangentially into the cut:

G-Code program showing G02 and G03 canned loops and helical thread milling operations
Figure 2: Industrial G-code programming integrates G02 and G03 commands with tool radius compensation (G41/G42) to produce dimensionally accurate bores and exterior contours.
  • Tangential Circular Lead-in: The tool activates G41 on a linear approach vector, sweeps a smooth 90-degree or 180-degree lead-in arc, and blends tangentially into the main circular cut. The cutting forces build up gradually, avoiding tool shock and chatter.
  • Tangential Circular Lead-out: After completing the circular cut, the tool sweeps a secondary tangent arc away from the finish surface before cutter compensation is canceled using a G40 command on a linear move.

6. Feed Rate Adjustments (Internal vs. External)

One of the most common causes of rapid tool wear, broken teeth, and poor surface finishes during circular milling is failing to adjust the program feed rate.

When cutting in a straight line (G01), the feed rate at the tool's center is identical to the feed rate at the cutting edge. However, during circular interpolation, the tool center and the tool edge travel along concentric paths of different radii.

  • Internal Milling (Bores & Pockets): The tool center travels along a path with a **smaller radius** than the contour being cut. If you run the catalog feed rate, the actual feed rate at the cutting edge will be much higher, leading to severe chip overloading and tool failure.
  • External Milling (Bosses & Columns): The tool center travels along a path with a **larger radius** than the contour being cut. The cutting edge moves slower than programmed, resulting in reduced productivity.

Feed Rate Adjustment Formula

Fadjusted = Fprogrammed × Dpart ± DcutterDpart

Fadjusted: The adjusted feed rate commanded in the G-code.

Fprogrammed: The target linear edge feed rate (from the tooling catalog).

Dpart: The diameter of the circular feature being machined.

Dcutter: The actual diameter of the milling cutter.

Use Minus (−): For internal circular milling (bores, pockets).

Use Plus (+): For external circular milling (bosses).

Practical Math Calculations

Example 1: Internal Bore Machining (Feed Overload Case)

We want to finish machine a 50.0mm bore (Dpart) using a 12.0mm carbide end mill (Dcutter). The tooling catalog recommends a linear edge feed rate of 500 mm/min (Fprogrammed).

Fadjusted = 500 × ((50.0 - 12.0) / 50.0)

Fadjusted = 500 × (38.0 / 50.0)

Fadjusted = 500 × 0.76 = 380 mm/min

Result: We must reduce our G-code feed rate parameter to **380 mm/min** (a **24% reduction**). If we program the raw 500 mm/min feed rate, the outer edge of the end mill will actually travel at **658 mm/min**, resulting in chipped teeth, chatter, and poor surface finish.

Example 2: External Boss Machining (Productivity Loss Case)

Using the same tooling combination, we now want to profile a 50.0mm cylindrical boss (Dpart).

Fadjusted = 500 × ((50.0 + 12.0) / 50.0)

Fadjusted = 500 × (62.0 / 50.0)

Fadjusted = 500 × 1.24 = 620 mm/min

Result: We can increase the commanded feed rate to **620 mm/min** (a **24% increase**). This maintains the target chip load, improving cycle times without risking tool damage.

Feed Rate Adjustment Reference Lookup Table

Use this standard lookup table to identify your Feed Correction Factors based on the ratio of the Cutter Diameter to the Part Diameter:

Cutter / Part Ratio Internal Factor (Minus) External Factor (Plus) Example: 10mm cutter in 40mm Bore
0.10 0.90 (90%) 1.10 (110%) Minimal shift
0.20 0.80 (80%) 1.20 (120%) Significant shift
0.25 0.75 (75%) 1.25 (125%) Standard pocketing limit
0.30 0.70 (70%) 1.30 (130%) Tool deflection risk rises
0.40 0.60 (60%) 1.40 (140%) Heavy compensation required
0.50 0.50 (50%) 1.50 (150%) Extreme limit (e.g. 10mm cutter in 20mm Bore)

7. Shop-Floor Troubleshooting & Metrology

Even with mathematically correct G-code, executing circular toolpaths can present mechanical and physical challenges. The table below lists common quality issues encountered during circular interpolation and their root causes:

Quality Defect Physical Symptom Primary Mechanical Root Cause Corrective Action
Ovality / Out-of-Roundness The finished bore is elliptical, measuring larger along one axis (e.g. X) than the other (e.g. Y). 1. Servomotor gain mismatch between X and Y axes.
2. Mechanical backlash in one axis ballscrew.
Run a dynamic Ballbar test (QC20-W). Adjust axis backlash parameters in the CNC controller.
Quadrant Crossover Marks Small gouges or flat spots appearing exactly at 0°, 90°, 180°, and 270° positions. Axis delay (stick-slip friction) when one linear axis reverses direction and momentarily halts. Adjust "Quadrant Glitch Compensation" torque pulse parameters in the controller.
Conical Bore Taper The diameter at the top of the hole is larger than at the bottom of the bore. Tool deflection caused by heavy radial cutting forces bending the end mill. 1. Program "spring passes" (repeating the profile with zero radial feed).
2. Switch to a shorter, more rigid carbide tool.
Gouged Entry Scars A permanent vertical mark or gouge at the tool's entry/exit location. 1. Direct radial linear plunge into the part profile.
2. Inactive or incorrectly configured cutter compensation.
Program tangential circular lead-in and lead-out sweeps. Never plunge directly onto a finished wall.

Understanding Quadrant Backlash Error

During a circular sweep in the XY plane, the axes must continuously reverse direction. For example, in a counter-clockwise arc (G03) starting at 3 o'clock (0°):

  • From 0° to 90°, the X-axis decelerates to zero while the Y-axis accelerates to maximum speed.
  • Exactly at 90° (12 o'clock), the X-axis must reverse direction, moving from positive to negative.

At that split second, static friction (stick-slip) must be overcome, and any physical play in the ballscrew bearings (backlash) will cause a momentary pause. During this pause, the Y-axis continues moving, creating a small flat spot on the surface.

Metrology Diagnostic: If you measure a bore using a three-point internal micrometer (bore gage) and detect out-of-roundness, measure the bore at 45-degree angles to isolate mechanical backlash from servo gain issues. If the diameter is smallest at 45°/225°, it indicates axis lag; if it is out-of-round exactly parallel to the X or Y axis, it points to mechanical backlash.

8. Complete G-Code Programming Examples

Below are three production-grade, shop-tested G-code programs demonstrating standard G02/G03 operations on Fanuc/Haas-compatible vertical machining centers.

Example 1: Bore Pocket Milling using IJK and Cutter Compensation (G41)

This program cuts a 3.000-inch diameter circular pocket centered at X0.0 Y0.0 to a depth of Z-0.500 inches, using a 0.500-inch diameter end mill. It features a tangential linear lead-in, a circular blend arc, a 360-degree sweep, a circular lead-out arc, and G40 cancellation.

%
O1001 (CIRCULAR BORE MILLING EXAMPLE)
G20 G90 G40 G80 G49 G17 (Standard safety block: Imperial, Absolute, Cancel Comp/Cycles, XY Plane)
T01 M06 (Select and load Tool 1: 0.500 inch End Mill)
S2400 M03 (Spindle speed 2400 RPM, Spindle Clockwise)
G54 G00 X0.0 Y0.0 (Rapid traverse to center of bore)
G43 H01 Z0.1 M08 (Apply tool length offset, rapid to clearance plane, coolant ON)
G01 Z-0.500 F15.0 (Feed linear to depth Z-0.500)

(---- BEGIN PROFILE RAMP AND MILLING ----)
G01 G41 X0.500 Y-0.500 D01 F30.0 (Linear startup block: activate G41 Cutter Comp, shift tool left)
G03 X1.000 Y0.000 I0.000 J0.500 (Tangential lead-in arc: sweep to start of bore diameter)
G03 X-1.000 Y0.000 I-1.000 J0.000 (Sweep first 180 degrees of bore)
G03 X1.000 Y0.000 I1.000 J0.000 (Sweep remaining 180 degrees to complete the 360 circle)
G03 X0.500 Y0.500 I-0.500 J0.000 (Tangential lead-out arc away from pocket wall)
G00 G40 X0.0 Y0.0 (Cancel cutter compensation G40 on a linear move back to center)
Z1.0 M09 (Retract Z axis, coolant OFF)
G53 G49 Y0.0 Z0.0 M05 (Return to home position, Spindle Stop)
M30 (End of program)
%

Example 2: External Boss Machining using Radius (R) Programming

This program profiles the exterior of a 2.000-inch diameter cylinder (boss) centered at X0.0 Y0.0 to a depth of Z-0.375 inches, using a 0.500-inch diameter end mill. It uses the R-word method.

%
O1002 (EXTERNAL BOSS MILLING - R METHOD)
G20 G90 G40 G80 G17 (Standard safety block)
T02 M06 (Select Tool 2: 0.500 inch Roughing End Mill)
S3200 M03 (Spindle Speed 3200 RPM)
G54 G00 X-1.750 Y-1.750 (Rapid to safe clearance position away from part)
G43 H02 Z0.1 M08 (Apply tool length, rapid to Z-clearance)
G01 Z-0.375 F20.0 (Feed linear to cutting depth)

(---- PROFILE WITH TANGENTIAL APPROACH ----)
G01 G41 X-1.250 Y-1.250 D02 F45.0 (Activate cutter compensation on a linear approach)
G01 X-1.000 Y0.000 (Linear move to start of boundary)
G02 X1.000 Y0.000 R1.000 (Clockwise arc sweep of first 180 degrees of the boss)
G02 X-1.000 Y0.000 R1.000 (Clockwise arc sweep of remaining 180 degrees)
G01 X-1.250 Y1.250 (Linear exit away from finished boss profile)
G00 G40 X-1.750 Y-1.750 (Cancel cutter compensation G40 on a linear move)
Z2.0 M09 (Retract tool to safe height)
G28 G91 Z0.0 (Return Z to home)
G28 Y0.0 M05 (Return Y to home, Spindle Stop)
M30 (End of program)
%

Example 3: Internal Thread Milling (1"-8 UNC Thread) using Helical Interpolation

This program cuts a 1"-8 UNC right-hand internal thread in a steel block, centered at X0.0 Y0.0. The thread pitch is 1/8 = 0.125 inches. The program uses a 0.750-inch diameter single-profile thread mill, starting at the bottom of the bore (Z-0.750) and climb-milling upward to Z0.100.

%
O1003 (INTERNAL THREAD MILLING 1-8 UNC)
G20 G90 G40 G80 G17
T03 M06 (Tool 3: 0.750" Thread Mill)
S1800 M03 (1800 RPM)
G54 G00 X0.0 Y0.0 (Rapid traverse to center of pre-drilled bore)
G43 H03 Z0.2 M08 (Apply height offset, coolant ON)
G01 Z-0.750 F25.0 (Plunge linear to bottom of thread depth)

(---- HELICAL INTERPOLATION THREAD LOOP ----)
(Thread Major Radius = 0.500". Tool Radius = 0.375". Shift radius = 0.125")
G01 G41 X0.125 Y0.000 D03 F10.0 (Feed linear to engage cutter comp offset)
G03 X0.125 Y0.000 I-0.125 J0.000 Z-0.625 F8.0 (1st full helical turn: CCW circular loop, Z climbs by +0.125 pitch)
G03 X0.125 Y0.000 I-0.125 J0.000 Z-0.500 (2nd helical turn)
G03 X0.125 Y0.000 I-0.125 J0.000 Z-0.375 (3rd helical turn)
G03 X0.125 Y0.000 I-0.125 J0.000 Z-0.250 (4th helical turn)
G03 X0.125 Y0.000 I-0.125 J0.000 Z-0.125 (5th helical turn)
G03 X0.125 Y0.000 I-0.125 J0.000 Z0.000 (6th helical turn to clear the top of the plate)

G01 G40 X0.0 Y0.0 (Cancel cutter compensation as tool returns to center)
G00 Z1.0 M09 (Rapid retract, coolant OFF)
G53 G49 Y0.0 Z0.0 M05 (Spindle Stop, return home)
M30 (End of program)
%

9. Exhaustive FAQ Section

1. What happens if I accidentally swap the I and J values in standard G-code?

Swapping I and J values shifts the target center of the circle to an incorrect coordinate plane. For example, if your I offset was meant to be 10.0 and J was meant to be 0.0, swapping them to I0.0 J10.0 moves the center along the Y-axis instead of the X-axis. Since the physical distance from the start point to this new center point no longer matches the distance to the end point, the CNC controller will immediately trigger an "Invalid Arc Endpoint" or "Radius Error" alarm and halt the machine before execution.

2. Why does my machine alarm with "Radius Difference Exceeded" during execution?

This alarm occurs when the calculated radius from the start point to the center differs from the calculated radius from the end point to the center by more than the tolerance set in the machine parameters (usually Haas Parameter 213 or Fanuc Parameter 3410, typically set to 0.005mm or 0.0002 inches). This is usually caused by rounding errors when converting imperial decimal values, or manual calculation mistakes. Using IJK offsets instead of R-values can help identify these discrepancies during programming.

3. Can I perform G02 or G03 circular interpolation commands in the Z-axis?

Yes. To perform circular moves in the Z-axis, you must activate the correct coordinate plane. Use G18 to select the ZX plane (arcs sweep in the Z and X axes) or G19 to select the YZ plane. Once active, the Z-axis can interpolate alongside either the X or Y axis. This is common when milling spherical radii, ball tracks on vertical walls, or 3-axis surface molds.

4. How does feed rate calculation differ on older controllers versus modern ones with Look-Ahead?

Older CNC controllers (1980s-1990s) executed blocks sequentially without analyzing future moves, which required programmers to manually calculate and reduce internal bore feed rates to prevent gouging or tool damage. Modern controllers equipped with Advanced Look-Ahead (such as Haas HSM or Fanuc AIAPC) scan hundreds of lines ahead. If configured correctly, the controller automatically scales and slows down feed rates during small-radius transitions to maintain a constant tool-edge velocity.

5. How does tool deflection impact the physical geometry of an interpolated circle?

Milling tools behave like cantilever beams under load. During circular interpolation, the radial cutting forces push the end mill away from the material wall. This deflection causes the cutter to leave excess stock, making internal bores smaller than programmed and external bosses larger. Using shorter, more rigid carbide tooling and programming multiple "spring passes" (profiling passes at final depth with zero radial feed) helps clean up deflection and achieve print specifications.

6. Should I use climb or conventional milling for internal circular interpolation?

For standard CNC setups and carbide tooling, climb milling is highly recommended. During internal bore milling, climb milling (using a G03 CCW path) keeps the cutting forces directed behind the tool, pushing chips out of the cutting path and resulting in excellent surface finishes and extended tool life. Conventional milling (using a G02 CW path) drags the cutter teeth through the cut, generating friction, heat, work hardening, and accelerated tool wear.

7. How do I program a tapered circular path (conical spiral) manually?

A tapered circular path requires the radius of the arc to change continuously alongside axial movement (Z-axis). Since G02 and G03 only support fixed-radius sweeps, you cannot program a continuous taper in a single standard block. Instead, you must break the path down into small, consecutive angular segments (e.g., 5-degree increments), recalculate the changing radius for each segment, and program them as a sequence of small G02/G03 blocks. Alternatively, modern controllers allow you to automate this process using parametric macro programming (Fanuc Macro B).

8. Why are absolute coordinates not used for IJK vectors in Fanuc systems?

Using incremental offsets from the start point for IJK vectors is a critical safety convention. In absolute programming (G90), a coordinate represents a fixed location relative to the Work Coordinate System (WCS). If IJK vectors were absolute, resetting the G54 datum or shifting the toolpath origin would require recalculating every single IJK value in the program. By keeping IJK vectors incremental, the circle center remains mathematically locked to the start point, allowing you to move or duplicate the toolpath anywhere on the machine envelope without modifying the arc blocks.

9. How does backlash compensation in the CNC control interact with G02/G03 paths?

Backlash compensation parameters automatically inject a brief, high-torque voltage pulse to the servo motors at the exact millisecond an axis reverses direction during a circular sweep. This pulse helps overcome physical play in the ballscrew and thrust bearings. If this compensation is set too low, the machine will dwell, leaving flat spots at the quadrant crossover points. If it is set too high, the motor will overshoot, leaving a small peak or notch on the finished surface.

10. Shop-Floor Verification Checklist

Before loading code, clamping material, and pressing the Cycle Start button on any circular interpolation operation, execute this rigorous shop-floor checklist to prevent tool breakage and part scrap:

Verify Active Plane G-Codes

Ensure the correct plane is active (G17 for VMC mills, G18 for lathes, G19 for horizontal mills). A plane mismatch will result in immediate tool wreckage or axis alarms.

Verify Tool Length and Radius Registers

Verify that the tool height offset (H-value) and tool radius offset (D-value) in the G-code match the exact tool slots and dimensions on the machine carousel.

Double-Check Linear Startup for G41/G42

Confirm that cutter compensation is activated on a linear G01 move that is longer than the tool radius. Never activate cutter compensation on a G02/G03 arc move.

Verify Feed Rate Compensation

Confirm that internal bore or pocket feed rates have been reduced, and external boss feed rates have been adjusted using the standard feed rate formula to prevent chip overloading.

Run Program Dry Run and Graphic Verification

Run a graphical simulation on the CNC controller to verify the toolpaths visually, then perform a dry run (cutting air at Z+2.0 inches) before executing the program on raw material.

Access Interactive ID/OD Interpolation Calculator

Calculate exact circular coordinate paths, centerline radius offsets, and adjusted feed rates instantly. Eliminate manual trigonometry errors and run high-efficiency helical ramps on the shop floor today.

Open ID/OD Calculator →
NX

Written by Nishikant Xalxo

CNC Programming Expert & Technical Writer

Nishikant is a seasoned manufacturing systems engineer specializing in G-code parameter optimization, high-speed machining, and automated toolpath generation. For feedback, tool suggestions, or technical support, contact him at nxdecore@gmail.com or follow @nishix_vamp.