NCBy Kezuriba Editorial Team

CNC M-Code List and Machine Builder Differences: Execution Timing, Multiple M-Codes per Block, and Colliding Numbers

Machine builders assign M-codes in the PLC. Even M07 behaves differently by machine, so always verify in your manual.

Chips, the Kezuriba mascot
CNC M-Code List and Machine Builder Differences: Execution Timing, Multiple M-Codes per Block, and Colliding Numbers

M-codes (miscellaneous functions) command machine actions other than axis motion, such as spindle rotation, coolant, tool changes, and program end[1][10]. While G-codes are largely defined by the CNC control (FANUC, Mitsubishi Electric, Siemens, etc.), M-codes are assigned by each machine tool builder inside the PLC (ladder logic)[2][4]. As a result, while core codes such as M00–M09 and M30 are widely shared, numbers like M07, M10/M11, M29, and the M50+ range can mean completely different things depending on the machine. This guide brings together a searchable lookup table comparing 7 control/builder dialects, an interactive execution-timing simulator showing simultaneous vs. post-motion behavior, rules for multiple M-codes per block and a safe program-reuse checklist all on one page.

  • Machine Builders Assign M-CodesEven between two FANUC-equipped machines, different builders or options produce different M-code tables[2][5].
  • Simultaneous vs. After MotionM03 and M08 typically fire with motion, whereas M05, M09, M00, and M30 normally execute after axis motion finishes[1][4].
  • Audit Colliding Numbers FirstAlways cross-check M07 (mist vs. shower), M10/M11 (chuck clamp/unclamp reversal), M29, and M97 before porting a program[5][9].

M-Code List(Search, Control Selector & Collision Filter)

Filter 22 essential M-codes by category, CNC/builder dialect, or collision warnings. Click any code link to open its full Kezuriba reference page (syntax, caveats, and related G-codes). This table summarizes standard assignments from public documentation; your specific machine's manual always takes precedence.

INTERACTIVE

Interactive M-Code Finder & Builder Comparison

Search by number or function and switch controls to check builder differences and code collisions.

* Many M-codes are assigned by each machine builder in PLC ladder logic and vary by model and options even on the same CNC. Always follow your machine's manual.

For the complete G-code and M-code database—including mill vs. lathe System A differences—see the G-Code & M-Code Reference Database.

Why M-Codes Differ by Machine Builder(CNC vs. PLC Architecture)

A CNC machine tool's controller operates in two distinct layers: the CNC (numerical controller) and the PLC (programmable logic controller / ladder logic)[2]. G-codes governing X/Y/Z interpolation are handled directly by the CNC, whereas M-code numbers are passed to the PLC, where the machine builder's ladder logic actuates solenoids, relays, and spindle drives. Once the action completes, the PLC sends a Finish signal (FIN) back to the CNC before execution advances to the next block[1][2].

CNC ControllerG-Codes → Axis ServosM-Codes → PLC (Ladder)Assigned by Machine BuilderInterprets blocks line by lineCustomized by each builderSpindle, Coolant, Chuck, ATCPLC returns Finish signal (FIN) to CNC before the next block starts
Conceptual diagram of CNC vs. PLC responsibilities. Because M-codes depend on the machine builder's PLC design, code assignments vary even across machines sharing the same CNC control[1][2].

Because of this architecture, even two machines both equipped with a FANUC 0i-MF Plus can assign through-spindle coolant to M50 on Builder A's mill and M07 or M88 on Builder B's machine. Conversely, core numbers such as M00, M01, M02, M03, M04, M05, M08, M09, M30, M98, and M99 remain standardized across builders under ISO 6983 conventions[8][3].

Execution Timing When Combined with Axis Motion on One Line

A frequent source of confusion—and near-misses on the shop floor—is which executes first when a motion command (G00/G01) and an M-code appear in the same block[1][4]. Switch between the 5 realistic NC blocks below to visualize how axis motion, M-code output, FIN wait, and the next block line up.

TIMING SIM

Interactive Single-Block Execution Timing Simulator

Select a sample NC block to inspect axis motion, M-code output, FIN wait timing, and FANUC-type vs. Haas behavior on a live timeline.

Under standard FANUC-compatible, Mitsubishi Electric, and Siemens defaults, M-codes split into simultaneous output (with motion) and post-motion output (after motion completes) as two standard execution modes[1][4][8].

