Collage pictures of many performers doing circus tricks
TOP
Function Calling:
MCALL
The subroutine in the block containing MCALL is called automatically after each successive block containing a path motion. The call acts until the next MCALL is called. The modal call of the subroutine which contains MCALL or quitting of the call requires a separate block.
MCALL is advantageous, for example, when producing drill patterns. N10 MCALL CYCLE82(100, 0, 1, -10, 2) ; Drilling cycle 82 N20 HOLES1(1, 2, 45, 2, 2, 1) ; Cycle for row of holes; after each approach of the hole position, CYCLE82(...) will be called with the transfer parameters N30 MCALL ; Modal call of CYCLE82(...) completed N40 M30
CALL
Indirect cycle call
Special form of the cycle call; no parameter transfer; the name of the cycle is stored in a variable; only intended for cycle-internal use e.g N10 CALL VARNAME ; variable name
Subroutine
Ways to call a subroutine
NOTE: A subroutine is a CNC file with extension SPF such as SPECIAL_DRILL.SPF. Subroutine execution terminates with M17 or RET. If you use an .mpf extension then use M30 for program end.
N10 DEF REAL RTP, RFP, SDIS, DP, DTB N50 CYCLE83(110, 90, 0, -80, 0, -10, 0, 0,0, 0, 1, 0) N70 RTP=100 RFP= 95.5 SDIS=1, DP=-5, DTB=3 ; Set transfer parameters for cycle 82 N80 CYCLE82(RTP, RFP, SDIS, DP, , DTB) N10 HELLO785 P3 ; Call subroutine HELLO785, 3 cycles N10 MCALL CYCLE82(100, 0, 1, -10, 2) ; Drilling cycle 82 N20 HOLES1(1, 2, 45, 2, 2, 1) ; Cycle for row of holes; after each approach of the hole position, CYCLE82(...) will be called with the transfer parameters N30 MCALL ; Modal call of CYCLE82(...) completed N40 M30 ; the subroutine format L785; N10 G00 X10 ... ... M2 or RET
: Good practice to GET and SAVE all modal states at the beginning of the subroutine and restore them at the end Basically, there is no difference between a main program and a subroutine. Frequently recurring machining sequences are stored in subroutines, e.g certain contour shapes. These subroutines are called at the appropriate locations in the main program and then executed. One form of a subroutine is the machining cycle. The machining cycles contain generally valid machining cases (e.g. drilling, tapping, groove cutting, etc.). By assigning values via included transfer parameters, you can adapt the subroutine to your specific application. See the following illustration for example for using a subroutine for a workpiece four times: Like main programs, subroutines contain M2 - end of program in the last block of the program sequence. This means a return to the program level where the subroutine was called from.

End of program

The end instruction RET can also be used instead of the M2 program end in the subroutine. RET must be programmed in a separate block. The RET instruction is used when G64 continuous-path mode is not to be interrupted by a return. With M2, G64 is interrupted and exact stop is initiated. See the following illustration for example of sequence when calling a subroutine twice:

Subroutine name

The program is given a unique name allowing it to be selected from several subroutines. When you create the program, the program name may be freely selected, provided the following conventions are observed. The same rules apply as for the names of main programs. Example: LRAHMEN7 It is also possible to use the address word L... in subroutines. The value can have 7 decimal places (integers only). Note With address L, leading zeros are meaningful for differentiation. Example: L128 is not L0128 or L00128. These are three different subroutines. Note The subroutine name LL6 is reserved for tool change.

Nesting depth

Subroutines can also be called from a subroutine, not only from a main program. In total, up to 8 program levels are available for this type of nested call, including the main program level. See the following illustration for execution with 8 program levels:

Information Modal

G functions can be changed in the subroutine, e.g. G90 -> G91. When returning to the calling program, ensure that all modal functions are set the way you need them to be. Please make sure that the values of your arithmetic parameters used in upper program levels are not inadvertently changed in lower program levels. When working with SIEMENS cycles, up to 4 program levels are needed.
EXAMPLE
Subroutine call N10 L785 ; Call subroutine L785 N20 LRAHMEN7 ; Call subroutine LRAHMEN7 Repitition N10 L785 P3 ; Call subroutine L785, 3 cycles L785; N10 G00 X10 ... ... M2 or RET