Case instruction, L-force | plc designer – Lenze PLC Designer PLC Designer (R3-1) User Manual

Page 764

Advertising
background image

L-force | PLC Designer

General Editors

762

DMS 4.1 EN 03/2011 TD29

Example:

IF temp<17
THEN heating_on := TRUE;
ELSE heating_on := FALSE;
END_IF;

Here the heating is turned on when the temperature sinks below 17 degrees.
Otherwise it remains off.

CASE instruction
With the CASE instructions one can combine several conditioned instructions with the
same condition variable in one construct.
Syntax:
CASE
<Var1> OF
<Value1>: <Instruction 1>
<Value2>: <Instruction 2>
<Value3, Value4, Value5>: <Instruction 3>
<Value6 .. Value10>: <Instruction 4>
...
<Value n>: <Instruction n>
ELSE <ELSE instruction>
END_CASE;

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> will be executed.

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

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. So you can
condition the common condition.

Advertising