In CNC machining with Fanuc controllers, the M198 code is a powerful feature that allows you to call and execute a subprogram stored on external memory (such as a memory card, data server, or USB device). Unlike the regular M98 subprogram call, which looks inside the machine’s control memory, M198 looks at the external storage and runs the program directly from there.
This can be especially useful when:
-
You want to store large programs externally (instead of limited CNC memory).
-
You run multiple similar programs (toolpaths, probing, etc.) from a card/USB without loading them into CNC memory.
-
You manage part programs centrally and operators only need to call them as needed.
📌 How M198 Works
The general format for calling a subprogram from external memory is:
M198 Pxxxx Lnn
-
Pxxxx → Subprogram number (e.g., 1001 means O1001)
-
Lnn → Number of repetitions (optional, just like in M98)
👉 If L is omitted, the program runs once.
👉 If P is omitted, the controller will look for a file matching the main program number.
⚙️ Important Fanuc Parameters for M198
M198 behavior depends on parameter settings inside the Fanuc control. Here are the key ones:
🔹 Parameter 3404 (I/O Channel Select)
-
This parameter defines the device channel where M198 looks for subprograms.
-
Example values:
-
0 = Puncher (rarely used now)
-
1= Reader (RS232)
-
4= Memory card (CF/PCMCIA slot)
-
5= Embedded Ethernet
-
6= USB memory (on newer Fanuc)
-
-
Bit 0 (NOB): If set to 1, the system ignores the O-number inside the subprogram file and only looks at the file name.
If set to 0, it requires the correct O-number inside the program.
👉 For USB or CF card, most modern Fanuc controls require 3404 = 4 (CF) or 3404 = 6 (USB).
🔹 Parameter 20 (Punch Code)
This defines how subprograms are read and handled. Usually set by OEM, not often changed by end users.
🔹 Program Naming Convention
-
On Fanuc, programs on external storage must follow strict file naming rules.
-
Example: O1000 program must be saved as 1001.MIN or O1001.MIN depending on parameter setting.
-
Some controls accept .nc or .txt , but .min is safest.
📝 Example Usage
Main program in CNC memory:
O0001 (MAIN PROGRAM IN MEMORY)
G21 G40 G90 G54
T0101 M06
G97 S1200 M03
M198 P1001 L1 (CALL SUBPROGRAM O1001 FROM USB / CARD)
M30
%
⚠️ Common Errors with M198
-
SR1966 “File Not Found”
-
The file isn’t named correctly (1001.MIN Vs. O1001.MIN).
-
Parameter 3404 bit0 (NOB) set incorrectly.
-
Wrong channel selected (USB vs. CF card).
-
-
Program Won’t Start
-
Check if the USB/CF card is formatted FAT16/FAT32 (NTFS not supported).
-
Verify the program actually has the correct 0 number inside.
-
-
Multiple Subprograms
-
If more than one program exists in the same file, ensure only one has the correct O-number.
-
✅ Best Practices for M198
-
Always use consistent file names (e.g., 1001.MIN for O1001).
-
Keep subprograms short and modular for easy reuse.
-
Double-check parameter 3404 on your machine for correct channel setup.
-
Use absolute paths if your CNC supports folder structures.
-
If errors occur, test first with a very simple O1001.MIN program.
🚀 Conclusion
The M198 command on Fanuc controllers is a highly efficient way to run external programs directly from a USB or memory card, freeing up your CNC’s internal memory and streamlining program management.
By setting the correct parameters (especially 3404) and following proper file naming conventions, you can eliminate common errors like “File Not Found” and take full advantage of this feature.
