Advanced G-Code and M-Code List by CNC Brand: Fanuc, Haas, Siemens, Heidenhain & Mazak
Professional CNC programmers often rely on more than just the standard G00–G03 and M03–M05 codes. Every controller brand offers advanced G/M codes that enable cycles, probing, macro programming, subroutines, and intelligent automation.
This guide compares advanced G and M codes used by Fanuc, Haas, Siemens, Heidenhain, and Mazak, with syntax, usage notes, and control-specific behavior.
📘 Fanuc Advanced Codes (Macro B Compatible)
| Code | Description | Example |
|---|---|---|
| G65 | Custom macro call | G65 P9010 A10 B5 |
| G66/G67 | Modal macro on/off | G66 P9010 A10 → G67 |
| G84.2 | Rigid tapping with peck | G84.2 R2 Z-20 Q5 F50 |
| M198 | Subprogram call from memory card (USB) | M198 P1234 |
| M99 | Return from subprogram | M99 |
| #100–#199 | Common user variables | #101 = 25 |
| #3000 | Alarm message with stop | IF[#101 GT 5] THEN #3000=1 |
🛠️ Haas Advanced Codes
| Code | Description | Notes |
|---|---|---|
| G146 | Bore threading cycle | Live tooling & sub-spindles |
| G47/G48 | Engraving cycles | Text input from code or macros |
| G84.2 | Peck tapping | Similar to Fanuc |
| M109 | Wait until spindle speed reached | Before next toolpath |
| M97 | Call local subprogram | M97 P123 (within same O program) |
| M199 | Auto start next program (USB/NET Share) | Kicks off next job |
| #3000–#3006 | Alarm and message system | Same as Fanuc compatible |
🧠 Siemens (Sinumerik 840D) Advanced Syntax
| Command | Description | Example |
|---|---|---|
| CYCLE800 | 5-Axis transformation cycle | CYCLE800(1,45,30,0,0,0,1) |
| CYCLE832 | High-speed machining | CYCLE832(1,0,2,1) |
| TRAORI | Tool orientation interpolation | TRAORI ON |
| CYCLE84 | Tapping cycle | Same name, different structure |
| $AA_IM[] | System variables | $AA_IM[TOOL] |
| WAIT SEC | Wait command in seconds | WAIT SEC=2.5 |
| CALL LBL / GOTO | Subprogram and flow control | CALL LBL[100] |
🧮 Heidenhain (iTNC 530/640) Advanced Programming
| Command | Description | Example |
|---|---|---|
| CYCL DEF | Fixed cycles (drill, tap, bore) | CYCL DEF 200 DRILLING… |
| LBL, CALL LBL | Label and call subroutines | CALL LBL 10 |
| TOOL DEF, TOOL CALL | Tool definition & usage | TOOL DEF 1 L+100 R+5 |
| FN 1: | Conditional logic (if/else) | FN 1: IF +V.SYS1==0 GOTO 100 |
| M128/M129 | TCP ON/OFF (tool center point) | M128 |
| Q-parameters | Local variables | Q1 = +50 |
⚙️ Mazak (Mazatrol) Advanced Features
Mazak uses conversational programming, but advanced users can still utilize select G/M codes in EIA mode (G-code mode):
| Code | Description | Notes |
|---|---|---|
| M198 | External subprogram call | Similar to Fanuc |
| M226 | Probing cycle (EIA only) | Requires probe option |
| G43.4 | Dynamic TCP (tool center point control) | 5-axis machine only |
| M140 | Turn on tailstock | Live tooling applications |
| M200 | Switch to Mazatrol program | Hybrid machine control |
| Macro Support | Limited in EIA mode | Less flexible than Fanuc/Haas |
📊 Summary Table: Unique Advanced Capabilities by Brand
| Feature/Capability | Fanuc | Haas | Siemens | Heidenhain | Mazak |
|---|---|---|---|---|---|
| Full Macro Support | ✅ | ✅ | ✅ | ⚠️ Partial | ⚠️ Limited |
| Probing Cycles (G65/G66) | ✅ | ✅ | ✅ | ✅ | ⚠️ |
| Advanced High-Speed Cycles | ✅ | ✅ | ✅ | ✅ | ✅ |
| TCP (Tool Center Point) | ✅ | ✅ | ✅ | ✅ | ✅ |
| External USB Subprogram (M198) | ✅ | ✅ | ✅ | ❌ | ✅ |
| Custom M-code Programmability | ⚠️ | ✅ | ✅ | ⚠️ | ❌ |
✅ Final Notes
- Fanuc and Haas offer flexible macro programming.
- Siemens and Heidenhain are powerful for structured cycle-based logic.
- Mazak is optimized for conversational programming but supports G-code in EIA mode.
💡 This guide is essential for any shop working with multiple CNC brands and seeking full postprocessor compatibility.
▶️ Next Suggested Topic:
“Universal CNC Probing Cycles: Cross-Brand Touch & Measurement Integration”
Would you like to continue with that topic?
Leave a comment