Glossary · PLC and control programming
Enumeration
Also known as: Enumerated data type, ENUM
German: Aufzählungstyp
In IEC 61131-3 programming, an enumeration is a derived data type whose variables can take only one of a fixed, named set of values, such as the states of a machine.
- PLC programming
- Standards
In one sentence
An enumeration is a data type with a fixed set of named values, such as IDLE, RUNNING and FAULT, used for states and modes.
Example
A state machine uses the enumeration E_State with the values IDLE, FILLING, HEATING and DRAINING instead of the integers 0 to 3.
How it applies
- Engineering: Enumerations make code readable and safer: a CASE statement over E_State shows state names instead of magic numbers, and the compiler can reject values outside the set. They are the natural data type for the states of a Finite-state machine (FSM) and for operating modes.
- Integration: HMI, SCADA and MES systems often receive the underlying integer value. The mapping of integers to names must be shared, otherwise screens show wrong state texts.
- Maintenance: Adding a value in the middle of an enumeration can shift the integer values of the following entries. Assign explicit values when other systems depend on them.
- Documentation: A state or mode table in the software documentation should list each enumeration value with its integer, its meaning and the HMI text. The same table can drive the operating manual's description of machine states, keeping program and manual consistent.
Enumeration vs. state model
An enumeration only lists the possible values. The State model also defines which transitions between them are allowed and what triggers them.