CNC Subroutines: M98, G65 & Nested Calls

Table of Contents

The main program can call subroutines, and a subroutine can call another subroutine, a process known as subroutine nesting.

Applying subroutine nesting in CNC machining simplifies calculations, fully utilizes CNC system capabilities, facilitates program verification, and reduces programming errors.

In CNC machine tool education, instructors emphasize subroutines as a key learning point. Several researchers have systematically introduced subroutine-related content.

Lathes, mills, and machining centers use subroutines, and Huazhong Century Star CNC articles focus on various groove machining.

Experts have introduced innovative applications of subroutines in CNC lathe programming, specifically achieving composite cycle functionality.

Experts studied deep-slot CNC lathe machining using four subroutine methods: G01, nested G01, G75, and G75 with subroutine.

Researchers have investigated subroutine programming and its applications in CNC lathe and milling operations.

Experts introduced the application of subroutine calls and milling cycles in keyway milling, utilizing the LCYC75 milling cycle for programming.

Tapping commands work on lathes and mills, with experts applying Siemens asynchronous subroutines for rigid tapping.

Subroutine Call Methods

Subroutines in CNC programming allow repeated execution of specific code blocks, improving program efficiency and maintainability. The following sections describe common methods for calling subroutines.

  • Calling Subroutines with the M98 Command

The M98 command, a common subroutine call, requires the programmer to pre-store the subroutine; using M98 with the subroutine number allows the program to call nested subroutines.

  • Calling Subroutines with the G65 Command

The programmer uses G65, another subroutine call method, by placing the subroutine at the end of the main program and specifying its address in the P segment.

Call a G65 subroutine with G65Px; control returns to the main program after completion.

Subroutine Call Examples

Three examples demonstrate how FANUC CNC systems simplify programming using subroutines.

Part 1 (Figure 1) requires two slots and a chamfer on the right side.

First, cut the slots, then chamfer the left and right sides using the respective tool positions to avoid interference.

Operators set and program the tools at the left position, while they machine the right chamfer from the right position.

Operators must take care to avoid confusion with programming coordinates. Table 1 below shows the program for Workpiece 1.

Figure 1 Workpiece 1
Figure 1 Workpiece 1
Table 1 Workpiece 1 Program
Table 1 Workpiece 1 Program

Part 2 (Figure 2) is a challenging intermediate CNC lathe exam question; first, study the drawing and use the tolerance midpoint for dimensions.

Programming uses three programs: O0231 for the left side, O0232 for the right side, and O0233 as the subroutine.

Figure 2 Workpiece 2
Figure 2 Workpiece 2

Use a ϕ56×98mm blank with an external cutter and 3mm grooving cutter, setting the right end center as origin; see Table 2 for the program.

Table 2 Workpiece 2 Program
Table 2 Workpiece 2 Program

Beginners should start with simple subroutine examples, mastering them before advancing; see Workpiece 3 in Figure 3.

Figure 3 Workpiece Three
Figure 3 Workpiece Three

Use a ϕ43×70mm blank with a 4mm slotting tool, setting the right end center as origin; assume a front tool holder.

After machining, the workpiece length can be manually cut to length using the grooving tool.

This task can also use the simpler G75 cycle; see Workpiece 3’s program in Table 3.

Table 3 Workpiece Three Program
Table 3 Workpiece Three Program

Conclusion

This article summarizes key techniques for subroutine calls:

When using subroutines, calculate tool-change and groove start coordinates, and reduce cutting speed slightly to prevent vibration.

Use the software’s dimension annotation to find unknown coordinates, avoiding complex calculations.

Third, subroutines can employ absolute programming, relative programming, or a combination of both.

Fourth, subroutines can sometimes be applied to shapes that are not entirely identical.

0/5 (0 Reviews)
Scroll to Top