– 206 –
61131-3
IEC:2003(E)
F.9 Use of enumerated data types
The following example illustrates the use of enumerated data types in ST CASE statements and in
Instruction List. Suppose an enumerated data type has been defined by the following declaration:
TYPE SPEED: (SLOW, MEDIUM, FAST, VERY_FAST); END_TYPE
In addition, suppose an input and output of a function block type is declared by:
VAR_INPUT MOTOR_SPEED: SPEED; END_VAR
VAR_OUTPUT SPEED_OUT: SPEED; END_VAR
Then if the body of the function block type is defined in the
ST language, a CASE statement such as
the following could be used:
CASE MOTOR_SPEED OF
SLOW: (* speed it up *);
MEDIUM: (* hold the current speed *);
FAST: (* slow it down *);
ELSE (* take special care *);
END_CASE;
If the body of the function block type is defined in the IL language, the following
instructions could be
used:
LD SPEED#SLOW (* enumerated value qualified by data type *)
ST SPEED_OUT
Do'stlaringiz bilan baham: