Print
Tutorial
Hits: 13508

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

      SubData

  4. This is the subroutine code:

    Subroutine

  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

    FC1Job

  7. The advantage of using ANY data as input parameter are:

 Here follow I share this sample project hoping it can be hopeful for you.