← Back to blog

Modal G Codes for CNC Operators: Catch Hidden Modes Before Cycle Start

October 15, 2026
Modal G Codes for CNC Operators: Catch Hidden Modes Before Cycle Start

Modal G-codes stay active until a different G-code from the same modal group replaces them, and that persistence is exactly what causes hidden crashes when programmers forget what mode the machine is already in. A code like G01 stays in effect across every following block until something cancels it. Before you hit cycle start on an unfamiliar program, check the controller's Active Codes screen and run a safe-start block.


TL;DR:

  • Controller definitions vary: Haas, Siemens, and Fanuc may assign codes to different modal groups, so check the specific machine’s chart before running unfamiliar programs.
  • After an interruption, MDI entry, probe check, or alarm recovery, inspect Active Codes, compare them with the program, and correct mismatches before resuming.
  • A line containing only axis words after G01 still moves at feed; Group 00 commands do not change motion mode, so restate G00 or G01 afterward.
  • Dry run a safe start such as G21 G90 G17 G40 G49 G54 G00 with Z retracted, checking the first moves in single block mode.

Availzyemachinistpro
availzye-machinist-pro.com
Check G-Code Before Cycle Start
Availzye Machinist Pro includes G-code analysis tools to help CNC operators review programs and catch potential machining errors.
Explore G-code analysis

Table of Contents

How modal groups work and why they exist

A modal group is a set of G-codes that do the same kind of job, where only one member of that group can be active at any moment. Setting G90 (absolute) automatically cancels G91 (incremental) because they belong to the same group and the control cannot run both at once, according to LinuxCNC's G-code documentation. This grouping keeps programs shorter: once you set a mode, you don't need to repeat it on every line.

The major modal groups you'll run into daily include:

  • Motion: G0, G1, G2, G3 control rapid, linear, and arc moves.
  • Plane selection: G17, G18, G19 set which two axes define circular motion.
  • Distance mode: G90 and G91 toggle absolute versus incremental positioning.
  • Units: G20 and G21 switch between inches and millimeters.
  • Cutter compensation: G40, G41, G42 manage tool-path offsets.
  • Tool length offset: G43 and G49 apply or cancel height compensation.
  • Coordinate systems: G54 through G59 select stored work offsets.
  • Canned cycles: codes like G81 and G83 stay active until canceled by G80.

Manufacturers don't always define these groups identically. Haas documentation notes that Siemens, Fanuc, and Haas controls can group codes differently, so verify your specific machine's modal chart rather than assuming behavior carries over from a different brand.

Common modal G-codes and short practical meanings

Most shop-floor confusion traces back to a handful of codes. Here's what you'll use most often and what each one does once it's active.

  • G0 / G00: Rapid positioning at maximum traverse speed, no cutting.
  • G1 / G01: Linear feed move at the programmed feed rate.
  • G2 / G3: Clockwise and counterclockwise arc moves.
  • G17 / G18 / G19: Select the XY, XZ, or YZ plane for arcs and cycles.
  • G20 / G21: Inch or millimeter unit mode.
  • G90 / G91: Absolute or incremental distance mode.
  • G40 / G41 / G42: Cancel, left, or right cutter compensation.
  • G43 / G49: Apply or cancel tool length offset.
  • G54 through G59: Select a stored work coordinate system.
  • G80 / G98 / G99: Cancel canned cycle, or set return-to-initial or return-to-R-plane behavior.
  • G96 / G97 / G93 / G94: Constant surface speed, RPM mode, inverse time feed, or feed-per-minute.
  • G61 / G64: Exact stop versus continuous path mode.

A motion mode set with G1 stays active across every subsequent block until another motion code appears, which means an axis-only line like X2.0 Y1.5 after a G1 call still cuts a straight line at the programmed feed, according to Haas's G-code guide. That persistence is convenient for writing compact programs, but it's also where most unintended rapid-into-stock errors start.

Non-modal (Group 00) codes vs modal codes

Group 00 codes are non-modal: they affect only the block where they appear, and the control forgets them immediately afterward. Haas's documentation lists codes like G4 (dwell), G10 (data setting), G28 (home return), G30 (secondary home), and G92 (coordinate system offset) in this category.

  • G4 (dwell) pauses motion for a set time, then has no further effect.
  • G28 with axis words sends the machine home through those axes for that line only.
  • G92 resets the active coordinate system for the block, not permanently.

Because a non-modal block can carry axis words, it can look like it changed the motion mode when it hasn't. The safe rule: restate G00 or G01 explicitly after any non-modal block that includes axis words, so the next move runs under the mode you actually intend, per guidance from Mt. Hood Community College's CNC workbook.

How modal states persist in real programs and common failure modes

Modal states don't reset themselves when you step away from a program. An operator who runs an MDI command mid-job, interrupts a cycle to check a probe, or resumes after an alarm can leave the machine in a mode nobody wrote down, and the next automatic block executes under that leftover state instead of what the programmer intended, according to Haas and the Mt. Hood CNC workbook.

