Programming Industrial Control Systems Using IEC 1131-3, Revised Edition

3.9: Derived data types

3.9 Derived data types

To assist program readability and ensure that data are used consistently, new data types can be defined from the elementary data types. A new data type is declared by framing the definition with TYPE and END_TYPE.

For example, all values for pressures could be held in a derived data type called PRESSURE which is based on the REAL data type. The type can be declared as:

     TYPE           PRESSURE : REAL;     END_TYPE;

Structured data types

New composite data types can be derived by defining a structure from existing data types. A structure is declared by framing the definition with STRUCT and END_STRUCT. Each element of the composite data can be given a meaningful name.

For example, the data from a pressure sensor may consist of the following information:

  1. The current pressure as an analogue value;

  2. The status of the device, i.e. operating or faulty;

  3. The calibration date;

  4. The maximum safe operating value;

  5. The number of alarms in the current operating period.

This can all be defined in a single structure as a new data type PRESSURE_SENSOR:

<a name="190"></a><a name="page66"></a>    TYPE PRESSURE_SENSOR:      STRUCT        INPUT:       PRESSURE;        STATUS:      BOOL;        CALIBRATION: DATE;

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Vacuum Viewports and Access Doors
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.