8 case instruction, Case instruction, Drive plc developer studio – Lenze DDS v2.3 User Manual

Page 45

Advertising
background image

Drive PLC Developer Studio

Programming languages

4-7

l

DDS EN 2.3

Example:

IF

temp < 17 THEN

heating_on:=TRUE;
ELSE
heating_on:=FALSE;

END_IF

;

In this example the heating is switched on only if the temperature falls below 17 degrees Centigrade,
otherwise the heating will remain off.

4.3.8

CASE instruction

Use the CASE instruction to aggregate several conditional instructions with the same conditional
variable.

Syntax:

CASE

<Var1> OF

<Value 1>:<instruction 1>
<Value 2>:<instruction 2>
...
<Value n>:<instruction n>
ELSE

<ELSE instruction>
END_CASE

;

A CASE instruction is processed as described below:

If the variable in <Var1> is set to <Value i>, the instruction <instruction i> will be
executed.

If <Var 1> does not equal one of the specified values, the <ELSE instruction> will be
executed.

If the same instruction is to be executed for several variable values, these values can be
comma-separated to indicate that they are linked to the same instruction.

If the same instruction is to be executed for a value aggregate of the variable, the start and
end values can be separated by two successive periods to indicate that they are linked to the
same instruction.

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

;

Show/Hide Bookmarks

Advertising