For loop, L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 59

Advertising
background image

L-force | PLC Designer

What is What in PLC Designer



DMS 3.2 EN 02/2011 TD29

57

A CASE instruction is processed according to the following model:

• If the variable in <Var1> has the value <Value i>, then the instruction <Instruction

i> is executed.

• If <Var 1> has none of the indicated values, then the <ELSE Instruction> is

executed.

• If the same instruction is to be executed for several values of the variables, then

one can write these values one after the other separated by commas, and thus

condition the common execution.

• If the same instruction is to be executed for a value range of a variable, one can

write the initial value and the end value separated by two dots one after the other.
So you can condition the common condition.

Example:

CASE INT1 OF
1, 5: BOOL1 := TRUE;
BOOL3 := FALSE;
2: BOOL2 := FALSE;
BOOL3 := TRUE;
10..20: BOOL1 := TRUE;
BOOL3:= TRUE;
ELSE
BOOL1 := NOT BOOL1;
BOOL2 := BOOL1 OR BOOL2;
END_CASE;

FOR loop

With the FOR loop one can program repeated processes.

Syntax:

INT_Var :INT;

FOR

<INT_Var> := <INIT_VALUE> TO <END_VALUE> {BY <Step

size>} DO

<Instructions>

END_FOR;

The part in braces {} is optional.

The <Instructions> are executed as long as the counter <INT_Var> is not greater than
the <END_VALUE>. This is checked before executing the <Instructions> so that the
<instructions> are never executed if <INIT_VALUE> is greater than <END_VALUE>.

Advertising