Owner manual

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:
Ifyo u use M99 in a: M99:
mainprogram executesall commandsin theblock,regardlessof ifi nformationis
programmed in theblock totherightofthe M99command
clearsallmodalcodes similarto an M02orM30(simulates
start-upconditions)
resetsthecurrentmain programto thefirstblock
automatically performs a cycle start on the programafter it is reset
and programexecutionstartsover
subprogram tellsthecontroltheend of a subprogram. T he control doesnot
execute anycommandsfollowing theM99as partofthe
subprogram
causesthe controlto returnto thecallprogram
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 t o 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.
ifyou programmed: Then:
M99X10; X10isignored in thissubprogramblock
X10M99; X10generatesanerrorin thissubprogram
M03M99; M03 isexecuted as normal in thissubprogram
Example 10.8
Subprogram Calls and Returns
MAINPROGRAM 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)