Nesting of programming techniques
Application
It is possible to combine programming techniques, for example when calling a separate NC program or subprogram from within a program-section repeat.
If you want to return to the origin after each call, use only one nesting level. If you program another call before returning to the origin, you will get one nesting level lower.
Related topics
- Subprograms
- Program section repeats
- Calling a separate NC program
Description of function
Please note the maximum nesting depth:
- Maximum nesting depth for subprogram calls: 19
- Maximum nesting depth for calls of external NC programs: 19 where a CYCL CALL has the same effect as calling an external program
- Program-section repeats can be nested as often as desired
Example
Subprogram call within a subprogram
0 BEGIN PGM UPGMS MM | |
* - ... | |
11 CALL LBL “UP1“ | ; Call subprogram LBL "UP1" |
* - ... | |
21 L Z+100 R0 FMAX M30 | ; Last program block of main program with M30 |
22 LBL “UP1“ | ; Start of subprogram "UP1" |
* - ... | |
31 CALL LBL 2 | ; Call subprogram LBL 2 |
* - ... | |
41 LBL 0 | ; End of sub program "UP1" |
42 LBL 2 | ; Start of subprogram LBL 2 |
* - ... | |
51 LBL 0 | ; End of subprogram LBL 2 |
52 END PGM UPGMS MM |
The control executes the NC program as follows:
- NC program UPGMS is executed up to NC block 11.
- Subprogram UP1 is called and executed up to NC block 31.
- Subprogram 2 is called, and executed up to NC block 51. End of subprogram 2 and return jump to the subprogram from which it was called.
- Subprogram UP1 is executed from NC block 32 up to NC block 41. End of subprogram UP1 and return jump to NC program UPGMS.
- NC program UPGMS is executed from NC block 12 up to NC block 21. Program end with return jump to NC block 0.
Program-section repeat within a program section repeat
0 BEGIN PGM REPS MM | |
* - ... | |
11 LBL 1 | ; Start of program section 1 |
* - ... | |
21 LBL 2 | ; Start of program section 2 |
* - ... | |
31 CALL LBL 2 REP 2 | ; Call program section 2 and repeat twice |
* - ... | |
41 CALL LBL 1 REP 1 | ; Call program section 1 including program section 2 and repeat once |
* - ... | |
51 END PGM REPS MM |
The control executes the NC program as follows:
- NC program REPS is executed up to NC block 31.
- The program section between NC block 31 and NC block 21 is repeated twice, meaning that it is executed three times in total.
- NC program REPS is executed from NC block 32 up to NC block 41.
- The program section between NC block 41 and NC block 11 is repeated once, meaning that it is executed twice in total (including the program section repeat between NC block 21 and NC block 31).
- NC program REPS is executed from NC block 42 up to NC block 51. Program end with return jump to NC block 0.
Subprogram call within a program section repeat
0 BEGIN PGM UPGREP MM | |
* - ... | |
11 LBL 1 | ; Start of program section 1 |
12 CALL LBL 2 | ; Call subprogram 2 |
13 CALL LBL 1 REP 2 | ; Call program section 1 and repeat twice |
* - ... | |
21 L Z+100 R0 FMAX M30 | ; Last NC block of main program with M30 |
22 LBL 2 | ; Start of subprogram 2 |
* - ... | |
31 LBL 0 | ; End of subprogram 2 |
32 END PGM UPGREP MM |
The control executes the NC program as follows:
- NC program UPGREP is executed up to NC block 12.
- Subprogram 2 is called, and executed up to NC block 31.
- The program section between NC block 13 and NC block 11 (including subprogram 2) is repeated twice, meaning that it is executed three times in total.
- NC program UPGREP is executed from NC block 14 up to NC block 21. Program end with return jump to NC block 0.