M198 Explained: Calling External Subprograms via USB, DNC, or Card
M198 is a powerful but underused M-code that allows CNC programs to call subprograms stored on external media — such as USB drives, memory cards, or DNC servers — without copying them into the main program memory.
This is essential for managing large part programs, families of similar parts, or modular toolpaths.
🔍 What Does M198 Do?
When called in a main program, M198 tells the controller:
“Execute a subprogram located in a different storage device or media.”
It is often used in Fanuc, Haas, Siemens, and other controllers with multi-channel I/O support.
🔧 Syntax (Fanuc-style Example)
M198 P1234
P1234→ Calls external subprogramO1234- That subprogram must exist on:
- USB drive
- Memory card (CF, SD, etc.)
- Network (DNC system)
- PCMCIA (older Fanuc)
The file should be named O1234 or 1234.NC depending on controller.
📁 Common Application: Family-of-Parts
Main program:
O1000 (Main)
T01 M06
G90 G54 X0 Y0
M198 P2000 ; Call program for part #1
G55
M198 P2001 ; Call program for part #2
G56
M198 P2002 ; Call program for part #3
M30
Each part-specific program stays in external memory — no need to load them all into control manually.
⚠️ Important Rules
- The controller must support external media read (check
I/O channelsettings) - File names must match controller format (e.g.,
O1234, not1234.tap) - Some systems require enabling
REMOTE MODEor settingMDI + EXTfor media access - On older controls, M198 may only work with Program Restart ON
🧪 Haas Example (Using USB)
M198 P2000 L3
P2000→ Call subprogramO2000.NCon USBL3→ Repeat the subprogram 3 times
The file must exist in the root directory of the USB drive.
🧰 Use Cases
| Scenario | Why Use M198? |
|---|---|
| Large files (CAM-generated) | Run from DNC without loading to RAM |
| Part families / modular paths | Share subprograms easily |
| Multiple machines with USB | Plug & play setup without reloading |
| Tool change optimization | One program per toolpath section |
✅ Best Practices
- Use consistent file naming: O2001, O2002, etc.
- Always test M198 calls in single block mode
- Maintain backups of external subprograms
- Use
GOTOorM99inside subprograms to ensure correct return - Avoid using
M30in subprograms — useM99instead!
🧠 Summary
| Feature | M198 |
|---|---|
| Purpose | Call external subprogram |
| Requires | USB, DNC, or card support |
| Controller Support | Fanuc, Haas, Siemens, others |
| Return Behavior | Returns to main after M99 |
| Use With | Modular or large CAM programs |
Leave a comment