4.875 1 1 1 1 1 1 1 1 1 1 Rating 4.88 (4 Votes)

User Rating: 3 / 5

Star ActiveStar ActiveStar ActiveStar InactiveStar Inactive

In this article I'll describe how to use an ANY data type as pointer input in a simple subroutine in Simatic Step 7 v.5.5. ANY parameter type, according to Simatic on-line help, is a 10 byte length with the following structure:

ANY Definition

  1. First of all I create a simple S7 project : CPU S7-315 6ES7 315-2EH14-0AB0

    HW config

  2. then in the project I define a new UDT1 (mnemonic name ANY_UDT) data type with length 1 word: 8 bit In + 8 bit Out. Scope of the subroutine is map the 1st Input bit of UDT to 1st Output bit

    UDT1 detail

  3. I define now the subroutine as FC1 (ANY_Pointer) containing:
    • IN: InData: ANY
    • TEMP: In :UDT1                // UDT1 data type in order to easily access the structure bits into subroutine logic
    • TEMP: InLaddr: DWORD  // pointer to "In" area
    • TEMP: InDBNum: INT        // "In" area DB number


  4. This is the subroutine code:


  5. Recall the sub into OB1 and assign it the input parameter (P#DB1.DBX0.0 BYTE 2) (=DB1.Sample1 ANY data)

    OB1  DB1

  6. And this is the PLC SIM runtime that show the subroutine job


  7. The advantage of using ANY data as input parameter are:
    • Low Work Memory Requirement (this sample FC need 104 bytes. Defining directly in parameters as UDT the Work Memory requirement is higher) :  the subroutine define not entire UDT, just pointer to it (ANY). Struct data are defined as TEMP data
    • Few In, Out, InOut parameters=clean code view

 Here follow I share this sample project hoping it can be hopeful for you. If you have any question, doubt, request, feel free to contact me



Download this file (ANY_InOu.7z)ANY_InOu.7z[ ]161 kB1449 Downloads2014-03-02 17:24