G90 and G91 CNC Code | Abs. and Inc. | Milling

G90 and G91 CNC Codes: Absolute vs. Incremental Positioning - A Complete Guide

Introduction:

In CNC machining, accurately controlling the position of the cutting tool is fundamental. The G90 (Absolute Positioning) and G91 (Incremental Positioning) G-codes are two of the most important commands in CNC programming, determining how the machine interprets coordinate values. Understanding the difference between these two modes is absolutely essential for writing correct and efficient CNC programs. This comprehensive guide explains G90 and G91 in detail, covering their function, syntax, applications, variations across control systems (Fanuc, Siemens, Haas, Mazatrol, Mitsubishi, Heidenhain, and others), best practices, troubleshooting, and programming examples. This guide is designed for all CNC users, from beginners to experienced machinists and programmers.

1. What are G90 (Absolute) and G91 (Incremental) Positioning?

G90 (Absolute Positioning):

  • In absolute mode (G90), all coordinate values (X, Y, Z, etc.) are interpreted as distances from a fixed origin point. This origin is typically the workpiece zero point (defined by a work offset like G54) or, less commonly, the machine zero point.
  • Think of it like giving directions from a fixed landmark: “Go to 100 Main Street.” The address is always relative to the same starting point.
  • G90 is the default mode on most modern CNC controls. This means that if you don’t explicitly program G90 or G91, the machine will usually assume G90 (absolute).

G91 (Incremental Positioning):

  • In incremental mode (G91), all coordinate values are interpreted as distances to move from the tool’s current position.
  • Think of it like giving directions relative to your current location: “Go 10 blocks east and 5 blocks north.” The starting point is wherever you happen to be.
  • G91 is not the default mode. You must explicitly program it to use it.

Key Concepts:

  • Workpiece Zero Point (Part Zero): The origin of the coordinate system used for programming the part. This is defined by the programmer and is typically set using work offsets (G54-G59, etc.).
  • Machine Zero Point: A fixed, absolute reference point on the CNC machine, determined by the manufacturer.
  • Absolute Coordinates: Coordinates that are always measured from the workpiece zero point.
  • Incremental Coordinates: Coordinates that are measured from the tool’s current position.
  • Modal: G90 and G91 are modal G-codes. This means they remain active until the other code is programmed.

2. Why the Difference Matters: A Simple Analogy

Imagine you’re giving someone directions to drive from point A to point B, and then to point C:

  • Absolute (G90): You would say: “First, drive to 10 miles north, 5 miles east (Point B). Then, drive to 15 miles north, 8 miles east (Point C).” Both sets of directions are relative to the starting point (Point A).
  • Incremental (G91): You would say: “First, drive 10 miles north, 5 miles east (Point B). Then, drive another 5 miles north and another 3 miles east (from Point B to Point C).” The second set of directions is relative to where you are after the first move.

If you gave the incremental directions without specifying that they were incremental, the person would end up in the wrong place! The same is true in CNC programming.

3. G90 and G91 Syntax

The syntax for G90 and G91 is very simple:

G90 ; Activate absolute positioning mode
G91 ; Activate incremental positioning mode

These commands typically appear on their own lines, before the coordinate movements they should affect. They do not take any parameters directly.

Example (Milling - Fanuc/Haas/Mitsubishi):

O0001 (G90 and G91 Example)
G90 G21 G17 G40 G80 ; Safety line: Absolute, metric, XY plane, cancel comp, cancel cycles
T01 M06 ; Select Tool 1
G54 ; Select Work Coordinate System
G00 X0 Y0 Z10.0 ; Rapid to origin in absolute (G90) mode

; --- Absolute Positioning (G90) ---
G01 X50.0 Y25.0 Z-5.0 F100 ; Feed to X50, Y25, Z-5 (absolute)
G01 X75.0 Y50.0 ; Feed to X75, Y50 (absolute)

; --- Incremental Positioning (G91) ---
G91 ; Switch to incremental mode
G01 X25.0 Y10.0 F80 ; Move *25mm in X* and *10mm in Y* from the *current* position
G01 X-10.0 Y-5.0  ; Move *another* -10mm in X and -5mm in Y

; --- Switch Back to Absolute ---
G90 ; Switch back to absolute mode
G00 X0 Y0 Z10.0 ; Rapid back to origin

M30 ; Program end

Explanation:

  1. Safety Line and Setup: Standard setup, including selecting absolute mode (G90) as the initial state.
  2. Absolute Moves (G90):
  • G00 X0 Y0 Z10.0: Rapid to the origin (X0, Y0) and a safe Z height.
  • G01 X50.0 Y25.0 Z-5.0 F100: Feed to the absolute position X50, Y25, Z-5.
  • G01 X75.0 Y50.0: Feed to the absolute position X75, Y50.
  1. Incremental Moves (G91):
  • G91: Switches to incremental mode.
  • G01 X25.0 Y10.0 F80: Moves the tool 25mm in the positive X direction and 10mm in the positive Y direction from its current position (which was X75, Y50). The new absolute position is X100, Y60.
  • G01 X-10.0 Y-5.0: Moves the tool 10mm in the negative X direction and 5mm in the negative Y direction. The new absolute position is X90, Y55.
  1. Switch Back to Absolute (G90):
  • G90: Switches back to absolute mode. This is essential to prevent further movements from being interpreted incrementally.
  • G00 X0 Y0 Z10.0: Rapids back to the origin (absolute).

4. Control System Variations

