Structures: Structured data types

Structures combine different data types to create structured data types. A structured data type can be assigned to a user-defined variable just like any other data type.
Structured data types are useful when you want a single variable to hold several related pieces of information. For example, define a structured data type to keep temperature ranges and alarm levels for a device in one variable rather than creating multiple variables for the values.
Define a structured data type using elementary IEC 61131-3 data types or derived data types. A data type structure is composed of sub-entries called Fields.
TIP: Indirect bit addressing is supported when a variable of the following data types or a defined word is used to specify the bit number.
  • SINT
  • INT
  • LINT
  • USINT
  • UINT
  • ULINT
  • DINT
  • UDINT

Structure examples

MyStruct1 is composed of:
Field1 which is BOOL Field2 which is DINT
MyStruct2 is composed of:
Field1 which is DINT Field2 which is BOOL Field3 which is an array of 10 DINT Field4 which is of type MyStruct1
MyVar of type MyStruct2 can be used as follows:
Value1 := MyVar.Field1; (* Value1 is of type DINT) MyVar.Field2; (* Ok1 is of type BOOL *) MyVar.Field3[5]; (* Tab is an array of DINT *) MyVar.Filed3[8]; (* Value2 is of type DINT *) MyVar.Field4.Field1; (* Ok2 is of type BOOL *)
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal