1 subprogram call (m98) – Rockwell Automation 8520-GUM 9/Series CNC Grinder Operation and Programming Manual Documentation Set User Manual

Page 291

Advertising
background image

Introduction to Programming

Chapter 10

10-13

Generally the control executes programs sequentially. When you enter an
M98Pnnnnn (“nnnnn” representing a subprogram number) command in a
program, the control merges the subprogram, designated by the address P,
with the main program immediately before the block that follows the M98
command.

The control first searches the main program directory for the subprogram
called by an M98. If the control does not find the subprogram in the main
program directory, it then checks the protectable program directory for the
subprogram. If subprograms in the main and protectable directories have
the same name, the control uses the subprogram in the main directory.
The control issues the error message “CANNOT OPEN SUBPROGRAM”
if it cannot find the subprogram designated by the M98 command.

For example,

M98 P00001 ;

causes execution to transfer from the current program to the subprogram
numbered 00001.

Important: For you to use a program as a subprogram, it must have a
program name starting with the letter O followed by up to a 5 digit
numeric value. When calling the subprogram with a P word, only the
numeric value is used. The letter O is omitted.

Sometimes you want to execute a subprogram more than once. For
example,

M98PnnnnnLmm;

causes the control to merge the subprogram numbered nnnnn in the main
program mm times. When you enter an L command in a M98 command,
the control merges the subprogram, designated by the address P, before the
block that immediately follows the M98 command the number of times
designated by the L word. Both the P and L words must follow the M98
command in a program block.

Omission of an L word is regarded as L1. An L word cannot be a negative
value or have a value of zero.

Important: If M02 or M30 codes are found in a subprogram before the
program reads an M99, they stop program execution. The program resets
or rewinds if an M30 code is executed or the program ends if the M02 code
is executed.

10.3.1
Subprogram Call (M98)

Advertising