2 main and subprogram return (m99) – Rockwell Automation 8520-GUM 9/Series CNC Grinder Operation and Programming Manual Documentation Set User Manual
Page 292

Introduction to Programming
Chapter 10
10-14
The M99 code acts as a return command in both subprograms and main
programs; however, there are specific differences:
If you use M99 in a:
M99:
main program
• executes all commands in the block, regardless of if information is
programmed in the block to the right of the M99 command
• clears all modal codes similar to an M02 or M30 (simulates
start-up conditions)
• resets the current main program to the first block
• automatically performs a cycle start on the program after it is reset
and program execution starts over
subprogram
• tells the control the end of a subprogram. The control does not
execute any commands following the M99 as part of the
subprogram
• causes the control to return to the call program
Program the M99 code anywhere in a program block, provided no axis
words are programmed to the left of M99. Any information (other than
axis words) programmed to the left of M99 is executed as part of the
subprogram, while information (including axis words) programmed in the
block to the right of the M99 command is ignored.
if you programmed:
Then:
M99X10;
X10 is ignored in this subprogram block
X10M99;
X10 generates an error in this subprogram
M03M99;
M03 is executed as normal in this subprogram
Example 10.8
Subprogram Calls and Returns
MAIN PROGRAM
SUBPROGRAM 1
SUBPROGRAM 2
(MAIN PROGRAM);
(SUBPROGRAM 1);
(SUBPROGRAM 2);
N00010...;
N00110;
N00210;
N00020...;
N00120...;
N00220...M99;
N00030M98P1;
N00130M99;
N00040...;
N00140...;
N00050...;
N00150M30;
N00060M98P2L2;
N00070M30;
10.3.2
Main and Subprogram
Return (M99)