IEC 61131-3 Struct Type

Help Contents

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 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

IEC 61131-3 Second Edition: Table 12.5.

IEC 61131-3 Third Edition: Table 11.6.

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 the meaning of terms used in Fernhill SCADA.