Subroutine end (M17/M29)
M17 and M29 terminate and close a local or global subroutine. This is followed by a jump in the calling NC program back to the start of the NC line that follows the subroutine call in order to continue the process. See also Section Subroutine techniques. A signal can also be forwarded to the PLC by configuration.
Parameterisable jump M17/M29 from a subroutine
Release Note
This function is available as of CNC Build V3.01.3081.02.
A jump can be parameterised by additional entries after M17/M29 so that the user can specify the higher program level and the program position at which the process is to continue. A practical example would be a detected tool breakage detected in a subroutine that should be dealt with immediately in the main program after the subroutine is exited.
Parameterising a jump with M17/M29 is programmed as followed:
Syntax of a parameterisable subroutine jump: |
M17 | M29 [ [ MAIN | JUMPS=.. ] [ [<LABEL>] | N.. ] ] |
MAIN | Jump to main program level |
JUMPS=.. | Number of program levels that are to be jumped to continue the process. Output of a warning if the number of jump levels exceeds the current call depth and jump to main program level. |
[ <LABEL> ] | Specify a string label as jump target in the jump level. The string label can be both in the forward and in the backward direction. |
N.. | Specify a block number as jump target in the jump level. A check is first made whether the block number already exists as expression label N..: and then the program branches there. An expression label can be both in the forward and in the backward direction. If this is not the case, the block number is only searched in the jump level in the forward direction towards program end. |
MAIN and JUMPS are explicit but optional. If no entry is made, the program jumps back to the next subroutine level (implicit JUMPS=1). The main program level is level 1. The current program level can be read in the NC program using V.G.PROG_LEVEL.
[LBL] and N.. are explicit and optional. If no entry is made, the program continues after jumping to the next NC block.
Notice
The jump target must be in the jump level. No search is made in local subroutines or in other subroutine calls.
Programing Example
Syntax examples of parameterised subroutine jumps with M17
M17 [MAIN] ;return to main program to the origin of the
;call chain and execute next NC block.
M17 [JUMPS=3 N150] ;jump 3 program levels and there execute N150
;as next NC block.
M17 [MAIN N500] ;jump to main program and there execute N500
;as next NC block.
M17 [N300] ;jump 1 program level and there execute N300
;as next NC block.
M17 [JUMPS=2 [LBL4]] ;jump 2 program levels and there execute
;the NC block with the jump label [LBL4].
M17 [MAIN [END] ] ;jump to main program and there execute
;the NC block with the jump label [END].
M17 [] ;jump 1 program level and execute the next
;NC block (analogous to M17).