Introduction
Subprograms help you reuse the same set of instructions multiple times without rewriting them. This saves time and reduces mistakes.
Subprograms help you reuse the same set of instructions multiple times without rewriting them. This saves time and reduces mistakes.
O[subprogram_number] (Subprogram start) ... M99 (Return to main program)
O100 (Drill hole subprogram) G81 R2 Z-10 F100 M99
M98 P100 L3
The main program moves to start position, calls the drilling subprogram twice, then ends. The subprogram drills a hole and returns.
O0001 (Main program)
G90 G54
G00 X0 Y0
M98 P100 L2 (Call subprogram O100 twice)
M30
O0100 (Subprogram for drilling)
G81 R2 Z-5 F75
M99Always check your machine's manual for exact subprogram syntax.
Use clear numbering for subprograms to avoid confusion.
Test subprograms separately before calling them multiple times.
Subprograms let you repeat CNC instructions easily.
Use M98 to call and M99 to return from subprograms.
This keeps your CNC code shorter and easier to manage.
O1000; G01 X10 Y10 F100; M99; N10 M98 P1000 L3; M30;
O2000; G01 X20 Y20 F150; M99; N20 M98 P2000 L0; M30;
Pass the test and this pattern moves unknown