beautypg.com

2 repeat ... until structure, 3 while ... endw structure – HEIDENHAIN TNC 306 Technical Manual User Manual

Page 400

background image


7-110

TNC 416/TNC 406/TNC 306

Commands

3/2000

3.17.2 REPEAT ... UNTIL Structure

The REPEAT ... UNTIL structure repeats a program sequence until a condition is fulfilled.

Under no circumstances may this structure wait for an external event in the cyclical PLC

program to happen!

The following commands are available:

REPEAT

(Repeat)

Repeat program sequence from here

UNTILT

(Until True)

Repeat sequence until Logic Accumulator=1

UNTILF

(Until False)

Repeat sequence until Logic Accumulator=0

A REPEAT ... UNTIL loop is always run at least once!

Example:

=

M100

;end of previous chain

REPEAT

;repeat following code

.....

;code to be executed

LX

;load Index Register

>=

K100

;check Index Register

UNTILT

;repeat until X>=100

3.17.3 WHILE ... ENDW Structure

The WHILE ... ENDW structure repeats a program sequence if a condition is fulfilled.
Under no circumstances must this structure wait for an external event in the cyclical PLC program to
happen!

The following commands are available:

WHILET

(While True)

Execute sequence if Logic Accumulator=1

WHILEF

(While False)

Execute sequence if Logic Accumulator=0

ENDW

(End While)

End of program sequence, go back to beginning

A WHILE ... ENDW loop is only run when the WHILE condition is fulfilled at the beginning. The
execution condition must be repeated before the ENDW instruction. The condition can also be
repeated differently than before the WHILE instruction!

Example:

.....
L

M100

;create condition for 1st WHILE scan

WHILET

;execute following code if Logic Accumulator = 1

.....

;code to be executed

L

M101

;create condition for repeat processing

A

M102

;next condition

ENDW

;return to WHILE scan

Two internal jump labels are generated for the WHILE ... ENDW structure.

This manual is related to the following products: