G12 CNC Code | Circular Pocket | Milling

G12 on CNC Mills: Mastering Circular Pocket Milling (Fanuc)

Circular pockets are a common feature in many machined parts. While you could create them using a series of G02/G03 circular interpolation commands, many CNC controls offer a more convenient and efficient method: a dedicated canned cycle for circular pocket milling. On Fanuc controls (and some compatible controls), this is often achieved using the G12 (clockwise) and G13 (counterclockwise) commands.

This article focuses primarily on the Fanuc implementation of G12 and G13, providing a clear explanation of their syntax, usage, and limitations. We’ll also discuss alternative methods for creating circular pockets and briefly touch on how other control systems might handle this operation.

Important Note: Before using any G-code, always consult the programming manuals for your specific CNC control system and machine tool. G-code implementations can vary between manufacturers and even between different control models from the same manufacturer.

1. G12 and G13 on Fanuc: Circular Pocket Milling Cycles

On Fanuc controls that support them, G12 and G13 are canned cycles specifically designed for milling circular pockets. They are not general-purpose circular interpolation commands like G02 and G03. Here’s the key difference:

  • G02/G03: Define a single circular arc. You need multiple G02/G03 commands (and likely G01 moves) to create a complete pocket.
  • G12/G13: Define a complete circular pocket milling operation in a single block. The control automatically generates a spiral toolpath to remove the material within the specified circle.

Key Features:

  • Clockwise (G12) and Counterclockwise (G13): G12 mills the pocket with a clockwise tool motion. G13 mills the pocket with a counterclockwise tool motion. The choice between them often depends on the desired cutter compensation direction (G41/G42).
  • Spiral Toolpath: The control typically generates a spiral toolpath, starting at the center of the circle and moving outward to the finished radius.
  • Single Block Execution: The entire pocket milling operation (for a single depth) is usually completed within the G12 or G13 block. You don’t need separate commands for each circular pass.
  • Cutter Compensation Required: You must use cutter compensation (G41 or G42) with G12 and G13. This is how the control knows the tool’s radius and can calculate the correct offset toolpath.

2. Syntax (Fanuc)

The syntax for G12 and G13 on Fanuc controls is:

G12 I... D... F... ;  Clockwise circular pocket
G13 I... D... F... ;  Counterclockwise circular pocket
  • G12: Clockwise circular pocket milling cycle.
  • G13: Counterclockwise circular pocket milling cycle.
  • I…: The incremental radius of the finished circular pocket. This is not a center offset like in G02/G03. It’s the radius of the pocket itself. The value is incremental from the starting position of the tool, which should be at the center of the pocket.
  • D…: The tool offset number (used with G41/G42 for cutter compensation). This tells the control which tool offset value to use to compensate for the tool’s radius.
  • F…: The feed rate.

Important Notes:

  • Starting Position: The tool must be positioned at the center of the desired circular pocket before the G12 or G13 command is executed.
  • Plane Selection: G12 and G13 typically operate in the currently active plane (usually G17 for the XY plane).
  • No X, Y, Z in the G12/G13 Block: You do not specify X, Y, or Z coordinates within the G12 or G13 block itself. The starting position (center of the pocket) is defined by the previous block, and the I value defines the pocket’s radius.
  • Incremental Depth: To mill the pocket to a specific depth, you would typically use a separate G01 move before the G12/G13 command to plunge the tool to the desired depth. G12/G13 themselves do not control the Z-axis depth within the cycle (although some controls may have optional parameters for this – check your manual).
  • Modal: G12 and G13 are modal within their group.

3. Cutter Compensation with G12/G13

Cutter compensation (G41/G42) is essential when using G12 and G13. Without it, you’ll mill a circle that’s either too small (if you’re thinking of I as the finished radius) or too large (if you’re thinking of I as the toolpath radius).

  • G41 (Left): Use G41 with G13 (counterclockwise). The tool will be offset to the left of the programmed path, resulting in a correct external circular pocket.
  • G42 (Right): Use G42 with G12 (clockwise). The tool will be offset to the right of the programmed path, resulting in a correct external circular pocket.

4. Programming Examples (Fanuc)

Example 1: Simple Circular Pocket (G12, G42)

O0001 (Circular Pocket with G12)
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, using offset D01
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
G28 G91 Z0; Home
M30 ; Program end

Example 2: Simple Circular Pocket (G13, G41)

O0002 (Circular Pocket with G13)
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, using offset D01
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
G28 G91 Z0; Home
M30 ; Program end

Example 3: Boss with G12

