You are on page 1of 3

How do you program "user-defined data types" or UDTs in STEP 7 (TIA Portal)?

Entry ID:51339155 Date:2013-11-07
STEP 7 (TIA Portal) -- Creating S7 programs -- Addressing variables and data structures
How do you program "user-defined data types" or UDTs in STEP 7 (TIA Portal)?
Unlike STEP 7 V5.x, data structures are defined in STEP 7 (TIA Portal) with the PLC data types which
you can then use repeatedly in your program. Just as you define a UDT (user-defined data type) in
STEP 7 V5.x, so too can you define a series of components with various data types in a PLC data
type in STEP 7 (TIA Portal).
You can assign any name to the PLC data type.
The PLC data types can be declared as data types for variables in the block interface in
functions and function blocks.
Or they can be used as data types in global data blocks.
The example below illustrates how to define a PLC data type and to program it in a data block. Once
you have generated a project and designed the device configuration, the "PLC data types" folder can
be found in the project navigation.
1. Click the command "Add new data type" in the "PLC data types" folder and enter the data types
in the declaration table.
2. A default name is allocated for the newly created PLC data type. If you wish to change the
name, right-click the data type and select the "Rename" function in the context menu. The
name "UserDataType" has been allocated for the purpose of this example, and the following
data types have been defined:
User_Variable_1 with the data type: Boolean.
User_Variable_2 with the data type: Byte.
Page 1 of 3 9/5/2014 5:12:07 PM

Fig. 01
3. Click the "Add new block" command in the "Program blocks" folder and create a new global
data block.
4. Enter your DB variable in the table with your defined PLC data type. In this example,
"DataBlock" was allocated as the DB name, and the variable "DB_Variable" was declared with
"UserDataType" as the PLC data type. If you then click the arrow to the left of the DB variables,
the data types which you defined in the PLC data type "UserDataType" are listed underneath
for the DB variable.

Fig. 02
5. You can now program the DB variable with the defined PLC data type in your code block. Fig.
Page 2 of 3 9/5/2014 5:12:07 PM
03 shows an example of how to assign parameters for the DB variables defined above with the
instruction "MOVE" in LAD view:
Parameter EN: "DataBlock".DB_Variable.User_Variable_1 (of boolean data type)
Parameter IN: "DataBlock".DB_Variable.User_Variable_2 (of byte data type)

Fig. 03
More information is available in the STEP 7 (TIA Portal) Online Help under "Programming PLC data
Creation environment
The screens in this FAQ response were created with STEP 7 (TIA Portal) V11.
Entry ID:51339155 Date:2013-11-07
© Siemens AG 2014 - Corporate Information - Privacy Policy - Terms of Use
Page 3 of 3 9/5/2014 5:12:07 PM