How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

download How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

of 10

Transcript of How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

  • 8/11/2019 How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

    1/10

    How do you create and parameterize variables and the IN, OUT and IN_OUT parameters of theUDT data type?

    Entry ID:11302987 Date:2007-02-08

    STEP 7 -- Creating S7 programs -- Addressing variables and data structures

    How do you create and parameterize variables and the IN, OUT and IN_OUT parameters of the UDTdata type?

    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 notloaded into the S7 CPU. They are either created by an incremental editor and edited or they originatefrom the compilation of sources. It is not possible to transfer UDTs for use as memory area whentransferring variables on block calls. For this it is recommended to specify the BYTE data type with therelevant data length as an absolute value, or to parameterize the IN, OUT and IN_OUT declarationsymbolically, because then the system creates the address accordingly.

    The table below describes how to proceed to create create and parameterize variables of the UDTtype. We will take the example of identical motors ten of which each stand in two different halls. TheUDT! 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 andright-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 (inthis example "Motor") and acknowledge with OK.

    http://support.automation.siemens.com/WW/view/en/11302987

    Page 1 of 10 9/5/2014 9:56:11

  • 8/11/2019 How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

    2/10

    Fig. 02

    3 Open the UDT1 and enter your variables with the relevant data types and initial values. Fig. 03here 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 inthe "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 (symbolicname "Motor"). The example as shown in Fig. 05 has two ARRAY variables each with 10components (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 inDB1. 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.

    http://support.automation.siemens.com/WW/view/en/11302987

    Page 2 of 10 9/5/2014 9:56:11

  • 8/11/2019 How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

    3/10

    Fig. 06

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

    7 Input of the IN parameter of a function or function block of the type UDTWhen 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_OUTparameters.

    8 Addressing and programming via the data block DB1Fig. 08 shows a sample program with the structure of the data block DB1 and the assignedUDT1.

    http://support.automation.siemens.com/WW/view/en/11302987

    Page 3 of 10 9/5/2014 9:56:11

  • 8/11/2019 How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

    4/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 inSTEP 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 andmake 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

    Example of an AND operation: "U Halle_Motoren".Halle_1_Motor[2].Einschalten ("UHall_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 blockWhen you call function FC1, the input of the UDT type must be supplied. In order to supply thefirst 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 theOUT 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

    http://support.automation.siemens.com/WW/view/en/11302987

    Page 4 of 10 9/5/2014 9:56:11

  • 8/11/2019 How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

    5/10

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

    Fig. 01

    Fig. 02

    http://support.automation.siemens.com/WW/view/en/11302987

    Page 5 of 10 9/5/2014 9:56:11

  • 8/11/2019 How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

    6/10

    Fig. 03

    Fig. 04

    http://support.automation.siemens.com/WW/view/en/11302987

    Page 6 of 10 9/5/2014 9:56:11

  • 8/11/2019 How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

    7/10

    Fig. 05

    Fig. 06

    http://support.automation.siemens.com/WW/view/en/11302987

    Page 7 of 10 9/5/2014 9:56:11

  • 8/11/2019 How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

    8/10

    Fig. 07

    http://support.automation.siemens.com/WW/view/en/11302987

    Page 8 of 10 9/5/2014 9:56:11

  • 8/11/2019 How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

    9/10

    Fig. 08

    Fig. 09

    http://support.automation.siemens.com/WW/view/en/11302987

    Page 9 of 10 9/5/2014 9:56:11

  • 8/11/2019 How Do You Create and Parameterize Variables and the in, OUT and IN_OUT Parameters of The

    10/10

    Fig. 10

    Entry ID:11302987 Date:2007-02-08

    Siemens AG 2014 - Corporate Information- Privacy Policy- Terms of Use

    http://support.automation.siemens.com/WW/view/en/11302987