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

Page 1035

Advertising
background image

L-force | PLC Designer

Programming Reference

DMS 4.1 EN 03/2011 TD29

1033

Syntax:
TYPE <Identifier>:(<Enum_0> ,<Enum_1>, ...,<Enum_n>) |<base data type>;
END_TYPE
A variable of type <Identifier> can take on one of the enumeration values <Enum_..>
and will be initialized with the first one. These values are compatible with whole
numbers which means that you can perform operations with them just as you would
do with integer variables. You can assign a number x to the variable. If the
enumeration values are not initialized with specific values within the declaration,
counting will begin with 0. When initializing, make sure that the initial values are
increasing within the row of components. The validity of the number will be checked
at the time it is run.
Example:

TYPE TRAFFIC_SIGNAL: (red, yellow, green:=10); (* The initial value for each of the
colors is red 0, yellow 1, green 10 *)
END_TYPE
TRAFFIC_SIGNAL1 : TRAFFIC_SIGNAL;
TRAFFIC_SIGNAL1:=0; (* The value of the traffic signal is red*)
FOR i:= red TO green DO
i := i + 1;
END_FOR;


Extensions to the IEC 61131-3 standard:

1.

The type name of enumerations can be used (as a scope operator) to disambiguate
the access to an enumeration constant.

So it is possible to use the same constant in different enumerations.

Example:
Definition of two enumerations:

TYPE COLORS_1: (red, blue);
END_TYPE
TYPE COLORS_2: (green, blue, yellow);
END_TYPE

Use of enumeration value blue in a POU:
Declaration:

colorvar1 : COLORS_1;
colorvar2 : COLORS_2;

Advertising