G13 CNC Code | Circular Motion

G12, G13, and Circular Motion on CNC Lathes and Mills: A Complete Guide

Programming circular movements is fundamental to CNC machining. While G02 and G03 are the universally recognized G-codes for circular interpolation, you might encounter G12 and G13 and wonder about their purpose. The truth is, G12 and G13 are not standard replacements for G02/G03 on most modern CNC lathes or mills. Their function is highly control-system specific, and understanding this is crucial to avoid programming errors.

This article provides a comprehensive guide to circular motion on both CNC lathes and machining centers, covering:

  • Standard Circular Interpolation (G02/G03): The foundation for all circular movements.
  • G12 and G13 on Fanuc Mills (Circular Pocket Milling): The one common, standardized use of these codes.
  • G12.1 and G13.1 on some Fanuc Controls (Polar Coordinate Interpolation): A specialized feature for lathes with live tooling.
  • Cylindrical Interpolation: A technique for machining features on cylindrical surfaces (often not involving G12 or G13).
  • Alternatives and Best Practices: Using CAM software and other techniques.
  • Control-Specific Information: Fanuc, Siemens, Haas, Mazak, and Mitsubishi
  • Troubleshooting

Crucial Note: Always consult the programming manuals for your specific CNC control system and machine tool before using any G-code. Never assume a G-code’s function without verification.

1. Circular Interpolation (G02/G03): The Foundation

On both CNC lathes and machining centers, G02 (clockwise) and G03 (counterclockwise) are the standard G-codes for circular interpolation:

  • They create arcs and circles within a single plane.
    • Lathe: XZ plane (G18 is often the default, but check).
    • Mill: Typically the XY plane (G17, the default on most mills).
  • You define the arc’s endpoint using X, Y, and/or Z coordinates.
  • You define the arc’s shape using:
    • R Parameter: The radius of the arc (positive for arcs ≤ 180°, negative for arcs > 180°).
    • I, J, and K Parameters: The incremental distances from the arc’s starting point to its center point.
      • Lathe: I (X-axis offset), K (Z-axis offset).
      • Mill (XY Plane): I (X-axis offset), J (Y-axis offset).

Example (Lathe - G03 Counterclockwise Arc):

G00 X20.0 Z5.0 ; Rapid to start
G01 Z0.0 F0.1 ; Feed to surface
G03 X40.0 Z-20.0 R15.0 F0.08 ; Counterclockwise arc
G01 X50.0 ; Continue with linear move

Example (Mill - G02 Clockwise Arc):

G00 X0 Y0 Z0.1 ; Rapid to start
G01 Z-0.25 F100 ; Feed to depth
G02 X20.0 Y10.0 R10.0 F50 ; Clockwise arc
G01 Y20.0 ; Continue with linear move

These are the standard and recommended G-codes for programming circular movements on most CNC lathes and mills.

2. G12 and G13 on Fanuc Mills: Circular Pocket Milling Cycles

The one common, standardized use of G12 and G13 is on Fanuc milling machines (and some compatible controls), where they function as canned cycles for circular pocket milling:

  • G12: Clockwise circular pocket milling.
  • G13: Counterclockwise circular pocket milling.

Key Features:

  • Spiral Toolpath: The control automatically generates a spiral toolpath, starting from the center of the pocket and moving outward to the finished radius.
  • Single Block Execution: The entire pocket (at a single Z-depth) is milled in one G12 or G13 block.
  • Cutter Compensation is Required: You must use G41 (left) or G42 (right) with these cycles.

Syntax (Fanuc Mills):

G12 I... D... F... ;  Clockwise circular pocket
G13 I... D... F... ;  Counterclockwise circular pocket
  • I...: The incremental radius of the finished circular pocket. Not a center offset. The tool must be positioned at the pocket’s center before the G12/G13 block.
  • D...: The tool offset number (for cutter compensation).
  • F...: The feed rate.

Example (Fanuc Mill - G12, Clockwise):

O0001 (Circular Pocket with G12 - Mill)
G21 G17 G90 ; Metric, XY plane, Absolute mode
T01 M06 ; Tool change (e.g., 10mm end mill)
G00 X50.0 Y50.0 Z10.0 ; Rapid to center of pocket location
S2000 M03 ; Spindle on
G42 D01 ; Cutter compensation RIGHT
G01 Z-5.0 F100 ; Feed down to cutting depth
G12 I25.0 D01 F150 ; Mill circular pocket (radius 25mm) - CLOCKWISE
G40 ; Cancel cutter compensation
G00 Z10.0 ; Rapid retract
M30 ; Program end

Example (Fanuc Mill - G13, Counterclockwise):

O0002 (Circular Pocket with G13 - Mill)
G21 G17 G90 ; Metric, XY plane, Absolute mode
T01 M06 ; Tool change (e.g., 10mm end mill)
G00 X50.0 Y50.0 Z10.0 ; Rapid to center of pocket location
S2000 M03 ; Spindle on
G41 D01 ; Cutter compensation LEFT
G01 Z-5.0 F100 ; Feed down to cutting depth
G13 I25.0 D01 F150 ; Mill circular pocket (radius 25mm) - COUNTERCLOCKWISE
G40 ; Cancel cutter compensation
G00 Z10.0 ; Rapid retract
M30 ; Program end

Important Considerations (G12/G13 on Fanuc Mills):

  • Starting Position: The tool must be at the center of the pocket before the G12/G13 block.
  • Cutter Compensation: G41 (left) with G13 (counterclockwise); G42 (right) with G12 (clockwise).
  • Z-Depth: Typically set with a prior G01 move. G12/G13 usually don’t control Z-depth within the cycle itself (though some variations might exist – check your manual).
  • Single Pass: The cycle completes a full circle in one pass.

