CNC G-Code & M-Code Comparison Across Fanuc, Haas, Siemens, Heidenhain & Mazak
CNC programming varies significantly across different machine brands. While G-codes and M-codes serve similar purposes, their implementation and syntax may differ between controllers like Fanuc, Haas, Siemens, Heidenhain, and Mazak (Mazatrol).
This guide compares the most important G/M codes across all major platforms — helping CNC programmers avoid errors and streamline cross-machine setups.
🧾 Full G-Code & M-Code Comparison Table
| Function | Fanuc | Haas | Siemens | Heidenhain | Mazak (Mazatrol) |
|---|---|---|---|---|---|
| Rapid Positioning | G00 | G00 | G00 | G00 | G00 |
| Linear Interpolation | G01 | G01 | G01 | G01 | G01 |
| CW Arc (Circle) | G02 | G02 | G02 | G02 | G02 |
| CCW Arc | G03 | G03 | G03 | G03 | G03 |
| Dwell (Pause) | G04 P# | G04 P# | G04 P# | G04 P# | G04 P# |
| Tool Length Compensation + | G43 | G43 | G43 | L… R… | T-code system |
| Tool Length Compensation – | G44 | G44 | G44 | L… R… | T-code system |
| Cancel Tool Length Comp. | G49 | G49 | G49 | G49 | T-code system |
| Cutter Compensation Left | G41 | G41 | G41 | L… | T-code system |
| Cutter Compensation Right | G42 | G42 | G42 | L… | T-code system |
| Cancel Cutter Comp. | G40 | G40 | G40 | G40 | T-code system |
| Drilling Cycle | G81 | G81 | CYCLE81 | CYCL DEF 200 | G81 |
| Peck Drilling | G83 | G83 | CYCLE83 | CYCL DEF 201 | G83 |
| Tapping Cycle | G84 | G84 | CYCLE84 | CYCL DEF 207 | G84 |
| Return to Zero (Home) | G28 | G28 | G28 | L Z0 | G28 |
| Program End | M30 | M30 | M30 | M30 | M30 |
| Spindle CW On | M03 | M03 | M03 | M03 | M03 |
| Spindle CCW On | M04 | M04 | M04 | M04 | M04 |
| Spindle Off | M05 | M05 | M05 | M05 | M05 |
| Coolant On | M08 | M08 | M08 | M08 | M08 |
| Coolant Off | M09 | M09 | M09 | M09 | M09 |
| Tool Change | M06 | M06 | M06 | TOOL DEF + CALL | M06 (T-code) |
| Optional Stop | M01 | M01 | M01 | M01 | M01 |
| Subprogram Call | M98 | M98 | CALL or CYCLE DEF | CALL LBL | G65–G66 or Mazatrol page |
| Subprogram Return | M99 | M99 | M17 or RETURN | RET | RETURN |
🧠 Key Observations
- Fanuc & Haas use very similar G/M code sets (Fanuc compatibility).
- Siemens introduces named cycles (e.g., CYCLE81) instead of G81–G89.
- Heidenhain uses conversational programming with
CYCL DEFsyntax. - Mazak (Mazatrol) often abstracts G/M codes behind menus or pages.
💡 For cross-platform programming, always confirm controller-specific behavior — even if the G-code is identical in name.
📘 How to Use This Table
- For multi-brand shops: use it as a cheat sheet for transferring part programs.
- For post-processor development: ensure each CAM post aligns with correct syntax.
- For training and onboarding: teach new operators how same function differs across brands.
✅ Final Tips
- Don’t assume G/M codes are universal.
- Use your machine’s parameter list or G-code guide (often stored in control).
- When in doubt, simulate first — especially with canned cycles or cutter compensation.
- In high-mix shops, label each program with the target controller:
O1000 (HAAS VF-2SS)vsO1000 (SIEMENS 840D)
📌 Bookmark this guide as your universal CNC G/M code translator.
▶️ Next Suggested Topic:
“Multi-Brand CNC Post Processor Design: How to Generate Compatible G-Code from One CAM Setup”
Would you like to continue with that subject?
Leave a comment