M-CodeFunctionTypical Execution TimingSafe Shop-Floor Practice
M03 / M04Spindle CW / CCWSimultaneous with motion (usually pre-output)Some machines spin up while moving; command spindle start on its own standalone line before approaching the workpiece.
M08Coolant ONSimultaneous with motion (usually pre-output)Starts spraying during approach; place on a standalone line or safe rapid approach ahead of the cut.
M05Spindle stopAfter motion completes (post-output)Stops after reaching the endpoint if paired with motion; best commanded alone after retracting Z to a safe clearance plane.
M09Coolant OFFAfter motion completes (post-output)Typically shuts off after retracting out of a bore, though some machines output early—verify on your machine.
M00 / M01Program / Optional StopAfter motion completes (post-output)Pauses after block motion completes. Explicitly retract and stop the spindle (M05) before opening doors.
M02 / M30Program End (and Rewind)After motion completes (post-output)Ends automatic cycle after motion finishes. M30 also rewinds the cursor to the start of the program.
Key Point: Waiting for the Finish Signal (FIN): When M03 or M08 shares a block with axis motion, the M-code is sent to the PLC as motion starts. Even after motion finishes, the CNC waits for the PLC's FIN signal (such as spindle-at-speed) before executing the next block. Still, if rapid approach finishes while the spindle is still accelerating, the tool can approach under-speed—so commanding spindle start (M03 S_) and spindle stop (M05) on standalone blocks is the safest baseline.

Can You Put Multiple M-Codes in One Block?(1 Standard vs. 3–4 Extended)

M03 S1500 M08 Whether multiple M-codes can be combined on a single line (e.g., M03 S1500 M08) depends on control specifications, multi-M options, and modal group conflicts[1][3][9].

With Multi-M Option (Different Groups)M03 S2000 M08 ;Mitsubishi M800/M80: up to 4 sets (parameter-dependent)Siemens 840D sl: up to 5 M-functions per blockFANUC-compatible: up to 3 with multi-M option* Same-group codes (e.g. M03 & M04) cannot be mixedPatterns That Alarm or ConflictM03 M05 / M08 M09 ;• Same-group combination → Alarm• 1-M-per-block controls (Haas, etc.) → Error• Cannot combine with M00/M01/M02/M30/M98/M99→ When in doubt, use 1 M-code per block
Rules and restrictions for multiple M-codes in one block, based on Mitsubishi Electric IB-1500057, Siemens ISO Dialects, Haas, and LinuxCNC specifications[1][3][5][9].

In particular, program-flow M-codes such as M00, M01, M02, M30, M98, and M99 generally cannot be combined with other M-codes even on multi-M controls[1][3]. Moreover, porting a multi-M program to a one-M-per-block control such as Haas triggers alarms on every combined line. Writing one M-code per line from the start adds virtually zero cycle time while keeping programs portable and safe across all machines.

6 Colliding M-Codes Across Builders(High-Risk Reuse Traps)

The classic example of one number triggering totally different hardware across builders is M07. In NIST RS274/NGC, LinuxCNC, and many FANUC-type machines, M07 turns on mist coolant, whereas on Haas machining centers M07 activates overhead shower coolant[8][9][7].

M08: Flood (Standard)M07: Mist (FANUC-type, etc.)M07: Shower (Haas Mill, etc.)Standard coolant across buildersMist in NIST / LinuxCNC specsSame M07, different hardware
Illustration comparing M08 and M07 coolant behaviors. Depending on the machine builder's PLC assignment, M07 can activate mist, air blast, enclosure shower, or high-pressure coolant[7][8][9].

Beyond M07, here are 6 colliding M-code pairs you should always inspect before reusing a program from another builder or CAM post. Because public Okuma OSP manuals were not available, Okuma references reflect Autodesk CAM post-processor output for guidance only[11].

NumberCommon Meaning AAlternate Builder Meaning BRisk When Porting Programs
M07Mist coolant ON (NIST, LinuxCNC, common FANUC-type)Shower coolant ON (Haas Mill) / through-spindle or high-pressure coolant (some models)Running M07 expecting mist or air can unexpectedly flood the enclosure or fire high-pressure coolant.
M10 / M11Chuck clamp / unclamp (Haas Lathe and some CNC lathes)4th-axis brake clamp / unclamp (Haas Mill, some VMCs) or pallet functionsNot only do lathes and mills differ, some lathe builders invert which number clamps vs. unclamps the chuck.
M19Spindle orientation (FANUC, Mitsubishi, Haas, Siemens ISO)Angle address word varies (P / R / S / SPOS=); arbitrary-angle positioning is often an optionUsed for boring bar retract or fixture clearance; wrong angle syntax causes alarms or misoriented stops.
M29Rigid tapping mode ON (FANUC-type, Mitsubishi, Siemens ISO)Haas runs rigid tapping with G84 alone (no M29); Okuma uses G284 / different M-code conventionsPorting M29 directly can trigger an invalid M-code alarm or invoke an unrelated builder function.
M97 / M98M98: External subprogram call (FANUC, Mitsubishi, Haas, etc.)M97: Haas local subroutine call within the same file (P targets line number N)Haas post output M97 P100 fails or triggers a builder-specific function on FANUC-compatible controls.
M88 / M89Haas Mill: Through-spindle coolant (TSC) ON / OFFBuilder-specific on FANUC-type Japanese mills (commonly M50/M51, M07/M09, etc.)High-pressure coolant codes vary widely across builders—replace every instance from the target manual.

