M99: Return from Subprogram

M99: Return from Subprogram, Goto

The M99 code has two specific uses; it can be used as a command to return from a subprogram or it can be used as a goto command.

Using M99 with subprograms:

When used in a subprogram, this code returns you to the block following the last M98 (Call to Subprogram) command. If the M98 uses an L code to specify multiple calls to the subprogram, the M99 returns to the block containing the M98 until the specified number of subprogram calls have been made; then it will proceed to the block following the M98.
You can use the P code plus a block number to override the block returned to; however, if this feature is used from a nested subprogram call, all return targets are discarded. The rules for a Goto target block apply to this use as well.

Using M99 as a Goto command:

This command can be used in the main NC program as a Goto command to jump to a block on a line before the first subprogram (as denoted by the O code).
Use the P code to identify the block number being jumped to. Control is transferred to the first occurrence of this N code; it cannot be used to transfer control between chained programs (see M20). This command can be used anywhere in the program to change the flow of program execution. It is good programming practice to place this command on a line by itself to improve the program’s readability.

JaneCampus.com

Jane Campus Blog

Leave a Reply