Vous êtes sur la page 1sur 1

SUB PROGRAM

STRUCTURE.

A program which contains fixed sequences or


frequently repeated patterns may be entered into
memory as a Sub Program, in order to simplify the
main program.
A sub program is entered into the machine controller
memory in Edit Mode, in the same manner as the main
program.
Differences between a sub and main program :
1) A sub program does not have a billet size definition
at the top of the program listing.
2) A sub program is ended by the M99 code.
The sub program can be called into operation when
the machine is set to run in Auto Mode. Sub programs
can also call other sub programs into operation.
When the main program calls one sub program into
operation, the process is called a one-loop sub
program call. It is possible to program a maximum fourloop sub program call within the main program. Shown
below is an illustration of a two-loop sub program call.

Main Program.

Sub Program - 1.

Sub Program - 2.

O1

O1

O2

N1 G21;

N1 ......

N1 ......

[BILLET X.... Y.... Z....

N2 ......

N2 ......

N2 ......

N3 ......

N3 ......

N3 ......

N4 ......

N4 ......

N4 ......

N5 ......

N5 ......

N5 ......

N6 ......

N6 ......

N6 ......

N7 ......

N7 ......

N7 ......

N8 ......

N8 ......

N8 M98 P1;

N9 ......

N9 ......

N9 ......

N1 ......

N1 ......

N1 ......

N11 M98 P2;

N11 ......

N11 ......

N12 ......

N12 ......

N12 ......

N13 ......

N13 ......

N13 ......

N14 ......

N14 ......

N14 ......

N15 ......

N15 ......

N15 M3;

N16 M99;

ONE-LOOP NESTING.
12 - BASIC PROGRAMMING

N16 M99;

TWO-LOOP NESTING.

Vous aimerez peut-être aussi