IEC 61131-3 Struct Type

Introduction

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

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

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

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

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

Accessing structure members

Within your code you can access structure members using the full stop (.) 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 2nd Edition.

Table 11.6 - IEC 61131-3 3rd 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.

Glossary

For definitions of the terms used in Fernhill SCADA.