IEC 61131-3 Struct Type

Help Contents


A struct type allows you to declare a composite type from existing data types. For example:

    (* Enumerated type for the motor state *)
    MotorDriveState : (Stopped, Running );

    (* The motor drive *)
    MotorDrive : Struct
        State : MotorDriveState;
        CurrentInAmps : REAL;
        StartStopCount : UDINT;
        TotalRunTime : TIME;

The MotorDrive structure declares a 17 byte block of memory laid out as follows:

01State (Enumerated)
14CurrentInAmps (REAL)
54StartStopCount (UDINT)
98TotalRunTime (TIME)

Accessing structure members

Within your code you can access structure members using the period (.) character. For example:

Var M1, M2 : MotorDrive End_Var

    (* Initialize the state of M1 *)
    M1.State := MotorDriveState#Stopped;
    M1.CurrentInAmps := 0;
    M1.StartStopCount := 0;
    M1.TotalRunTime := T#0s;

Standards Compliance

Table 12.5 - IEC 61131-3 Second Edition.

Table 11.6 - IEC 61131-3 Third Edition.

Further Information

Derived Data Types

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

Elementary Types

To learn about the built-in elementary types for example REAL, or TIME.

Common Elements

To learn about other common language elements.


For the meaning of terms used in Fernhill SCADA.