121
96-8000 Rev AC
May 2010
Subroutines
S
UbroUtineS
Subroutines (
subprograms) are usually a series of commands that are repeat-
ed several times in a program. Instead of repeating the commands many times
in the main program, subroutines are written in a separate program. The main
program then has a single command that “calls” the subroutine program. A sub-
routine is called using an M97 and a P address. The P code is the same as the
sequence number (Onnnnn) of the subroutine to be called, that is located after
an M30. A subprogram is called using an M98 and a P address. The P address
with an M98 is for the program number.
Canned Cycles are the most common use of subroutines. The X and Y loca
-
tions of the holes are placed in a separate program and then called. Instead of
writing the X, Y locations once for each tool, the X, Y locations are written once
for any number of tools.
The subroutines can include an L or repeat count. If there is an L, the subrou
-
tine call is repeated that number of times before the main program continues
with the next block.
e
xternal
S
UbroUtine
An external subroutine is a separate program that is referenced several times
by the main program. Local subroutines are commanded (called) using an M98
and a Pnnnnn which refers it to the program number of the sub program.
External Subroutine Example
O00104 (sub program with an M98)
Sub Program
T1 M06
O00105
G90 G54 G00 X1.5 Y-0.5
X.5 Y-.75
S1406 M03
Y-2.25
G43 H01 Z1. M08
G98 X1.5 Y-2.5
G81 G99 Z-0.26 R0.1 F7.
G99 X3.5
M98 P105 (Call Sub-Program O00105)
X4.5 Y-2.25
Y-.75
T2 M06
X3.5 Y-.5
G90 G54 G00 X1.5 Y-0.5
G80 G00 Z1.0 M09
S2082 M03
G53 G49 Z0. M05
G43 H02 Z1. M08
M99
G83 G99 Z-.75 Q0.2 R0.1 F12.5
4.50
3.50
1.50
.50
.50
.75
2.25
2.50
1
2
3 4
5 6
7
8
.75
.375
M98 P105 (Call Sub-Program O00105)
T3 M06
G90 G54 G00 X1.5 Y-0.5
S750
G43 H03 Z1. M08
G84 G99 Z-.6 R0.1 F37.5
M98 P105 (Call Sub-Program O00105)
G53 G49 Y0.
M30 (End Program)
Summary of Contents for 96-8000
Page 15: ...6 96 8000 Rev AC May 2010 Mill Warning Decals ...
Page 16: ...7 96 8000 Rev AC May 2010 Safety Lathe Warning Decals ...
Page 41: ...32 96 8000 Rev AC May 2010 ...
Page 93: ...84 96 8000 Rev AC May 2010 ...
Page 129: ...120 96 8000 Rev AC May 2010 ...
Page 133: ...124 96 8000 Rev AC May 2010 ...
Page 268: ......
Page 269: ......