|
|
Flexible NC programming
1.3 Arithmetic functions
1.3
Arithmetic functions
Function
The arithmetic functions are primarily for R parameters and variables (or constants and
functions) of type REAL. The types INT and CHAR are also permitted.
Operator / arithmetic function Meaning
+
Addition
-
Subtraction
*
Multiplication
/
Division
Notice:
(type INT)/(type INT)=(type REAL); example: 3/4 = 0.75
DIV
Division, for variable type INT and REAL
Notice:
(type INT)DIV(type INT)=(type INT); example: 3 DIV 4 = 0
MOD
Modulo division (only for type INT) supplies remainder of an
INT division
Example: 3 MOD 4 = 3
:
Chain operator (for FRAME variables)
Sin()
Sine
COS()
Cosine
TAN()
Tangent
ASIN()
Arcsine
ACOS()
Arccosine
ATAN2( , )
Arctangent2
SQRT()
Square root
ABS()
Absolute value
POT()
2nd power (square)
TRUNC()
Truncate to integer
The accuracy for comparison commands can be set using
TRUNC (see "Precision correction on comparison errors
(TRUNC) (Page 66)")
ROUND()
Round to integer
LN()
Natural logarithm
EXP()
Exponential function
MINVAL ()
Lower value of two variables
(see "Variable minimum, maximum and range (MINVAL,
MAXVAL and BOUND) (Page 68)")
MAXVAL ()
Larger value of two variables
(see "Variable minimum, maximum and range (MINVAL,
MAXVAL and BOUND) (Page 68)")
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
61
Flexible NC programming
1.3 Arithmetic functions
BOUND ()
Variable value within the defined value range
(see "Variable minimum, maximum and range (MINVAL,
MAXVAL and BOUND) (Page 68)")
CTRANS()
Translation
CROT ()
Rotation
CSCALE()
Change of scale
CMIRROR()
Mirroring
Programming
The usual mathematical notation is used for arithmetic functions. Priorities for execution are
indicated by parentheses. Angles are specified for trigonometry functions and their inverse
functions (right angle = 90°).
Examples
Example 1: ATAN2
The arithmetic function ATAN2 calculates
the angle of the total vector from two
5
$7$1
mutually perpendicular vectors.
The result is in one of four quadrants
(-180° < 0 < +180°).
The angular reference is always based
$QJOH
r
on the 2nd value in the positive direction.
QG YHFWRU
5
$7$1
$QJOH
r
QG YHFWRU
Job Planning
62
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.3 Arithmetic functions
Example 2: Initializing complete variable arrays
Program code
Comment
R1=R1+1
; New R1 = old R1 +1
R1=R2+R3 R4=R5-R6 R7=R8*R9
R10=R11/R12 R13=SIN(25.3)
R14=R1*R2+R3
; Multiplication or division takes precedence
over addition or subtraction.
R14=(R1+R2)*R3
; Parentheses are calculated first.
R15=SQRT(POT(R1)+POT(R2))
; Inner parentheses are resolved first:
R15 = square root of (R1+R2)
RESFRAME=FRAME1:FRAME2
; The concatenation operator links frames
to form a resulting frame or assigns values
FRAME3=CTRANS(…):CROT(…)
to frame components.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
63
Flexible NC programming
1.4 Comparison and logic operations
1.4
Comparison and logic operations
Function
Comparison operations can be used , for example, to formulate a jump condition. Complex
expressions can also be compared.
The comparison operations are applicable to variables of type CHAR, INT, REAL and BOOL.
The code value is compared with the CHAR type.
For types STRING, AXIS and FRAME, the following are possible: == and <>, which can be used
for STRING type operations, even in synchronous actions.
The result of comparison operations is always of BOOL type.
Logic operators are used to link truth values.
The logical operations can only be applied to type BOOL variables. However, they can also be
applied to the CHAR, INT and REAL data types via internal type conversion.
For the logic (Boolean) operations, the following applies to theBOOL, CHAR,INT and REAL data
types:
●
0 corresponds to: FALSE
● not equal to 0 means: TRUE
Bit logic operators
Logic operations can also be applied to single bits of types CHAR and INT. Type conversion is
automatic.
Programming
Relational operator
Significance
==
equal to
<>
not equal to
>
greater than
<
less than
>=
greater than or equal to
<=
less than or equal to
Logic operator
Significance
AND
AND
OR
OR
NOT
Negation
XOR
Exclusive OR
Job Planning
64
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.4 Comparison and logic operations
Bit-by-bit logic operator
Significance
B_AND
Bit-serial AND
B_OR
Bit-serial OR
B_NOT
Bit-serial negation
B_XOR
Bit-serial exclusive OR
Note
In arithmetic expressions, the execution order of all the operators can be specified by
parentheses, in order to override the normal priority rules.
Note
Spaces must be left between BOOLEAN operands and operators.
Note
The operator B_NOT only refers to one operand. This is located after the operator.
Examples
Example 1: Relational operators
IF R10>=100 GOTOF DEST
or
R11=R10>=100
IF R11 GOTOF DEST
The result of the R10>=100 comparison is first buffered in R11.
Example 2: Logic operators
IF (R10<50) AND ($AA_IM[X]>=17.5) GOTOF DESTINATION
or
IF NOT R10 GOTOB START
NOT only refers to one operand.
Example 3: Bit-by-bit logic operators
IF $MC_RESET_MODE_MASK B_AND 'B10000' GOTOF ACT_PLANE
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
65
Flexible NC programming
1.5 Precision correction on comparison errors (TRUNC)
1.5
Precision correction on comparison errors (TRUNC)
Function
The TRUNC command truncates the operand multiplied by a precision factor.
Settable precision for comparison commands
Program data of type REAL are displayed internally with 64 bits in IEEE format. This display
format can cause decimal numbers to be displayed imprecisely and lead to unexpected
results when compared with the ideally calculated values.
Relative equality
To prevent the imprecision caused by the display format from interfering with program flow,
the comparison commands do not check for absolute equality but for relative equality.
Syntax
Precision correction on comparison errors
TRUNC (R1*1000)
Significance
TRUNC:
Truncate decimal places
Relative quality of 10-12 taken into account for
● Equality: (==)
● Inequality: (<>)
● Greater than or equal to: (>=)
● Less than or equal to: (<=)
● Greater/less than: (><) with absolute equality
● Greater than: (>)
● Less than: (<)
Compatibility
For compatibility reasons, the check for relative quality for (>) and (<) can be deactivated by
setting machine data MD10280 $MN_ PROG_FUNCTION_MASK Bit0 = 1.
Note
Comparisons with data of type REAL are subject to a certain imprecision for the above
reasons. If deviations are unacceptable, use INTEGER calculation by multiplying the
operands by a precision factor and then truncating with TRUNC.
Job Planning
66
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.5 Precision correction on comparison errors (TRUNC)
Synchronized actions
The response described for the comparison commands also applies to synchronized actions.
Examples
Example 1: Precision considerations
Program code
Comments
N40 R1=61.01 R2=61.02 R3=0.01
; Assignment of initial values
N41 IF ABS(R2-R1) > R3 GOTOF ERROR
; Jump would have been executed up
until now
N42 M30
; End of program
N43 ERROR: SETAL(66000)
;
R1=61.01 R2=61.02 R3=0.01
; Assignment of initial values
R11=TRUNC(R1*1000) R12=TRUNC(R2*1000)
; Accuracy correction
R13=TRUNC(R3*1000)
IF ABS(R12-R11) > R13 GOTOF ERROR
; Jump is no longer executed
M30
; End of program
ERROR: SETAL(66000)
;
Example 2: Calculate and evaluate the quotient of both operands
Program code
Comments
R1=61.01 R2=61.02 R3=0.01
; Assignment of initial values
IF ABS((R2-R1)/R3)-1) > 10EX-5 GOTOF ERROR
; Jump is not executed
M30
; End of program
ERROR: SETAL(66000)
;
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
67
Flexible NC programming
1.6 Variable minimum, maximum and range (MINVAL, MAXVAL and BOUND)
1.6
Variable minimum, maximum and range (MINVAL, MAXVAL and
BOUND)
Function
The MINVAL and MAXVAL commands can be used to compare the values of two variables. The
smaller value (in the case of MINVAL) or the larger value (in the case of MAXVAL) respectively is
delivered as a result.
The BOUND command can be used to test whether the value of a test variable falls within a
defined range of values.
Syntax
<smaller value>=MINVAL(<variable1>,<variable2>)
<larger value>=MAXVAL(<variable1>,<variable2>)
<return value>=<BOUND>(<minimum>,<maximum>,<test variable>)
Significance
MINVAL:
Obtains the smaller value of two variables (<variable1>,
<variable2>)
<smaller value>:
Result variable for the MINVAL command
Set to the smaller variable value.
MAXVAL:
Obtains the larger value of two variables (<variable1>,
<variable2>)
<larger value>:
Result variable for the MAXVAL command
Set to the larger variable value.
BOUND:
Tests whether a variable (<test variable) is within a defined
range of values.
<minimum>:
Variable which defines the minimum value of the range of values.
<maximum>:
Variable which defines the maximum value of the range of
values.
<return value>:
Result variable for the BOUND command
If the value of the test variable is within the defined range of
values, the result variable is set to the value of the test variable.
If the value of the test variable is greater than the maximum
value, the result variable is set to the maximum value of the
definition range.
If the value of the test variable is less than the minimum value,
the result variable is set to the minimum value of the definition
range.
Job Planning
68
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.6 Variable minimum, maximum and range (MINVAL, MAXVAL and BOUND)
Note
MINVAL, MAXVAL, and BOUND can also be programmed in synchronized actions.
Note
Behavior if values are equal
If the values are equal MINVAL/MAXVAL are set to this equal value. In the case of BOUND the
value of the variable to be tested is returned again.
Example
Program code
Comments
DEF REAL rVar1=10.5, rVar2=33.7, rVar3, rVar4, rVar5, rValMin, rValMax, rRetVar
rValMin=MINVAL(rVar1,rVar2)
; rValMin is set to value 10.5.
rValMax=MAXVAL(rVar1,rVar2)
; rValMax is set to value 33.7.
rVar3=19.7
rRetVar=BOUND(rVar1,rVar2,rVar3)
; rVar3 is within the limits, rRetVar is set to 19.7.
rVar3=1.8
rRetVar=BOUND(rVar1,rVar2,rVar3)
; rVar3 is below the minimum limit, rRetVar is set to
10.5.
rVar3=45.2
rRetVar=BOUND(rVar1,rVar2,rVar3)
; rVar3 is above the maximum limit, rRetVar is set to
33.7.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
69
Flexible NC programming
1.7 Priority of the operations
1.7
Priority of the operations
Function
Each operator is assigned a priority. When an expression is evaluated, the operators with
the highest priority are always applied first. Where operators have the same priority, the
evaluation is from left to right.
In arithmetic expressions, the execution order of all the operators can be specified by
parentheses, in order to override the normal priority rules.
Order of operators
From the highest to lowest priority
1.
NOT, B_NOT
Negation, bit-serial negation
2.
*, /, DIV, MOD
Multiplication, division
3.
+, -
Addition, subtraction
4.
B_AND
Bit AND
5.
B_XOR
Bit-serial exclusive OR
6.
B_OR
Bit-serial OR
7.
AND
AND
8.
XOR
Exclusive OR
9.
OR
OR
10.
<<
Concatenation of strings, result type STRING
11.
==, <>, >, <, >=, <=
Comparison operators
Note
The concatenation operator ":" for Frames must not be used in the same expression as other
operators. A priority level is therefore not required for this operator.
Example: IF statement
If (otto==10) and (anna==20) gotof end
Job Planning
70
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.8 Possible type conversions
1.8
Possible type conversions
Function
Type conversion on assignment
The constant numeric value, the variable, or the expression assigned to a variable must be
compatible with the variable type. If this is this case, the type is automatically converted
when the value is assigned.
Possible type conversions
to
REAL
INT
BOOL
CHAR
STRING
AXIS
FRAME
from
REAL
yes
yes*
yes1)
yes*
-
-
-
INT
yes
yes
yes1)
yes 2)
-
-
-
BOOL
yes
yes
yes
yes
yes
-
-
CHAR
yes
yes
yes 1)
yes
yes
-
-
STRING
-
-
yes 4)
yes 3)
yes
-
-
AXIS
-
-
-
-
-
yes
-
FRAME
-
-
-
-
-
-
yes
Explanation
*
At type conversion from REAL to INT, fractional values that are >=0.5 are rounded
up, others are rounded down (cf. ROUND function).
1)
Value <> 0 is equivalent to TRUE; value == 0 is equivalent to FALSE
2)
If the value is in the permissible range
3)
If only 1 character
4)
String length 0 = >FALSE, otherwise TRUE
Note
If conversion produces a value greater than the target range, an error message is output.
If mixed types occur in an expression, type conversion is automatic. Type conversions are
also possible in synchronous actions, see Chapter "Motion-synchronous actions, implicit type
conversion".
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
71
Flexible NC programming
1.9 String operations
1.9
String operations
Sting operations
In addition to the classic operations "assign" and "comparison" the following string
operations are possible:
● Type conversion to STRING (AXSTRING)
● Type conversion from STRING (NUMBER, ISNUMBER, AXNAME)
● Concatenation of strings (<<)
● Conversion to lowercase/uppercase letters (TOLOWER, TOUPPER)
● Define string length (STRLEN)
● Search for character/string in a string (INDEX, RINDEX, MINDEX, MATCH)
● Select a partial string (SUBSTR)
● Select an individual character (STRINGVAR, STRINGFELD)
Special significance of the 0 character
Internally, the 0 character is interpreted as the end identifier of a string. If a character is
replaced with the 0 character, the string is truncated.
Example:
Program code
Comments
DEF STRING[20] STRG="axis . stationary"
STRG[6]="X"
MSG(STRG)
; Supplies the message "axis X
stationary".
STRG[6]=0
MSG(STRG)
; Supplies the message "axis".
Job Planning
72
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.9 String operations
1.9.1
Type conversion to STRING (AXSTRING)
Function
Using the function "type conversion to STRING" variables of different types can be used as a
component of a message (MSG).
When using the << operator this is realized implicitly for data types INT, REAL, CHAR and
BOOL (see "Concatenation of strings (<<) (Page 75)").
An INT value is converted to normal readable format. REAL values convert with up to 10
decimal places.
Type AXIS variables can be converted to STRING using the AXSTRING command.
Syntax
<STRING_ERG> = << <any_type>
<STRING_ERG> = AXSTRING(<axis identifier>)
Significance
<STRING_ERG>:
Variable for the result of the type conversion
Type:
STRING
<any_type>:
Variable types INT, REAL, CHAR, STRING and BOOL
AXSTRING:
The AXSTRING command supplies the specified axis identifier
as string.
<axis identifier>:
Variable for axis identifier
Type:
AXIS
Note
FRAME variables cannot be converted.
Examples
Example 1:
MSG("Position:"<<$AA_IM[X])
Example 2: AXSTRING
Program code
Comments
DEF STRING[32] STRING_ERG
STRING_ERG=AXSTRING(X)
; STRING_ERG == "X"
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
73
Flexible NC programming
1.9 String operations
1.9.2
Type conversion from STRING (NUMBER, ISNUMBER, AXNAME)
Function
A conversion is made from STRING to REAL using the NUMBER command. The ability to be
converted can be checked using the ISNUMBER command.
A string is converted into the axis data type using the AXNAME command.
Syntax
<REAL_ERG>=NUMBER("<string>")
<BOOL_ERG>=ISNUMBER("<string>")
<AXIS_ERG>=AXNAME("<string>")
Significance
NUMBER:
The NUMBER command returns the number represented by the <string>
as REAL value.
<string>:
Type STRING variable to be converted
<REAL_ERG>:
Variable for the result of the type conversion with NUMBER
Type: REAL
ISNUMBER:
The ISNUMBER command can be used to check whether the <string> can
be converted into a valid number.
:
Variable for the result of the interrogation with ISNUMBER
<BOOL_ERG>
Type: BOOL
Value: TRUE
ISNUMBER supplies the value TRUE, if the
<string> represents a valid REAL number in
compliance with the language rules.
FALSE
If ISNUMBER supplies the value FALSE, when
calling NUMBER with the same <string>, an alarm
is initiated.
AXNAME:
The AXNAME command converts the specified <string> into an axis
identifier.
Note:
If the <string> cannot be assigned a configured axis identifier, an alarm
is initiated.
<AXIS_ERG>:
Variable for the result of the type conversion with AXNAME
Type: AXIS
Job Planning
74
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.9 String operations
Example
Program code
Comments
DEF BOOL BOOL_ERG
DEF REAL REAL_ERG
DEF AXIS AXIS_ERG
BOOL_ERG=ISNUMBER("1234.9876Ex-7")
; BOOL_ERG == TRUE
BOOL_ERG=ISNUMBER("1234XYZ")
; BOOL_ERG == FALSE
REAL_ERG=NUMBER("1234.9876Ex-7")
; REAL_ERG == 1234.9876Ex-7
AXIS_ERG=AXNAME("X")
; AXIS_ERG == X
1.9.3
Concatenation of strings (<<)
Function
The function "concatenation strings" allows a string to be configured from individual
components.
The concatenation is realized using the operator "<<". This operator has STRING as the
target type for all combinations of basic types CHAR, BOOL, INT, REAL, and STRING. Any
conversion that may be required is carried out according to existing rules.
Syntax
<any_type> << <any_type>
Significance
<any_type>:
Variable, type CHAR, BOOL, INT, REAL or STRING
<< :
Operator to chain variables (<any_type>) to configure a character string
(type STRING).
This operator is also available alone as a so-called "unary" variant. This
can be used for explicit type converter to STRING (not for FRAME and
AXIS):
<< <any_type>
For example, such a message or a command can be configured from text lists and
parameters can be inserted (for example a block name):
MSG(STRG_TAB[LOAD_IDX]<<BAUSTEIN_NAME)
CAUTION
The intermediate results of string concatenation must not exceed the maximum string
length.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
75
Flexible NC programming
1.9 String operations
Note
The FRAME and AXIS types cannot be used together with the operator "<<".
Examples
Example 1: Concatenation of strings
Program code
Comments
DEF INT IDX=2
DEF REAL VALUE=9.654
DEF STRING[20] STRG="INDEX:2"
IF STRG=="Index:"<<IDX GOTOF NO_MSG
MSG("Index:"<<IDX<<"/value:"<<VALUE)
; Didplay:
"Index:2/value:9.654"
NO_MSG:
Example 2: Explicit type conversion with <<
Program code
Comments
DEF REAL VALUE=3.5
<<VALUE
; The specified type REAL variable is converted into a
STRING type.
Job Planning
76
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.9 String operations
1.9.4
Conversion to lower/upper case letters (TOLOWER, TOUPPER)
Function
The "conversion to lower/upper case letters" function allows all of the letters of a string to be
converted into a standard representation.
Syntax
<STRING_ERG>=TOUPPER("<string>")
<STRING_ERG>=TOLOWER("<string>")
Significance
TOUPPER:
Using the TOUPPER command, all of the letters in a character string
are converted into upper case letters.
TOLOWER:
Using the TOLOWER command, all of the letters in a character string
are converted into lower case letters.
<string>:
Character string that is to be converted
Type:
STRING
<STRING_ERG>:
Variable for the result of the conversion
Type:
STRING
Example
Because user inputs can be initiated on the operator interface, they can be given standard
capitalization (upper or lower case):
Program code
DEF STRING [29] STRG
IF "LEARN.CNC"==TOUPPER(STRG) GOTOF LOAD_LEARN
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
77
Flexible NC programming
1.9 String operations
1.9.5
Determine length of string (STRLEN)
Function
The STRLEN command can be used to determine the length of a character string.
Syntax
<INT_ERG>=STRLEN("<STRING>")
Significance
STRLEN:
The STRLEN command determines the length of the specified character
string.
The number of characters that are not the 0 character, counting from the
beginning of the string is returned.
<string>:
Character string whose length is to be determined
Type: STRING
<INT_ERG>:
Variable for the result of the determination
Type: INT
Example
In conjunction with the single character access, this function allows the end of a character
string to be determined:
Program code
IF (STRLEN(BAUSTEIN_NAME)>10) GOTOF ERROR
1.9.6
Search for character/string in the string (INDEX, RINDEX, MINDEX, MATCH)
Function
This functionality searches for single characters or a string within a string. The function
results specify where the character/string is positioned in the string that has been searched.
Syntax
INT_ERG=INDEX(STRING,CHAR) ; Result type: INT
INT_ERG=RINDEX(STRING,CHAR) ; Result type: INT
INT_ERG=MINDEX(STRING,STRING) ; Result type: INT
INT_ERG=MATCH(STRING,STRING) ; Result type: INT
Job Planning
78
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.9 String operations
Semantics
Search functions: It supplies the position in the string (fist parameter) where the search has
been successful. If the character/string cannot be found, then the value -1 is returned. The
first character has position 0.
Significance
INDEX:
Searches for the character specified as second parameter (from the
beginning) in the first parameter.
RINDEX:
Searches for the character specified as second parameter (from the end) in
the first parameter.
MINDEX:
Corresponds to the INDEX function, except for the case that a list of
characters is transferred (as string) in which the index of the first found
character is returned.
MATCH:
Searches for a string in a string.
This allows strings to be broken up according to certain criteria, for example, at positions
with blanks or path separators ("/").
Example
Breaking up an input into path and block names
Program code
Comments
DEF INT PFADIDX, PROGIDX
DEF STRING[26] INPUT
DEF INT LISTIDX
INPUT = "/_N_MPF_DIR/_N_EXECUTE_MPF"
LISTIDX = MINDEX (INPUT, "M,N,O,P") + 1
; The value returned in LISTIDX is 3;
because "N" is the fist character in
the parameter INPUT from the
selection list starting from the
beginning.
PFADIDX = INDEX (INPUT, "/") +1
; Therefore the following applies:
PFADIDX = 1
PROGIDX = RINDEX (INPUT, "/") +1
; Therefore the following applies:
PROGIDX = 12
The SUBSTR function introduced in the
next section can be used to break-up
variable INPUT in the components
"path" and "module":
VARIABLE = SUBSTR (INPUT, PFADIDX, PROGIDX-PFADIDX-1)
; Then returns "_N_MPF_DIR"
VARIABLE = SUBSTR (INPUT, PROGIDX)
; Then returns "_N_EXECUTE_MPF"
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
79
Flexible NC programming
1.9 String operations
1.9.7
Selection of a substring (SUBSTR)
Function
This functionality extracts a substring from a string. For this purpose, the index of the first
character and the desired string length (if applicable) are specified. If no length information is
specified, then the string data refers to the remaining string.
Syntax
STRING_ERG = SUBSTR (STRING,INT) ; Result type: INT
STRING_ERG = SUBSTR(STRING,INT, INT) ; Result type: INT
Semantics
In the first case, the substring from the position specified by the second parameter is
returned up to the end of the string.
In the second case, the result string is limited to the maximum length, specified by the third
parameter.
If the initial position is after the end of the string, the empty string (" ") will be returned.
If the initial position or the length is negative, an alarm is output.
Example
Program code
Comments
DEF STRING[29] ERG
ERG = SUBSTR ("ACK:10 to 99", 10, 2)
; Therefore the following
applies: ERG == "10"
1.9.8
Selection of a single character (STRINGVAR, STRINGFELD)
Function
This functionality selects a single character from a string. This applies both to read access
and write access operations.
Syntax
CHAR_ERG = STRINGVAR [IDX] ; Result type: CHAR
CHAR_ERG = STRINGFELD [IDX_FELD, IDX_CHAR] ; Result type: CHAR
Semantics
The character at the specified position is read/written within the string. If the position
parameter is negative or greater than the string, then an alarm is output.
Job Planning
80
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.9 String operations
Example messages:
Insertion of an axis identifier into a prepared string.
Program code
Comments
DEF STRING [50] MESSAGE = "Axis n has reached position"
MESSAGE [6] = "X"
MSG (MESSAGE)
; Returns the message "axis X has
reached position"
Parameters
Single character access is possible only to user-defined variables (LUD, GUD, and PUD
data).
This type of access is also possible only for "call-by-value" type parameters in subprogram
calls.
Examples
Example 1: Single character access to system data, machine data, etc.
Program code
Comments
DEF STRING [50] STRG
DEF CHAR ACK
…
STRG = $P_MMCA
ACK = STRG [0]
; Evaluating the acknowledgement
components
Example 2: Single character access with call-by-reference parameter
Program code
Comments
DEF STRING [50] STRG
DEF CHAR CHR1
EXTERN UP_CALL (VAR CHAR1)
; Call-by-reference parameters!
…
CHR1 = STRG [5]
UP_CALL (CHR1)
; Call-by-reference
STRG [5] = CHR1
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
81
Flexible NC programming
1.10 Program jumps and branches
1.10
Program jumps and branches
1.10.1
Return jump to the start of the program (GOTOS)
Function
The GOTOS command can be used to jump back to the beginning of a main or sub program in
order to repeat the program.
Machine data can be used to set that for every return jump to the beginning of the program:
● The program runtime is set to "0".
● Workpiece counting is incremented by the value "1".
Syntax
GOTOS
Significance
GOTOS
:
Jump instruction where the destination is the beginning of the program.
The execution is controlled via the NC/PLC interface signal:
DB21, to DBX384.0 (control program branching)
Value:
Significance:
0
No return jump to the beginning of the program. Program
execution is resumed with the next part program block after GOTOS.
1
Return jump to the beginning of the program. The part program is
repeated.
Supplementary conditions
● GOTOS internally initiates a STOPRE (pre-processing stop).
● For a subprogram with data definitions (LUD variables) with the GOTOS a jump is made to
the first program block after the definition section, i.e. data definitions are not executed
again. This is the reason that the defined variables retain the value reached in the GOTOS
block and are not reset to the standard values programmed in the definition section.
● The GOTOS command is not available in synchronized actions and technology cycles.
Job Planning
82
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.10 Program jumps and branches
Example
Program code
Comments
N10 ...
; Beginning of the program
N90 GOTOS
; Jump to beginning of the program
1.10.2
Program jumps to jump markers (GOTOB, GOTOF, GOTO, GOTOC)
Function
Jump markers (labels) can be set in a program, that can be jumped to from another location
within the same program using the commands GOTOF, GOTOB, GOTO or GOTOC. Program
execution is resumed with the instruction that immediately follows the destination marker.
This means that branches can be realized within the program.
In addition to jump markers, main and sub-block numbers are possible as jump designation.
If a jump condition (IF ...) is formulated before the jump instruction, the program jump is
only executed if the jump condition is fulfilled.
Syntax
GOTOB <jump destination>
IF <jump condition> = TRUE GOTOB <jump destination>
GOTOF <jump destination>
IF <jump condition> = TRUE GOTOF <jump destination>
GOTO <jump destination>
IF <jump condition> = TRUE GOTO <jump destination>
GOTOC <jump destination>
IF <jump condition> = TRUE GOTOC <jump destination>
Significance
GOTOB:
Jump instruction with jump destination towards the beginning of the
program.
GOTOF:
Jump instruction with jump destination towards the end of the program.
GOTO:
Jump instruction with jump destination search. The search is first
made in the direction of the end of the program, then in the direction of
the beginning of the program.
GOTOC:
Same effect as for GOTO with the difference that Alarm 14080 "Jump
designation not found" is suppressed.
This means that program execution is not interrupted in the case that
the jump destination search is unsuccessful - but is continued with the
program line following the GOTOC command.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
83
Flexible NC programming
1.10 Program jumps and branches
<jump
Jump destination parameter
destination>:
Possible data include:
<jump marker>:
Jump destination is the jump marker (label) set
in the program with a user-defined name: <jump
marker>:
<block number>:
Jump destination is main block or sub-block
number (e.g.: 200, N300)
STRING type
Variable jump destination. The variable stands
variable:
for a jump marker or a block number.
IF:
Keyword to formulate the jump condition.
The jump condition permits all comparison and logical operations
(result: TRUE or FALSE). The program jump is executed if the result of
this operation is TRUE.
Note
Jump markers (labels)
Jump markers (labels) are always located at the beginning of a block. If a program number
exists, the jump marker is located immediately after the block number.
The following rules apply when naming jump markers:
• Number of characters:
- At least 2
- A maximum of 32
• Permitted characters include:
- Letters
- Numbers
- Underscore symbols
• The first two characters must be letters or underscores.
• The name of the jump marker is followed by a colon (":").
Supplementary conditions
● The jump destination can only be a block with jump marker or block number, that is
located within the program.
● A jump instruction without jump condition must be programmed in a separate block. This
restriction does not apply to jump instructions with jump conditions. In this case, several
jump instructions can be formulated in a block.
● For programs with jump instructions without jump conditions, the end of the program
M2/M30 doesn't necessarily have to be be at the end of the program.
Job Planning
84
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.10 Program jumps and branches
Examples
Example 1: Jumps to jump markers
Program code
Comments
N10 …
N20 GOTOF Label_1
; Jump towards the end of the program to the jump
marker "Label_1".
N30 …
N40 Label_0: R1=R2+R3
; Jump marker "Label_0" set.
N50 …
N60 Label_1:
; Jump marker "Label_1" set.
N70 …
N80 GOTOB Label_0
; Jump in the direction of the beginning of the
program to the jump marker "Label_0".
N90 …
Example 2: Indirect jump to the block number
Program code
Comments
N5 R10=100
N10 GOTOF "N"<<R10
; Jump to the block whose block number is located
in R10.
N90 ...
N100 ...
; Jump destination
N110 ...
Example 3: Jump to variable jump destination
Program code
Comments
DEF STRING[20] DESTINATION
DESTINATION = "Marker2"
GOTOF DESTINATION
; Jump in the direction of the end of the program
to the variable jump destination DESTINATION.
Marker 1: T="Drill1"
Marker 2: T="Drill2"
; Jump destination
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
85
Flexible NC programming
1.10 Program jumps and branches
Example 4: Jump with jump condition
Program code
Comments
N40 R1=30 R2=60 R3=10 R4=11 R5=50 R6=20
; Assignment of the initial values.
N41 LA1: G0 X=R2*COS(R1)+R5 Y=R2*SIN(R1)+R6
; Jump marker LA1 set.
N42 R1=R1+R3 R4=R4-1
N43 IF R4>0 GOTOB LA1
; If the jump condition is
fulfilled, then a jump in the
direction of the beginning of the
program to jump marker LA1.
N44 M30
; End of program
1.10.3
Program branch (CASE ... OF ... DEFAULT ...)
Function
The CASE function provides the possibility of checking the actual value (type: INT) of a
variable or an arithmetic function and, depending on the result, to jump to different positions
in the program.
Syntax
CASE(<expression>) OF <constant_1> GOTOF <jump destination_1>
<constant_2> GOTOF <jump destination_2> ... DEFAULT GOTOF <jump
destination_n>
Significance
CASE:
Jump statement
<expression>:
Variable or arithmetic function
OF:
Keyword to formulate conditional program branches.
<constant_1>:
First specify constant value for the variable or arithmetic function
Type: INT
<constant_2>
:
Second specified constant value for the variable or arithmetic
function
Type: INT
DEFAULT:
For the cases where the variable or arithmetic function does not
assume any of the specified constant values, the DEFAULT
instruction can be used to determine the branch destination.
Note:
If the DEFAULT instruction is not programmed, then in these
cases, the block following the CASE instruction is the jump
destination.
Job Planning
86
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.10 Program jumps and branches
GOTOF:
Jump instruction with jump destination towards the end of the
program.
Instead ofGOTOF all other GOTO commands can be programmed
(refer to the subject "Program jumps to jump markers").
:
A branch is made to this jump destination if the value of the
<jump destination_1>
variable or arithmetic function corresponds to the first specific
constant.
The jump destination can be specified as follows:
<jump marker>:
Jump destination is the jump marker (label)
set in the program with a user-defined name:
<jump marker>:
<block number>:
Jump destination is main block or sub-block
number (e.g.: 200, N300)
STRING type
Variable jump destination. The variable
variable:
stands for a jump marker or a block number.
<jump destination_2>: A branch is made to this jump destination if the value of the
variable or arithmetic function corresponds to the second specified
constant.
<jump destination_n>: A branch is made to this jump destination if the value of the
variable does not assume the specified constant value.
Example
Program code
N20 DEF INT VAR1 VAR2 VAR3
N30 CASE(VAR1+VAR2-VAR3) OF 7 GOTOF Label_1 9 GOTOF Label_2 DEFAULT GOTOF Label_3
N40 Label_1: G0 X1 Y1
N50 Label_2: G0 X2 Y2
N60 Label_3: G0 X3 Y3
The CASE instruction from N30 defines the following program branch possibilities:
1. If the value of the arithmetic function VAR1+VAR2-VAR3 = 7, then jump to the block with
the jump marker definition "Label_1" (→ N40).
2. If the value of the arithmetic function VAR1+VAR2-VAR3 = 9, then jump to the block with
the jump marker definition "Label_2" (→ N50).
3. If the value of the arithmetic function VAR1+VAR2-VAR3 is neither 7 nor 9, then jump to
the block with the jump marker definition "Label_3" (→ N60).
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
87
Flexible NC programming
1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)
1.11
Repeat program section (REPEAT, REPEATB, ENDLABEL, P)
Function
Program section repetition allows you to repeat existing program sections within a program
in any order.
The program lines or program sections to be repeated are identified by jump markers
(labels).
Note
Jump markers (labels)
Jump markers are always located at the beginning of a block. If a program number exists,
the jump marker is located immediately after the block number.
The following rules apply when naming jump markers:
• Number of characters:
- Minimum 2
- Maximum 32
• The following characters are permitted:
- Letters
- Numbers
- Underscores
• The first two characters must be letters or underscores.
• The name of the jump marker is followed by a colon (":").
Syntax
1. Repeat individual program line:
<jump marker>:
REPEATB <jump marker> P=<n>
2. Repeat program section between jump marker and REPEAT statement:
<jump marker>:
REPEAT <jump marker> P=<n>
Job Planning
88
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)
3. Repeat section between two jump markers:
<start jump marker>:
<end jump marker>:
REPEAT <start jump marker> <end jump marker> P=<n>
Note
It is not possible to nest the REPEAT statement with the two jump markers in parentheses. If
the <start jump marker> appears before the REPEAT statement and the <end jump marker> is
not reached before the REPEAT statement, the section between the <start jump marker> and
the REPEAT statement will be repeated.
4. Repeat section between jump marker and ENDLABEL:
<jump marker>:
ENDLABEL:
REPEAT <jump marker> P=<n>
Note
It is not possible to nest the REPEAT statement with the <jump marker> and the ENDLABEL in
parentheses. If the <jump marker> appears before the REPEAT statement and the ENDLABEL is
not reached before the REPEAT statement, the section between the <jump marker> and the
REPEAT statement will be repeated.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
89
Flexible NC programming
1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)
Significance
REPEATB:
Command for repeating a program line
REPEAT:
Command for repeating a program section
<jump marker>
:
The <jump marker> identifies:
• the program line to be repeated (in the case of REPEATB)
or
• the start of the program section to be repeated (in the case of
REPEAT)
The program line identified by the <jump marker> can appear before
or after the REPEAT/REPEATB statement. The search initially
commences toward the start of the program. If the jump marker is
not found in this direction, the search continues working toward the
end of the program.
Exception:
If the program section between the jump marker and the REPEAT
statement needs to be repeated (see 2. under Syntax), the program
line identified by the <jump marker> has to appear before the REPEAT
statement, since in this case the search runs only toward the
beginning of the program.
If the line with the <jump marker> contains further operations, these
are executed again on each repetition.
ENDLABEL:
Keyword marking the end of a program section to be repeated.
If the line with the ENDLABEL contains further operations, these are
executed again on each repetition.
ENDLABEL can be used more than once in the program.
P:
Address for specifying the number of repetitions
<n>
:
Number of program section repetitions
Type: INT
The program section to be repeated is repeated <n> times. After the
last repetition, the program is resumed at the line following the
REPEAT/REPEATB line.
Note:
In the absence of a number being specified for P=<n>, the program
section is repeated just once.
Job Planning
90
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)
Examples
Example 1: Repeat individual program line
Program code
Comments
N10 POSITION1: X10 Y20
N20 POSITION2: CYCLE(0,,9,8)
; Position cycle
N30 ...
N40 REPEATB POSITION1 P=5
; Execute BLOCK N10 five times.
N50 REPEATB POSITION2
; Execute block N20 once.
N60 ...
N70 M30
Example 2: Repeat program section between jump marker and REPEAT statement
Program code
Comments
N5 R10=15
N10 Begin: R10=R10+1
; Width
N20 Z=10-R10
N30 G1 X=R10 F200
N40 Y=R10
N50 X=-R10
N60 Y=-R10
N70 Z=10+R10
N80 REPEAT BEGIN P=4
; Execute section from N10 to N70 four times.
N90 Z10
N100 M30
Example 3: Repeat section between two jump markers
Program code
Comments
N5 R10=15
N10 Begin: R10=R10+1
; Width
N20 Z=10-R10
N30 G1 X=R10 F200
N40 Y=R10
N50 X=-R10
N60 Y=-R10
N70 END: Z=10
N80 Z10
N90 CYCLE(10,20,30)
N100 REPEAT BEGIN END P=3
; Execute section from N10 to N70 three times.
N110 Z10
N120 M30
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
91
Flexible NC programming
1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)
Example 4: Repeat section between jump marker and ENDLABEL
Program code
Comments
N10 G1 F300 Z-10
N20 BEGIN1:
N30 X10
N40 Y10
N50 BEGIN2:
N60 X20
N70 Y30
N80 ENDLABEL: Z10
N90 X0 Y0 Z0
N100 Z-10
N110 BEGIN3: X20
N120 Y30
N130 REPEAT BEGIN3 P=3
; Execute section from N110 to N120 three times.
N140 REPEAT BEGIN2 P=2
; Execute section from N50 to N80 twice.
N150 M100
N160 REPEAT BEGIN1 P=2
; Execute section from N20 to N80 twice.
N170 Z10
N180 X0 Y0
N190 M30
Example 5: Milling, machine drill position with different technologies
Program code
Comments
N10 CENTER DRILL()
; Load centering drill.
N20 POS_1:
; Drilling positions 1
N30 X1 Y1
N40 X2
N50 Y2
N60 X3 Y3
N70 ENDLABEL:
N80 POS_2:
; Drilling positions 2
N90 X10 Y5
N100 X9 Y-5
N110 X3 Y3
N120 ENDLABEL:
N130 DRILL()
; Change drill and drilling cycle.
N140 THREAD(6)
; Load tap M6 and threading cycle.
N150 REPEAT POS_1
; Repeat program section once from POS_1 up to ENDLABEL.
N160 DRILL()
; Change drill and drilling cycle.
N170 THREAD(8)
; Load tap M8 and threading cycle.
N180 REPEAT POS_2
; Repeat program section once from POS_2 up to ENDLABEL.
N190 M30
Job Planning
92
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)
Further information
● Program section repetitions can be nested. Each call uses a subprogram level.
● If M17 or RET is programmed during processing of a program section repetition, the
repetition is canceled. The program is resumed at the block following the REPEAT line.
● In the actual program display, the program section repetition is displayed as a separate
subprogram level.
● If the level is canceled during the program section repetition, the program resumes at the
point after the program section repetition call.
Example:
Program code
Comments
N5 R10=15
N10 BEGIN: R10=R10+1
; Width
N20 Z=10-R10
N30 G1 X=R10 F200
N40 Y=R10
; Interrupt level
N50 X=-R10
N60 Y=-R10
N70 END: Z10
N80 Z10
N90 CYCLE(10,20,30)
N100 REPEAT BEGIN END P=3
N120 Z10
; Resume program execution.
N130 M30
● Check structures and program section repetitions can be used in combination. There
should be no overlap between the two, however. A program section repetition should
appear within a check structure branch or a check structure should appear within a
program section repetition.
● If jumps and program section repetitions are mixed, the blocks are executed purely
sequentially. For example, if a jump is performed from a program section repetition,
processing continues until the programmed end of the program section is found.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
93
Flexible NC programming
1.11 Repeat program section (REPEAT, REPEATB, ENDLABEL, P)
Example:
Program code
N10 G1 F300 Z-10
N20 BEGIN1:
N30 X=10
N40 Y=10
N50 GOTOF BEGIN2
N60 ENDLABEL:
N70 BEGIN2:
N80 X20
N90 Y30
N100 ENDLABEL: Z10
N110 X0 Y0 Z0
N120 Z-10
N130 REPEAT BEGIN1 P=2
N140 Z10
N150 X0 Y0
N160 M30
Note
The REPEAT statement should appear after the traversing block.
Job Planning
94
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.12 Check structures
1.12
Check structures
Function
The control processes the NC blocks as standard in the programmed sequence.
This sequence can be variable by programming alternative program blocks and program
loops. These check structures are programmed using the check structure elements (key
words) IF...ELSE, LOOP, FOR, WHILE and REPEAT.
CAUTION
Check structures may only be inserted in the statement section of a program. Definitions in
the program header may not be executed conditionally or repeatedly.
It is not permissible to superimpose macros on keywords for check structures or on branch
destinations. No such check is made when the macro is defined.
Effectiveness
Check structures apply locally within programs.
Nesting depth
A nesting depth of up to 16 check structures can be set up on each subprogram level.
0DLQ SURJUDP
6XESURJUDP
352& 68%352*
/223
5(3($7
)25
:+,/(
)25
,)
:+,/(
(1',)
(1':+,/(
:+,/(
:+,/(
(1':+,/(
68%352*
(1')25
(1':+,/(
(1')25
(1':+,/(
817,/
(1'/223
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
95
Flexible NC programming
1.12 Check structures
Runtime response
In interpreter mode (active as standard), it is possible to shorten program processing times
more effectively by using program branches than can be obtained with check structures.
There is no difference between program branches and check structures in precompiled
cycles.
Supplementary conditions
● Blocks with check structure elements cannot be suppressed.
● Jumper markers (labels) are not permitted in blocks with check structure elements.
● Check structures are processed interpretively. When a loop end is detected, a search is
made for the loop beginning, allowing for the check structures found in the process. For
this reason, the block structure of a program is not checked completely in interpreter
mode.
● It is not generally advisable to use a mixture of check structures and program branches.
● A check can be made to ensure that check structures are nested correctly when cycles
are preprocessed.
1.12.1
Program loop with alternative (IF, ELSE, ENDIF)
Function
A construction with IF and ELSE is used if the program loop should contain an alternative
program block: If the IF condition is fulfilled, then the program block following the IF is
executed. If the IF condition is not fulfilled, then the alternative program block following ELSE
is executed.
Note
If an alternative is not required, then an IF loop can be programmed also without ELSE
instruction and the program block following ELSE.
Syntax
IF <condition>
ELSE
ENDIF
Job Planning
96
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.12 Check structures
Significance
IF:
Introduces the IF loop.
ELSE:
Introduces the alternative program block.
ENDIF:
Marks the end of the IF loop and results in a return jump to the
beginning of the loop.
<condition>:
Condition that determines which program block is executed.
Example
Tool change subprogram
Program code
Comments
PROC L6
; Tool change routine
N500 DEF INT TNR_AKTUELL
; Variable for active T number
N510 DEF INT TNR_VORWAHL
; Variable for pre-selected T
number
; Determine current tool
N520 STOPRE
N530 IF $P_ISTEST
; In the program test mode ...
N540 TNR_AKTUELL = $P_TOOLNO
; ... The "current" tool is read
from the program context.
N550 ELSE
; Otherwise ...
N560 TNR_AKTUELL = $TC_MPP6[9998,1]
; ... The tool of the spindle is
read-out.
N570 ENDIF
N580 GETSELT(TNR_VORWAHL)
; Read the T number of the pre-
selected tool in the spindle.
N590 IF TNR_AKTUELL <> TNR_VORWAHL
; If the pre-selected tool is
still not the current tool,
then ...
N600 G0 G40 G60 G90 SUPA X450 Y300 Z300 D0
; ... Approach tool change
position ...
N610 M206
; ... and execute a tool change.
N620 ENDIF
N630 M17
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
97
Flexible NC programming
1.12 Check structures
1.12.2
Continuous program loop (LOOP, ENDLOOP)
Function
Endless loops are used in endless programs. At the end of the loop, there is always a branch
back to the beginning.
Syntax
LOOP
ENDLOOP
Significance
LOOP:
Initiates the endless loop.
ENDLOOP:
Marks the end of the loop and results in a return jump to the beginning of the
loop.
Example
Program code
LOOP
MSG ("no tool cutting edge active")
M0
STOPRE
ENDLOOP
Job Planning
98
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.12 Check structures
1.12.3
Count loop (FOR ... TO ..., ENDFOR)
Function
The count loop is used if an operation must be repeated with a fixed number of runs.
Syntax
FOR <variable> = <initial value> TO <end value>
ENDFOR
Significance
FOR:
Initiates the count loop.
ENDFOR:
Marks the end of the loop and results in a return jump to the beginning
of the loop, as long as the end value of the count has still not been
reached.
<variable>
:
Count variable, which is incremented from the initial to the end value
and is increased by the value "1" at each run.
Type INT or REAL
Note:
The REAL type is used if R parameters are programmed for a
count loop, for example. If the count variable is of the REAL
type, its value is rounded to an integer.
<initial value>: Initial value of the count
Condition: The start value must be lower than the end value.
<full-scale
End value of the count
value>:
Examples
Example 1: INTEGER variable or R parameter as count variable
INTEGER variable as count variable:
Program code
Comments
DEF INT iVARIABLE1
R10=R12-R20*R1 R11=6
FOR iVARIABLE1 = R10 TO R11
; Count variable = INTEGER variable
R20=R21*R22+R33
ENDFOR
M30
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
99
Flexible NC programming
1.12 Check structures
R parameter as count variable:
Program code
Comments
R11=6
FOR R10=R12-R20*R1 TO R11
; Count variable = R parameter (real variable)
R20=R21*R22+R33
ENDFOR
M30
Example 2: Production of a fixed quantity of parts
Program code
Comments
DEF INT WKPCCOUNT
; Defines type INT variable with the name
"WKPCCOUNT".
FOR WKPCCOUNT = 0 TO 100
; Initiates the count loop. The "WKPCCOUNT"
variable increments from the initial value "0"
to the end value "100".
G01 …
ENDFOR
; End of count loop
M30
1.12.4
Program loop with condition at start of loop (WHILE, ENDWHILE)
Function
For a WHILE loop, the condition is at the beginning of the loop. The WHILE loop is executed
as long as the condition is fulfilled.
Syntax
WHILE <condition>
ENDWHILE
Significance
WHILE:
Initiates the program loop.
ENDWHILE:
Marks the end of the loop and results in a return jump to the beginning
of the loop.
<condition>:
The condition must be fulfilled so that the WHILE loop is executed.
Job Planning
100
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.12 Check structures
Example
Program code
Comments
WHILE $AA_IW[DRILL_AXIS] > -10
; Call the WHILE loop under the following
condition: The actual WCS setpoint for the
drilling axis must be greater than -10.
G1 G91 F250 AX[DRILL_AXIS] = -1
ENDWHILE
1.12.5
Program loop with condition at the end of the loop (REPEAT, UNTIL)
Function
For a REPEAT loop, the condition is at the end of the loop. The REPEAT loop is executed
once and repeated continuously until the condition is fulfilled.
Syntax
REPEAT
UNTIL <significance>
Significance
REPEAT:
Initiates the program loop.
UNTIL:
Marks the end of the loop and results in a return jump to the beginning
of the loop.
<condition>:
The condition that must be fulfilled so that the REPEAT loop is no
longer executed.
Example
Program code
Comments
REPEAT
; Call the REPEAT loop.
UNTIL ...
; Check whether the condition is fulfilled.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
101
Flexible NC programming
1.12 Check structures
1.12.6
Program example with nested check structures
Program code
Comments
LOOP
IF NOT $P_SEARCH
; No block search
G01 G90 X0 Z10 F1000
WHILE $AA_IM[X] <= 100
G1 G91 X10 F500
; Hole drilling template
Z-F100
Z5
ENDWHILE
Z10
ELSE
MSG("No drilling during block search")
ENDIF
$A_OUT[1] = 1
; Next drilling plate
G4 F2
ENDLOOP
M30
Job Planning
102
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.13 Program coordination (INIT, START, WAITM, WAITMC, WAITE, SETM, CLEARM)
1.13
Program coordination (INIT, START, WAITM, WAITMC, WAITE,
SETM, CLEARM)
Function
Channels
A channel can process its own program independently of other channels. It can control the
axes and spindles temporarily assigned to it via the program.
Two or more channels can be set up for the control during startup.
Program coordination
If several channels are involved in the machining of a workpiece it may be necessary to
synchronize the programs.
There are special statements (commands) for this program coordination. Each statement is
programmed separately in a block.
Note
Program coordination is also possible in its own channels.
Program coordination statements
● Specification with absolute path
The absolute path is programmed according to
the following rules:
INIT (n,"/_HUGO_DIR/_N_name_MPF" )
- Current directory/_N_name_MPF
or
"current directory" stands for the selected
workpiece directory or the standard
directory/_N_MPF_DIR.
INIT (n,"/_N_MPF_DIR/_N_name_MPF" )
-
Selects a particular program for execution in
a particular channel:
n: Number of the channel, the value depends
on the control configuration
- Complete program name
Example:
Up to SW 3:
INIT(2,"/_N_WKS_DIR/_DRESS_MPF")
At least one executable block must be
programmed between an init command
G01F0.1
(without synchronization) and an NC start.
START
With subprogram calls "_SPF" must be added
to the path.
INIT
(2,"/_N_WKS_DIR/_N_UNDER_1_SPF")
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
103
Flexible NC programming
1.13 Program coordination (INIT, START, WAITM, WAITMC, WAITE, SETM, CLEARM)
● Relative path specification
The same rules apply to relative path definition
Example:
as for program calls.
INIT(2,"DRESS")
INIT(3,"UNDER_1_SPF")
With subprogram calls "_SPF" must be added
to the program name.
Parameters
Variables, which all channels can access (NCK-specific global variables), can be used for
data exchange between programs. Otherwise separate programs must be written for each
channel.
INIT(n, path name, acknowledgement
Instruction for execution in a channel.
mode)
Selection of a particular program with an
absolute or relative path name.
START (n, n)
Starts the selected programs in the other
channels.
n,n: Enumeration of the channel numbers:
value depends on control configuration
WAITM (marker no., n, n, ...)
Sets the marker "marker no." in the same
channel. Terminate previous block with
exact stop. Waits for the markers with the
same "marker no." in the specified channels
"n" (current channel does not have to be
specified). Marker is deleted after
synchronization.
10 markers can be set per channel
simultaneously.
WAITMC (marker No., n, n,
Sets the marker "marker no." in the same
channel. An exact stop is initiated only if
the other channels have not yet reached the
marker. Waits for the marker with the same
"marker No." in the specified channels "n"
(current channel does not have to be
specified). As soon as marker "marker no."
in the specified channels is reached,
continue without terminating exact stop.
WAITE (n, n, ...)
Waits for the end of program of the
specified channels (current channel not
specified) Example: programming a delay
time after the Start command.
N30 START(2)
N31 G4 F0.01
N40 WAITE(2)
SETM (marker No., marker No.,
Sets the markers "marker no." in the same
channel without affecting current
processing. SETM() remains valid after
RESET and NC START.
Job Planning
104
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.13 Program coordination (INIT, START, WAITM, WAITMC, WAITE, SETM, CLEARM)
CLEARM (marker No., marker No.,
Deletes the markers "Marker No." in the
same channel without affecting current
processing. All markers can be deleted with
CLEARM(). CLEARM (0) deletes the marker
"0". CLEARM() remains valid after RESET and
NC START.
n
Corresponding channel number or channel
name
Note
All the above commands must be programmed in separate blocks.
The number of markers depends on the CPU used.
Channel numbers
Up to 10 channels can be specified as channel numbers (integer value) for the channels
requiring coordination.
Channel names
Channel names must be converted into numbers using variables (see "Variables and
arithmetic parameters"). Alternatively, the channel names defined using $MC_CHAN_NAME
(identifier or keyword) can also be programmed rather than channel numbers. The defined
names must comply with the NC naming conventions (i.e., the first two characters must be
either letters or an underscore).
CAUTION
Protect the number assignments so that they are not changed unintentionally.
The names must not already exist in the NC with a different meaning, e.g. as key words,
commands, axis names etc.
SETM() and CLEARM()
SETM()and CLEARM() can also be programmed independently of a synchronized action. See
Chapter "Set/delete wait markers: SETM CLEARM"
Example
Channel called "MACHINE" is to contain channel number 1,
channel called "LOADER" is to contain channel number 2:
DEF INT MACHINE=1, LOADER=2
The variables are given the same names as the channels.
The statement START is therefore:
START(MACHINE)
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
105
Flexible NC programming
1.13 Program coordination (INIT, START, WAITM, WAITMC, WAITE, SETM, CLEARM)
Example: program coordination
Channel 1:
_N_MPF100_MPF
Program code
Comments
N10 INIT(2,"MPF200")
N11 START(2)
; Processing in channel 2
N80 WAITM(1,1,2)
; Wait for WAIT marker 1 in channel 1 and
in channel 2 additional processing in channel 1
N180 WAITM(2,1,2)
; Wait for WAIT marker 1 in channel 2 and
in channel 2 additional processing in channel 1
N200 WAITE(2)
; Wait for the end of program for channel 2
N201 M30
; End of program channel 1, total end
Channel 2:
_N_MPF200_MPF
Program code
Comments
;$PATH=/_N_MPF_DIR
; Processing in channel 2
N70 WAITM(1,1,2)
; Wait for WAIT marker 2 in channel 1 and in channel 2
additional processing in channel 1
N270 WAITM(2,1,2)
; Wait for WAIT marker 2 in channel 1 and in channel 2
additional processing in channel 2
N400 M30
; End of program in channel 2
Job Planning
106
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.13 Program coordination (INIT, START, WAITM, WAITMC, WAITE, SETM, CLEARM)
1
1
:$,70
:$,70
&KDQQHO
1
03)
1
:DLW
0
&KDQQHO
1
1
1
:DLW
:DLW
0
1
1
1
67$57
:$,70
:$,70
:$,7(
6WDUW
67$57
0
0
(QG WLPH
Example: Program from workpiece
Program code
N10 INIT(2,"/_N_WKS_DIR/_N_SHAFT1_WPD/_N_CUT1_MPF")
Example: INIT command with relative path specification
Program /_N_MPF_DIR/_N_MAIN_MPF is selected in channel 1
Program code
Comments
N10 INIT(2,"MYPROG")
; Select program /_N_MPF_DIR/_N_MYPROG_MPF in channel 2
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
107
Flexible NC programming
1.13 Program coordination (INIT, START, WAITM, WAITMC, WAITE, SETM, CLEARM)
Example: Channel name and channel number with integer variable
$MC_CHAN_NAME[0]= "CHAN_X" ;name of 1st channel
$MC_CHAN_NAME[1]= "CHAN_Y" ;name of 2nd channel
Program code
Comments
START(1, 2)
; Execute start in the 1st and 2nd channels
Similar to this, programming with the channel identifiers:
Program code
Comments
START(CHAN_X, CHAN_Y)
; Execute start in the 1st and 2nd channels
; The channel_X and channel_Y identifiers represent
channel numbers 1 and 2 internally, due to the
$MC_CHAN_NAME machine data. They also execute a start
in the 1st and 2nd channel accordingly.
Programming with integer variable:
Program code
Comments
DEF INT chanNo1, chanNo2)
; Define channel number
chanNo1=CHAN_X chanNo2=CHAN_Y
START(chanNo1, chanNo2)
Job Planning
108
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.14 Interrupt routine (ASUB)
1.14
Interrupt routine (ASUB)
1.14.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.
Function
A typical example should clarify the function of an interrupt routine:
LQWHUUXSW URXWLQH
5HWUDFWLRQ IURP WKH
FRQWRXU
7RRO FKDQJH
1HZ FRUUHFWLRQ
YDOXHV
5HSRVLWLRQLQJ
0DLQ
SURJUDP
The tool breaks during machining. This triggers a signal that stops the current machining
process and simultaneously starts a subprogram - the so-called 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 contour
(Page 476)").
CAUTION
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.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
109
Flexible NC programming
1.14 Interrupt routine (ASUB)
References
Function Manual, Basic Functions; BAG, Channel, Program Operation, Reset Response
(K1), Chapter: "Asynchronous subprograms (ASUBs), interrupt routines"
1.14.2
Creating an interrupt routine
Create interrupt routine as subprogram
The interrupt routine is identified as a subprogram in the definition.
Example:
Program code
Comments
PROC LIFT_Z
; Program name "ABHEB_Z"
N10 ...
; The NC blocks then follow:
N50 M17
; At the end, the end of the program and return to the main
program.
Save modal G functions (SAVE)
The interrupt routine can be designated by defining with SAVE.
The SAVE attribute means that the active modal G functions saved before calling the interrupt
routine and are re-activated after the end of the interrupt routine (see "Subprograms with
SAVE mechanism (SAVE) (Page 157)").
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 instructions can be programmed within the interrupt routine (see "Assign and start
interrupt routine (SETINT)" (Page 111)) therefore activating additional interrupt routines.
They are triggered via the input.
References
You will find more information on how to create subprograms in Chapter "Subprograms,
Macros".
Job Planning
110
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.14 Interrupt routine (ASUB)
1.14.3
Assign and start interrupt routine (SETINT, PRIO, BLSYNC)
Function
The control has signals (inputs 1...8) that initiate that the program being executed is
interrupted and a corresponding interrupt routine can be started.
The assignment as to which input starts which program is realized in the part program using
the SETINT command.
If several SETINT instructions are in the part program and therefore several signals can be
simultaneously received, the assigned interrupt routines must be allocated priorities that
define the sequence in which the interrupt routines are executed: PRIO=<value>
If new signals are received while interrupt routines are being executed, the current interrupt
routines are interrupted by routines with higher priority.
Syntax
SETINT(<n>) PRIO=<value> <NAME>
SETINT(<n>) PRIO=<value> <NAME> BLSYNC
SETINT(<n>) PRIO=<value> <NAME> LIFTFAST
Significance
SETINT(<n>):
Command: Assign input <n> to an interrupt routine. The assigned interrupt
routine starts when input <n> switches.
Note:
If an input that is already assigned is allocated to a new routine, then the
old assignment is automatically cancelled.
<n>:
Parameters: Input number
Type:
INT
Range of values:
1 ... 8
PRIO= :
Command: Defining the priority
<value>
:
Priority value
Type:
INT
Range of values:
1 ... 128
Priority 1 corresponds to the highest priority.
<NAME>:
Name of the subprogram (interrupt routine) that should be executed.
BLSYNC:
If the SETINT operation is programmed together with BLSYNC, when the
interrupt signal is received the program block which is in progress will
continue to be processed; only once this is complete will the interrupt
routine be launched.
LIFTFAST:
If the SETINT operation is programmed together with LIFTFAST, when the
interrupt signal is received a "fast retraction of the tool from the contour"
will be performed before the start of the interrupt routine (see "Fast
retraction from the contour (SETINT LIFTFAST, ALF) (Page 115)").
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
111
Flexible NC programming
1.14 Interrupt routine (ASUB)
Examples
Example 1: Assign interrupt routines and define the priority
Program code
Comments
N20 SETINT(3) PRIO=1 ABHEB_Z
; If input 3 switches, then interrupt routine
"ABHEB_Z" should start.
N30 SETINT(2) PRIO=2 ABHEB_X
; If input 2 switches, then interrupt routine
"ABHEB_X" should start.
The interrupt routines are executed in the sequence of the priority values if the inputs
become available simultaneously (are energized simultaneously): First "ABHEB_Z", the
"ABHEB_X".
Example 2: Newly assign an interrupt routine
Program code
Comments
N20 SETINT(3) PRIO=2 ABHEB_Z
; If input 3 switches, then interrupt routine
"ABHEB_Z" should start.
…
N120 SETINT(3) PRIO=1 ABHEB_X
; Input 3 is assigned to a new interrupt
routine: Instead of "ABHEB_Z", "ABHEB_X"
should start if input 3 switches.
Job Planning
112
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.14 Interrupt routine (ASUB)
1.14.4
Deactivating/reactivating the assignment of an interrupt routine (DISABLE,
ENABLE)
Function
A SETINT instruction can be deactivated with DISABLE and reactivated with ENABLE without
losing the input → interrupt routine assignment.
Syntax
DISABLE(<n>)
ENABLE(<n>)
Significance
DISABLE(<n>):
Command: Deactivating the interrupt routine assignment of input <n>
ENABLE(<n>):
Command: Reactivating the interrupt routine assignment of input <n>
<n>:
Parameter: Input number
Type:
INT
Range of values:
1 ... 8
Example
Program code
Comments
N20 SETINT(3) PRIO=1 ABHEB_Z
; If input 3 switches, then interrupt routine
"ABHEB_Z" should start.
N90 DISABLE(3)
; The SETINT instruction from N20 is
deactivated.
N130 ENABLE(3)
; The SETINT instruction from N20 is
reactivated.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
113
Flexible NC programming
1.14 Interrupt routine (ASUB)
1.14.5
Delete assignment of interrupt routine (CLRINT)
Function
An input → interrupt routine defined using SETINT can be deleted with CLRINT.
Syntax
CLRINT(<n>)
Significance
CLRINT(<n>):
Command: Deleting the interrupt assignment of input <n>
<n>
:
Parameter: Input number
Type:
INT
Range of values:
1 ... 8
Example
Program code
Comments
N20 SETINT(3) PRIO=2 ABHEB_Z
;
N50 CLRINT(3)
; The assignment between input "3" and
interrupt routine "ABHEB_Z" is deleted.
Job Planning
114
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.14 Interrupt routine (ASUB)
1.14.6
Fast retraction from the contour (SETINT LIFTFAST, ALF)
Function
For a SETINT instruction 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 instruction 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.
Syntax
SETINT(<n>) PRIO=1 LIFTFAST
SETINT(<n>) PRIO=1 <NAME> LIFTFAST
Significance
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
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
115
Flexible NC programming
1.14 Interrupt routine (ASUB)
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 contour
ALF=… :
Command: Programmable traverse direction (in motion block)
Regarding the possibilities of programming with ALF refer to the subject
" Traversing direction for fast retraction from the contour (Page 117)".
Supplementary conditions
Behavior for active frame with mirroring
When determining the lift 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 using 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
Comments
N10 SETINT(1) PRIO=1 W_WECHS LIFTFAST
; When input 1 is switched, the tool
is immediately retracted from the
contour with rapid lift (code No.
7 for tool radius compensation
G41). Then interrupt routine
"W_WECHS" is executed.
N20 G0 Z100 G17 T1 ALF=7 D1
N30 G0 X-5 Y-22 Z2 M3 S300
N40 Z-7
N50 G41 G1 X16 Y16 F200
N60 Y35
N70 X53 Y65
N90 X71.5 Y16
N100 X16
N110 G40 G0 Z100 M30
Job Planning
116
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.14 Interrupt routine (ASUB)
Subprogram:
Subprogram
Comments
PROC W_CHANGE SAVE
; Subprogram where the actual operating
state is saved
N10 G0 Z100 M5
; Tool changing position, spindle stop
N20 T11 M6 D1 G41
; Change tool
N30 REPOSL RMB M3
; Reposition at the contour and return
jump into the main program (this is
programmed in a block)
1.14.7
Traversing direction for fast retraction from the contour
Retraction movement
The following G code defines 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/machining plane that is
selected using G codes G17, G18 or G19. The direction of the retraction movement is not
dependent on the path tangent. This allows a fast lift 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 lift direction for several axes and for several axes in a linear
system.
References:
Programming Manual, Fundamentals, Chapter: "Fast retraction for thread cutting"
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.
Example:
Program code
N10 SETINT(2) PRIO=1 LIFT_Z LIFTFAST
ALF=7
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
117
Flexible NC programming
1.14 Interrupt routine (ASUB)
With G41 activated (machining direction to the left of the contour) the tool vertically moves
away from the contour.
*
$/)
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 liftoff 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.
7DQJHQW
7DQJHQW
,QWHUYHQWLRQ
SRLQW
7DQJHQW
7DQJHQW
,QWHUYHQWLRQ
SRLQW
Job Planning
118
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.14 Interrupt routine (ASUB)
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.
9LHZ LQ WKH
WUDYHUVLQJ GLUHFWLRQ
r
r
3ODQ YLHZ
*
*
7UDYHUVLQJ GLUHFWLRQ
The retraction in the tool direction is defined for ALF=1.
The "fast retraction" function is deactivated with ALF=0.
CAUTION
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.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
119
Flexible NC programming
1.14 Interrupt routine (ASUB)
Code numbers with traversing directions for LFWP
For LFWP, the direction in the working/machining plane has the 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
1.14.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 RMI.
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.
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.
Job Planning
120
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.15 Axis replacement, spindle replacement (RELEASE, GET, GETD)
1.15
Axis replacement, spindle replacement (RELEASE, GET, GETD)
Function
One or more axes or spindles can only ever be interpolated in one channel. If an axis has to
alternate between two different channels (e.g., pallet changer) it must first be enabled in the
current channel and then transferred to the other channel. Axis replacement is effective
between channels.
Axis replacement extensions
An axis/spindle can be replaced either with a preprocessing stop and synchronization
between preprocessing and main run, or without a preprocessing stop. Axis replacement is
also possible via:
● Axis container rotation AXCTSWE or AXCTWED using implicit GET/GETD
● Frame with rotation if this process links the axis with other axes.
● Synchronized actions, see Motion-synchronous actions, "Axis replacement RELEASE, GET".
Machine manufacturer
Please refer to the machine manufacturer's instructions. For the purpose of axis
replacement, one axis must be defined uniquely in all channels in the configurable machine
data and the axis replacement characteristics can also be set using machine data.
Syntax
RELEASE (axis name, axis name, ...) or RELEASE (S1)
GET (axis name, axis name, ...) or GET (S2)
GETD(axis name, axis name, ...) or GETD(S3)
With GETD (GET Directly), an axis is fetched directly from another channel. That means that
no suitable RELEASE must be programmed for this GETD in another channel. It also means
that other channel communication has to be established (e.g. wait markers).
Significance
RELEASE (axis name, axis name, etc.):
Release the axis (axes)
GET (axis name, axis name, etc.):
Accept the axis (axes)
GETD (axis name, axis name, etc.):
Directly accept the axis (axes)
Axis name:
Axis assignment in system: AX1, AX2, ... or
specify machine axis name
RELEASE(S1) :
Release spindles S1, S2, ...
GET(S2) :
Accept spindles S1, S2, ...
GETD(S3) :
Direct acceptance of spindles S1, S2, ...
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
121
Flexible NC programming
1.15 Axis replacement, spindle replacement (RELEASE, GET, GETD)
GET request without preprocessing stop
If, following a GET request without preprocessing stop, the axis is enabled again with
RELEASE(axis) or WAITP(axis), a subsequent GET will induce a GET with preprocessing stop.
CAUTION
An axis or spindle accepted with GET remains assigned to this channel even after a key or
program RESET.
When a program is restarted the replaced axes or spindles must be reassigned in the
program if the axis is required in its original channel.
It is assigned to the channel defined in the machine data on POWER ON.
Examples
Example 1: Axis exchange between two channels
Of the 6 axes, the following are used for machining in channel 1: 1st, 2nd, 3rd and 4th axis.
The 5th and 6th axes in channel 2 are used for the workpiece change.
Axis 2 should be exchanged between two channels and after POWER ON can be assigned
to channel 1.
Program "MAIN" in channel 1:
Program code
Comments
INIT (2,"TRANSFER2")
; Select program TRANSFER2 in channel 2.
N… START (2)
; Start the program in Channel 2.
N… GET (AX2)
; Accept axis AX2.
N… RELEASE (AX2)
; Release axis AX2.
N… WAITM (1,1,2)
; Wait for WAIT marker in channel 1 and 2 for
synchronizing in both channels.
; Rest of program after axis replacement.
N… M30
Program "TRANSFER2" in channel 2:
Programming
Comments
N… RELEASE (AX2)
N160 WAITM(1,1,2)
; Wait for WAIT marker in channel 1 and 2 for
synchronizing in both channels.
N150 GET(AX2)
; Accept axis AX2.
; Rest of program after axis replacement.
N… M30
Job Planning
122
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.15 Axis replacement, spindle replacement (RELEASE, GET, GETD)
Example 2: Axis exchange without synchronization
If the axis does not have to be synchronized no preprocessing stop is generated by GET.
Programming
Comments
N01 G0 X0
N02 RELEASE(AX5)
N03 G64 X10
N04 X20
N05 GET(AX5)
; If synchronization is not required, then this is
not a block that can be executed.
N06 G01 F5000
; Block that cannot be executed.
N07 X20
; Block that cannot be executed, as X position as in
N04.
N08 X30
; First block that can be executed after N05.
Example 3: Activating an axis exchange without a preprocessing stop
Prerequisite: Axis replacement without a preprocessing stop must be configured via machine
data.
Programming
Comments
N010 M4 S100
N011 G4 F2
N020 M5
N021 SPOS=0
N022 POS[B]=1
N023 WAITP(B)
; Axis b becomes the neutral axis.
N030 X1 F10
N031 X100 F500
N032 X200
N040 M3 S500
; Axis does not trigger preprocessing stop/REORG.
N041 G4 F2
N050 M5
N099 M30
If the spindle or axis B is traversed, e.g., to 180 degrees and then back to 1 degree
immediately after block N023 as the PLC axis, this axis will revert to its neutral status and
will not trigger a preprocessing stop in block N40.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
123
Flexible NC programming
1.15 Axis replacement, spindle replacement (RELEASE, GET, GETD)
Requirements
Preconditions for axis replacement
● The axis must be defined in all channels that use the axis in the machine data.
● It is necessary to define to which channel the axis will be assigned after POWER ON in
the axis-specific machine data.
Description
Release axis: RELEASE
When enabling the axis please note:
1. The axis must not be involved in a transformation.
2. All the axes involved in an axis link (tangential control) must be enabled.
3. A concurrent positioning axis cannot be replaced in this situation.
4. All the following axes of a gantry master axis are transferred with the master.
5. With coupled axes (coupled motion, master value coupling, electronic gear) only the
leading axis of the group can be enabled.
Accept axis: GET
The actual axis replacement is performed with this command. The channel for which the
command is programmed takes full responsibility for the axis.
Effects of GET:
Axis replacement with synchronization:
An axis always has to be synchronized if it has been assigned to another channel or the PLC
in the meantime and has not been resynchronized with "WAITP", G74 or delete distance-to-
go before GET.
● A preprocess stop follows (as for STOPRE).
● Execution is interrupted until the replacement has been completed.
Automatic "GET"
If an axis is in principle available in a channel but is not currently defined as a "channel axis",
GET is executed automatically. If the axis/axes is/are already synchronized no preprocess
stop is generated.
Job Planning
124
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.15 Axis replacement, spindle replacement (RELEASE, GET, GETD)
Varying the axis replacement behavior
The transfer point of axes can be set as follows using machine data:
● Automatic axis replacement between two channels then also takes place when the axis
has been brought to a neutral state by WAITP (response as before)
● When requesting an axis container rotation, all axes of the axis container which can be
assigned to the executing channel are brought into the channel using implicit GET or
GETD. A subsequent axle replacement is only permitted again once the axis container
rotation has been completed.
● When an intermediate block is inserted in the main run, a check will be made to
determine whether or not reorganization is required. Reorganization is only necessary if
the axis states of this block do not match the current axis states.
● Instead of a GET block with preprocessing stop and synchronization between
preprocessing and main run, axes can be replaced without a preprocessing stop. In this
case, an intermediate block is simply generated with the GET request. In the main run,
when this block is executed, the system checks whether the states of the axes in the
block match the current axis states.
For more information about how axis or spindle replacement works, see
/FB2/ Function Manual, Extended Functions, Mode Groups, Channels, Axis Replacement (K5).
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
125
Flexible NC programming
1.16 Transfer axis to another channel (AXTOCHAN)
1.16
Transfer axis to another channel (AXTOCHAN)
Function
The AXTOCHAN language command can be used to request an axis in order to move it to a
different channel. The axis can be moved to the corresponding channel both from the NC
part program and from a synchronized action.
Syntax
AXTOCHAN(axis name,channel number[,axis name,channel number[,...]])
Significance
AXTOCHAN:
Request axis for a specific channel
Axis name:
Axis assignment in the system: X, Y, … or entry of machine axis
names concerned. The executing channel does not have to be the
same channel or even the channel currently in possession of the
interpolation right for the axis.
Channel number:
Name of the channel to which the axis is to be assigned
Note
Competing positioning axis and PLC controlled axis exclusively
A PLC axis cannot replace the channel as a competing positioning axis. An axis controlled
exclusively by the PLC cannot be assigned to the NC program.
References:
Function Manual, Extended Functions; Positioning Axes (P2)
Example
AXTOCHAN in the NC program
Axes X and Y have been declared in the first and second channels. Currently, channel 1 has
the interpolation right and the following program is started in that channel.
Program code
Comments
N110 AXTOCHAN(Y,2)
; Move Y axis to second channel.
N111 M0
N120 AXTOCHAN(Y,1)
; Retrieve Y axis (neutral).
N121 M0
N130 AXTOCHAN(Y,2,X,2)
; Move Y axis and X axis to second channel (axes are
neutral).
N131 M0
N140 AXTOCHAN(Y,2)
; Move Y axis to second channel (NC program).
N141 M0
Job Planning
126
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.16 Transfer axis to another channel (AXTOCHAN)
Further information
AXTOCHAN in the NC program
A GET is only executed in the event of the axis being requested for the NC program in the
same channel (this means that the system waits for the state to actually change). If the axis
is requested for another channel or is to become the neutral axis in the same channel, the
request is sent accordingly.
AXTOCHAN from a synchronized action
In the event of an axis being requested for the same channel, AXTOCHAN from a synchronized
action is mapped to a GET from a synchronized action. In this case, the axis becomes the
neutral axis on the first request for the same channel. On the second request, the axis is
assigned to the NC program in the same way as the GET request in the NC program. For
more information about GET requests from a synchronized action, see "Motion-synchronous
actions".
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
127
Flexible NC programming
1.17 Activate machine data (NEWCONF)
1.17
Activate machine data (NEWCONF)
Function
The NEWCONF command is used to set all machine data of the "NEW_CONFIG" effectiveness
level active. The function can also be activated in the HMI user interface by pressing the "MD
data effective" softkey.
When the "NEWCONF" function is executed there is an implicit preprocessing stop; in other
words, path movement is interrupted.
Syntax
NEWCONF
Significance
NEWCONF:
Command for setting all machine data of the "NEW_CONFIG" effectiveness
level active
Cross-channel execution of NEWCONF from the part program
If changes are made to axial machine data from the part program and then activated with
NEWCONF, NEWCONF will only activate the machine data containing changes affecting the part
program channel.
Note
In order to ensure that all changes are applied, the NEWCONF command must be executed in
every channel in which the axes or functions affected by the changes to the machine data
are being calculated.
No axial machine data are effective for NEWCONF.
An axial RESET must be performed for axes controlled by the PLC.
Example
Milling: Machine drill position with different technologies
Program code
Comments
N10 $MA_CONTOUR_TOL[AX]=1.0
; Change machine data.
N20 NEWCONF
; Activate machine data.
Job Planning
128
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
Flexible NC programming
1.18 Write file (WRITE)
1.18
Write file (WRITE)
Function
The WRITE command can be used to write blocks/data from the part program to the end of a
specific file (log file) or to the end of the part program currently being executed. The
blocks/data are/is inserted at the end of the file, i.e. after M30.
Note
If no such file exists in the NC, one will be created and can be written to using the WRITE
command.
The storage location is the static NC memory. In the case of SINUMERIK 840D sl this is the
CompactFlash Card. Unlike SINUMERIK 840D this increases the runtime of the WRITE
command by approx. 75 ms.
If a file with the same name exists on the hard disk, it is overwritten after the file is closed (in
the NC). Remedy: Change the name in the NC in the "Services" operating area using the
"Properties" softkey.
Condition
The currently set protection level must be equal to or greater than the WRITE right of the file.
If this is not the case, access is denied with an error message (return value of error variable
= 13).
Syntax
DEF INT <error>
WRITE(<error>,"<file name>","<block/data>")
Significance
WRITE:
Command for appending a block or data to the end of the specified file.
Job Planning
Programming Manual, 03/2010, 6FC5398-2BP20-1BA0
129
|