Advanced & Hidden G/M Codes in CNC Machines: Fanuc, Haas, Siemens, Heidenhain, Mazak & More
Most CNC programmers only scratch the surface of what their machines can do. While standard G-codes like G0, G1, or M-codes like M3, M5 handle the basics, many control systems support undocumented or OEM-specific codes — often known only to integrators, service engineers, or automation specialists.
This guide reveals powerful, hidden, or rarely documented G/M codes across the top CNC brands and explains how to use them safely, practically, and professionally.
⚠️ Disclaimer: These codes can affect machine behavior. Use simulation and backups. Always verify OEM documentation or consult your control supplier.
🔧 FANUC Hidden G & M Codes
FANUC controls (0i, 30i, 31i, 32i series) hide advanced power inside system variables and custom macro environments. Most are not included in basic user manuals.
🔹 G-Codes
| Code | Function | Notes |
|---|---|---|
| G10 | Write parameter via program | Must enable parameter write via 137#7 |
| G66 | Modal macro subprogram call | Advanced cycle control |
| G70–G76 | Threading cycles | Not all are documented in menus |
| G53.1 | Cancel tool offset + position | Not standard in all versions |
🔹 M-Codes
| Code | Function | Use Case |
|---|---|---|
| M19 | Spindle orientation | Required for rigid tapping |
| M29 | Rigid tapping pre-activation | Must precede tapping motion |
| M198 | Subprogram call from memory card | External program from CF/USB |
| M88/M89 | Through-spindle coolant ON/OFF | Only if machine has TSC unit |
🛠️ Example: Rigid Tapping with Custom Macro
G20 G40 G80 G17 G90
M6 T10
G0 G90 G54 X0 Y0 S1000 M3
G43 H10 Z1.0 M8
M29 S1000 ; Engage rigid tapping mode
G84 Z-0.75 R0.1 F20.0
G80 M9
G28 G91 Z0 M5
M30
💡 M29 must precede the tapping motion. Omit it, and tapping fails or errors.
🔍 Hidden System Access
- PARAM WRITE ENABLE must be set to 1 to allow G10 to function.
- Diagnostic Page → Monitor PMC signals (in/out relays like X0123 or Y0145).
- System Variables (e.g., #500–#999) → Track spindle load, alarms, timers.
🛠️ HAAS Hidden & User M-Codes
Haas CNC controls (Classic and NGC) include user-definable M-codes, undocumented macro codes, and even the ability to display images/videos through commands.
🔹 M-Codes
| Code | Function | Hidden? |
|---|---|---|
| M36 | Clamp pallet (HMC) | ✔️ Often undocumented |
| M117 | Display message on screen | ✔️ Internal use |
| M130 | Display image or video via USB | ✔️ Needs setup |
| M88/M89 | Through-spindle coolant control | ✔️ With TSC |
| M199 | Program auto-restart on power up | ✔️ Optional feature |
🔹 G-Codes
| Code | Function | Comment |
|---|---|---|
| G187 | Control smoothness (accuracy) | Rarely used but powerful |
| G103 | Limit motion buffer | Useful for short burst control |
| G107 | Cylindrical interpolation (lathe) | Very few use it |
🧪 Example: Display Custom Work Instruction
M130 P1.jpg ; Displays image on Haas screen from USB drive
M117 Work Setup Complete
P1.jpgmust exist in the root of the USB.- Enable “Media Display” feature in Haas control.
🧠 Haas DEBUG + Hidden Startup Modes
| Action | Description |
|---|---|
DEBUG + Power ON | Activates diagnostic/debug mode |
MEM + Power ON | Access memory test utility |
PRGRM/CONVRS + Power | Access graphic preview |
🛡️ Use only under guidance. Some menus allow parameter modification.
⚙️ SIEMENS SINUMERIK: OEM Cycles & Advanced Functions
Siemens controls (828D, 840D sl) offer deep customization through HMI variables and hidden user cycles.
🔹 Hidden Cycles & G/M Codes
| Code | Function |
|---|---|
| G700–G799 | OEM-defined user cycles |
| G250 | Rotary frame transformation |
| M101–M199 | OEM-reserved M codes |
| M30 R1 | Reset + rewind option |
🧠 Siemens Engineering Menu Access
- Power on + hold “NC Start”
- Access Diagnosis > Internal Logs
- Use HMI Advanced for variable tracing
Siemens also supports inline
IFlogic using ISO codes + NC variables, though rarely used in basic shops.
🎯 HEIDENHAIN (iTNC 530, TNC 640): Q Logic & Service Modes
Heidenhain is famous for its conversational format, but advanced users exploit:
- Q Parameters: Logic, arrays, conditional jumps
- MOD Key + Power ON: Hidden service menu
- LIFTOFF, PLANE RESET: For dynamic 5-axis recovery
🔹 Example: Tool Lift If Z-depth Reached
IF +Z < -50
LIFTOFF
ENDIF
🔹 Special M Codes
| M Code | Function |
|---|---|
| M91 | Disable override |
| M92 | Enable override |
| M125 | Coolant via tool |
🧠 MAZAK (MAZATROL + EIA): EIA Hidden Features
Mazak supports both conversational and EIA (G-code). Hidden codes often depend on SmoothX or Matrix controls.
🔹 Rare Codes
| Code | Function |
|---|---|
| G05.1 Q1 | AI Contour Control (high-speed accuracy) |
| M203 | Custom M-code range start |
| M299 | Last user-defined M-code |
📌 Example: Synchronized Spindle Control
G05.1 Q1
G97 S2500 M203 ; Sync spindle motion with servo
🌀 OKUMA (OSP-P300 / P200)
Okuma hides many advanced operations under:
- Eng Param Access: Technician-only screen
- G140: Unique threading retraction not in manuals
- G111–G199: Custom cycles, probing, M-code triggers
🔹 Unique Hidden Functions
| G/M Code | Function |
|---|---|
| G140 | Threading withdrawal |
| M98 P1 | Calls subprogram 1 |
| M250 | Spindle mode switching |
🧩 FAGOR 8065 / 8070 Hidden Controls
Fagor uses both standard and conversational logic, but you can unlock:
- G87.1: Deep hole drilling with high-pressure logic
- M19.2: High-accuracy spindle orientation
- G10.1: Write system parameter from NC block
🧷 HURCO (WinMax): Macro Commands
Hurco’s conversational programming is powerful, but it also supports standard G-code + user M-codes.
| Code | Function |
|---|---|
| M117 | Start auxiliary device |
| G103.1 | Buffered motion control |
| G83.2 | Deep peck drilling with dwell |
Hurco’s hidden menus accessed via USB + internal parameter reset.
🛠️ DMG MORI (MAPPS / CELOS)
DMG Mori uses Siemens or FANUC as base, but extends them via:
- CELOS apps
- High-speed mode via
G05 P10000 - Vacuum chuck M-codes (
M1200–M1299)
🧪 Real-World Use: Probe Activation via Hidden M-Code
Example on FANUC-based Mazak:
G65 P9810 Z0.1 F100 ; Call probing macro (hidden file)
M61 ; Probe arm extend
G103 ; Buffer flush for probing sequence
📊 Summary Table: Brand vs Hidden Code Usage
| Brand | Hidden G-Codes | Hidden M-Codes | Service Modes Access |
|---|---|---|---|
| Fanuc | G53.1, G66 | M198, M29 | PARAM + PMC ladder |
| Haas | G187, G103 | M130, M199 | DEBUG mode, USB boot menus |
| Siemens | G700 series | M199+ | NC Start + power-on + HMI |
| Mazak | G05.1 Q1 | M203–299 | Maintenance > EIA unlock |
| Heidenhain | LIFTOFF, Q logic | M91–M125 | MOD + Power key |
| Okuma | G140, G111 | M250+ | Engineer parameters + OSP SIM |
| Fagor | G87.1 | M19.2 | OEM codes in conv. editor |
| Hurco | G83.2 | M117 | USB + WinMax debug |
| DMG Mori | G05 P10000 | M12xx | CELOS + Siemens core access |
✅ Best Practices for Hidden G/M Code Usage
- Simulate first – use NC simulators like NC Viewer or CAM software
- Backup system parameters
- Log every undocumented code used in production
- Do not allow operators to run service codes
- Use custom macros as alternatives when possible
📌 Final Thoughts
Hidden and advanced codes are like secret keys to your CNC machine. They:
- Enhance performance
- Enable smarter automation
- Allow deeper control and customization
- Let integrators bypass limitations
But with power comes responsibility. Never use undocumented codes without testing and understanding the impact.
💬 Want brand-specific cheat sheets, parameter unlock tutorials, or advanced macro guides? Just ask.
Leave a comment