9 Programming: Subprograms and Program Section Repeats
240
9.1 Marking Subprograms and Program Section Repeats
9.2 Subprograms
9.1 Marking Subprograms and
Program Section Repeats
Subprograms and program section repeats enable you to program a
machining sequence once and then run it as often as desired.
Labels
The beginnings of subprograms and program section repeats are
marked in a part program by labels.
A label is identified by a number between 1 and 254. Each label can
be set only once with LABEL SET in a program.
If a label is set more than once, the TNC sends an error
message at the end of the LBL SET block. With very long
programs, you can limit the number of blocks to be
checked for repeated labels with MP7229.
LABEL 0 (LBL 0) is used exclusively to mark the end of a
subprogram and can therefore be used as often as desired.
9.2 Subprograms
Operating sequence
1 The TNC executes the part program up to the block in which a
subprogram is called with CALL LBL.
2 The subprogram is then executed from beginning to end. The
subprogram end is marked with LBL 0.
3 The TNC then resumes the part program from the block after the
subprogram call.
Programming notes
■
A main program can contain up to 254 subprograms.
■
You can call subprograms in any sequence and as often as
desired.
■
A subprogram cannot call itself.
■ Write subprograms at the end of the main program (behind the
block with M2 or M30).
■
If subprograms are located before the block with M02 or M30,
they will be executed at least once even if they are not called.
0 BEGIN PGM ...
CALL LBL1
L Z+100 M2
LBL1
LBL0
END PGM ...
LKAP9.PM6 30.06.2006, 07:04240
www.EngineeringBooksPdf.com