68
Subroutines
96-8000 rev R June 2007
SUBROUTINES
Subroutines (subprograms) are usually a series of commands that are repeated 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 subroutine is called using M97 or
M98 and a P address. The P code is the same as the program number (Onnnnn) number of the subroutine to be
called.
Canned Cycles are the most common use of subroutines. The X and Y locations 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 subroutine call is repeated that number of
times before the main program continues with the next block.
L
OCAL
S
UBROUTINES
A local subroutine is a block of code in the main program that is referenced several times by the main program.
Local subroutines are commanded (called) using an M97 and a Pnnnnn which refers it to the N line number of the
local subroutine.
The local subroutine format is to end the main program with an M30 then enter the local subroutines after the M30.
Each subroutine must have an N line number at the start and a M99 at the end that will send the program back to
the next line in the main program.
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
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)
4.50
3.50
1.50
.50
.50
.75
2.25
2.50
1
2
3 4
5
6
7
8
.75
.375
Содержание Mill
Страница 12: ...96 8000 rev R June 2007 Safety 5 ...
Страница 14: ...96 8000 rev R June 2007 Safety 7 LATHE WARNING DECALS ...
Страница 15: ...8 Safety 96 8000 rev R June 2007 ...
Страница 17: ...10 Introduction 96 8000 rev R June 2007 ...
Страница 117: ...110 4 5 Axis Programming 96 8000 rev R June 2007 ...
Страница 199: ...Settings 192 96 8000 rev R June 2007 ...
Страница 213: ...206 Maintenance 96 8000 rev R June 2007 ...