5-Step Safety Verification Before Reusing Programs on Another Machine

Before pressing Cycle Start on a ported program or new CAM post output, audit all M-codes using these 5 steps.

1. Verify M-codes & toolpath on screen2. Dry-run clear of the workpiece3. Lowest rapid override + Single Block ON, line by line
Illustration of first-article dry-run verification. Because M-code mismatches can cause crashes or unclamping hazards, always prove out line by line at a safe clearance height.
  1. Search every M-code in the programSearch for 'M' in your editor and list every number outside core M00–M09, M30, and M98/M99 (especially M07, M10–M29, and M50+).
  2. Cross-check each code against the target machine manualEven with the same CNC (e.g., FANUC), different machine builders and options have different M-code tables. Treat the machine's manual as the single source of truth.
  3. Split multi-M and motion-mixed blocksSplitting combined lines such as 'G00 Z50. M05 M09' into separate Z-retract, M05, and M09 lines eliminates both timing ambiguity and one-M-per-block alarms.
  4. Dry-run at minimum rapid override in Single BlockWith the tool well clear of the part (or no workpiece loaded), step through block by block and confirm spindle, coolant, chuck, ATC, and FIN handshakes visually.
  5. Standardize your CAM post processorHand-editing every time invites repeat errors on the next post. Save verified M-code mappings in each machine's dedicated CAM post.

To practice CNC programming fundamentals interactively in your browser, try Introduction to CNC Lathe Programs / Machining Center Programming for Beginners / 30 CNC Programming Practice Problems (auto-graded). For subprograms (M98/M99) and parametric programming, see Introduction to custom macros and subprograms.

FAQ

What is the difference between M02 and M30?
Both end the program (often stopping the spindle/coolant and resetting modals), but M30 also rewinds control back to the start of the program[1][8]. For repeat production runs, M30 is standard because the next Cycle Start begins immediately from the top.
When should I use M00 vs. M01?
M00 always pauses regardless of panel switches (for mandatory part flips or chip clearing), whereas M01 pauses only when the panel's Optional Stop switch is turned ON[1][5]. Placing M01 before tool changes lets you inspect first articles easily, then run continuously in production with the switch OFF.
Are all M-codes identical across machines that share a FANUC control?
No. While core codes like M00–M09, M30, and M98/M99 are largely shared, high-pressure coolant, air blast, chip conveyors, part catchers, chuck clamp/unclamp, and 4th-axis brakes are assigned independently by each machine tool builder in the PLC[2]. Always confirm in each machine's own manual.
Is it safe to write two M-codes like M03 S1500 M08 on one line?
Mitsubishi M800/M80, Siemens, and FANUC machines with the multi-M option allow different groups on one line, but one-M-per-block machines such as Haas raise an alarm.[1][5]. Combining M00/M01/M02/M30/M98/M99 with another M-code is also prohibited on most controls. For safety and portability, writing one M-code per line is best.

Sources

  1. Mitsubishi Electric, "M800/M80/E80/C80 Series Programming Manual (Machining Center) IB-1500057" (M-codes, multi-M blocks, FIN signal)
  2. Mitsubishi Electric FA e-Learning, "CNC Basics" (CNC vs. PLC architecture and M-code FIN handshake)
  3. Siemens, "SINUMERIK 840D sl / 828D ISO Dialects Milling" (FANUC-compatible M-codes and multi-M blocks)
  4. Siemens, "SINUMERIK Programming Manual Fundamentals" (Auxiliary function output timing and M00–M30)
  5. Haas Automation, "Mill M-Codes" (M07 shower coolant, M19, M88, M97/M98, etc.)
  6. Haas Automation, "Lathe M-Codes" (M10/M11 chuck, M14/M15, M31/M33, etc.)
  7. Haas Automation, "M08 Coolant On / M07 Shower Coolant"
  8. NIST, "The NIST RS274NGC Interpreter - Version 3" (M-code specifications and in-block order of execution)
  9. LinuxCNC Documentation, "M Codes" (M07 mist, M08 flood, modal groups and limits)
  10. Ministry of Health, Labour and Welfare (Japan), Vocational Training Text "NC Lathe Operation" (FANUC-type M-codes)
  11. Autodesk CAM Post Library, "Okuma Post Processor" (Reference: Okuma OSP M-code output)

More articles