Chapter 9 NC Control Function
(4) Call multiplicity of the subprogram
The main program can call a subprogram, and the subprogram can call another subprogram. If calling the
subprogram for the first time is the Call Step 1, the NC program of the motion controller can be called up to 9 steps
as shown below. If the subprogram call multiplicity goes beyond step 9, an error occurs.
The motion controller's NC program supports the multiple calls up to 9 steps but it does not allow "recursive calls of
the subprogram" that call the subprogram itself or "recursive calls" that may lead to call deadlock between
subprograms. If the subprogram is called in this way, an error will occur.
(5) Call and return of the subprogram
The subprogram is called by M98. The procedures for call and return of the subprogram are as follows.
M98: Call of the subprogram
M99: End of the subprogram
P _: For M98, the name of the subprogram (_ is a 4-digit number.)
For M99, the statement Number of the block to return
Q _: Statement Number of the start block of the subprogram (if omitted, it starts from the first block).
R _: Statement Number of the end block of the subprogram (if omitted, it proceeds until M99.)
L _: Repeat count of the subprogram calls
In addition to M98, you can call the reserved sub program using the macro program calling M code set in NC
channel parameter. This method can be used only in the main program, and when used in the subprogram, it
operates with the general M code.
If there is no program to call, or if the syntax or argument is wrong, an error occurs. For alarms occurred, please
refer to Appendix 2‘Error Information & Solutions'.
(6) Repeat of the main program
When M99 is commanded in the main program, the details of the main program can be executed through the repeat
mode. If P_ is not commanded, it is repetitively executed from the first block of the main program. If L_ is not
commanded, it runs repeatedly and infinitely.
M99: Repeat of the main program
P _: Statement Number of the repeated start block
L _: Repeat count of calls
CALL P1111 CALL P4444CALL P3333CALL P2222
'main'
'1111'
'3333'
'2222' '9999'
……
……
……
Step 1 call Step 3 callStep 2 call Step 9 callStep 4 call