Introduction

A derived data type corresponds with:

A derived data type is one of the following

  • a structure type:

    • Structure for input/output data, the type is not created by the user in this case, but by the manufacturer (IODDT),

    • Structure for other data; in this case the type is created by user.

  • an array type.

  • a reference type.

Memory Structure

The different PLC families vary in memory structure.

Creating a Structure Type

Step

Action

1

Double click in the Data Editor in the DDT Types tab on the empty field (marked by an arrow Name, and enter the name of the structure type (e.g. IDENTITY); the default type is <Struct>. Enter a comment (optional).

2

Call up the newly created structure by clicking on +.

Example:

3

Double-click on the corresponding Name field and enter the name of the first element of the structure (e.g. Name, Age) and its type and comment (optional).

Example:

4

Double-click on the next cell (marked with an arrow) to enter the name of the next element etc.

5

Go to the name of the structure type (IDENTITY) and select Analyze Type in the shortcut menu.

Result: The structure was successfully analyzed (the symbol in front of the structure type has changed):

Result: The IDENTITY structure is created in the structure view of the project:

NOTE: Using the shortcut menu and the Open command you can access the IDENTITY structure.

Creating a Structure Type with an Extracted Bit

The user can create structure type using extracted bit.

The Bit Rank dialog box is accessible by right clicking on the instance or data type which type must be:

  • WORD

  • UINT

  • INT

  • BYTE

  • an extracted bit with a compatible parent

Step

Action

1

Double click in the Data Editor in the DDT Types tab on the empty field (marked by an arrow Name, and enter the name of the structure type (for example, MyDDT); the default type is <Struct>. Enter a comment (optional).

2

Call up the newly created structure by clicking on +:

3

Double-click on the corresponding Name field and enter the name of the first element of the structure (e.g. Extract, Extract1) and its type and comment (optional):

4

Double-click on the next cell (marked with an arrow) to enter the name of the next element etc.

5

Select the variable to create the extracted bit and right-click on the variable.

The Edit Bit Rank is available in the contextual menu list:

Here below is the Bit Rank dialog box:

6

Within the Bit Rank menu, the user can select to named each variable manually or automatically using the Generate button.

NOTE: The Bit name can be edited manually directly in the Data Editor.

7

Go to the name of the structure type (MyDDT) and select Analyze Type in the shortcut menu.

Result: The structure was successfully analyzed (the symbol in front of the array type has changed):

Result: The MyDDT structure is created in the structure view of the project:

NOTE: Using the shortcut menu and the Open command you can access the IDENTITY structure.

Creating an Array Type

Use this procedure to create an array type:

Step

Action

1

Double click in the Data Editor in the DDT Types tab on the empty field (marked by an arrow Name , and enter the name of the array type (e.g. SERIAL_NUMBER); the default type is <Struct>. Enter a comment (optional).

2

Double click on the Type field, select <Array>, and confirm by pressing Enter.

Result: The Variable Type Selection dialog appears.

3

The ARRAY checkbox is automatically checked:

  • Enter the size of the array in the corresponding field (for example, 1..6)

  • In the libraries/families area select the types that should be displayed:

    • the <Application> directory for a derived type already in the application

    • the <EDT> directory for an elementary type

    • the <GDT> directory (displayed but not applicable here)

    • the <Libset> directory for a derived type archived in a library

4

Confirm with OK.

5

Change to the name of the array type and go to the shortcut menu and select Analyze Type.

Result: The array was successfully analyzed (the symbol in front of the array type has changed):

NOTE: Comments cannot be entered for the sub elements of the array type.

The array type SERIAL_NUMBERS is created in the project structure view:

NOTE: You can access the array of the SERIAL_NUMBER type in the context menu using the Open command.

Creating a Reference Type

Step

Action

1

Double click in the Data Editor in the DDT Types tab on the empty field (marked by an arrow Name , and enter the name of the reference type (e.g. MyRefInt); the default type is <Struct> . Enter a comment (optional).

2

Double click on the Type field, select <Reference>, and confirm by pressing Enter.

Result: The Variable Type Selection dialog appears.

3

The REF_TO checkbox is automatically checked. Select the reference data type, in this example: INT.

4

Confirm with OK.

5

In the Data Editor, right-click the name MyRefInt and select Analyze Type .

Result: The reference was successfully analyzed (the symbol in front of the reference type has changed).

The reference type MyRefInt is created in the Project Browser Structure view .

NOTE: You can access the reference of the MyRefInt type using the contextual menu using the Open command.

Array of References

You cannot make directly, for example, an Array of REF_TO INT. You must first make a reference DDT with type REF_TO INT as in the figure above. Then you make a new DDT type, an array of the references.

In <Application> , select MyRefInt:

After confirming with OK and performing an Analyze Type , you obtain an array of references:

Structure with References

This example shows the creation of an array of reference type variables:

Step

Action

1

Double click DDT Types tab in the Data Editor on the empty field (marked by an arrow Name, enter the name of the structured type and press ENTER. The default type is <Struct>.

2

Double click Types and select <Array> in the drop-down menu.

3

Press ENTER to open the Variable Type Selection dialog.

4

Set the size of the array.

5

Select <Application>.

6

Select MyDDTRefINT.

The array of reference types example: