G65 vs M98: Macro Calls vs Subprograms in CNC Programming
Both G65 and M98 are used to call external blocks of G-code, but they serve very different purposes.
G65is used to call a macro program with parametersM98is used to call a fixed-format subprogram
Understanding when and how to use each helps make your programs cleaner, modular, and more powerful.
🧠 Key Differences
| Feature | G65 | M98 |
|---|---|---|
| Type | Macro call | Subprogram call |
| Parameters | Accepts variables (A, B, C…) | No direct parameters |
| Return | Auto return after M99 | Auto return after M99 |
| Flexibility | High – dynamic behavior | Medium – fixed behavior |
| Common Use | Probing, loops, automation | Repeated drilling, moves |
| Required Setup | Macro B enabled | None (standard support) |
🔧 G65 Syntax
G65 P9010 A50.0 B25.0
P9010: Calls macro programO9010A,B, etc.: Pass parameters as#1,#2, etc. in the macro
Inside O9010:
O9010
G00 X#1 Y#2
M99
✅ Best for probing, tool measurement, parametric routines
🔧 M98 Syntax
M98 P1234 L3
P1234: Calls subprogramO1234L3: Repeats it 3 times (optional)
Inside O1234:
O1234
G81 Z-15 R2 F100
M99
✅ Best for repetitive canned cycles, fixed drilling patterns
📘 When to Use G65
- You want to pass different values each time
- You need calculations, conditional logic, or loops
- Macro B is available and enabled
- You’re working with probing cycles (e.g., Renishaw routines)
📘 When to Use M98
- You need to repeat identical blocks
- The call requires no variable input
- You’re using a simple subprogram (e.g., spot drill pattern)
- Compatible with older machines without macro support
🧪 Example Use Case
G65 for Probing:
G65 P9811 X0 Y0 Z10 Q1
Calls Renishaw macro O9811 to probe the center of a bore.
M98 for Drilling:
M98 P3000 L5
Calls program O3000 (fixed peck drilling cycle) five times.
⚠️ Caution
- G65 can lead to variable conflicts if macros are not isolated or protected
- M98 programs are less flexible, can’t change behavior without editing subprogram
- Always test return flow (
M99) carefully in both
✅ Best Practices
- Use G65 for automation, smart routines, and macros
- Use M98 for basic loops, patterns, or canned cycles
- Keep macro programs in
O9000–O9999range and protect them - Comment your parameter usage (
#1 = A,#2 = B, etc.)
🧠 Summary
| Feature | G65 | M98 |
|---|---|---|
| Purpose | Parametric macro call | Static subprogram call |
| Parameters | Yes (A–Z → #1–#26) | No direct parameters |
| Flexibility | Very High | Medium |
| Requires | Macro B enabled | None |
| Return With | M99 | M99 |
Leave a comment