364 ISO Programming
4.32 Conditional Block Run
4.32 Conditional Block Run
Program branching IF..THEN..ELSE..ENDIF
A conditional branch consists of the elements:
IF, followed by a condition. The condition includes a variable or
mathematical expression on either side of the relational operator.
THEN. If the condition is fulfilled, the THEN branch is executed.
ELSE. If the condition is not fulfilled, the ELSE branch is executed.
ENDIF concludes the conditional program branch.
Interrogate bitset: You can also use the BITSET function as
condition. The function returns 1 if the numerical value contains the
requested bit. The function returns 0 if the numerical value does not
contain the requested bit.
Syntax: BITSET (x,y)
x: Bit number (0 to 15)
y: Numerical value (0 to 65535)
The relationship between bit number and numerical value is shown in
the table at right. You can also use variables for x, y.
Programming:
U Select “Extras > DINplus word...”. The MANUALplus opens the
“Insert DIN PLUS word” selection list.
U Select IF.
U Enter the condition.
U Insert NC blocks of the THEN branch.
U If required: Insert NC blocks of the ELSE branch.
Relational operators
< Less than
<= Less than or equal to
<> Not equal to
> Greater than
>= Greater than or equal to
== Equal to
Combining conditions:
AND Logical AND operation
OR Logical OR operation
Bit
which means
numerical
value
Bit
which means
numerical
value
01 8256
12 9512
2 4 10 1024
3 8 11 2048
4 16 12 4096
5 32 13 8192
6 64 14 16384
7 128 15 32768
Example: IF..THEN..ELSE..ENDIF
N.. IF (#l1==1) AND (#g250>50)
N.. THEN
N.. G0 X100 Z100
N.. ELSE
N.. G0 X0 Z0
N.. ENDIF
. . .
N.. IF 1==BITSET(0,#l1)
N.. THEN
N.. PRINT(“bit 0: OK”)
. . .
NC blocks with IF, THEN, ELSE, ENDIF can have no
further commands.
You can combine up to two conditions.