SINUMERIK 840D sl NC programming. Programming Manual (2020) - page 8

 

  Index      Manuals     SINUMERIK 840D sl NC programming. Programming Manual (2020)

 

Search            copyright infringement  

 

   

 

   

 

Content      ..     6      7      8      9     ..

 

 

 

SINUMERIK 840D sl NC programming. Programming Manual (2020) - page 8

 

 

Work preparation
3.2 Subprogram technique
3.2
Subprogram technique
3.2.1
General information
3.2.1.1
Subprogram
The term "subprogram" has its origins during the time when part programs were split strictly into
main and subprograms. Main programs were the part programs selected for processing on the
control and then launched. Subprograms were the part programs called from within the main
program.
This strict division no longer exists with today's SINUMERIK NC language. In principle, each part
program can be selected as a main program and launched or called from another part program
as a subprogram.
Accordingly, the subprogram can then be used to refer to a part program called from within
another part program.
Main program
Subprogram
Application
As in all high-level programming languages, in the NC language, subprograms swaps out
program sections used more than once to independent, self-contained programs.
Subprograms offer the following advantages:
• Increase the transparency and readability of programs
• Increase quality by reusing tested program parts
• Offer the possibility of creating specific machining libraries
• Save memory space
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
491
Work preparation
3.2 Subprogram technique
3.2.1.2
Subprogram names
Naming rules
The subprogram name can be chosen freely providing the following rules are observed:
• Permissible characters:
- Letters: A ... Z, a ... z
- Numbers: 0 ... 9
- Underscore: _
• The first two characters should either be two letters or an underscore followed by a letter.
Note
If this condition is satisfied, then an NC program can be called as subprogram from another
program just by specifying the program name. However, if the program name starts with
digits, the subprogram call is then only possible via the CALL statement.
• Maximum length: 24 characters
Note
Uppercase/lowercase letters
The SINUMERIK NC language does not distinguish between uppercase and lowercase letters.
Note
Impermissible program names
To avoid problems with Windows applications, the following program names may not be used:
• CON, PRN, AUX, NUL
• COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9
• LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9
Control-internal extensions
The program name assigned when the subprogram is created is expanded within the control
with the addition of a prefix and a suffix:
• Prefix: _N_
• Postfix: _SPF
Using the program name
When using the program name, e.g. in the context of a subprogram call, all combinations of
prefix, program name, and suffix are possible.
Example:
NC programming
492
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
The subprogram with the program name SUB_PROG can be started using the following
identifiers:
1. SUB_PROG
2. _N_SUB_PROG
3. SUB_PROG_SPF
4. _N_SUB_PROG_SPF
Main programs and subprograms with the same name
If a main program (.MPF) and a subprogram (.SPF) exist with the same program name, the
appropriate file extension for the unique identification must be specified when the program
name in the NC program is used. Otherwise the program found first in the search path with the
specified name is used.
File name and program name
The file name and the name of the program contained in this file must always be identical.
One file therefore always contains one program.
3.2.1.3
Nesting of subprograms
A main program can call subprograms which in turn call more subprograms. As such, the
sequences of the programs are nested within each other. Each program runs on a dedicated
program level.
Nesting depth
The NC language currently provides 16 program levels. The main program always runs at the
uppermost program level, 0. A subprogram always runs at the next lowest program level
following the call. Program level 1 is, therefore, the first subprogram level.
Division of program levels:
• Program level 0: Main program level
• Program level 1 to 15: Subprogram level 1 to 15
3URJUDP OHYHOV PD[
0DLQ
6XE
SURJU
6XE
SURJU
SURJU
6XE
SURJU
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
493
Work preparation
3.2 Subprogram technique
Interrupt routines (ASUB)
If a subprogram is called in the context of an interrupt routine, this will not be executed at the
program level currently active in the channel (n) but at the next lowest program level (n+1). So
that this remains possible even at the lowest program level, 2 additional program levels (16 and
17) are available in conjunction with interrupt routines.
If more than 2 program levels are required, this has to be taken into account explicitly in the
structuring of the part program executed in the channel. In other words, only a maximum of as
many program levels may be used in order to leave sufficient program levels available for
interrupt processing.
If interrupt processing needs 4 program levels for example, the part program must be structured
so that it uses a maximum of up to program level 13. In the event of an interrupt, the 4 program
levels it requires (14 to 17) will be available to it.
Siemens cycles
Siemens cycles need 3 program levels. Therefore, a Siemens cycle must be called at the latest in:
• Part program processing: program level 12
• interrupt routine: program level 14
3.2.1.4
Search path
When a subprogram without path details is called, the control system searches the available
program memory using a predefined search sequence (see "Search path for subprogram call
(Page 560)").
3.2.1.5
Formal and actual parameters
Formal and actual parameters occur in conjunction with the definition and calling of
subprograms with parameter transfer.
Formal parameter
When a subprogram is defined, the parameters to be transferred to it (known as the formal
parameters) have to be defined with type and parameter name.
The formal parameters define, therefore, the interface of the subprogram.
Example:
Program code
Comment
PROC CONTOUR (REAL X, REAL Y)
; Formal parameters: X and Y, both REAL type
N20 X1=X Y1=Y
; Traversing of axis X1 to position X and axis
Y1 to position Y
N100 RET
NC programming
494
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Actual parameters
When a subprogram is called, absolute values or variables (known as actual parameters) have to
be transferred to it.
As such, the actual parameters assign up-to-date values to the interface of the subprogram
when the latter is called.
Example:
Program code
Comment
N10 DEF REAL WIDTH
; Variable definition
N20 WIDTH=20.0
; Variable assignment
N30 CONTOUR(5.5, WIDTH)
; Subprogram call with actual parameters: 5.5
and WIDTH
N100 M30
3.2.1.6
Parameter transfer
Definition of a subprogram with parameter transfer
A subprogram with parameter transfer is defined using the PROC keyword and a complete list of
all the parameters expected by the subprogram.
Incomplete parameter transfer
When the subprogram is called, not all the parameters defined in the subprogram interface have
to be transferred explicitly. If a parameter is omitted, the default value "0" is transferred for it.
So that the parameter sequence can be uniquely identified, however, the commas used as
parameter separators always have to be included. The last parameter is an exception. If it is
omitted from the call, the last comma can also be left out.
Example:
Subprogram:
Program code
Comment
PROC SUB_PROG (REAL X, REAL Y, REAL Z)
; Formal parameters: X, Y, and Z
N100 RET
Main program:
Program code
Comment
PROC MAIN_PROG
N30 SUB_PROG(1.0,2.0,3.0)
; Subprogram call with complete parameter transfer:
X=1.0, Y=2.0, Z=3.0
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
495
Work preparation
3.2 Subprogram technique
Program code
Comment
…
N100 M30
Examples for the subprogram call in N30 with incomplete parameter transfer:
N30 SUB_PROG( ,2.0,3.0)
; X=0.0, Y=2.0, Z=3.0
N30 SUB_PROG(1.0, ,3.0)
; X=1.0, Y=0.0, Z=3.0
N30 SUB_PROG(1.0,2.0)
; X=1.0, Y=2.0, Z=0.0
N30 SUB_PROG( , ,3.0)
; X=0.0, Y=0.0, Z=3.0
N30 SUB_PROG( , , )
; X=0.0, Y=0.0, Z=0.0
NOTICE
Call-by-reference parameter transfer
Parameters transferred using call-by-reference must not be left out of the subprogram call.
NOTICE
AXIS data type
AXIS data type parameters must not be left out of the subprogram call.
Checking the transfer parameters
System variable $P_SUBPAR [ n ] where n = 1, 2, etc., can be used to check whether a parameter
has been transferred explicitly or left out in the subprogram. The index n refers to the sequence
of the formal parameters. Index n = 1 refers to the first formal parameter, index n = 2 to the
second formal parameter, and so on.
The following program excerpt shows an example of how a check can be performed based on
the first formal parameter:
Programming
Comment
PROC SUB_PROG (REAL X, REAL Y, REAL Z)
; Formal parameters: X, Y, and Z
N20 IF $P_SUBPAR[1]==TRUE
; Check of the first formal parameter
X.
; These actions are taken if the formal
parameter X has been transferred ex-
plicitly.
N40 ELSE
; These actions are taken if the formal
parameter X has not been transferred.
N60 ENDIF
; General actions
N100 RET
NC programming
496
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
3.2.2
Definition of a subprogram
3.2.2.1
Subprogram without parameter transfer
When defining subprograms without parameter transfer, the definition line at the beginning of
the program can be omitted.
Syntax
[PROC <program name>]
Meaning
PROC:
Definition operation at the beginning of a program
<program name>:
Name of the program
Example
Example 1: Subprogram with PROC operation
Program code
Comment
PROC SUB_PROG
; Definition line
N10 G01 G90 G64 F1000
N20 X10 Y20
N100 RET
; Subprogram return
Example 2: Subprogram without PROC operation
Program code
Comment
N10 G01 G90 G64 F1000
N20 X10 Y20
N100 RET
; Subprogram return
See also
Subprogram call without parameter transfer (Page 523)
3.2.2.2
Subprogram with call-by-value parameter transfer (PROC)
A subprogram with call-by-value parameter transfer is defined using the PROC keyword followed
by the name of the program and a complete list of all the parameters with their type and name.
The definition operation must appear in the first program line.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
497
Work preparation
3.2 Subprogram technique
Call-by-value
The calling program transfers only the value of a variable to the subprogram on a call-by-value
parameter transfer. Thus the subprogram is not given direct access to the variable. In this way,
only the value visible in the subprogram is modified when the parameter value is changed. The
value of the variables defined in the calling program remains unchanged. As a consequence, the
call-by-value parameter transfer does not affect the calling program.
Main program
Value assignment
LENGTH=12
WIDTH=10
Subprogram
LENGTH, WIDTH
New value
assignment
LENGTH=20
WIDTH=15
New values
valid
Old values valid
Syntax
PROC <program name> (<parameter type> <parameter
name>=<init_value>, ...)
Note
Up to 127 parameters can be transferred.
Meaning
PROC:
Definition operation at the beginning of a program
<program name>:
Name of the program
<parameter type>:
Data type of the parameter (e.g. REAL, INT, BOOL)
<parameter name>:
Name of the parameter
<init_value>:
Optional value for the initialization of the parameter (optional)
If no parameter is specified when calling the subprogram, the param-
eter is assigned the initialization value.
NC programming
498
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Examples
Example 1
Definition of a subprogram SUB_PROG with three parameters of type REAL with default values:
Program code
PROC SUB_PROG(REAL LENGTH=10.0, REAL WIDTH=20.0, REAL HIGHT=30.0)
Example 2
Various call versions
Program code
PROC MAIN_PROG
REAL PAR_1 = 100
REAL PAR_2 = 200
REAL PAR_3 = 300
; Call variants
SUB_PROG
SUB_PROG(PAR_1, PAR_2, PAR_3)
SUB_PROG(PAR_1)
SUB_PROG(PAR_1, , PAR_3)
SUB_PROG( , , PAR_3)
N100 RET
See also
Subprogram call with parameter transfer (EXTERN) (Page 525)
3.2.2.3
Subprogram with call-by-reference parameter transfer (PROC, VAR)
A subprogram with call-by-reference parameter transfer is defined using the PROC keyword
followed by the name of the program and a complete list of all the parameters with the VAR
keyword, type, and name. The definition operation must appear in the first program line. As
parameters, references to arrays can also be transferred.
Call-by-reference
The calling program transfers not the value of a variable to the subprogram on a call-by-
reference parameter transfer, but a reference (pointer) to the variable. This gives the
subprogram direct access to the variable. In this way, not only the value visible in the
subprogram is modified when a parameter value is changed, but also the value of the variables
defined in the calling program. Call-by-reference parameter transfer therefore affects the calling
program, even after the subprogram has ended.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
499
Work preparation
3.2 Subprogram technique
Main program
Value
assignment
LENGTH=20
WIDTH=10
Subprogram
LENGTH, WIDTH
New value
assignment
LENGTH=20
WIDTH=15
New values
valid
LENGTH, WIDTH
New values valid
Note
The call-by-reference parameter transfer is then only necessary if the transferred variable was
defined locally in the calling program (LUD). Channel-global or NC-global variables do not have
to be transferred, since these cannot be accessed directly from within the subprogram.
Syntax
PROC <program name> (VAR <parameter type> <parameter name>, etc.)
PROC <program name> (VAR <array type> <array name>, [<m>,<n>,<o>],
etc.)
Note
Up to 127 parameters can be transferred.
Meaning
PROC:
Definition operation at the beginning of a program
VAR:
Keyword for parameter transfer via reference
<program name>:
Name of the program
<parameter type>:
Data type of the parameter (e.g. REAL, INT, BOOL)
<parameter name>:
Name of the parameter
<array type>:
Data type of the array elements (e.g. REAL, INT, BOOL)
<array name>:
Name of the array
NC programming
500
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
[<m>,<n>,<o>]:
Array size
Currently, up to 3-dimensional arrays are possible:
<m>:
Array size for 1st dimension
<n>:
Array size for 2nd dimension
<o>:
Array size for 3rd dimension
Note
• The program name specified after the PROC keyword must match the program name
assigned on the user interface.
• With arrays of an undefined array length, subprograms can process arrays of variable length
as formal parameter. When defining a two-dimensional array as a formal parameter, for
example, the length of the 1st dimension is not specified. However, the comma must be
written.
Example: PROC <program name> (VAR REAL ARRAY[,5])
Example
Definition of a subprogram with two parameters as reference to REAL type:
Program code
; Parameter 1: Reference to type: REAL, name: LENGTH
; Parameter 2: Reference to type: REAL, name: WIDTH
PROC SUB_PROG(VAR REAL LENGTH, VAR REAL WIDTH)
See also
Subprogram call with parameter transfer (EXTERN) (Page 525)
3.2.2.4
Save modal G functions (SAVE)
The SAVE attribute means that before the subprogram call, active modal G commands are saved
and are reactivated after the end of the subprogram.
NOTICE
Interrupt continuous-path mode
If, for active continuous-path mode, a subprogram is called with the SAVE attribute, the
continuous-path mode is interrupted at the end of the subprogram (return jump).
Syntax
PROC <subprogram name> SAVE
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
501
Work preparation
3.2 Subprogram technique
Meaning
SAVE:
Saves the modal G commands before the subprogram call and restores after the end of the
subprogram.
Example
In the CONTOUR subroutine, the modal G command G91 applies (incremental dimension). The
modal G command G90 is effective in the main program (absolute dimension). G90 is again
effective in the main program after the end of the subprogram as a result of the subprogram
definition with SAVE.
Subprogram definition:
Program code
Comment
PROC CONTOUR (REAL VALUE1) SAVE
; Subprogram definition with the SAVE parame-
ter
N10 G91 ...
; Modal G command G91: Incremental dimension
N100 M17
; End of subprogram
Main program:
Program code
Comment
N10 G0 X... Y... G90
; Modal G command G90: Absolute dimensions
N20 ...
N50 CONTOUR (12.4)
;Subprogram call
N60 X... Y...
; Modal G command G90 reactivated using SAVE
Supplementary conditions
Frames
The behavior of frames regarding subprograms with the SAVE attribute depends on the frame
time and can be set using machine data.
3.2.2.5
Suppress single block execution (SBLOF, SBLON)
Even with active single block machining, the user can completely or partly process an NC
program without interruption. Single block machining is suppressed via the SBLOF command,
and reactivated via the SBLON command.
Suppressing single block machining for the complete NC program
If the deactivation of single block machining (SBLOF) is programmed in the first line (PROC ...)
of a main program, this remains valid until the end of the NC program or until the NC program
is canceled. The NC program is then executed without stopping when in the single block mode.
If deactivating single block machining (SBLOF) is programmed in the first line (PROC ...) of a
subprogram, this remains valid until the end of the NC program or until the NC program is
NC programming
502
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
canceled. With the programmed return command, the decision is made whether to stop at the
end of the subprogram:
• Return with M17: Stop at the end of the subprogram
• Return with RET: No stop at end of subprogram
Suppressing single block machining within the NC program
If the deactivation of single block machining (SBLOF) is programmed in a block within an NC
program, then single block machining is deactivated from this block onward up to the next
programmed activation of single block machining (SBLON) - or at the end of the active
subprogram level.
Syntax
Suppressing single block machining for the complete NC program:
PROC ... SBLOF
Suppressing single block machining within the NC program:
SBLOF
SBLON
Meaning
PROC:
First operation in a program
SBLOF:
Predefined procedure to deactivate single block machining
Alone in the block:
Yes, possible in the PROC block
Effectiveness:
Modal
SBLON:
Predefined procedure to activate single block machining
Alone in the block:
yes
Effectiveness:
Modal
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
503
Work preparation
3.2 Subprogram technique
Special aspects
•
Block display with suppressed single block machining
The current block display can be suppressed in subprograms using DISPLOF. If DISPLOF is
programmed together with SBLOF, for single block stops within the subprogram, the
subprogram call is displayed.
•
Suppression of single block machining with asynchronous subprograms (ASUB)
In order to execute an ASUB with active single block machining in one step, a PROC statement
must be programmed in the ASUB with SBLOF. This also applies to the function "Editable
system ASUB" (MD11610 $MN_ASUP_EDITABLE).
If the single block stop in the system or user ASUB is suppressed by programming SBLOF in
the PROC line or using the settings in machine data
MD10702 $MN_IGNORE_SINGLEBLOCK_MASK (bit0 = 1 or bit1 = 1), then the single block
stop can be reactivated by programming SBLON in the ASUB.
If the single block stop in the user ASUB is suppressed using the setting in machine data
MD20117 $MC_IGNORE_SINGLEBLOCK_ASUP, the single block stop cannot be reactivated
by programming SBLON in the ASUB.
•
Special features for various single block machining types
- "SB2: Arithmetic block" AND MD10702 $MN_IGNORE_SINGLEBLOCK_MASK, Bit 12 = 1:
→ The program is not stopped in the SBLON block.
- "SB3: single block fine":
→ The SBLOF command is suppressed.
•
Suppression of single block machining in nested programs
If SBLOF was programmed in the PROC statement in a subprogram, then execution is stopped
at the subprogram return with M17. That prevents the next block in the calling program from
already running. If, in a subprogram with SBLOF, without SBLOF in the PROC statement, a
suppression of single block machining is activated, execution is only stopped after the next
machine function block of the calling program. If that is not wanted, SBLON must be
programmed in the subprogram before the return (M17). Execution does not stop for a
return to a higher-level program with RET.
Examples
Example 1: Suppressing single block machining within the NC program
Initial situation: Single block machining is active.
Program code
Comment
N10 G1 X100 F1000
N20 SBLOF
; Switch off single block machining
N30 Y20
N40 M100
N50 R10=90
N60 SBLON
; Reactivate single block machining
N70 M110
N80 ...
The area between N20 and N60 is executed as one step in single block mode.
NC programming
504
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Example 2: A cycle is to act like a command for a user
Initial situation: Single block machining is active.
Main program:
Program code
N100 G1 X10 G90 F200
N120 X-4 Y6
N130 CYCLE1
N140 G1 X0
N150 M30
Cycle CYCLE1:
Program code
Comment
N100 PROC CYCLE1 DISPLOF SBLOF
; Suppress single block machining for the com-
plete program.
N110 R10=3*SIN(R20)+5
N120 IF (R11 <= 0)
N130 SETAL(61000)
N140 ENDIF
N150 G1 G91 Z=R10 F=R11
N160 M17
The cycle CYCLE1 is processed with active single block machining. CYCLE1 is processed for active
single block machining, i.e. the Start key must be pressed once to process CYCLE1.
Example 3: An ASUB, which is started by the PLC in order to activate a modified zero offset
and tool offsets, is to be executed invisibly
Program code
Comment
N100 PROC NV SBLOF DISPLOF
; Suppress single block machining and block
display.
N110 CASE $P_UIFRNUM OF
0 GOTOF _G500
1 GOTOF _G54
2 GOTOF _G55
3 GOTOF _G56
4 GOTOF _G57
DEFAULT GOTOF END
N120 _G54: G54 D=$P_TOOL T=$P_TOOLNO
N130 RET
N140 _G54: G55 D=$P_TOOL T=$P_TOOLNO
N150 RET
N160 _G56: G56 D=$P_TOOL T=$P_TOOLNO
N170 RET
N180 _G57: G57 D=$P_TOOL T=$P_TOOLNO
N190 RET
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
505
Work preparation
3.2 Subprogram technique
Program code
Comment
N200 END: D=$P_TOOL T=$P_TOOLNO
N210 RET
Example 4: Specific stopping in the subprogram
Initial situation:
• Single block machining is active.
• MD10702 $MN_IGNORE_SINGLEBLOCK_MASK, Bit12 = 1
Main program:
Program code
Comment
N10 G0 X0
; single block stop
N20 X10
; single block stop
N30 CYCLE
; Traversing block generated by the cycle.
N50 G90 X20
; single block stop
M30
Cycle CYCLE:
Program code
Comment
PROC CYCLE SBLOF
; Suppress single block machining
N100 R0=1
N110 SBLON
; No single block stop due to MD10702 bit12 = 1
N120 X1
; single block stop
N140 SBLOF
N150 R0=2
RET
Example 5: Suppression of single block machining with program nesting
Initial situation:
• Single block machining type 2 is active.
• The program execution shall not be interrupted in the SBLON block
(MD10702 $MN_IGNORE_SINGLEBLOCK_MASK, Bit12 = 1)
Program code
Comment
N10 X0 F1000
; single block stop
N20 UP1(0)
PROC UP1(INT _NR) SBLOF
; Deactivate single block machining for
UP1
N100 X10
N110 UP2(0)
PROC UP2(INT _NR)
N200 X20
N210 SBLON
; Activate single block machining
N220 X22
; single block stop
NC programming
506
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Program code
Comment
N230 UP3(0)
PROC UP3(INT _NR)
N300 SBLOF
; Switch off single block machining
N305 X30
N310 SBLON
; Activate single block machining
N320 X32
; single block stop
N330 SBLOF
; Switch off single block machining
N340 X34
N350 M17
; single block stop (M17)
N240 X24
; single block stop (N210)
N250 M17
; single block stop (M17)
N120 X12
N130 M17
; single block stop (M17)
N30 X0
; single block stop
N40 M30
; single block stop
3.2.2.6
Suppress current block display (DISPLOF, DISPLON, ACTBLOCNO)
The current program block is displayed as standard in the block display. The display of the current
block can be suppressed in cycles and subprograms using the DISPLOF command. Instead of
the current block, the call of the cycle or the subprogram is displayed. The DISPLON command
revokes suppression of the block display.
DISPLOF and DISPLON are programmed in the program line with the PROC operation and are
effective for the entire subprogram and implicitly for all subprograms called from it which do not
contain a DISPLON or DISPLOF command. This is true for all ASUBs.
Syntax
PROC … DISPLOF
PROC … DISPLOF ACTBLOCNO
PROC … DISPLON
Meaning
DISPLOF:
Command to suppress the current block display.
Location:
At the end of the program line with the PROC operation
Effective:
Up to the return jump from the subprogram or end of program.
Note:
If further subprograms are called from the subprogram using the DISPLOF com-
mand, then the current block display is also suppressed in these subprograms un-
less DISPLON is explicitly programmed in them.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
507
Work preparation
3.2 Subprogram technique
DISPLON:
Command for revoking suppression of the display of the current block
Location:
At the end of the program line with the PROC operation
Effective:
Up to the return jump from the subprogram or end of program.
Note:
If further subprograms are called from the subprogram using the DISPLON com-
mand, then the current block will also be displayed in these subprograms
unless DISPLOF is explicitly programmed in them.
ACTBLOCNO:
DISPLOF together with the ACTBLOCNO attribute means that in the case of an
alarm, the number of the actual block is output in which the alarm occurred. This
also applies if only DISPLOF is programmed in a lower program level.
On the other hand, for DISPLOF without ACTBLOCNO, the block number of the
cycle or subprogram call from the last program level not designated with DISPLOF
is displayed.
Examples
Example 1: Suppress current block display in the cycle
Program code
Comment
PROC CYCLE (AXIS TOMOV, REAL POSITION)
; Suppress current block display Instead,
SAVE DISPLOF
the cycle call should be displayed, e.g.:
CYCLE(X,100.0)
DEF REAL DIFF
;Cycle contents
G01 ...
RET
; Subprogram return jump. The block follow-
ing the cycle call is displayed in the block
display.
Example 2: Block display for alarm output
Subprogram SUBPROG1 (with ACTBLOCNO):
Program code
Comment
PROC SUBPROG1 DISPLOF ACTBLOC-
NO
N8000 R10 = R33 + R44
N9040 R10 = 66 X100
; Trigger alarm 12080
N10000 M17
Subprogram SUBPROG2 (without ACTBLOCNO):
Program code
Comment
PROC SUBPROG2 DISPLOF
N5000 R10 = R33 + R44
NC programming
508
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Program code
Comment
N6040 R10 = 66 X100
; Trigger alarm 12080
N7000 M17
Main program:
Program code
Comment
N1000 G0 X0 Y0 Z0
N1010 ...
N2050 SUBPROG1
; Alarm output = "12080 channel K1 block N9040 syntax
error for text R10="
N2060 ...
N2350 SUBPROG2
; Alarm output = "12080 channel K1 block N2350 syntax
error for text R10="
N3000 M30
Example 3: Revoke suppression of the current block display
Subprogram SUB1 with suppression:
Program code
Comment
PROC SUB1 DISPLOF
; Suppress current block display in SUB1 subprogram.
Instead, the block is to be displayed with the SUB1
call.
N300 SUB2
; Call subprogram SUB2.
N500 M17
Subprogram SUB2 without suppression:
Program code
Comment
PROC SUB2 DISPLON
; Revoke suppression of the current block display in
subprogram SUB2.
N200 M17
; Return to subprogram SUB1. Suppression of the cur-
rent block display is restored in SUB1.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
509
Work preparation
3.2 Subprogram technique
Example 4: Display response for different DISPLON/DISPLOF combinations
3URJUDP OHYHO
03
ZLWKRXW
63
352&
63
352&
63
',63/2)
ZLWKRXW
352&
63
352&
$68%
',63/21
352&
63
',63/2)
352&
63
352&
',63/2)
352&
63
',63/2)
63
',63/21
ZLWKRXW
352&
352&
',63/2)
03 0DLQ SURJUDP
63 6XESURJUDP
$68% $V\QFKURQRXV VXESURJUDP LQWHUUXSW URXWLQH
① The part program lines from program level 0 are displayed in the current block display.
② The part program lines from program level 3 are displayed in the current block display.
③ The part program lines from program level 3 are displayed in the current block display.
④ The part program lines from program level 7/8 are displayed in the current block display.
3.2.2.7
Identifying subprograms with preparation (PREPRO)
All files can be identified with the PREPRO keyword at the end of the PROC operation line during
power up.
Note
This type of program preprocessing depends on the setting of machine data MD10700
$MN_PREPROCESSING_LEVEL. Please follow the manufacturer's instructions.
Syntax
PROC … PREPRO
Meaning
PREPRO:
Keyword for identifying all files (of the NC programs stored in the cycle directories)
prepared during power up
NC programming
510
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Read subprogram with preparation and subprogram call
The cycle directories are processed in the same order both for subprograms preprocessed with
parameters during power up and during subprogram call.
1. _N_CUS_DIR user cycles
2. _N_CMA_DIR manufacturer cycles
3. _N_CST_DIR standard cycles
In the case of NC programs sharing the same name but having different characteristics, the first
PROC operation found is activated and the other PROC operation is overlooked without an alarm
message.
3.2.2.8
Subprogram return M17
The return command M17 (or the part program end command M30) appears at the end of a
subprogram. It prompts the return to the calling program at the part program block following the
subprogram call.
Note
M17 and M30 are treated as equivalents in the NC language.
Syntax
PROC <program name>
M17/M30
Supplementary conditions
Effect of the subprogram return on continuous-path mode
If M17 (or M30) appears on its own in the part program block, active continuous-path mode in
the channel will be interrupted.
To avoid continuous-path mode being interrupted, M17 (or M30) has to be included in the last
traversing block. Furthermore, the following machine data must be set to "0":
MD20800 $MC_SPF_END_TO_VDI = 0 (no M30/M17 output to the NC/PLC interface)
Example
1. Subprogram with M17 in a separate block
Program code
Comment
N10 G64 F2000 G91 X10 Y10
N20 X10 Z10
N30 M17
; Return jump with interruption of continuous-path
mode.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
511
Work preparation
3.2 Subprogram technique
2. Subprogram with M17 in the last traversing block
Program code
Comment
N10 G64 F2000 G91 X10 Y10
N20 X10 Z10 M17
; Return jump without interruption of continuous-
path mode.
3.2.2.9
RET subprogram return
The RET command can also be used in the subprogram as a substitute for the M17 return jump
command. RET must be programmed in a separate part program block. Like M17, RET prompts
the return to the calling program at the part program block following the subprogram call.
Note
Parameters can be programmed to change the return jump behavior of RET (see
"Parameterizable subprogram return jump (RET ...) (Page 513)").
Application
The RET operation should then be used if a G64 continuous-path mode (G641 to G645) is not
to be interrupted by the return jump.
Requirement
The RET command can only be used in subprograms, which were not defined with the SAVE
attribute.
Syntax
PROC <program name>
RET
Example
Main program:
Program code
Comment
PROC MAIN_PROGRAM
; Start of the program
N50 SUB_PROG
; Subprogram call: SUB_PROG
N60 ...
N100 M30
; End of program
NC programming
512
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Subprogram:
Program code
Comment
PROC SUB_PROG
N100 RET
; Return jump to block N60 in the main program.
3.2.2.10
Parameterizable subprogram return jump (RET ...)
Generally, a return jump is made from a subprogram into the calling program using the RET
command. Processing is then continued with the program line following the subprogram call.
The following options are available if program processing is to be continued at another location:
• Resume program execution after calling the stock removal cycles in the ISO dialect mode
(after describing the contour).
• Return to main program from any subprogram level (even after ASUB) for error handling.
• Return jump across several program levels for special applications in compile cycles and in the
ISO dialect mode.
To achieve this, the RET command should be programmed with additional parameters.
Search direction
When specifying parameter <target block>, a return jump is first made to the block after the
calling block. A search is then made for the target in the direction of the end of the program into
which a return jump was made. A search is made toward the start of the program if the search
was not successful.
Syntax
RET("<target block>")
RET("<target block>",<block after target block>)
RET("<target block>",<block after target block> <number of return
jump levels>)
RET("<target block>", ,<number of return jump levels>)
RET("<target block>",<block after target block>,<number of return
jump levels>,
<return jump to the beginning of the program>)
RET( , ,<number of return jump levels>,<return jump to the beginning
of the program>)
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
513
Work preparation
3.2 Subprogram technique
Meaning
RET:
End of subprogram
<target block>:
Declares as jump target the block where program execution should
be resumed.
If parameter <number of return jump levels> is not programmed,
then the jump target is in the program from which the current
subprogram was called.
Possible data include:
<block number>
Number of the target block.
The search for the block number is made in the
program to which a return jump is made - ini-
tially toward the end of the program.
<jump marker>
Jump marker, which must be available in the
program into which a return jump is made.
The search for the jump marker is made in the
program to which a return jump is made - ini-
tially toward the end of the program.
<character string>
Character string that must be available in the
program into which a return jump is made
(e.g. program or variable name).
The search for the character string is made in
the program to which a return jump is made -
initially toward the end of the program.
The following rules apply when programming
the character string:
• Blank at the end (contrary to the jump
marker, which is identified by ":" at the
end).
• Before the character string only one
block number and/or a jump marker may
be set, no program commands.
<block after target
The parameter specifies as to whether program processing should
block>:
be continued in the block specified under parameter <target
block> or in the following block.
Type:
INT
Value:
0
The return jump is made to the block specified
in parameter <target block>.
> 0
The return jump is made to the next block
specified in parameter <target block>.
NC programming
514
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
<number of
The parameter specifies the number of program levels that should
return jump levels>:
be jumped through (return jumps) to search there for the target
block and continue processing the program.
Type:
INT
Value:
1
The program is resumed at the "current pro-
gram level -1" (just like RET without parame-
ter).
2
The program is resumed at the "current pro-
gram level -2", i.e. one level is skipped.
3
The program is resumed at the "current pro-
gram level -3", i.e. two levels are skipped.
Range of
1 ... 15
values:
<return jump to the
The parameter specifies, for a return jump into the main program,
beginning of the program>:
whether the program should be continued at the start of the pro-
gram in the active ISO dialect mode.
Type:
BOOL
Value:
1
If the return jump is made into the main pro-
gram and an ISO dialect mode is active there,
then the program branches to the beginning of
the program.
Note
For a subprogram return jump with a character string to specify the target block search, initially,
a search is always made for a jump marker in the calling program.
If a jump target is to be uniquely defined using a character string, it is not permissible that the
character string matches the name of a jump marker, as otherwise the subprogram return jump
would always be made to the jump marker and not to the character string (refer to example 2).
Supplementary conditions
When making a return jump through several program levels, the SAVE statements of the
individual program levels are evaluated.
If, for a return jump over several program levels, a modal subprogram is active and if in one of
the skipped programs the deselection command MCALL is programmed for the modal
subprogram, then the modal subprogram remains active.
NOTICE
Programming error
For a return jump across several program levels, it is the user's responsibility to ensure that
processing is continued with the necessary modal settings. This can be achieved, e.g. by
programming an appropriate main block.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
515
Work preparation
3.2 Subprogram technique
Examples
Example 1: Resuming in the main program after ASUB execution
Programming
Comment
N10010 CALL "UP1"
; Program level 0 (main program)
N11000 PROC UP1
; Program level 1
N11010 CALL "UP2"
N12000 PROC UP2
; Program level 2
N19000 PROC ASUP
; Program level 3 (ASUB execution)
N19100 RET("N10900", ,$P_STACK)
; Subprogram return jump into the main program
; $P_STACK: actual program level
N10900
; Target block in the main program
N10910 MCALL
; Deactivate the modal subprogram call
N10920 G0 G60 G40 M5
; Initialize additional modal settings
Example 2: Character string (string>) to specify the target block search
Main program:
Program code
Comment
PROC MAIN_PROGRAM
N1000 DEF INT iVar1=1, iVar2=4
N1010 ...
N1200 subProg1
; Calls subprogram "subProg1"
N1210 M2 S1000 X10 F1000
N1220
N1400 subProg2
; Calls subprogram "subProg2"
N1410 M3 S500 Y20
N1420 ..
N1500 lab1: iVar1=R10*44
N1510 F500 X5
N1520 ...
N1550 subprog1: G1 X30
; "subProg1" is defined here as jump marker.
N1560 ...
N1600 subProg3
; Calls subprogram "subProg3"
N1610 ...
N1900 M30
Subprogram subProg1:
Program code
Comment
PROC subProg1
NC programming
516
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Program code
Comment
N2000 R10=R20+100
N2010 ...
N2200 RET("subProg2")
; Return jump into the main program at block
N1400
Subprogram subProg2:
Program code
Comment
PROC subProg2
N2000 R10=R20+100
N2010 ...
N2200 RET("iVar1")
; Return jump into the main program at block
N1500
Subprogram subProg3:
Program code
Comment
PROC subProg3
N2000 R10=R20+100
N2010 ...
N2200 RET("subProg1")
; Return jump into the main program at block
N1550
Additional information
The following diagrams show the different effects of return jump parameters
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
517
Work preparation
3.2 Subprogram technique
1. <target block> = "N200", <block after target block> = 0
0DLQ SURJUDP
6XESURJUDP
1
68%
1
*
352& 68%
1
1
5(7 ರ1
ರ
1
After the RET command, program execution is continued with block N200 in the main program.
2. <target block> = "N200", <block after target block> = 1
0DLQ SURJUDP
6XESURJUDP
1
68%
1
*
352& 68%
1
1
5(7 ರ
ರ
1
1
1
After the RET command, program execution is continued with the block (N210) that follows
block N200 in the main program.
NC programming
518
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
3. <target block> = "N220", <number of return jump levels> = 2
PD[
SURJUDP OHYHOV
0DLQ
SURJU
6XS
SURJU
6XE
SURJU
6XE
SURJU
5(7 1
1
5HWXUQ MXPS
5HWXUQ MXPS
After the RET command, two program levels are jumped through and program execution is
continued with block N220.
3.2.2.11
Parameterizable subprogram return jump (RETB ...)
Generally, a return jump is made from a subprogram into the calling program using the RETB
command. Processing is then continued with the program line following the subprogram call.
The following options are available if program processing is to be continued at another location:
• Resume program execution after calling the stock removal cycles in the ISO dialect mode
(after describing the contour).
• Return to main program from any subprogram level (even after ASUB) for error handling.
• Return jump across several program levels for special applications in compile cycles and in the
ISO dialect mode.
To achieve this, the RETB command should be programmed with additional parameters.
Search direction
When specifying parameter <target block>, a return jump is first made to the block after the
calling block. A search is then made for the target in the direction of the beginning of the
program into which a return jump is made. A search is made toward the end of the program if
the search was not successful.
Syntax
RETB("<target block>")
RETB("<target block>",<block after target block>)
RETB("<target block>",<block after target block> <number of return
jump levels>)
RETB("<target block>", ,<number of return jump levels>)
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
519
Work preparation
3.2 Subprogram technique
RETB("<target block>",<block after target block>,<number of return
jump levels>,
<return jump to the beginning of the program>)
RETB( , ,<number of return jump levels>,<return jump to the beginning
of the program>)
Meaning
RETB:
End of subprogram
<target block>:
Declares as jump target the block where program execution should
be resumed.
If parameter <number of return jump levels> is not programmed,
then the jump target is in the program from which the current
subprogram was called.
Possible data include:
<block number>
Number of the target block.
The search for the block number is realized in
the program to which a return jump was made
initially in the direction toward the beginning
of the program.
<jump marker>
Jump marker, which must be available in the
program into which a return jump is made.
The search for the jump marker is realized in
the program to which a return jump was made
initially in the direction toward the beginning
of the program.
<character string>
Character string that must be available in the
program into which a return jump is made
(e.g. program or variable name).
The search for the character string is realized
in the program to which a return jump was
made initially in the direction toward the be-
ginning of the program.
The following rules apply when programming
the character string:
• Blank at the end (contrary to the jump
marker, which is identified by ":" at the
end).
• Before the character string only one
block number and/or a jump marker may
be set, no program commands.
<block after target
The parameter specifies as to whether program processing should
block>:
be continued in the block specified under parameter <target
block> or in the following block.
Type:
INT
Value:
0
The return jump is made to the block specified
in parameter <target block>.
> 0
The return jump is made to the next block
specified in parameter <target block>.
NC programming
520
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
<number of
The parameter specifies the number of program levels that should
return jump levels>:
be jumped through (return jumps) to search there for the target
block and continue processing the program.
Type:
INT
Value:
1
The program is resumed at the "current pro-
gram level -1" (just like RET without parame-
ter).
2
The program is resumed at the "current pro-
gram level -2", i.e. one level is skipped.
3
The program is resumed at the "current pro-
gram level -3", i.e. two levels are skipped.
Range of
1 ... 15
values:
<return jump to the
The parameter specifies, for a return jump into the main program,
beginning of the program>:
whether the program should be continued at the start of the pro-
gram in the active ISO dialect mode.
Type:
BOOL
Value:
1
If the return jump is made into the main pro-
gram and an ISO dialect mode is active there,
then the program branches to the beginning of
the program.
Note
For a subprogram return jump with a character string to specify the target block search, initially,
a search is always made for a jump marker in the calling program.
If a jump target is to be uniquely defined using a character string, it is not permissible that the
character string matches the name of a jump marker, as otherwise the subprogram return jump
would always be made to the jump marker and not to the character string (refer to example 2).
Supplementary conditions
When making a return jump through several program levels, the SAVE statements of the
individual program levels are evaluated.
If, for a return jump over several program levels, a modal subprogram is active and if in one of
the skipped programs the deselection command MCALL is programmed for the modal
subprogram, then the modal subprogram remains active.
NOTICE
Programming error
For a return jump across several program levels, it is the user's responsibility to ensure that
processing is continued with the necessary modal settings. This can be achieved, e.g. by
programming an appropriate main block.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
521
Work preparation
3.2 Subprogram technique
Example
Program code
Comment
EXAMPLE.MPF
…
N3000 START_CYC(parm1, param2, …)
N3010 TECH_CYC1(param1, param2, …)
N3020 TECH_CYC2(param1, param2, …)
N3030 TECH_CYC3(param1, param2, …)
N3040 END_CYC(param1, param2, …)
N3040 END_CYC(param1, param2, …)
N3050 …
N4500 START_CYC(param11, param12, …)
N4510 …
N4590 END_CYC(param11, param12, ..)
N5000 …
…
N6000 M30
Program code
Comment
PROC END_CYC(…)
; Call in the main program, line N3040
N10000 …
N15000 if status == 1
N15010 RETB(“START_CYC”)
; Return jump to the calling program EXAMPLE.MPF
; Search for character string "START_CYC"
; Search direction: backward in the program start
direction
; Program processing is continued with line N3000
N15020 endif
N15030 if status == 0
N15040 RET
; Return jump to the calling program EXAMPLE.MPF
; Program processing is continued with line N3050
N15050 endif
N16000 RET(“START_CYC”)
; Return jump to the calling program EXAMPLE.MPF
; Search for character string "START_CYC"
; Search direction: forward in the program end di-
rection
; Program processing is continued with line N4500
N17060 RETB
; Return jump to the calling program EXAMPLE.MPF
; Program processing is continued with line N3050
; RETB without parameter is identical to RET
NC programming
522
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
3.2.3
Subprogram call
3.2.3.1
Subprogram call without parameter transfer
A subprogram is called either with address L and subprogram number or by specifying the
program name.
A main program can also be called as a subprogram. The end of program M2 or M30 set in the
main program is evaluated as M17 in this case (end of program with return to the calling
program).
Note
Accordingly, a subprogram can also be started as a main program.
Search strategy of the control:
Are there any *_MPF?
Are there any *_SPF?
This means, if the name of the subprogram to be called is identical to the name of the main
program, the main program that issued the call is called again. This is generally an undesirable
effect and must be avoided by assigning unique names to subprograms and main programs.
Note
Subprograms not requiring parameter transfer can also be called from an initialization file.
Syntax
L<number>/<program name>
Note
The subprogram call must always be programmed in a separate NC block.
Meaning
L:
Address for the subprogram call
<number>:
Name of the subprogram
Type:
INT
Value:
Maximum 7 decimal places
Notice:
Leading zeros are significant in names (⇒ L123, L0123 and
L00123 are three different subprograms).
<program name>:
Name of the subprogram (or main program)
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
523
Work preparation
3.2 Subprogram technique
Examples
Example 1: Subprogram call without parameter transfer
Main program
N10 L47
or
Subprogram
N10
Spigot_2
Example 2: Calling a main program as a subprogram
Main program
N10 MPF739
Additional main
or
program
N10WELLE3
N10
N50 M30
See also
Subprogram without parameter transfer (Page 497)
NC programming
524
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
3.2.3.2
Subprogram call with parameter transfer (EXTERN)
For a subprogram call with parameter transfer, variables or values can be transferred directly
(but not VAR parameters).
Subprograms with parameter transfer must be declared with EXTERNAL in the main program
before they are called in the main program (e.g. at the beginning of the program). The name of
the subprogram and the variable types are thereby specified in the sequence in which they are
transferred.
NOTICE
Risk of confusion
Both the variable types and the sequence of the transfer must match the definitions declared
under PROC in the subprogram. The parameter names can be different in the main program and
the subprogram.
Syntax
EXTERNAL <program name>(<type_Par1>,<type_Par2>,<type_Par3>)
<program name>(<value_Par1>,<value_Par2>,<value_Par3>)
Note
The subprogram call must always be programmed in a separate NC block.
Meaning
<program name>:
Name of subprogram
EXTERNAL:
Keyword to declare a subprogram with pa-
rameter transfer.
Note:
You only have to specify EXTERNAL if the
subprogram is in the workpiece or in the
global subprogram directory. Cycles do not
have to be declared as EXTERNAL.
<type_par1>,<type_par2>,<type_par3>:
Variable types of the parameters to be trans-
ferred in the sequence of the transfer
<value_par1>,<value_par2>,<value_par3>:
Variable values for the parameters to be
transferred
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
525
Work preparation
3.2 Subprogram technique
Examples
Example 1: Subprogram call preceded by declaration
Program code
Comment
N10 EXTERNAL BORDERS(REAL,REAL,REAL)
; Specify the subprogram.
N40 BORDER(15.3,20.2,5)
; Call the subprogram with parameter
transfer.
Main program
N10 EXTERNAL
BORDER(REAL,REAL,REAL)
N40 BORDER(15.3,20.2,5)
Example 2: Subprogram call without declaration
Program code
Comment
N10 DEF REAL LENGTH, WIDTH, DEPTH
N20 …
N30 LENGTH=15.3 WIDTH=20.2 DEPTH=5
N40 BORDER(LENGTH,WIDTH,DEPTH)
; or: N40 BORDER(15.3,20.2,5)
NC programming
526
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Main program
N30 LENGTH=15.3 WIDTH=20.2 DEPTH=5
N40 BORDER(LENGTH,WIDTH,DEPTH)
or
N40 BORDER(15.3,20.2,5)
See also
Subprogram with call-by-value parameter transfer (PROC) (Page 497)
Subprogram with call-by-reference parameter transfer (PROC, VAR) (Page 499)
3.2.3.3
Number of program repetitions (P)
If a subprogram is to be executed several times in succession, the desired number of program
repetitions can be entered at address P in the block with the subprogram call.
CAUTION
Subprogram call with program repetition and parameter transfer
Parameters are transferred only when the program is called, i.e., on the first run. The
parameters remain unchanged for the remaining repetitions. If you want to change the
parameters during program repetitions, you must make the appropriate provision in the
subprogram.
Syntax
<program name> P<value>
Meaning
<program name>:
Subprogram call
P:
Address to program program repetitions
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
527
Work preparation
3.2 Subprogram technique
<value>:
Number of program repetitions
Type:
INT
Range of values:
1 … 9999
(unsigned)
Example
Program code
Comment
N40 FRAME P3
; The BORDER subprogram is to be executed three times one after
the other.
Main program
Subprogram
N40 FRAME P3
1
2
3
3.2.3.4
Modal subprogram call (MCALL)
The specified subprogram is not immediately called as a result of the modal subprogram
call MCALL <program name>. Instead, the call is performed as of this time in the part program
after each traversing block with path motion. Also across program levels.
Note
When a program is being executed, only the last modal subprogram call MCALL <program
name> is effective in each case. The current modal subprogram call replaces the one that has
been active up until then.
If parameters are transferred to the subprogram, the parameters are only transferred with call:
MCALL(<ProgName>(Par1, Par2, ...))
NC programming
528
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Note
The data definition area at the start of the subprogram is only executed once when executing the
block with the programmed MCALL call. For the following subprogram calls, after the traversing
blocks, the data definition area is no longer executed. This means that a value assigned in the
definition of a local user variable (LUD) is no longer available after the first call, but the value that
was last written in the cycle. The variable is not recreated after the first call but keeps the last
value from the previous call. To work around this response, we recommend that the LUD
definition and the value assignment are separated from one another, and the value assignment
is programmed in a dedicated block after the data definition area.
NOTICE
Modal subprogram calls without path motion
In the following situations the modal subprogram is also called without programming path
motion:
• Programming addresses S or F if G0 or G1 is active.
• If G0 or G1 were programmed alone in the block or with additional G commands.
Syntax
MCALL <program name>
MCALL
Meaning
MCALL <program
Activate the "Modal subprogram call" function
name>:
<program name>:
Name of subprogram
MCALL:
The "Modal subprogram call" function is deactivated with MCALL without
specification of a program name.
Boundary conditions
ASUB
If the part program processing is interrupted by an ASUB (see Chapter "Interrupt routine (ASUB)
(Page 540)"), then no modal subprogram calls are executed in this ASUB.
If an ASUB is started in the "Reset" channel state, then it behaves just like a normal part program
with regard to the modal subprogram calls.
Tool change cycle
If the "Modal subprogram call" function is deselected during the tool change cycle, note that the
tool change cycle is called implicitly, even after a block search, via the search ASUB, or manually
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
529
Work preparation
3.2 Subprogram technique
via overstore. In this situation, the "Modal subprogram call" function must not be deselected
because otherwise the search result is falsified. It is therefore recommended that the deselection
of the "Modal subprogram call" function in the tool change cycle is programmed as follows:
Program code
Comment
IF $AC_ASUB == 0
; Call is not performed via search ASUB or overstore.
MCALL
; Deactivate the "Modal subprogram call" function.
ENDIF
Examples
Example 1
Program code
Comment
N10 G0 X0 Y0
N20 MCALL L70
; Activate the modal subprogram call for L70.
N30 X10 Y10
; X10 Y10 is approached, and then L70 is called.
N40 X20 Y20
; X20 Y20 is approached, and then L70 is called.
N100 MCALL
; Deactivate the "Modal subprogram call" function.
N110 X0 Y0
; X0 Y0 is approached, L70 is not called.
Example 2
Program code
N10 G0 X0 Y0
N20 MCALL L70
N30 L80
In this example, the following NC blocks with programmed path axes are in subprogram L80. L70
is called by L80.
3.2.3.5
Indirect subprogram call (CALL)
Depending on the prevailing conditions at a particular point in the program, different
subprograms can be called. The name of the subprogram is stored in a variable of the STRING
type. The subprogram call is realized with CALL and the variable name.
Note
The indirect subprogram call is only possible for subprograms without parameter transfer. For a
direct subprogram call, save the name in a STRING constant.
Syntax
CALL <program name>
NC programming
530
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Meaning
CALL:
Command for the indirect subprogram call.
<program name>:
Name of the subprogram (variable or constant)
Type:
STRING
Example
Direct call with STRING constant:
Program code
Comment
…
CALL "/_N_WKS_DIR/_N_SUBPROG_WPD/_N_PART1_SPF"
; Direct call to subprogram
PART1 with CALL.
…
Indirect call via variable:
Program code
Comment
…
DEF STRING[100] PROGNAME
: Define variable.
PROGNAME="/_N_WKS_DIR/_N_SUBPROG_WPD/_N_PART1_SPF"
; Assign subprogram PART1 to
the PROGNAME variable.
CALL PROGNAME
; Indirect call to subprogram
PART1 via CALL and the PROG-
NAME variable.
…
3.2.3.6
Indirect subprogram call with specification of the calling program part (CALL
BLOCK ... TO ...)
CALL and the keyword combination BLOCK ... TO is used to call a subprogram indirectly and
execute the program section designated by the start and end labels.
Syntax
CALL <program name> BLOCK <start label> TO <end label>
CALL BLOCK <start label> TO <end label>
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
531
Work preparation
3.2 Subprogram technique
Meaning
CALL:
Command for the indirect subprogram call.
<program name>:
Name of the subprogram (variable or constant) that contains the pro-
gram section to be executed (specification optional).
Type:
STRING
Note:
If a <program name> has not been programmed, the program section
designated by <start label> and <end label> is searched for in
the current program and executed.
BLOCK ... TO ... :
Keyword combination for indirect program section execution
<start label>:
Variable that refers to the start of the program section to be executed.
Type:
STRING
<end label>:
Variable that refers to the end of the program section to be executed.
Type:
STRING
Example
Main program:
Program code
Comment
DEF STRING[20] STARTLABEL, ENDLABEL
; Variable definition for the start and
end labels.
STARTLABEL="LABEL_1"
ENDLABEL="LABEL_2"
CALL "CONTUR_1" BLOCK STARTLABEL TO ENDLA-
; Indirect subprogram call and identifi-
BEL
er associated with the calling program
section.
Subprogram:
Program code
Comment
PROC CONTUR_1 ...
LABEL_1
; Start label: Start of program section execution.
N1000 G1 ...
LABEL_2
; End label: End of program section execution.
3.2.3.7
Indirect call of a program programmed in ISO language (ISOCALL)
A program programmed in an ISO language can be called using the indirect program call
ISOCALL. The ISO mode set in the machine data is then activated. The original execution mode
becomes effective again at the end of the program. If no ISO mode is set in the machine data,
the subprogram is called in Siemens mode.
NC programming
532
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Additional information about the ISO mode: Function Manual ISO Dialects
Syntax
ISOCALL <program_name>
Meaning
ISOCALL:
Keyword for an indirect subprogram call with which the ISO mode set in
the machine data is activated.
<program name>:
Name of the program programmed in an ISO language (variable or con-
stant, type STRING)
Example: Calling a contour with cycle programming from ISO mode
Program code
Comment
0122_SPF
; Contour description in ISO mode
N1010 G1 X10 Z20
N1020 X30 R5
N1030 Z50 C10
N1040 X50
N1050 M99
N0010 DEF STRING[5] PROGNAME = “0122“
; Siemens part program (cycle)
N2000 R11 = $AA_IW[X]
N2010 ISOCALL PROGNAME
N2020 R10 = R10+1
; Execute program 0122.spf in ISO mode
N2400 M30
3.2.3.8
Call subprogram with path specification and parameters (PCALL)
With PCALL, you can call subprograms with the absolute path and parameter transfer.
Syntax
PCALL <path/program name>(<parameter 1>,…,<parameter n>)
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
533
Work preparation
3.2 Subprogram technique
Meaning
PCALL:
Keyword for subprogram call with absolute path name
<path/program name>:
Absolute path data including subprogram names.
Rules regarding path data, see "Addressing program memory files
(Page 555)".
If no absolute path name is specified, PCALL behaves like a stand-
ard subprogram call with a program identifier.
The program name is specified without prefix and without file
identifier. If the program name is to be programmed with prefix
and file identifier, then it must be explicitly declared with prefix and
file identifier using the EXTERN command.
<parameter 1>, ...:
Actual parameters in accordance with the PROC operation of the
subprogram.
Example
Program code
PCALL/_N_WKS_DIR/_N_SHAFT_WPD/SHAFT(parameter1,parameter2,…)
3.2.3.9
Extend search path for subprogram calls (CALLPATH)
The search path for subprogram calls can be extended using the CALLPATH command. This
means that also subprograms can be called from a non-selected workpiece directory without
having to specify the complete, absolute path name of the subprogram.
Another application option is possible in the EES mode "EES without GDIR", if another directory
is used on an external program memory to save global subroutines. In this case, using
CALLPATH the search path can be extended by this subprogram directory.
The search path extension is made before the entry for user cycles (_N_CUS_DIR).
The search path extension is deselected again as a result of the following events:
• CALLPATH with blanks
• CALLPATH without parameter
• End of part program
• Reset
Syntax
CALLPATH("<path name>")
NC programming
534
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Meaning
CALLPATH:
Keyword for the programmable search path exten-
sion.
Is programmed in a separate part program line.
<path name>:
Constant or variable, STRING type.
Contains the absolute path name of the directory
by which the search path should be extended.
Rules regarding path data, see "Addressing pro-
gram memory files (Page 555)".
Example
The search path should be extended by a certain workpiece directory:
Program code
CALLPATH ("/_N_WKS_DIR/_N_MYWPD_WPD")
This means that the following search path is set (position 5. is new):
1. Actual directory/name
2. Actual directory/name_SPF
3. Actual directory/name_MPF
4.
//NC:/_N_SPF_DIR / name_SPF
5.
/_N_WKS_DIR/_N_MYWPD_WPD/name_SPF
6. /N_CUS_DIR/name_SPF
7.
/_N_CMA_DIR/name_SPF
8.
/_N_CST_DIR/name_SPF
Supplementary conditions
• CALLPATH checks whether the programmed path name actually exists. In the case of an
error, part program execution is interrupted with correction block alarm 14009.
• CALLPATH can also be programmed in INI files. It is only effective for the time it takes to
process the INI file (WPD-INI file or initialization program for NC active data, e.g. frames in the
1st channel _N_CH1_UFR_INI). The search path is again reset.
3.2.3.10
Execute external subroutine (EXTCALL)
A part program can be loaded from an external memory and executed with the EXTCALL
command.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
535
Work preparation
3.2 Subprogram technique
The following are available as external memory:
• Local drive
• Network drive
• USB drive
Note
Only the USB interfaces on the operator panel front or the TCU can be used as an interface
for processing an external program on a USB drive.
NOTICE
Tool/workpiece damage when using a USB flash drive
It is recommended that a USB flash drive is not used to execute an external subprogram. A
communication interruption to the USB flash drive while executing the subprogram as a
result of contact problems, drop out, interruption through a knock or accidental unplugging
stops the machining immediately. The tool and/or workpiece could be damaged.
Default setting of the external program path
The path for the external program directory can be preset with the setting data:
SD42700 $SC_EXT_PROG_PATH
Together with the program path and identifier specified with the EXTCALL call, this forms the
entire path for the subprogram to be called.
Note
If the program path is specified only via the EXTCALL call, then SD42700 must be empty.
Note
Parameters
When an external program is called, no parameters can be transferred to it.
Syntax
EXTCALL("<Path/><Program name>")
NC programming
536
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Meaning
EXTCALL:
Command for calling an external subprogram.
"<Path/><Program name>":
Constant/variable of type STRING
<Path/>:
Absolute or relative path specifica-
tion (optional)
<Program name>:
The program name is specified with-
out prefix "_N_".
The file extensions ("MPF", "SPF") can
be attached to program names using
the "_" or "." character (optional).
Example:
"SHAFT"
"SHAFT_SPF"
"SHAFT.SPF"
Path specification: Short designations
The following short designations can be used to specify the path:
• Local drive: "LOCAL_DRIVE:"
• CF card: "CF_CARD:"
• USB drive (operator panel front): "USB:"
Alternatively, the abbreviations "CF_CARD:" and "LOCAL_DRIVE:" can be used.
Example
Execute from local drive
The "MAIN.MPF" main program is stored in the NC memory and is selected for execution.
Subprogram "SP_1"
The external subprogram "SP_1.SPF" or "SP_1.MPF" is on the local drive in the directory "/user/
sinumerik/data/prog/WKS.DIR/WST1.WPD".
The path for the external program directory is set with:
SD42700 $SC_EXT_PROG_PATH = LOCAL_DRIVE:WKS.DIR/WST1.WPD
Note
Specification of the path for calling the external subprogram:
• Without the default setting: "LOCAL_DRIVE:WKS.DIR/WST1.WPD/SP_1"
• With the default setting: "SP_1"
Subprogram "SP_2"
The external subprogram "SP_2.SPF " or "SP_2.MPF " is in the WKS.DIR/WST1.WPD directory of
the USB drive. The default setting of the path to the external program directory is used for the
path of subprogram "SP_1" and is also not rewritten in the main program. Therefore, the
complete path has to be specified when subprogram "SP_2" is called.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
537
Work preparation
3.2 Subprogram technique
Main program "MAIN"
Program code
N010 PROC MAIN
N020 ...
N030 EXTCALL("SP_1")
N030 EXTCALL("USB:WKS.DIR/WST1.WPD/SP_2")
N050 ...
N060 M30
Further information
EXTCALL call with absolute path name
If the subprogram exists under the specified path, it is executed with the EXTCALL call. If the
subprogram does not exist under the specified path, the program execution is aborted with the
EXTCALL call.
EXTCALL call with relative path name / without path name
In the event of an EXTCALL call with a relative path name or without a path name, the available
program memories are searched as follows:
1. If a path name is preset in SD42700 $SC_EXT_PROG_PATH, the data specified in the EXTCALL
call (program name or with relative path name) is searched for first, starting from this path.
The absolute path is obtained from linking the following characters:
- Default path specification in SD42700 $SC_EXT_PROG_PATH
- Separator "/"
- Path specification and subprogram name in the EXTCALL command
2. If the subprogram was not found under 1., the directories of the user memory are searched.
The search ends when the subprogram is found for the first time. If the subprogram is not found,
the program execution is aborted with the EXTCALL call.
Adjustable reload memory (FIFO buffer)
A reload memory is required for the execution of an external subprogram. The size of the reload
memory is preset with 30 kB and can only be changed by the machine manufacturer (using
MD18360 MM_EXT_PROG_BUFFER_SIZE).
Note
Subprograms with jump commands
For external subprograms that contain jump commands (GOTOF, GOTOB, CASE, FOR, LOOP,
WHILE, REPEAT, IF, ELSE, ENDIF etc.) the jump destinations must lie within the post loading
memory.
NC programming
538
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.2 Subprogram technique
Note
ShopMill/ShopTurn programs
The contour descriptions added at the file end mean the ShopMill and ShopTurn programs must
be stored completely in the read-only memory.
A separate reload memory is required for external subprograms executed in parallel.
Reset / end of program / POWER ON
Reset and POWER ON cause external subprogram calls to be interrupted and the associated load
memory to be deleted.
A program selected for "Execution from external source" remains selected for "Execution from
external source" after a reset / end of program. The behavior does not differ from internally
selected programs, assuming that the external program memory is still available.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
539
Work preparation
3.3 Interrupt routine (ASUB)
3.3
Interrupt routine (ASUB)
3.3.1
Function of an interrupt routine
Note
The terms "asynchronous subprogram (ASUB)" and "interrupt routine" are used interchangeably
in the description below to refer to the same functionality.
A typical example should clarify the function of an interrupt routine:
interrupt routine
Retraction from the
contour
Tool change
New correction
values
Repositioning
Main
program
The tool breaks during machining. This triggers a signal that stops the current machining process
and simultaneously starts a subprogram - known as an interrupt routine. The interrupt routine
contains all the statements which are to be executed in this case.
When the interrupt routine has finished being executed and the machine is ready to continue
operation, the control jumps back to the main program and continues machining at the point of
interruption - depending on the REPOS command (see "Repositioning at the contour
(Page 852)").
CAUTION
Risk of collision
If a REPOS command has not been programmed in the subprogram, then the control goes to
the end point of the block that follows the interrupted block.
NC programming
540
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.3 Interrupt routine (ASUB)
3.3.2
Creating an interrupt routine
Create interrupt routine as subprogram
The interrupt routine is identified as a subprogram in the definition.
Example:
Program code
Comment
PROC LIFT_Z
; Program name "ABHEB_Z"
N10 ...
; The NC blocks then follow:
N50 M17
; Finally, end the program and return to the main program.
Saving modal G commands (SAVE)
The interrupt routine can be designated by defining with SAVE.
The SAVE attribute means that the active modal G commands are saved before calling the
interrupt routine and are reactivated after the end of the interrupt routine (see " Subprograms
with SAVE mechanism (SAVE) (Page 501) ").
This means that it is possible to resume processing at the interruption point after the interrupt
routine has been completed.
Example:
Program code
PROC LIFT_Z SAVE
N10 ...
N50 M17
Assign additional interrupt routines (SETINT)
SETINT statements can be programmed within the interrupt routine (see "Assign and start
interrupt routine (SETINT)" (Page 541)) therefore activating additional interrupt routines. They
are triggered via the input.
3.3.3
Assign and start interrupt routine (SETINT, PRIO, BLSYNC)
The control has several fast inputs (inputs 1 ... 8), which initiate an interrupt (1 ... 8). Each
interrupt can be assigned a priority and an interrupt routine using the SETINT command. If the
interrupt is initiated by setting the fast input, then processing in the channel is interrupted and
the interrupt routine started.
Interrupt priority
If, in a part program, several inputs are assigned interrupts, then the interrupts must be assigned
different priorities.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
541
Work preparation
3.3 Interrupt routine (ASUB)
An interrupt can be assigned a priority value from 1 ... 128. Priority value 1 corresponds to the
highest priority and 128 the lowest.
Syntax
SETINT(<n>) <NAME>
SETINT(<n>) PRIO=<value> <NAME>
SETINT(<n>) PRIO=<value> <NAME> BLSYNC
SETINT(<n>) PRIO=<value> <NAME> LIFTFAST
Meaning
SETINT(<n>):
Input <n> is assigned the interrupt routine <Name>. The assigned interrupt routine
is started as soon as input <n> == 1 is detected.
Note:
If an already programmed input <n> is assigned another interrupt routine, then the
previous assignment is no longer effective.
<n>:
Input number
Type:
INT
Range of values:
1 ... 8
PRIO= :
Priority of the interrupt
(optional)
<value>:
Priority value
(optional)
Type:
INT
Range of values:
1 ... 128 (1 ⇒ highest priority)
<NAME>:
Name of the interrupt routine (subprogram)
BLSYNC:
BLSYNC ensures that after initiating the interrupt, the system first waits until the
actual block has been completed. Only then is the interrupt routine executed.
(optional)
LIFTFAST:
LIFTFAST ensures that after initiating the interrupt, initially a fast retraction is
realized (see Chapter "Fast retraction from the contour (SETINT LIFTFAST, ALF)
(Page 545)"). Only then is the interrupt routine executed.
(optional)
NC programming
542
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.3 Interrupt routine (ASUB)
Supplementary conditions
Interrupt rules
1. For every interrupt that cannot be immediately executed, or is presently already being
processed, an additional interrupt request is saved. All other interrupt requests for this
interrupt are lost.
2. If an interrupt is currently being processed and an additional interrupt with higher priority
initiated, then this interrupts the lower-priority interrupt. The lower priority interrupt is
continued after the higher priority interrupt has been completed. If, while the higher priority
interrupt is being processed, additional requests are received for the lower-priority interrupt,
then one request is saved. All others are lost.
3. If an interrupt is currently being processed and an additional interrupt with higher priority
initiated, then this interrupts the lower-priority interrupt. The higher priority interrupt is
processed. If a higher priority interrupt is initiated, the actual interrupt is interrupted and the
higher priority interrupt processed. A maximum of six active interrupt levels are possible. One
interrupt level presently being processed and five waiting interrupt levels. For each active
interrupt level, a maximum of one additional interrupt request is saved. All other interrupt
requests are lost. Interrupt requests are also lost if these are requested for additional interrupt
levels (interrupt level ≥ 7).
Examples
Example 1: Assign interrupt routines and define the priority
Program code
Comment
N20 SETINT(3) PRIO=1 ABHEB_Z
; IF input 3 == 1 THEN start interrupt routine
"ABHEB_Z"
N30 SETINT(2) PRIO=2 ABHEB_X
; IF input 2 == 1 THEN start interrupt routine
"ABHEB_X".
The interrupt routines are executed in the sequence of the priority values if the inputs become
available simultaneously (are energized simultaneously): First "ABHEB_Z", then "ABHEB_X".
Example 2: Newly assign an interrupt routine
Program code
Comment
N20 SETINT(3) PRIO=2 ABHEB_Z
; IF input 3 == 1 THEN start interrupt routine
"ABHEB_Z"
N80 SETINT(3) PRIO=1 ABHEB_X
; IF input 3 == 1 THEN start interrupt routine
"ABHEB_X"
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
543
Work preparation
3.3 Interrupt routine (ASUB)
3.3.4
Deactivating/reactivating the assignment of an interrupt routine (DISABLE,
ENABLE)
A SETINT statement can be deactivated with DISABLE and reactivated with ENABLE without
losing the input → interrupt routine assignment.
Syntax
DISABLE(<n>)
ENABLE(<n>)
Meaning
DISABLE(<n>):
Command: Deactivating the interrupt routine assignment of input <n>
ENABLE(<n>):
Command: Reactivating the interrupt routine assignment of input <n>
<n>:
Parameter: Number of the interrupt signal
Type:
INT
Range of values:
1 ... 32
Example
Program code
Comment
N20 SETINT(3) PRIO=1 ABHEB_Z
; If input 3 switches, then interrupt
; routine "ABHEB_Z" should start.
N90 DISABLE(3)
; The SETINT statement from N20 is deactivated.
N130 ENABLE(3)
; The SETINT statement from N20 is reactivated.
3.3.5
Delete assignment of interrupt routine (CLRINT)
An interrupt signal assignment defined with SETINT for an NC program (ASUP) can be deleted
with CLRINT.
Syntax
CLRINT(<n>)
NC programming
544
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.3 Interrupt routine (ASUB)
Meaning
CLRINT(<n>):
Command: Delete assignment of the interrupt signal <n> to the NC program
(ASUP) defined with SETINT <n>
<n>:
Parameter: Number of the interrupt signal
Type:
INT
Range of values:
1 ... 32
Example
Program code
Comment
N20 SETINT(3) PRIO=2 ABHEB_Z
N50 CLRINT(3)
; The assignment between input "3" and inter-
rupt routine "ABHEB_Z" is deleted.
3.3.6
Fast retraction from the contour (SETINT LIFTFAST, ALF)
For a SETINT statement with LIFTFAST, when the input is switched, the tool is moved away
from the workpiece contour using fast retraction.
The further sequence is then dependent on whether the SETINT statement includes an
interrupt routine in addition to LIFTFAST:
With interrupt routine:
After the fast retraction, the interrupt routine is executed.
Without interrupt routine: Machining is stopped after fast retraction and an alarm is output.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
545
Work preparation
3.3 Interrupt routine (ASUB)
Syntax
SETINT(<n>) PRIO=1 LIFTFAST
SETINT(<n>) PRIO=1 <NAME> LIFTFAST
Meaning
SETINT(<n>):
Command: Assign input <n> to an interrupt routine. The assigned interrupt routine
starts when input <n> switches.
<n>:
Parameter: Input number
Type:
INT
Range of values:
1 ... 8
PRIO= :
Defining the priority
<value>:
Priority value
Range of values:
1 ... 128
Priority 1 corresponds to the highest priority.
<NAME>:
Name of the subprogram (interrupt routine) that is to be executed.
LIFTFAST:
Command: Fast retraction from the contour
ALF=… :
Command: Programmable traverse direction (in motion block)
Regarding the possibilities of programming with ALF, refer to the subject "Travers-
ing direction for fast retraction from the contour (Page 547)".
Supplementary conditions
Behavior for active frame with mirroring
When determining the retraction direction, a check is performed to see whether a frame with
mirror is active. In this case, for the retraction direction, right and left are interchanged referred
to the tangential direction. The direction components in tool direction are not mirrored. This
behavior is activated with the MD setting:
MD21202 $MC_LIFTFAST_WITH_MIRROR = TRUE
Example
A broken tool should be automatically replaced by a daughter tool. Machining is then continued
with the new tool.
Main program:
Main program
Comment
N10 SETINT(1) PRIO=1 W_WECHS LIFTFAST
; When input 1 is switched, the
tool is immediately retracted from
the contour with fast retraction
(code no. 7 for tool radius compen-
sation G41). Then interrupt rou-
tine "W_WECHS" is executed.
N20 G0 Z100 G17 T1 ALF=7 D1
N30 G0 X-5 Y-22 Z2 M3 S300
N40 Z-7
NC programming
546
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.3 Interrupt routine (ASUB)
Main program
Comment
N50 G41 G1 X16 Y16 F200
N60 Y35
N70 X53 Y65
N90 X71.5 Y16
N100 X16
N110 G40 G0 Z100 M30
Subprogram:
Subprogram
Comment
PROC W_CHANGE SAVE
; Subprogram where the actual operat-
ing state is saved
N10 G0 Z100 M5
;Tool changing position, spindle stop
N20 T11 M6 D1 G41
;Change tool
N30 REPOSL RMBBL M3
; Reposition at the contour and return
jump into the main program (this is
programmed in a block)
3.3.7
Traversing direction for fast retraction from the contour
Retraction movement
The following G commands define the retraction movement plane:
• LFTXT
The retraction movement plane is defined by the path tangent and the tool direction (default
setting).
• LFWP
The plane of the retraction movement is the active working plane selected with G
commands G17, G18 or G19. The direction of the retraction movement is not dependent on
the path tangent. This allows a fast retraction to be programmed parallel to the axis.
• LFPOS
Retraction of the axis declared using POLFMASK/POLFMLIN to the absolute axis position
programmed with POLF.
ALF has no influence on the retraction direction for several axes and for several axes in a
linear system.
Programmable traversing direction (ALF=…)
The direction is programmed in discrete steps of 45 degrees with ALF in the plane of the
retraction movement.
The possible traversing directions are stored in special code numbers on the control and can be
called up using these numbers.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
547
Work preparation
3.3 Interrupt routine (ASUB)
Example:
Program code
N10 SETINT(2) PRIO=1 ABHEB_Z LIFTFAST
ALF=7
With G41 activated (machining direction to the left of the contour) the tool vertically moves
away from the contour.
G41
ALF = 7
Reference plane for defining the traversing direction for LFTXT
At the point of application of the tool to the programmed contour, the tool is clamped at a plane
which is used as a reference for specifying the retraction movement with the corresponding
code number.
The reference plane is derived from the longitudinal tool axis (infeed direction) and a vector
positioned perpendicular to this axis and perpendicular to the tangent at the point of application
of the tool.
NC programming
548
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.3 Interrupt routine (ASUB)
Tangent
Tangent
Intervention
point
Tangent
Tangent
Intervention
point
Code numbers with traversing direction for LFTXT
Starting from the reference plane, you will find the code numbers with traversing directions in
the following diagram.
View in the
traversing direction
1
2
8
45¡˘
7
3
45¡˘
6
4
5
6
7
8
Plan view
G41
5
1
G42
Traversing direction
2
3
4
The retraction in the tool direction is defined for ALF=1.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
549
Work preparation
3.3 Interrupt routine (ASUB)
The "fast retraction" function is deactivated with ALF=0.
CAUTION
Risk of collision
When the tool radius compensation is activated, then:
• For G41 codes 2, 3, 4
• For G42 codes 6, 7, 8
should not be used, as in these cases, the tool would move to the contour and would collide
with the workpiece.
Code numbers with traversing directions for LFWP
For LFWP, the direction in the machining plane is derived from following assignment:
• G17: X/Y plane
ALF=1: Retraction in the X direction
ALF=3: Retraction in the Y direction
• G18: Z/X plane
ALF=1: Retraction in the Z direction
ALF=3: Retraction in the X direction
• G19: Y/Z plane
ALF=1: Retraction in the Y direction
ALF=3: Retraction in the Z direction
See also
Fast retraction during thread cutting (LFON, LFOF, DILF, ALF, LFTXT, LFWP, LFPOS, POLF,
POLFMASK, POLFMLIN) (Page 231)
3.3.8
Motion sequence for interrupt routines
Interrupt routine without LIFTFAST
Axis motion is braked along the path down to standstill (zero speed). The interrupt routine then
starts.
The standstill position is saved as interrupt position and is approached at the end of the interrupt
routine for REPOS with RMIBL.
Interrupt routine with LIFTFAST
Axis motion is braked along the path. The LIFTFAST motion is simultaneously executed as
superimposed motion. If the path motion and LIFTFAST motion have come to a standstill (zero
speed), the interrupt routine is started.
NC programming
550
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.3 Interrupt routine (ASUB)
The position on the contour is saved as interrupt position where the LIFTFAST motion is started
and therefore the path was left.
The interrupt routine with LIFTFAST and ALF=0 behaves in precisely the same way as the
interrupt routine without LIFTFAST.
Note
The absolute value through which the geometry axes move when quickly retracting from the
contour can be set using machine data.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
551
Work preparation
3.4 File and Program Management
3.4
File and Program Management
3.4.1
Program memory
3.4.1.1
Program memory in the NCK
Files and programs (e.g. main programs and subprograms, macro definitions) are saved in the
non-volatile program memory (→ passive file system).
A number of file types are also stored here temporarily; these can be transferred to the work
memory as required (e.g. for initialization purposes when machining a specific workpiece).
3URJUDP PHPRU\ LQ WKH 1&.
B1B'()B',5
B1B&67B',5
B1B&0$B',5
B1B&86B',5
B1B63)B',5
B1B03)B',5
B1B:.6B',5
B1B&20B',5
B1B60$&B'()
B1B/
B63)
B1B*/2%B63)
B1B03) B03)
B1B00$&B'()
B1B B63)
B1B B63)
B1B029B03)
B1B80$&B'()
B1B B03)
B1B6*8'B'()
B1B
B1B0*8'B'()
B1B8*8'B'()
B1B*8' B'()
B1B*8' B'()
B1B32&.(7 B63)
B1B:(//(B:3'
B1B03)
B:3'
B1B B63)
B1B:(//(B03)
B1B03)
B03)
B1B3$57 B03)
B1B/ B63)
B1B3$57 B63)
B1B B
B1B3$57 B63)
B1B:(//(B,1,
B1B:(//(B6($
B1B3$57 B,1,
B1B3$57 B8)5
%ODFN QDPHV SHUPDQHQWO\ DYDLODEOH
B1B3$57 B&20
*UD\ QDPHV DOORFDWHG E\ WKH XVHU
B1B:(//(
Standard directories
The following standard directories are available:
Directory
Content
_N_DEF_DIR
Data modules and macro modules
_N_CST_DIR
Standard cycles
NC programming
552
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.4 File and Program Management
Directory
Content
_N_CMA_DIR
Manufacturer cycles
_N_CUS_DIR
User cycles
_N_WKS_DIR
Workpieces
_N_SPF_DIR
Global subprograms
_N_MPF_DIR
Main programs
_N_COM_DIR
Comments
File types
The following file types can be stored in the main memory:
File type
Description
<name>_MPF
Main program
<name>_SPF
Subprogram
<name>_TEA
Machine data
<name>_SEA
Setting data
<name>_TOA
Tool offsets
<name>_UFR
Work offsets/frame
<name>_INI
Initialization files
<name>_GUD
Global user data
<name>_RPA
R parameters
<name>_COM
Comment
<name>_DEF
Definitions for global user data and macros
Workpiece main directory (_N_WKS_DIR)
The workpiece main directory exists in the standard setup of the program memory under the
name _N_WKS_DIR. The workpiece main directory contains all the workpiece directories for the
workpieces that you have programmed.
Workpiece directories (..._WPD)
A workpiece directory contains all files required for machining a workpiece. These can be main
programs, subprograms, any initialization programs and comment files.
The first time a part program is started, initialization programs are executed once, depending on
the selected program (in accordance with machine data MD11280 $MN_WPD_INI_MODE).
Example:
The workpiece directory _N_SHAFT_WPD, created for SHAFT workpiece contains the following
files:
File
Description
_N_SHAFT_MPF
Main program
_N_PART2_MPF
Main program
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
553
Work preparation
3.4 File and Program Management
File
Description
_N_PART1_SPF
Subprogram
_N_PART2_SPF
Subprogram
_N_SHAFT_INI
General initialization program for the data of the workpiece
_N_SHAFT_SEA
Setting data initialization program
_N_PART2_INI
General initialization program for the data for the Part 2 program
_N_PART2_UFR
Initialization program for the frame data for the Part 2 program
_N_SHAFT_COM
Comment file
Data can also be stored in the workpiece directory which is not directly required by the NC for the
machining. In addition to ASCII files, this can be binary files, such as images in JPG format or
descriptions in PDF format. In order that these can be interpreted as binary files by the NC, the
file extensions must be known in the NC (setting during commissioning via MD17000 $MN_
EXTENSIONS_OF_BIN_FILES; the following file extensions are preset in the basic setting: JPG,
GIF, PNG, BMP, PDF, ICO, HTM).
Select workpiece for machining
A workpiece directory can be selected for execution in a channel. If a main program with
the same name or only a single main program (_MPF) is stored in this directory, this is
automatically selected for execution.
3.4.1.2
External program memory
In addition to the passive file system in the NC, external program memories can also be available
at the machine (e.g. on the local drive or on a network drive).
Using the functions "Execute from external" or "EES (Execution from External Storage)" part
programs can be directly executed from external program memories.
Further information: Function Manual Basic Functions
Global part program memory (GDIR)
When declaring the drives, one of the drives can be designated the global part program memory
(GDIR).
The system automatically creates the MPF.DIR, SPF.DIR and WKS.DIR directories on the drive.
These three directories form the GDIR.
The GDIR only plays a role for the EES function. Depending on the drive configuration, the GDIR
replaces or extends the NC part program memory. The creation of a GDIR is, however, not
essential for EES operation.
The directories and files of the GDIR can be addressed in the part program in the same way as in
the passive file system. This permits a compatible transfer of an NC program with path details
from the passive file system to the GDIR. The directory SPF.DIR of the GDIR is contained in the
search path for subprograms.
NC programming
554
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.4 File and Program Management
Program organization
The program organization on external program memories is shown in the following diagram:
3DVVLYH ILOH V\VWHP LQ WKH 1&.
([WHUQDO SURJUDP PHPRU\
'(9
$Q\ GULYH
3URJV
&\FOHV
0\3URJ 0SI
B1B&67B',5
SS
[[[
B1B&0$B',5
PRUH3URJV
6+$)7
B1B&86B',5
0\6XE3 63)
'(9
3DUW SURJUDP PHPRU\
*OREDO SDUW SURJUDP
PHPRU\ *',5
03) ',5
03) ',5
B1B352* B03)
352*
03)
B1B352* B03)
352*
03)
63) ',5
63) ',5
B1B68% B63)
68%
63)
B1B68% B63)
68%
63)
:.6 ',5
:.6 ',5
Case-insensitive file systems
Note
To avoid problems with case-sensitivity for the file addressing (see "Addressing program memory
files (Page 555)"), case-insensitive file systems should be used as external program memory.
3.4.1.3
Addressing program memory files
A file in the program memory, which is addressed with a file handling command (e.g. WRITE,
DELETE, READ, ISFILE, FILEDATE, FILETIME, FILESIZE, FILESTAT, FILEINFO), is referenced with an
absolute path plus file names or only with the file names. In the second case, the path of the
selected program is used as file path.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
555
Work preparation
3.4 File and Program Management
Addressing in the NC/EES notation
3DVVLYH ILOH V\VWHP LQ WKH 1&.
([WHUQDO SURJUDP PHPRU\
'(9
DQ\ GULYH
3URJV
&\FOHV
B1B&67B',5
0\3URJ 0SI
SS
[[[
$GGUHVVLQJ LQ WKH ((6 QRWDWLRQ
B1B&0$B',5
PRUH3URJV
'(9
3URJV SS
[[[
6+$)7
B1B&86B',5
0\6XE3 63)
'(9
3DUW SURJUDP PHPRU\
*OREDO SDUW SURJUDP
PHPRU\ *',5
$GGUHVVLQJ LQ WKH 1&. QRWDWLRQ
$GGUHVVLQJ LQ WKH 1&. QRWDWLRQ
B1B03)B',5
03) ',5
B1B03)B',5 B1B352* B03)
B1B03)B',5 B1B352* B03)
B1B352* B03)
352*
03)
B1B352* B03)
352*
03)
$GGUHVVLQJ LQ WKH ((6 QRWDWLRQ
B1B63)B',5
63) ',5
03) ',5 352* 03)
B1B68% B63)
68%
63)
$GGUHVVLQJ LQ WKH ((6 QRWDWLRQ
B1B68% B63)
68%
63)
([SOLFLW DGGUHVVLQJ
'(9
63) ',5 68%
63)
B1B:.6B',5
:.6 ',5
1& B1B63)B',5 B1B68% B63)
RU
1& 63) ',5 68%
63)
Addressing files of the passive file system
Files of the passive file system are generally addressed in the NC notation (directory and file
names begin with the domain identifier "_N_", "_" is the separator for the file identifier) without
specifying the drive name. An addressing in EES notation (without domain identification "_N_",
separator for the directory/file extension is ".") is, however, also permitted.
Example:
• NC notation: "/_N_SPF_DIR/_N_SUB1_SPF"
• EES notation: "/SPF.DIR/SUB1.SPF"
Note
The addressing schemes for files of the passive file system in EES notation are converted
internally into NC notation in accordance with the following rules:
• Directory and file names are extended with the domain identification "_N_".
• If the fourth-last character in the directory or file name is a period ("."), it will be converted
into an underscore ("_").
The passive file system can also be explicitly addressed using the predefined drive names "//NC:".
Example:
• NC notation: "//NC:/_N_SPF_DIR/_N_SUB1_SPF"
• EES notation: "//NC:/SPF.DIR/SUB1.SPF"
Addressing files of an external program memory
Files of an external program memory not recorded as GDIR must be addressed in EES notation.
The drive name (e.g. "//DEV1:") must be specified at the start of the addressing path. All symbolic
device names configured in /user/sinumerik/hmi/cfg/logdrive.ini are permissible.
NC programming
556
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.4 File and Program Management
Example:
• EES notation: "//DEV1:/MyProgDir/pp1.xxx"
• NC notation: Not permissible
Addressing files of the global part program memory (GDIR)
When addressing files of the GDIR, in addition to specifying the path in the EES notation, it is also
permissible to specify the path in the NC notation.
Example:
• EES notation: "//DEV2:/MPF.DIR/PROG11.MPF"
• NC notation: "/_N_MPF_DIR/_N_PROG11_MPF"
Note
The addressing schemes for files of the GDIR in NC notation are converted internally into EES
notation in accordance with the following rules:
• The domain identification "_N_" in directory and file names is removed.
• If the fourth-last character in the directory or file name is an underscore ("_"), it will be
converted into a period (".").
Rules for the path specification
A complete path specification consists of drive name, directory path and file name.
Drive name
The following rules govern the specification of the drive name:
• All symbolic device names configured in /user/sinumerik/hmi/cfg/logdrive.ini are permissible.
• The character "//" is at the beginning, followed by at least one letter or one digit.
• The following characters can be any combination of letters, digits, "_" and spaces.
• The name is ended with a letter or a digit, followed by a ":".
• Other special characters are not permitted.
Note
The drive name "//NC:" is predefined for the passive file system.
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
557
Work preparation
3.4 File and Program Management
Examples:
• External program memory:
-
//Drive1:
–
//Drive_1:
–
//Drive 1:
–
//A B:
–
//1 B C 2:
Directory path
The following rules govern the specification of the directory path:
• A "/" is located at the start and end of the directory path and as separator for the individual
path sections.
Note
A double slash ("//") within the directory path is not permitted!
• Directory names:
- Directory names must begin with a letter or a digit. Only for addressing in the NC notation
do directory names begin with the domain identification "_N_".
- The following characters can be any combination of letters, digits and "_".
Note
Spaces in directory names are also permitted for external program memories. This is not
true, however, when the external program memory is created as global part program
memory (GDIR).
- Other special characters are not permitted.
• Directory extensions:
- Directory extensions must consist of three letters/digits.
- They are separated with "_" (NC notation) or "." (EES notation) from the directory name.
Note
The passive file system has only the directory extensions _DIR and _WPD.
NC programming
558
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
Work preparation
3.4 File and Program Management
Examples:
• Passive file system or GDIR:
- NC notation: _N_WKS_DIR/_N_MYNCPROGS_WPD/...
- EES notation: WKS.DIR/MYPROGS.WPD/...
• External program memory:
- /abc
- /ab_c.def
- /ab c1.def
- /a b c .d11
- /abc.def/ghi.klm
File name
The following rules apply to the file names:
• Only for addressing in NC notation do file names begin with the domain identification "_N_".
• The next two characters should be either two letters or an underscore followed by a letter.
Note
If this condition is satisfied, then an NC program can be called as subprogram from another
program just by specifying the program name. However, if the program name starts with
digits, the subprogram call is then only possible via the CALL statement.
• The following characters can be any combination of letters, digits and "_".
• File extension:
- The file extension must consist of three letters/digits.
Note
Permitted file extensions in the passive file system, see "Program memory in the NCK
(Page 552)".
- They are separated with "_" (NC notation) or "." (EES notation) from the file names.
Examples:
• Passive file system or GDIR:
- NC notation: _N_SUB1_SPF
- EES notation: SUB1.SPF
• External program memory:
- Part 1
- _Part1
- Part_1.spf
- Part1.mpf
NC programming
Programming Manual, 10/2020, 6FC5398-2EP40-0BA1
559

 

 

 

 

 

 

 

Content      ..     6      7      8      9     ..