O0003 (Circular Boss with G12);
(Cutting a 40mm diameter boss centered at X50 Y50);
G21 G17 G90;
T01 M06; (10mm End Mill);
G00 X50.0 Y50.0 Z10.0;
G41 D01;
S2000 M03;
G01 Z-5.0 F100.0;
G01 X65 Y50 F200; move to edge of stock
G03 X50 Y35 I-15 J0 F150; Arc to 6 o'clock position
G12 I15 D1; Mill around boss
G03 X65 Y50 I0 J15;
G01 X80; Move clear
G40;
G00 Z10.0;
G28 G91 Z0;
M30;

5. Other Control Systems

  • Siemens: Siemens controls do not typically use G12 for circular pocket milling. Siemens provides dedicated canned cycles for pocket milling, such as CYCLE76 (circular pocket) and CYCLE77 (circular spigot). These cycles offer more flexibility and control than a simple G12/G13 command.
  • Haas: Haas controls may have a G-code for circular pocket milling, but it is unlikely to be G12. Consult your Haas manual. Haas often uses intuitive, conversational programming features for common operations like pocket milling. It’s possible a different G-code exists, or the function is accessed through a menu or a different programming mode.
  • Mazak: Uses conversational programming (Mazatrol), but also has G-codes.
  • Mitsubishi: Consult your machine’s documentation, as different series can have different codes.
  • Other Controls: Always consult your machine’s documentation.

6. Alternatives to G12/G13

Even on Fanuc controls, G12/G13 are not the only way to mill circular pockets. Here are alternatives:

  • G02/G03 with a Macro or Manual Calculation: You can create a circular pocket by programming a series of G02 (clockwise) or G03 (counterclockwise) arcs, gradually increasing or decreasing the radius to create a spiral. This requires significant manual calculation or the use of a custom macro. It’s generally much less efficient than using G12/G13 or CAM software.
  • CAM Software (Highly Recommended): This is the best approach for almost all circular pocket milling. CAM software:
    • Provides a graphical interface for defining the pocket geometry.
    • Automatically generates the optimal toolpath (often a spiral, but other strategies are possible).
    • Handles cutter compensation automatically.
    • Allows for roughing and finishing passes.
    • Provides simulation and verification capabilities.

7. Troubleshooting (G12/G13 and Circular Pocket Milling)

Incorrect Pocket Size:

  • Cutter Compensation: Make sure you’re using the correct cutter compensation (G41 with G13, G42 with G12) and that the correct tool offset (D value) is active.
  • Incorrect I Value: Double-check the I value (pocket radius). Make sure you’re using the radius, not the diameter.
  • Tool Offset Error: Verify that the tool offset value in the control is correct for the tool you’re using.

Non-Circular Pocket:

  • Machine Backlash: Excessive backlash in the machine’s axes can cause the pocket to be non-circular.
  • Machine Calibration: Ensure your machine is properly calibrated.

Rough Surface Finish:

  • Feed Rate: Too high a feed rate can cause a poor surface finish.
  • Tool Condition: Use a sharp, appropriate tool.
  • Cutting Strategy: Consider using a finishing pass with a smaller stepover.

Tool Not Starting at Center:

  • Ensure that the tool is positioned at the center before calling G12 or G13.

8. Frequently Asked Questions (FAQ)

Q: Can I use G12/G13 without cutter compensation?
A: No. You must use cutter compensation (G41/G42) with G12/G13 on Fanuc controls.

Q: Can I change the Z-depth within a G12/G13 block?
A: Generally, no. G12/G13 typically mill the pocket at a constant Z-depth. You would use a separate G01 move to change the depth before calling G12/G13. Some controls may offer optional parameters for helical interpolation within the cycle – check your manual.

Q: What’s the best way to mill a circular pocket?
A: Use CAM software. It’s the most efficient, reliable, and flexible method.

Q: What is the difference between G12 and G02?
A: G02 is circular interpolation, used for creating arcs. You must calculate the center point yourself. G12 is a canned cycle, the machine will automatically create a circular pocket, spiraling outward from the current tool position.

9. Conclusion

The G12 (clockwise) and G13 (counterclockwise) commands on Fanuc CNC machining centers provide a convenient canned cycle for milling circular pockets. They simplify programming by automatically generating a spiral toolpath, starting from the center of the pocket. However, it’s essential to use cutter compensation (G41/G42) correctly and to understand the specific syntax and limitations of these commands. For other control systems, dedicated canned cycles or CAM software are the recommended methods for circular pocket milling. Always prioritize using officially supported methods and consult your machine’s documentation. CAM software is generally the best approach for generating toolpaths for circular pockets, offering greater flexibility, optimization, and ease of use.