beautypg.com

While..endwhile program repeat – HEIDENHAIN SW 548328-05 DIN Programming User Manual

Page 402

background image

402

DIN programming

4.32 Conditional bloc

k r

u

n

WHILE..ENDWHILE program repeat

A program repeat consists of the elements:

WHILE, followed by a condition. The condition includes a variable or

mathematical expression on either side of the relational operator.

ENDWHILE concludes the conditional program repeat.

NC blocks programmed between WHILE and ENDWHILE are

executed repeatedly for as long as the condition is fulfilled. If the

condition is not fulfilled, the Control continues execution of the

program with the block programmed after ENDWHILE.

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 WHILE.

Enter the condition.

Insert NC blocks between WHILE and ENDWHILE.

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: WHILE..ENDWHILE

. . .

N.. WHILE (#l4<10) AND (#l5>=0)

N.. G0

Xi10

. . .

N.. ENDWHILE

. . .

You can combine up to two conditions.

If the condition you program in the WHILE command is

always true, the program remains in an endless loop.

This is one of the most frequent causes of error when

working with program repeats.