show the entry list
STEP 7 -- Creating S7 programs -- Addressing variables and data structures
How can you process 64-bit floating-point numbers in STEP 7 V5.5 with a SIMATIC S7-300/400 CPU?
How can you access the parameters of the FBs interconnected in the CFC chart from the CFC library (e.g. "CONT_C") in the LAD/FBD/STL editor?
Rewiring in STEP 7
Reference data of indirect pointers in STEP 7
Global and local symbols
How can you set the block parameters of the data type "DATE_AND_TIME" in an FB?
Why can't you set the parameters for block inputs with the constants "TRUE" and "FALSE" in the LAD/FDB editor?
How can you copy STRING data types such as e.g. FB/FC parameters and DB variables?
What influence does the choice of address priority have when changing names in the symbol table and in the block editor?
Information on the topic of "Addressing variables and data structures"
Where and when do you need peripheral addressing?
How do you create and parameterize variables and the IN, OUT and IN_OUT parameters of the UDT data type?
Why does a function sporadically yield inaccurate return values in OUT parameters and what should you watch for when you assign input and output parameters?
How do you create and parameterize variables and the IN, OUT and IN_OUT parameters of the UDT data type?
Part number:

Instructions:
The UDT is not a data type in the sense of a data type that the CPU recognizes, but it is a user-defined (composed) data type in the offline project. User-defined data types of the S7 program are not loaded into the S7 CPU. They are either created by an incremental editor and edited or they originate from the compilation of sources. It is not possible to transfer UDTs for use as memory area when transferring variables on block calls. For this it is recommended to specify the BYTE data type with the relevant data length as an absolute value, or to parameterize the IN, OUT and IN_OUT declaration symbolically, because then the system creates the address accordingly.

The table below describes how to proceed to create create and parameterize variables of the UDT type. We will take the example of identical motors ten of which each stand in two different halls. The UDT! maps all the inputs of these motors.
 
No. Procedure
1 Insert a user-defined data type in your STEP 7 project. For this you mark the block folder and right-click. Then select "Insert New Object > Data Type" in the pop-up menu that opens.


Fig. 01

2 In the "Properties - Data Type" dialog that opens you enter a symbolic name for the UDT1 (in this example "Motor") and acknowledge with OK.


Fig. 02

3 Open the UDT1 and enter your variables with the relevant data types and initial values. Fig. 03 here shows a sample variable declaration in the UDT1.


Fig. 03

4 Then add a data block DB1 to your STEP 7 project via "Insert > S7 Block > Data Block" and in the "Properties - Data Block" dialog assign a symbolic name (like here in this example "Halle_Motoren" (Hall - Motors). Then acknowledge with "OK".


Fig. 04

5 Open the DB1 and now enter the variables in the data block with the data type UDT1 (symbolic name "Motor"). The example as shown in Fig. 05 has two ARRAY variables each with 10 components (Index 1 to 10) of the data type UDT1.


Fig. 05

Since for this example the two halls are to be separate, create a data structure for each hall in DB1. The structure for Hall 1 would then be "Hall_1_Motor" with an Array[1..10] of the type "Motor".

6 Select the menu command "View > Data View" to view the data.


Fig. 06

Note:
In the case of data blocks assigned to a UDT you can only edit the actual values for the variables. You input current values for the variables in the Data View of data blocks. The "Initial Value" column shows the preset values that you defined for the variables in the UDT. The initial value is taken as the current value for the variable when the data block is stored for the first time.

7 Input of the IN parameter of a function or function block of the type UDT
When you create a function or function block you can create an input of the type UDT1 (Motor) as shown in Fig. 07.

Example of an AND operation: "U  #Eingabe.Einschalten" (#Input.Switch On)

  • Input: Input parameter of function FC1
  • Switch On: Name of one of the variables from UDT1


Fig. 07

These inputs are also valid for other variables of the data type UDT for the OUT and IN_OUT parameters.

8 Addressing and programming via the data block DB1
Fig. 08 shows a sample program with the structure of the data block DB1 and the assigned UDT1.

Example of an AND operation: "U  Halle_Motoren".Halle_1_Motor[2].Einschalten ("U Hall_Motors.Hall_1_Motor[2].Switch On)

  • Halle_Motoren: Symbolic name of DB1
  • Halle_1_Motor[2]: DB variable of data type "ARRAY" and Index 2
  • Switch On: Name of one of the variables from UDT1


Fig. 08

9 Parameterizing the IN parameters of a function or a function block
When you call function FC1, the input of the UDT type must be supplied. In order to supply the first motor in Hall 1, for example, you write the following to the input:
  • "Halle_Motoren".Halle_1_Motor[1] ("Hall_Motors".Hall_1_Motor[1]).


Fig. 09

This parameterization is of course also valid for other variables of the data type UDT for the OUT and IN_OUT parameters.

10 When the cross-reference list is displayed you get a list of the operands of the memory area (e.g. DB1) used in the S7 user program, its addresses and their application.


Fig. 10

Notes on data blocks with the property "unlinked".
If you use UDTs in your data blocks and you configure your DBs with the property "unlinked", then in STEP 7 V5.2 / V5.3, if you change the UDTs and then automatically adapt your data blocks using the "Check block consistency" function, the "unlinked" property might be lost. After the block consistency check, make sure that the DBs configured with the "unlinked" property still have that property and make the appropriate changes to the property as necessary.

More information is also available in the STEP 7 Online Help under

  • User-Defined Data Types (UDT)
  • Entering and Displaying the Structure of Data Blocks Referencing a UDT
  • Entering the Data Structure of Shared Data Blocks

Keywords:
Template, Sample block, User-Defined Data Type

 Entry ID:11302987   Date:2007-02-08 
I regard this article....as helpfulas not helpful                                 
mySupport
My Documentation Manager 
Newsletter 
CAx-Download-Manager 
Support Request
To this entry
Print
Create PDF 
Send to a friend
QuickLinks
Compatibility tool 
Help
Online Help
Guided Tour