collection of plc signals in step 7 with subsequent excel evaluation www.otomasyonegitimi.com

Upload: wwwotomasyonegitimicom

Post on 05-Apr-2018

217 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    1/41

    Tool on Control Technology

    Collection of PLC Signals in STEP 7 withsubsequent Excel EvaluationSTS7 Service Tool for the Analysis of PLC Signals

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    2/41

    Warranty, Liability and Support

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 2/41

    CopyrightS

    iemensAG2

    005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    Ent

    ryID:21902350

    Warranty, Liability and SupportWe do not accept any liability for the information contained in thisdocument.

    We do not accept liability, whatever the legal basis, for any damagesarising from the use of examples, notes, programs, configuration andperformance data, etc. described in this document, except where we areobliged to by the German Product Liability Act or in cases of willful damageor gross negligence, injury to life, body or health, breach of guarantee forthe condition of products or items assumed by us, fraudulent concealmentof a defect or breach of a substantial contractual obligation. However,claims arising from a breach of a condition which goes to the root of thecontract shall be limited to the foreseeable damage which is intrinsic to thecontract, unless caused by intent or gross negligence or based onmandatory liability for injury of life, body or health. The above provisions donot imply a change in the burden of proof to your detriment.

    The Functional Examples do not purport to cover all details or variations inequipment, nor do they provide for every possible contingency. They arenot customer-specific solutions. They are only intended to provide supportfor typical tasks. Every user is responsible for proper operation of thedescribed products. These Functional Examples do not relieve you of theresponsibility to use sound practices in application, installation, operationand maintenance. By using this Functional Example you accept that

    Siemens is not liable for any damages except for those specified in theabove liability clause. We reserve the right to make changes in thisFunctional Example at any time without prior notice. If there are anydeviations between the recommendations provided in this FunctionalExample and other Siemens publications e.g. Catalogs the contents ofthe other documents have priority.

    Copyright 2005 Siemens A&D. It is not permissible to transfer orcopy these Micro Automation Sets or excerpts of them without firsthaving prior authorization from Siemens A&D in writing.

    For questions about this document please use the following e-mail address:

    [email protected]

    mailto:[email protected]:[email protected]
  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    3/41

    Foreword

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 3/41

    CopyrightS

    iemensAG2

    005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    Ent

    ryID:21902350

    ForewordThe functional examples are functional and tested automation solutionsbased on A&D standard products for easy, fast and inexpensiveimplementation of automation tasks in automation technology. Each of theavailable functional examples covers a frequently occurring subtask of atypical customer problem in automation technology.

    Aside from a list of all required software and hardware components and adescription of the way they are connected to each other, the functionalexamples include the tested and commented code. This ensures that thefunctionalities described here can be reset in a short period of time andthus also be used as a basis for individual expansions.

    Table of Contents

    Table of Contents ......................................................................................................... 31 Automation Function...................................................................................... 41.1 Overview........................................................................................................... 41.2 Advantages/customer benefit ........................................................................... 42 Used Hardware and Software Components................................................. 52.1 Overview of the downloads............................................................................... 63 Principle of Operation of FB STS7 ............................................................ 73.1 Description........................................................................................................ 73.2 Network structure.............................................................................................. 83.3 Structure of the instance data block ................................................................. 94 Principle of Operation of the Excel Table................................................... 124.1 Description...................................................................................................... 124.2 VBA scripts ..................................................................................................... 175 Parameterization........................................................................................... 215.1 Adapting the function block............................................................................. 216 Operating Instructions ................................................................................. 276.1 Introduction..................................................................................................... 276.2 Parameterization of FB STS7 (FB502)......................................................... 306.3 Evaluation with Excel...................................................................................... 33

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    4/41

    Automation Function

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 4/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    1 Automation Function

    1.1 Overview

    In industrial plants, it is always possible that sporadic events occur whichcannot be located immediately. If, for instance, in a system for conveyingcontainers, one of these containers stops for no apparent reason, theanalysis may prove difficult if the cause occurs sporadically or only for avery short period of time. In these cases, monitoring with the standardPG functions (status) does not work. Analyzers are required which recordthe signals at the I/O or in the CPU.

    In this functional example, we show you an easy option for logging signals

    in an adjustable circular buffer and for convenient evaluation of the circularbuffer using an Excel table. The function can be used on all CPU versionsof SIMATIC S7-300, S7-400, C7 and WinAC.

    Figure 1-1

    1.2 Advantages/customer benefit

    No complex measuring setup with external analyzers necessary

    Easy implementation in customer plants

    Easy adaptation to customer-specific problems possible

    Clear display in Excel tables

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    5/41

    Used Hardware and Software Components

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 5/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    2 Used Hardware and Software Components

    To describe and to verify the functionality in this document, the componentslisted below were used.

    Hardware components

    Table 2-1

    Component No. MLFB/Order number Note

    Programming devicefield PG

    1 6ES7-711-1DB35-3FB2 Or other PGs

    PS307load power supply120/230V AC:24VDC/2A

    1 6ES7307-1BA00-0AA0 Any PS withsufficient powerspecifications canbe used.

    CPU 315-2 DP 1 6ES7315-2AG10-0AB0 Or comparableCPU

    SIMATIC S7-300,simulated I/O module

    1 6ES7 374-2XH01-0AA0 Optional

    Software components

    Table 2-2Component MLFB/Order number Note

    PC operating systemWindows 2000 SP3 orWindows XP ProfessionalEdition SP2

    Order via Microsoft

    SIMATIC S7 STEP 7Professional Edition 2004version 5.3 + SP2

    6ES7810-4CC07-0YA5

    MS Excel/Office 2003(German version)

    Order via Microsoft

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    6/41

    Used Hardware and Software Components

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 6/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    2.1 Overview of the downloads

    Download of the required files

    You can download the files of this functional example from the same website from which you downloaded this document.

    After downloading, the following files have to be available on yourcomputer:

    Table 2-3

    No. File name Note

    1. 21902350_ServiceToolS7_CODE.zip Includes the loadablefunctional example.

    2. 21902350_ServiceToolS7_BIB.zip The library includes the originalblocks without the useradaptations for the functionalexample.

    3. 21902350_ServiceToolS7_Analyse_d.xls

    21902350_ServiceToolS7_Analyse_e.xls

    Table with VBA scripts for theevaluation.You only require one of the twofiles.Select the respective file:- (..._d.xls) with Germancomments or- (..._e.xls) with Englishcomments

    Note If you do not want to perform the functional example, only copy the library(no. 2) and the Excel table (no. 3).

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    7/41

    Principle of Operation of FB STS7

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 7/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    3 Principle of Operation of FB STS7

    This program was realized with the SIMATIC STEP 7 software. The blockcalled ServiceToolS7 (STS7) can be integrated into any SIMATIC STEP 7program. It is only required to generate the corresponding DI (instance datablock). If the block is integrated in the STEP 7 program, it performs its taskin the background.

    The standard program execution is not impaired by the STS7 programblock. Its field of application can be all SIMATIC STEP 7 programs in whicha change is to be logged.

    3.1 Description

    The program block is capable of detecting the change of a bit pattern (16bits) and/or of a word (integer) and of logging this change in an instancedata block (DI). When one of these values changes, the current values aresaved with cycle counter content and time stamp (date and time) in theassociated DI. This DI (instance data block) is designed as circular buffer ofwhich the size can be defined by the user.

    A programmable trigger function enables a defined stop of the logging. Thisis particularly important for sporadically occurring events. In addition, adefined number of changes can be logged after the occurrence of thetrigger event before the logging is completed.

    An evaluation of the recorded bit patterns in the opened DI is possible;however, since the display is not automatically updated, we recommendthat you first load the values of the DI data block from the CPU to the PG.Subsequently you can analyze the logging of the changes in the data block(DI) or prepare the information for convenient analysis using VBA scripts.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    8/41

    Principle of Operation of FB STS7

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 8/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    3.2 Network structure

    Parameterization bythe user. The signalsto be monitored areentered.

    Parameterization bythe user. Thecondition for stoppingthe data recording isdefined.

    Memory depth afterSTOP trigger can beset. Presetting: 10

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    9/41

    Principle of Operation of FB STS7

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 9/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    3.3 Structure of the instance data block

    The structure of the instance data block is defined in the function block FBSTS7. A variable overview is displayed in the interface window of thefunction block. An output parameter, static data and temporary data weredeclared.Static data are local data of a function block which are stored in theinstance data block and which are retained until the next processing of theblock.Temporary data are local data of a block which are stored in the local datastack during the processing of a block and which are no longer availableafter the processing.The number of memory locations is defined in the Speicher array.

    The user can adapt thearray for data storage.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    10/41

    Principle of Operation of FB STS7

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 10/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Output parameters (OUT)

    Table 3-1

    Parameter Meaning

    1. TRIG_STOP Indicates the end of the data recording with the 1signal.

    Static data (STAT)

    The function block uses the following static variables:

    Table 3-2

    No. Variable name Meaning

    1. int_vergl If the integer value changes, the change bit is set.

    2. word_vergl If the bit pattern changes, the change bit is set.

    3. stoppen Activates the counter for the last 10 entries afterthe arrival of the STOP trigger.The number of entries can be changed by theuser.

    4. STOPP Stop command in case of more than 10 entriesafter the occurrence of the STOP trigger event.

    The data recording is definitely finished.5. fin_Eintr Counter for the last 10 entries after the arrival of

    the STOP trigger.

    6. Zeit Date and time of the change.

    7. Anfang Value indicating where the memory in the DB forthe data recording starts.

    8. alt_int Stores the old integer value for the new valuecomparison.

    9. alt_word Stores the old bit pattern for the new valuecomparison.

    10. Laenge Indicates the length of the structure of the

    Speicher array.11. naechstEintr Pointer offset

    12. AnzahlSp Number of memory locations (structure)

    13. Zyklen Value of the cycle counter

    14. Speicher (array) Zykluszaehler int_Wert Bitmuster Zeitstempel

    Structure of the data recording. The size isindicated as array in the data typee.g. array [1..100] Of Struct.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    11/41

    Principle of Operation of FB STS7

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 11/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Temporary data (TEMP)

    Table 3-3

    No. Variable name Meaning

    1. Bit_0 bis Bit_7 Bits of the bit pattern to be monitored in thelocal data byte LB 0

    2. Bit_8 bis Bit_15 Bits of the bit pattern to be monitored in thelocal data byte LB 1

    3. Fehlinfo Error information of SFC1 (reading system time) iscurrently not evaluated.

    4. int_Wert Stores the current integer value

    5. DBreg Stores the value of the DB register

    6. DIreg Stores the value of the DI register

    7. AR1reg Stores the value of address register 1

    8. AR2reg Stores the value of address register 2

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    12/41

    Principle of Operation of the Excel Table

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 12/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    4 Principle of Operation of the Excel Table

    4.1 Description

    To prepare the logging stored in the instance data block for an Excelevaluation, the Excel workbook21902350_ServiceToolS7_Analyse_e.xls is provided.

    The following spreadsheets are included in this workbook:

    Table 4-1

    EXCELsheet

    Name Description

    1 Description Includes a brief description with the buttons forexecuting the individual functions.

    2 Source Includes the STL source of the current instance datablock DI.

    3 STS7 NW2 Bits Includes the signals and values to be monitored.The content is simply copied fromnetwork 2 of FB STS7. (Copy & Paste function).

    4 Bit Conversion Includes the data records of the monitored signals.

    5 Diagrams The charts for the bit evaluation and the integervalue are stored.

    Opening the workbook

    Open the XLS workbook using a file browser to select the above-mentionedXLS file with a double-click.

    Alternatively you can also start MS Excel via the Windows start buttonStart > Programs > Microsoft Office > Microsoft Office Excel 2003.... Usethe file command File > Open to select your storage folder and open theabove-mentioned XLS file. The security warning is acknowledged byclicking the Enable macros button.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    13/41

    Principle of Operation of the Excel Table

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 13/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Spreadsheet Description

    In this spreadsheet, the sequence is described and the VBA scripts arestarted. The flowchart shows you the necessary steps for the preparation ofthe STL source in an Excel table.When activated, the integrated buttons execute the corresponding VBAscript. To-do lists are located between the individual buttons which have tobe performed by the user before the next script may be executed.

    Note Before the execution, it is required that the current instance data block DI isavailable as STL source.

    Figure 4-1

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    14/41

    Principle of Operation of the Excel Table

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 14/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Spreadsheet Source

    The user copies the current content of the instance data block previouslygenerated as STL source into this spreadsheet.When copying the STL source, it has to be observed that the entire contentfrom the first row DATA_BLOCK Protocol_DB up to and including the endidentifier END_DATA_BLOCK is selected.

    Figure 4-2

    First row of theSTL source

    Last row of theSTL source

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    15/41

    Principle of Operation of the Excel Table

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 15/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Spreadsheet STS7 NW2 Bits

    The user copies network 2 of the function block STS7 into thisspreadsheet. The bits to be monitored and the integer value areprogrammed in this network. With the VBA script Quelle, the operandnames are read and entered in the Source spreadsheet.

    Figure 4-3

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    16/41

    Principle of Operation of the Excel Table

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 16/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Spreadsheet Bit Conversion

    In this spreadsheet, the data bits copied by the user are prepared in such away that a chart can be created with the ChartWizard. The preparation isperformed by executing the VBA script Bit Conversion. The figure showsthe table after executing the script.

    Figure 4-4

    To clearly display the bit pattern in the chart, the signal status (0 or 1) of theindividual operands is converted into numerical valuesfrom 0-31. Due to this, the operands are displayed one upon the other inthe bit chart and can thus be better evaluated.

    Table 4-2

    Bit no.Operand

    is on 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

    0 signal 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 0

    1 signal 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    17/41

    Principle of Operation of the Excel Table

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 17/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    4.2 VBA scripts

    The data recording in the data block (DI) is prepared in Excel tables withthe provided VBA scripts.The database for the VBA scripts is a manually created STL source fromthe current instance data block.The scripts delete not required strings such as variable names orcomments, they delete STEP 7 type identifiers and allocate the recordedinformation in rows and columns.After the execution of the scripts, a table is available to the user with whichhe can easily evaluate the monitored signals/values or edit them graphicallyas charts.

    The preparation of the data is realized with five tables and five programmodules.

    VBA scripts

    Table 4-3

    Script Name Function

    1 delQuelle Deletes the content of the Source table

    2 delBits Deletes the content of the STS7 NW2 Bits table

    3 delUmstellung Deletes the content of the Bit Conversion table

    4 Quelle Processes the copied STL source (ASCII code),sorts and allocates the data in rows and columns.

    5 Aufbereiten Prepares the bit pattern for a chart evaluation.

    Script excerpt

    In the following program excerpts, a string is used as an example toillustrate the preparation of data from an STL source using VBA scripts.The example shows the preparation of the data for the cycle counter.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    18/41

    Principle of Operation of the Excel Table

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 18/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step 1:

    Table 4-4

    Program code Explanation

    z = 20S6: inhalt = Cells(z, 2)If Mid(inhalt, 1, 16) = "Zykluszaehler :=" Thenza = zGoTo S7

    Else: z = z + 1GoTo S6

    End If

    S7: inhalt = Cells(z, 1)If Mid(inhalt, 1, 8) = "END_DATA" Thenze = z - 1GoTo S8

    Else: z = z + 1GoTo S7

    End IfS8: Range(Cells(za, 2), Cells(ze, 2)).Select

    Selection.TextToColumns Destination:=Range("B20"), _DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 9),

    Array(16, 1))

    In the Source data sheet,searches the text entry Zyklus-

    zaehler:= from the position (row20, column 2).The determined row no. isentered in the za variable.

    -----The data end is searched for andthe determined row no. isentered in the ze variable.

    The area is selected.Subsequently the cells areanalyzed and the values, e.g.L#221456;, are copied into thecolumns from position B20without the text "Zykluszaehler:=".

    String beforethe preparation

    String after thepreparation

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    19/41

    Principle of Operation of the Excel Table

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 19/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step 2:

    In the next program part, the semicolon (;) is removed from the string.

    Table 4-5

    Program code Explanation

    'z = 20inn: inhalt = Cells(z, 2)

    If Mid(inhalt, 1, 15) = "" ThenGoTo out

    End If

    i3 = InStr(Cells(z, 2), ";")i3 = i3 - 1

    Cells(z, 2).Select

    Selection.TextToColumns Destination:=Range(Cells(z,2), Cells(z, 2)), _ DataType:=xlFixedWidth,FieldInfo:=Array(Array(0, 1), Array(i3, 9))

    z = z + 1GoTo innout: z = 20

    If the content of the cell (row 20,column 2) is not empty, theposition of the ; character issearched for.

    The position is stored in the i3variable.

    The cell is selected.

    In the selected cell, the numericalstring is extracted and againcopied into the same cell. Thiseliminates the semicolon.

    The row number is increased andsubsequently the jump to thestart of the loop takes place.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    20/41

    Principle of Operation of the Excel Table

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 20/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step 3:

    In this part, the last L# characters which are not required are removedfrom the actual numerical string. The L# character is theSTEP 7 code for a 32 bit integer constant not required for the evaluation.

    Table 4-7

    Program code Explanation

    out: z = 20in2: inhalt = Cells(z, 2)

    If Mid(inhalt, 1, 1) = "L" Theni = InStr(Cells(z, 2), "#")

    i2 = Len(Cells(z, 2))bitwert = Mid(Cells(z, 2), i + 1, i2 - i)

    Cells(z, 2) = bitwert

    z = z + 1GoTo in2

    End If

    The string in the inhalt variable (e.g.L#221456) is to be evaluated.

    The Mid function returns the firstcharacter of the string.

    The i variable includes the position

    of the # character.The i2 variable includes the entirelength of the string.With the Mid function, the numericalstring is assigned to the bitwertvariable.

    The current cell is overwritten withthe content of the bitwert variable.

    String beforethe preparation

    String after thepreparation

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    21/41

    Parameterization

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 21/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    5 Parameterization

    5.1 Adapting the function block

    Before ServiceToolS7 (STS7) can be integrated into a SIMATIC STEP 7program, it has to be adapted to the program for the analysis. Thesechanges are limited to networks 2 and 3 and to the declaration table.

    The required SFC1 (system function for reading time from the CPU)independently generates itself in the SIMATIC Manager if it is not available.

    Note Ensure that date and time in the CPU are up to date. Corrections arepossible via the menu command PLC > Diagnostic/Setting > Set Time of

    Day.

    Changes in network 2

    The user has to allocate his bits or his integer value to be monitored in theblock.The integer value (integer 16bits) to be monitored is loaded instead of theload instruction (L 0).

    When allocating the bits, it is required that each bit to be logged isindividually transferred to the local data (0.0...0.7, 1.0...1.7). The names ofthe symbolic identifiers for the local data are: #Bit_0...#Bit15.The relevant CLR command lines are overwritten with the operands to bemonitored (e.g. U E 0.1). Logic operations or comparisons are alsopermissible.The CLR instructions are used as wildcards. In the status word, the CLRcommand sets the RLO to signal status 0.

    Example 1:

    U I 0.1U M 10.1= #Bit_1

    Example 2:

    L DB10.DBW 40L MW 30== I= #Bit_2

    Shows a comparison of integers(16bits). If they are identical, status 1is assigned to logging bit #Bit_2.

    Shows the allocation of an operandlinking to the logging bit #Bit_1.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    22/41

    Parameterization

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 22/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Example 3:

    //bergabe des int_wertesL MW50T #int_Wert

    The figure below shows network 2 in its original status, in which theallocations are later programmed.

    Figure 5-1

    Transfer of the integer to bemonitored (16bits).

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    23/41

    Parameterization

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 23/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Stopping the logging (trigger event)

    In network 3 of the function block STS7, the user is provided with theoption of stopping the logging defined by a specific trigger event. This isparticularly important for sporadically occurring events. A logic operationwhich occurs in case of an error has to be programmed for the triggerevent. If available, a fault bit is the best solution.After the occurrence of the trigger event, the next ten changes of theoperands to be monitored are logged(see network 6). Due to this, also the direct effects after the occurrence ofthe trigger event are captured and support you during the error analysis ofprocess sequences which, in the case of sporadic faults, are frequentlydifficult to analyze.If no signal is available, leave the CLR instructions.

    Figure 5-2

    In the lower part of network 3, you can program the condition for acontinuation of the logging.

    Note If you want to restart the monitoring, we recommend retransferring thedata block DI in its original status for better evaluation.

    Programming of the condition forstopping the logging. Overwrite theCLR instruction.

    Programming of the condition forcontinuing the logging. Overwrite theCLR instruction.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    24/41

    Parameterization

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 24/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    If the preset ten entries are inadequate, this can be changed in network 6 of

    the function block STS7.

    Figure 5-3

    Defining memory location for the logging

    The number of storing options for the logging depends on the length of theinstance data block DI. In the delivery status of the function block STS7,100 memory locations are available to you.

    When changing the monitored operands, a memory location is assignedwith the following variable structure: - Zykluszhler- int_Wert- Bitmuster- Zeitstempel

    You can increase the number of memory locations by changing the lengthof the array of the Speicher structure in the declaration table of STS7.Since the program calculates the number of memory locations in network 7,the length of the DI can be variably selected using this method. If thememory is full, it is again overwritten from the start (circular buffer).If the number of memory locations is increased, the maximum possiblelength of a data block and the main memory of the respective CPU have tobe considered. For a CPU315-2DP, the maximum length of a data block is16420 bytes. Consequently, the maximum number of memory locations islimited to 1022.

    Note The performance data of your used CPU are available via PLC >Diagnostic/Setting > Module Information > Performance Data.

    You increase the number of entries.The presetting is ten.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    25/41

    Parameterization

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 25/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    If, for instance, you want to parameterize a DI with 400 memory locations,

    proceed as follows:

    Step-by-step instructions

    Table 5-1

    Step Procedure

    1. If not yet done, open the SIMATIC Manager and open the function block FB502 withthe LAD/STL/FBD Editor.

    2. In the variable overview, click the static data and enter the value 400 instead of 100in the ARRAY data type.

    3. Save the block and continue the saving by clicking the YES button. This messagebox indicates that the instance data block has to be regenerated.

    Array [1..400] of Struct

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    26/41

    Parameterization

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 26/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step Procedure

    4. Regenerate or update the instance data block. Several options are available, e.g.: Updating the DI in the SIMATIC Manager using the menu command

    Edit > Check Block Consistency.... New generation via the instruction: Call FB502, DB502. In the SIMATIC Manager via the menu command Insert > S7 Block > Data

    Block > with the parameter Instance DB and the FB.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    27/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 27/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    6 Operating Instructions

    6.1 Introduction

    We use a simple example to illustrate the steps required for the evaluationand the creation of an Excel chart.The following subchapters describe the individual steps and the realizationis described in step-by-step instructions.A function block (FC100) was created in the FBD programming languagefor the example. FC100 is cyclically called in the organization block OB1.

    ScenarioSome operands in the function block FC100 are to be logged for a signalevaluation. The function FC100 includes simple clock generators for twooutputs and a counter (C1) which is incremented depending on the Q0.0output. The Q0.2 output indicates the end of the data recording.

    The following operands are captured:

    Table 6-1

    No. Operands Description

    1. Input I1.0 With this operand, the clock generator isenabled (start)

    2. Input I1.1 With this operand, the counter C1 is set to thecount value 1 (MW32).In addition, the STOP trigger of the functionblock STS7 is set. This terminates the datarecording after ten additional modificationentries.

    3. Output Q0.0 The output remains switched on for fiveseconds and switched off for five seconds.

    4. Output Q0.1 The output remains switched on for tenseconds and switched off for ten seconds.

    5. Output Q0.2 An output parameter of the STS7 block.Signal 1 means: End of the datatransmission.

    6. Counter value MW34 At a positive edge of the Q0.0 output, thecontent of MW34 is incremented by one.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    28/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 28/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Program code excerpt

    The figure shows the programmed on and off time for the Q0.0 output. Theswitching duration for each process is 5 seconds and 10 seconds in thesecond clock generator (not shown).

    Figure 6-1

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    29/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 29/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    The figure shows the programmed counter function. The counter is reset

    when count value 20 is reached and the I1. input resets the counter valueto the value 1.

    Figure 6-2

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    30/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 30/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    6.2 Parameterization of FB STS7 (FB502)

    The operands defined above are entered in the function block STS7.

    Step-by-step instructions

    Table 6-2

    Step Instruction

    1. In the LAD/STL/FBD Editor, open the function block FB502 and scroll to network 2.Overwrite the CLR instruction with the desired operand and load the counter valueinto the int-wert variable.

    The counter value (MW34)is transferred.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    31/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 31/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step Instruction

    2. In network 3, enter the operand for the STOP trigger event. In our example, input I1.1 is used for this process.Note: Programming the STOP trigger event is optional.

    3. The parameterization is completed if the presettings listed below are adequate for

    your monitoring. 100 memory units in the circular buffer 10 entries in the circular buffer after occurrence of the STOP trigger event

    For the information required for changing the default setting please refer to theChapter Parameterization.

    4. Generate the instance data block DB502 for the function block STS7.You generate an instance data block when calling the STS7 block with a Callinstruction (Call STS7, Protocol_DB) in the program.Note: You can also generate the instance data block in the SIMATIC Manager with

    the menu command: Insert > S7 Block > Data Block

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    32/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 32/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step Instruction

    5. If all settings have been made, the function block STS7 can be integrated into anySIMATIC STEP 7 program. Basically, it is not of importance at which point of theprogram STS7 is called. Ideally, it should be called directly behind the block in whichthe bit pattern to be monitored or the integer value is processed.The STS7 block features an output parameter. With the 1 signal, it indicates thatthe recording has been stopped. Optionally you can interconnect the output. In theexample, it was interconnected with the Q0.2 output.

    Copy the blocks to the station in the following sequence: Instance data block (DB502) Function block STS7 (FB502)

    Program with the call of STS7 (in our example OB1)

    Note: Check the date/time setting of the CPU. This requires an online connection tothe station. The time is set using the menu command PLC > Diagnostic/Setting >Set Time of Day.

    6. To start the data recording, perform the following actions. Open the Vat_1 table and start the clock generator with the controlling of the

    I1.0 input (function: Modify to 1). Control input I1.1 after approximately one minute (function: Modify to 1). Wait until output Q0.2 is on status value 1. The recording is completed.

    Note: You can only use the function Modify to 1 or Modify to 0 if no input moduleis plugged.

    7. The online instance data block is now the basis for the subsequent evaluation withMicrosoft Excel. The evaluation and the preparation of the data is shown in the nextchapter.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    33/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 33/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    6.3 Evaluation with Excel

    For the evaluation in Excel you require the STL source of the DI and theExcel file 21902350_ServiceToolS7_Analyse_e.xls. The necessary stepsfor the creation of a chart are listed in the following table.

    Table 6-3

    Step Instruction

    1. Generate an STL source with the current values from the instance data block(DB502).

    In the SIMATIC Manager, change to online mode by clicking this button .Open the instance data block (DB502) and save the DI via Data block > Save.The current values of the DI are now saved in the block folder (on the hard disk).

    2. Return to offline mode and generate the STL source as follows:Open the LAD/STL/FBD Editor and generate the source using the menu commandFile > Generate Source.

    3. Enter an object name (e.g. DI_DB502) for the STL source and confirm the dialogbox by clicking OK.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    34/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 34/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step Instruction

    4. In this dialog box, select the data block DB502 from which you want to generate thesource. Use the arrow button to move the selected block to the Blocks Selectedwindow. Confirm with OK.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    35/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 35/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step Instruction

    5. The STL source with the object name DI_DB502 has now been created in theSources block folder. In the LAD/STL/FBD Editor, open the STL sourceDI_DB502.

    6. Leave the LAD/STL/FBD Editor with the STL source opened.In addition, open the XLS file 21902350_ServiceToolS7_Analyse_e.xls.

    Note: When opening the Excel file it has to be observed to enable the macros. Ifrequired, you have to adapt your security setting.

    7. Select the Description spreadsheet and click the Delete Source button. Thecontent is deleted from the Source spreadsheet.Subsequently click the Delete STS7 NW2 Bits button. The content is deleted fromthe STS7 NW2 Bits spreadsheet.Note: Only has to be performed if the content of the STS7 NW2 Bits data sheetdoes not correspond to network 2 of STS7 or if it is completely empty.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    36/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 36/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step Instruction

    8. Change to the already opened LAD/STL/FBD Editor of the STL source, select theentire content and insert it in Excel in the Source spreadsheet in field A1.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    37/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 37/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step Instruction

    9. In the LAD/STL/FBD Editor, open the function block STS7 and scroll to network 2.Copy the program code from network 2 and insert it in Excel in the STS7 NW2 Bitsspreadsheet in field A1.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    38/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 38/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step Instruction

    10. Change to the Description spreadsheet and click the Preparing of Source button.The source is now prepared in such a way that the user can perform a sensibleanalysis of the data.

    After executing the script, the data sheet looks as shown in the figure below.

    In this spreadsheet, you can now evaluate your bit pattern or the operands and theinteger value (Int-Wert).If you want to display the evaluation in a chart, additionally perform the next steps.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    39/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 39/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step Instruction

    11. For the display of the inputs and outputs in an Excel chart it is required to preparethe information in the Source data sheet with an additional script.Change to the Description spreadsheet and click the Delete Bit Conversionbutton. The content is deleted from the Bit Conversion spreadsheet.

    12. Change to the Source spreadsheet and select the area covering the columns withthe entries Zykluszhler, Int-Wert, Bitmuster (Spalten D-S) and Zeitstempel.You can select any number of rows.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    40/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    V1.0 08/29/05 40/41

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Step Instruction

    13. Copy the area into the Bit Conversion spreadsheet and click the Preparing of BitArea button.

    After running the script, the data sheet looks as shown in the figure below.

    14. In Excel, use the ChartWizard to create the chart for the inputs and outputs. Inthe Standard Types tab, select the Line chart type and the Line chart sub-typeand perform the remaining steps 2 to 4. The finished chart is displayed in theDiagrams spreadsheet and stored.Figure 6-3 shows a typical graphical evaluation of the Bit Conversion spreadsheet.

    15. For the graphical representation of the integer value again call the ChartWizard .When defining the data area, you have to select the Source spreadsheet.Figure 6-4 shows a typical graphical evaluation of the integer valuefrom the Source spreadsheet.

  • 8/2/2019 Collection of PLC Signals in STEP 7 With Subsequent Excel Evaluation Www.otomasyonegitimi.com

    41/41

    Operating Instructions

    STS7 Service Tool for the Analysis of PLC Signals

    CopyrightS

    iemensAG2005Allrightsreserved

    21902350_

    ServiceToolS7_

    Analyse_

    V10_

    e.doc

    21902

    350

    Figure 6-3

    Figure 6-4