Subprograms and program section repeats – HEIDENHAIN TNC 122 User Manual User Manual
Page 43
![background image](https://www.manualsdir.com/files/815240/content/doc043.png)
5
Programming
TNC 122
43
Subprograms and Program Section Repeats
Subprograms and program section repeats only need to be entered
once in the program. You can then run them up to 999 times.
Subprograms can be run at any point in the program, while pro-
gram section repeats are run several times in succession.
Inserting program markers (labels)
You identify subprograms and program section repeats with labels
(abbreviated in the program to LBL).
Labels 1 to 99
Labels 1 to 99 identify the beginning of a subprogram or a program
section that is to be repeated.
Label 0
Label 0 is used only to identify the end of a subprogram.
Label call
Subprogram and program sections are called within the program
with a CALL L command.
The command CALL L 0 is not allowed.
Subprograms:
When it reaches a CALL L block, the TNC immediately executes
the called subprogram.
Program section repeats:
The TNC repeats the program section above the CALL L block.
Together with the CALL L command you also enter the number
of desired repetitions.
Nesting
You can run subprograms and repeat program sections within
other subprograms and program sections. This is called nesting.
An example of nesting is when you call a subprogram from within
another subprogram.
Maximum nesting depth: 8 levels
.
.
.
.
.
.
.
.
.
.
.
.
3
2
0 BEGIN PGM ...
CALL LBL 1
L Z + 100 M2
LBL 1
LBL 0
END PGM ...
1
Fig 8.1:
Operating sequence of a
subprogram
Fig. 8.2:
Operating sequence of a program
section repeat
.
.
.
.
.
.
.
.
.
.
.
.
1
3
5
4
2
R
R
0
BEGIN PGM ...
LBL 1
CALL LBL 1 REP 2/2
END PGM ...