When something feels off before a cycle start, work through this sequence:

  1. Open the controller's Active Codes or Current Commands screen and read every modal group's current value.
  2. Compare that state against what your program expects at that line number.
  3. If anything doesn't match, run the correcting code in MDI before resuming.
  4. Step through the first few blocks in single-block mode to confirm the motion matches what you see on screen.

Checking Active Codes after any interrupt is the single most reliable habit for catching a mismatched mode before it reaches the spindle.

Pro Tip: Treat any manual MDI entry as a reason to recheck every modal group before resuming automatic operation, not just the one you touched.

Practical examples and annotated snippets showing modal behavior

Seeing modal persistence in a short program clears up more confusion than reading a definition twice.

  1. Modal motion example: G1 sets linear feed mode. The next axis-only line has no G-code, yet it still executes as a linear feed move at the programmed feed because G1 remains active, as Haas's guide describes.
  2. Non-modal interruption example: G28 sends the machine toward its reference position for that block only. The Mt. Hood workbook notes that the following line still needs an explicit G01 or G00 restated, because the home-return command did not change the stored motion mode and only borrowed the line.
  3. Safe-start block: A clean program opening typically reads something like G21 G90 G17 G40 G49 G54 G00, explicitly setting millimeters, absolute distancing, the XY plane, canceling cutter and length compensation, and selecting a known work offset before any cutting move.

Run that opening sequence as a dry move with the Z axis retracted before committing to the full program; our safe-start G-code templates walk through building this block for different controllers.

A handful of habits catch most modal errors before they become a scrap part or a broken tool.

  • Open every program with an explicit safe-start block and keep that block in any file you hand off to another operator.
  • After an MDI command, probing cycle, or alarm recovery, check Active Codes and restate your intended motion mode before resuming.
  • Keep a short written checklist for first-run dry moves so new operators aren't guessing which screen to check.
  • Review a controller's modal-group chart before running a program on a machine you haven't programmed before, since groupings vary by manufacturer.

If cutter compensation is part of your workflow, our cutter compensation guide covers how G41 and G42 interact with these same modal rules.

Pro Tip: Laminate your machine's modal-group chart and keep it at the control panel, not just in a binder in the office.

Laminated modal group chart beside CNC control panel

Why modal clarity matters to us

Modal mix-ups are one of the most common, preventable causes of crashes we see discussed across machinist forums and shop floors, and most of them trace back to a mode nobody double-checked before cycle start. We build calculation tools to help address that gap. Use the blog templates referenced above as a starting checklist for your own safe-start habits.

— Availzye

Try Availzye Machinist Pro's G-code tools

We built our G-Code analysis tools to help users review programs. Our GCode Generator and GCode Wizard support G-code work.

Availzyemachinistpro

These calculators sit alongside Job Tracker, Tool Crib, and Maintenance Log inside one subscription, so you're not toggling between a spreadsheet, a paper modal chart, and a separate calculator app. Plans start at Individual for $9.99 CAD per month, with Small Shop and Team tiers for growing crews, all backed by a 7-day free trial. Start your trial and check your next program's modal states before it touches the spindle.

FAQ

How do you use G41 and G42 in CNC turning?

G41 applies cutter compensation to the left of the programmed path and G42 applies it to the right, both staying active until canceled by G40 or replaced by the other. In turning, compensation direction depends on tool orientation relative to the part, so confirm which side matches your setup before the first cut.

What is the difference between G-codes and M-codes?

G-codes control geometric and motion functions such as positioning, feed rate, and coordinate systems, while M-codes handle miscellaneous machine functions like spindle start and stop, coolant, and program end. Both appear in the same program blocks but govern separate parts of machine behavior.

How do you program a CNC machine from scratch?

Programming starts with defining the part geometry, choosing tooling and cutting parameters, then writing G-code blocks that set units, distance mode, work offset, and motion before any cutting moves. A safe-start sequence at the top of the program, followed by a dry run, is standard practice before committing to a full cycle.

What does G28 X0 Y0 Z0 mean?

Hood CNC workbook](https://mhcc.pressbooks.pub/supportcnc/chapter/day-7-the-body/). The X0 Y0 Z0 values define an intermediate point the machine passes through on its way home, not a permanent coordinate change, and any motion mode used before G28 needs to be restated afterward.

Do modal G-codes work the same way on every controller?

The core concept, that a modal code stays active until replaced by another from its group, holds across controllers, but the exact grouping and default states can differ between manufacturers. Always check your specific controller's modal-group chart, since Haas documentation notes these definitions aren't universal.

Sources

For definitive modal-group tables and interpreter behavior, consult Haas's G-code guide, LinuxCNC's documentation, and the NIST RS-274NGC interpreter reference for the standardized interpreter view.