beautypg.com

32 conditional block run, Program branching if..then..else..endif – HEIDENHAIN SW 548328-05 DIN Programming User Manual

Page 400

background image

400

DIN programming

4.32 Conditional bloc

k r

u

n

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:

Select "Extras > DINplus word...". The Control opens the "Insert DIN

PLUS word" selection list.

Select IF.

Enter the condition.

Insert NC blocks of the THEN branch.

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

0

1

8

256

1

2

9

512

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.