3. G12.1 and G13.1 on Some Fanuc Controls: Polar Coordinate Interpolation

On some Fanuc controls (often on lathes with live tooling, and potentially on some mills), G12.1 and G13.1 are used for polar coordinate interpolation. This is not the same as G12/G13 circular pocket milling.

  • G12.1 (or G13.1): Enables polar coordinate interpolation mode. The specific code can vary.
  • G12 (or sometimes G12.1): Often used to cancel polar coordinate interpolation mode. The specific code can vary greatly.

Polar Coordinate Interpolation:

Instead of defining positions with X and Z (lathe) or X and Y (mill), you define them using:

  • A Linear Axis: Usually X on a lathe (representing diameter), or X/Y on a mill.
  • A Virtual Rotary Axis: Usually designated as C, representing rotation around the Z-axis (lathe) or around a defined center point (mill).

This is useful for milling features on the face of a turned part (lathe with live tooling) or for programming movements relative to a center point other than the machine origin (mill).

Example (Fanuc Lathe - Conceptual - Milling on Face):

; Assume workpiece zero is at the center of the face.

G28 U0 W0; Home
T0101 M06 ; Select milling tool
G97 S2000 M03 ; Spindle on (constant RPM)
G00 X0 Z0.1 C0 ; Rapid to a safe position
G13.1 ; Enter polar coordinate interpolation mode (may be G12.1 on your control)
G01 X1.0 C45.0 F5.0 ; Mill a slot (X = radius, C = angle)
G00 Z0.1 ; Rapid retract
G12.1 ; Cancel polar coordinate interpolation mode
G28 U0 W0 ; Home
M30 ; Program end

Important: The availability and syntax of polar coordinate interpolation (G12.1, G13.1, or other codes) are highly control-specific.

4. Cylindrical Interpolation (Lathes and Mills)

Cylindrical interpolation is another feature, often confused with polar coordinate interpolation, that allows you to machine features on the circumference of a cylinder. It’s not typically controlled by G12 or G13.

  • Concept: The cylindrical surface is “unwrapped” into a flat plane. You program movements in terms of a virtual rotary axis (C or sometimes Y) and a linear axis (Z on lathes, often X/Y on mills).
  • Fanuc: Uses G07.1 (or G107) on some controls (often an option). Syntax: G07.1 C<radius>.
  • Siemens: Uses TRANSMIT (face milling) and TRACYL (circumference milling).
  • Haas: Often uses G107.

Example (Fanuc Lathe - G07.1 - Circumferential Slot): Refer to detailed examples from the previous G07 article.

5. Other Control Systems (Siemens, Haas, Mazak, Mitsubishi)

  • Siemens: Does not typically use G12 or G13 for circular pocketing or polar coordinate interpolation. Uses dedicated cycles (CYCLE76, CYCLE77) for pockets, and TRANSMIT/TRACYL for cylindrical/polar transformations.
  • Haas: Likely uses canned cycles for circular pocketing, not G12/G13. Cylindrical interpolation is often G107. Polar coordinate interpolation may have a different G-code or be handled through settings.
  • Mazak: Mazatrol (conversational programming) handles these operations through its menus and graphical interface. In EIA/ISO mode, the specific commands will vary. G12/G13 are unlikely to be used for standard circular interpolation or pocketing.
  • Mitsubishi: Consult the MELDAS documentation.

Always consult your specific control system’s documentation.

6. Alternatives and Best Practices (All Cases)

  • CAM Software: For any complex geometry (circular pockets, non-circular contours, polar/cylindrical features), CAM software is the recommended approach. It handles all the calculations, generates optimized toolpaths, and minimizes errors.
  • Standard G02/G03: For simple circular arcs, always use G02/G03.
  • Use a Canned Cycle if available.

7. Troubleshooting

  • Unexpected Behavior: If G12 or G13 don’t behave as expected, you’re likely using them incorrectly or on a control system where they have a different meaning (or no meaning).
  • Circular Pocket Issues (G12/G13 on Fanuc Mills):
    • Incorrect Size: Check cutter compensation (G41/G42) and the D offset value. Ensure you’re using the radius (I), not the diameter.
    • Not Starting at Center: Position the tool at the pocket’s center before the G12/G13 block.
  • General Milling Issues: Refer to general milling troubleshooting guides.

8. Frequently Asked Questions (FAQ)

  • Q: Are G12 and G13 interchangeable with G02 and G03?
    • A: Absolutely not. G02 and G03 are for standard circular interpolation within a plane. G12 and G13 on Fanuc mills are specialized canned cycles for circular pocket milling. On many other controls, including most lathes, G12 and G13 have no standard meaning or a completely different function.
  • Q: How do I mill a circular pocket on a Siemens or Haas mill?
    • A: Use the appropriate canned cycle for your specific control (consult the manual).
  • What is the purpose of G12 on a Fanuc Lathe?
    • A: It is likely used to cancel Polar Coordinate Interpolation mode.
  • Q: Is G12/G13 the best way to make circular pockets?
    • A: CAM software is often preferred.

9. Conclusion

G12 and G13 are not universal replacements for G02 and G03 for circular motion on CNC lathes and mills. On Fanuc mills, they are useful canned cycles for circular pocket milling. On some Fanuc lathes, G12.1 and G13.1 are used for polar coordinate interpolation, a distinct feature. For all other cases, and especially for complex geometries, CAM software is the recommended approach.