IEC 61131-3 Enumerated Type

Help Contents

Introduction

Enumerated types allow you to associate a set of names with a unique set of values. For example:

TYPE
    PumpState : ( Stopped, Running, Invalid, Failed );
END_TYPE

Within your code you can declare variables of type PumpState, assign enumerated values, and use in tests. For example:

Var
    P1, P2 : PumpState := Stopped;
End_Var

    If P1 = Stopped AND P2 = Stopped Then
        ....
    End_If

Enumerated Type Prefix

There may be situations where you want to declare the same value in different enumerated types. In this example the enumerated value Failed is used in both PumpState, and ValveState:

TYPE
    PumpState : ( Stopped, Running, Invalid, Failed );
    ValveState : ( Open, Closed, Failed );
END_TYPE

When you wish to use enumerated value Failed, you should qualify the value with the enumerated type prefix to remove any ambiguity. For example:

Var
    P1, P2 : PumpState := PumpState#Stopped;
End_Var

    If P1 = PumpState#Failed AND P2 = PumpState#Failed Then
        ....
    End_If

Standards Compliance

IEC 61131-3 Second Edition: Table 12.1.

IEC 61131-3 Third Edition: Table 11.1.

Further Information

Derived Data Types

To learn about other derived data types, for example STRUCT, or ARRAY.

Common Elements

To learn about other common language elements.

Glossary

For the meaning of terms used in Fernhill SCADA.