While G90 and G91 are standard G-codes, there are some subtle differences and alternative approaches across control systems:

  • Fanuc, Haas, Mitsubishi: The syntax and behavior are generally as described above. G90 is the default mode on startup.
  • U, V, W: They can be used for incremental movements even in G90 mode.
  • Siemens (SINUMERIK):
    • G90/G91: Siemens fully supports G90 and G91.
    • AC(...) and IC(...): Siemens also provides AC() (Absolute Coordinates) and IC() (Incremental Coordinates) within a movement command, allowing you to mix absolute and incremental moves on the same line. This is a powerful feature.
      • Example: G01 X=AC(100) Y=IC(10) (Move to absolute X100, and incrementally 10 units in Y).
    • Modal vs. Non-Modal: G90 and G91 are typically modal.
  • Mazatrol (Mazak):
    • Conversational Programming: Absolute and incremental positioning are typically handled within the conversational programming interface. You would select the appropriate mode when defining a machining operation.
    • EIA/ISO (G-code): Mazak machines can run standard G-code, and G90/G91 would function as expected.
  • Heidenhain:
    • L Command: Heidenhain uses the L command for linear movements.
    • Absolute vs. Incremental: You specify absolute coordinates directly (e.g., L X100 Y50 Z-10). For incremental moves, you use IX, IY, and IZ (e.g., L IX10 IY5 IZ-2). You don’t typically switch between G90 and G91 modes in the same way as on Fanuc-style controls.
  • Other Controls: Always consult the programming manual. Okuma, Fagor, and others will have their own specific ways of handling absolute and incremental positioning.

Key Takeaways:

  • G90/G91 are standard, but…: While the concept of absolute and incremental is universal, the specific implementation can vary.
  • Siemens AC() and IC(): Offer powerful flexibility for mixing modes.
  • Heidenhain uses IX, IY, IZ: Incremental moves are specified directly within the L command.
  • Mazatrol is conversational: The choice between absolute and incremental is made within the conversational interface.
  • Always check your machine’s manual!

5. Applications of G90 and G91

  • G90 (Absolute):

    • Most Common Mode: G90 is generally the preferred mode for most machining operations, especially when starting out. It’s easier to understand and less prone to cumulative errors.
    • Precise Positioning: Ideal when you need to move the tool to specific, known locations relative to the workpiece zero.
    • Complex Contours: When machining complex shapes, G90 is usually easier to program, as you can directly use the coordinates from the part drawing.
    • Using with Work Offsets (G54-G59): G90 works seamlessly with work offsets. The coordinates you program are relative to the active work offset.
  • G91 (Incremental):

    • Repetitive Patterns: G91 is very useful for creating repetitive patterns, such as a series of holes along a line or a grid of features. You only need to program the relative movement between each feature.
    • Subprograms: G91 is often used within subprograms to make them more flexible and reusable. The subprogram can be called at different locations, and the movements within the subprogram will be relative to the starting point.
    • Manual Adjustments: G91 can be useful for making small, manual adjustments to the tool position during setup or while running a program (e.g., using the handwheel in incremental mode).
    • Engraving: G91 can be useful for engraving text or patterns.
    • Looping: G91 can be used with looping structures.

6. Best Practices for Using G90 and G91

  • Start with G90: It’s generally recommended to start your programs in G90 (absolute) mode. This provides a clear and predictable reference point.
  • Use G91 Strategically: Use G91 only when it offers a clear advantage (e.g., for repetitive patterns or subprograms).
  • Comment Your Code: Clearly indicate in your program comments when you are switching between G90 and G91, and why.
  • Double-Check Your Coordinates: Carefully check your coordinate values, especially when using G91, to avoid errors.
  • Simulate Your Program: Always simulate your program before running it on the machine, paying close attention to the tool movements in both G90 and G91 sections.
  • Safety: Always consider safety.

7. Troubleshooting Common G90/G91 Problems

  • Unexpected Tool Movement:
    • Cause: Forgetting to switch back to G90 after using G91, or vice versa. Using the wrong mode for the intended operation.
    • Solution: Carefully review your program and ensure that G90 and G91 are used correctly. Add comments to your code to clarify the mode.
  • Cumulative Errors (G91):
    • Cause: Small rounding errors or machine positioning errors can accumulate over many incremental moves, leading to inaccuracies.
    • Solution: Use G90 whenever possible for critical positioning. If you must use G91 for long sequences of moves, consider periodically returning to an absolute reference point to “reset” the position.
  • Machine Alarms:
    • Cause: Syntax errors or attempting to use G90/G91 in a way that is not supported by the control.
    • Solution: Consult your machine’s manual for specific alarm codes and troubleshooting information.

8. G90 and G91 in CNC Turning

While this article primarily focuses on machining centers, it’s important to note that G90 and G91 also have meanings in CNC turning, but their functions are different.

  • G90 (Turning): On lathes, G90 can have two different meanings, depending on the context:

    • Absolute Programming (like in milling): Most modern lathes support G90 as absolute programming mode (similar to milling). X values are usually diameters (but can be radii on some controls), and Z values are distances along the axis of rotation.
    • Canned Cycle for Straight Turning (Diameter Cutting Cycle): On some lathes (especially older Fanuc and compatible controls), G90 is a canned cycle for straight turning (reducing the diameter of a workpiece). This is different from absolute positioning. This is the usage described in the G90 article you provided.
  • G91 (Turning): On lathes, G91 is generally used for incremental programming, just like on machining centers. X values are usually incremental radial movements (half the diameter change), and Z values are incremental movements along the axis.

Important Note: The dual meaning of G90 on lathes can be a source of confusion. Always consult your lathe’s programming manual to determine the specific function of G90 on your machine.

9. Conclusion: Mastering Absolute and Incremental Control

The G90 (Absolute Positioning) and G91 (Incremental Positioning) G-codes are fundamental to CNC programming on both machining centers and lathes (although G90 has a different, specialized meaning as a canned cycle on some lathes). Understanding the difference between these two modes, how to use them effectively, and how they are implemented on different control systems is essential for any CNC programmer or machinist.