You are on page 1of 41

Tool on Control Technology

Collection of PLC Signals in STEP 7 with subsequent Excel Evaluation STS7 Service Tool for the Analysis of PLC Signals

Warranty, Liability and Support

STS7 Service Tool for the Analysis of PLC Signals

Warranty, Liability and Support


We do not accept any liability for the information contained in this document. We do not accept liability, whatever the legal basis, for any damages arising from the use of examples, notes, programs, configuration and performance data, etc. described in this document, except where we are obliged to by the German Product Liability Act or in cases of willful damage or gross negligence, injury to life, body or health, breach of guarantee for the condition of products or items assumed by us, fraudulent concealment of a defect or breach of a substantial contractual obligation. However, claims arising from a breach of a condition which goes to the root of the contract shall be limited to the foreseeable damage which is intrinsic to the contract, unless caused by intent or gross negligence or based on mandatory liability for injury of life, body or health. The above provisions do not imply a change in the burden of proof to your detriment. The Functional Examples do not purport to cover all details or variations in equipment, nor do they provide for every possible contingency. They are not customer-specific solutions. They are only intended to provide support for typical tasks. Every user is responsible for proper operation of the described products. These Functional Examples do not relieve you of the responsibility to use sound practices in application, installation, operation and maintenance. By using this Functional Example you accept that Siemens is not liable for any damages except for those specified in the above liability clause. We reserve the right to make changes in this Functional Example at any time without prior notice. If there are any deviations between the recommendations provided in this Functional Example and other Siemens publications e.g. Catalogs the contents of the other documents have priority. Copyright 2005 Siemens A&D. It is not permissible to transfer or copy these Micro Automation Sets or excerpts of them without first having prior authorization from Siemens A&D in writing. For questions about this document please use the following e-mail address: csweb@ad.siemens.de
Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

Entry ID: 21902350

V1.0

08/29/05

2/41

Foreword

STS7 Service Tool for the Analysis of PLC Signals

Foreword
The functional examples are functional and tested automation solutions based on A&D standard products for easy, fast and inexpensive implementation of automation tasks in automation technology. Each of the available functional examples covers a frequently occurring subtask of a typical customer problem in automation technology. Aside from a list of all required software and hardware components and a description of the way they are connected to each other, the functional examples include the tested and commented code. This ensures that the functionalities described here can be reset in a short period of time and thus also be used as a basis for individual expansions.

Table of Contents
Table of Contents ......................................................................................................... 3
Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

Entry ID: 21902350

1 1.1 1.2 2 2.1 3 3.1 3.2 3.3 4 4.1 4.2 5 5.1 6 6.1 6.2 6.3

Automation Function...................................................................................... 4 Overview........................................................................................................... 4 Advantages/customer benefit ........................................................................... 4 Used Hardware and Software Components ................................................. 5 Overview of the downloads............................................................................... 6 Principle of Operation of FB STS7 ............................................................ 7 Description........................................................................................................ 7 Network structure.............................................................................................. 8 Structure of the instance data block ................................................................. 9 Principle of Operation of the Excel Table................................................... 12 Description...................................................................................................... 12 VBA scripts ..................................................................................................... 17 Parameterization........................................................................................... 21 Adapting the function block............................................................................. 21 Operating Instructions ................................................................................. 27 Introduction ..................................................................................................... 27 Parameterization of FB STS7 (FB502)......................................................... 30 Evaluation with Excel...................................................................................... 33

V1.0

08/29/05

3/41

Automation Function

STS7 Service Tool for the Analysis of PLC Signals

1
1.1

Automation Function
Overview
In industrial plants, it is always possible that sporadic events occur which cannot be located immediately. If, for instance, in a system for conveying containers, one of these containers stops for no apparent reason, the analysis may prove difficult if the cause occurs sporadically or only for a very short period of time. In these cases, monitoring with the standard PG functions (status) does not work. Analyzers are required which record the 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 circular buffer using an Excel table. The function can be used on all CPU versions of SIMATIC S7-300, S7-400, C7 and WinAC.

Figure 1-1
Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

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

V1.0

08/29/05

4/41

Used Hardware and Software Components

STS7 Service Tool for the Analysis of PLC Signals

Used Hardware and Software Components


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

Hardware components
Table 2-1

Component Programming device field PG PS307 load power supply 120/230V AC:24VDC/2A CPU 315-2 DP SIMATIC S7-300, simulated I/O module
Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

No. 1 1

MLFB/Order number 6ES7-711-1DB35-3FB2 6ES7307-1BA00-0AA0

Note Or other PGs Any PS with sufficient power specifications can be used. Or comparable CPU Optional

1 1

6ES7315-2AG10-0AB0 6ES7 374-2XH01-0AA0

21902350

Software components
Table 2-2

Component PC operating system Windows 2000 SP3 or Windows XP Professional Edition SP2 SIMATIC S7 STEP 7 Professional Edition 2004 version 5.3 + SP2 MS Excel/Office 2003 (German version)

MLFB/Order number

Note Order via Microsoft

6ES7810-4CC07-0YA5

Order via Microsoft

V1.0

08/29/05

5/41

Used Hardware and Software Components

STS7 Service Tool for the Analysis of PLC Signals

2.1

Overview of the downloads

Download of the required files You can download the files of this functional example from the same web site from which you downloaded this document. After downloading, the following files have to be available on your computer:
Table 2-3

No. 1. 2.

File name 21902350_ServiceToolS7_CODE.zip 21902350_ServiceToolS7_BIB.zip

Note Includes the loadable functional example. The library includes the original blocks without the user adaptations for the functional example. Table with VBA scripts for the evaluation. You only require one of the two files. Select the respective file: - (..._d.xls) with German comments or - (..._e.xls) with English comments

3.
Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350_ServiceToolS7_Analyse_d.xls 21902350_ServiceToolS7_Analyse_e.xls

21902350

Note

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

V1.0

08/29/05

6/41

Principle of Operation of FB STS7

STS7 Service Tool for the Analysis of PLC Signals

Principle of Operation of FB STS7


This program was realized with the SIMATIC STEP 7 software. The block called ServiceToolS7 (STS7) can be integrated into any SIMATIC STEP 7 program. It is only required to generate the corresponding DI (instance data block). If the block is integrated in the STEP 7 program, it performs its task in the background. The standard program execution is not impaired by the STS7 program block. Its field of application can be all SIMATIC STEP 7 programs in which a change is to be logged.

3.1

Description
The program block is capable of detecting the change of a bit pattern (16 bits) and/or of a word (integer) and of logging this change in an instance data block (DI). When one of these values changes, the current values are saved with cycle counter content and time stamp (date and time) in the associated DI. This DI (instance data block) is designed as circular buffer of which the size can be defined by the user. A programmable trigger function enables a defined stop of the logging. This is particularly important for sporadically occurring events. In addition, a defined number of changes can be logged after the occurrence of the trigger 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 recommend that 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.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

7/41

Principle of Operation of FB STS7

STS7 Service Tool for the Analysis of PLC Signals

3.2

Network structure

Parameterization by the user. The signals to be monitored are entered.

Parameterization by the user. The condition for stopping the data recording is defined.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

Memory depth after STOP trigger can be set. Presetting: 10

V1.0

08/29/05

8/41

Principle of Operation of FB STS7

STS7 Service Tool for the Analysis of PLC Signals

3.3

Structure of the instance data block


The structure of the instance data block is defined in the function block FB STS7. A variable overview is displayed in the interface window of the function block. An output parameter, static data and temporary data were declared. Static data are local data of a function block which are stored in the instance data block and which are retained until the next processing of the block. Temporary data are local data of a block which are stored in the local data stack during the processing of a block and which are no longer available after the processing. The number of memory locations is defined in the Speicher array.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

The user can adapt the array for data storage.

V1.0

08/29/05

9/41

Principle of Operation of FB STS7

STS7 Service Tool for the Analysis of PLC Signals

Output parameters (OUT)


Table 3-1

Parameter 1. TRIG_STOP

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

Static data (STAT) The function block uses the following static variables:
Table 3-2

No. 1. 2. 3.
Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

Variable name int_vergl word_vergl stoppen

Meaning If the integer value changes, the change bit is set. If the bit pattern changes, the change bit is set. Activates the counter for the last 10 entries after the arrival of the STOP trigger. The number of entries can be changed by the user. Stop command in case of more than 10 entries after the occurrence of the STOP trigger event. The data recording is definitely finished. Counter for the last 10 entries after the arrival of the STOP trigger. Date and time of the change. Value indicating where the memory in the DB for the data recording starts. Stores the old integer value for the new value comparison. Stores the old bit pattern for the new value comparison. Indicates the length of the structure of the Speicher array. Pointer offset Number of memory locations (structure) Value of the cycle counter Structure of the data recording. The size is indicated as array in the data type e.g. array [1..100] Of Struct.

4.
21902350

STOPP

5. 6. 7. 8. 9. 10. 11. 12. 13. 14.

fin_Eintr Zeit Anfang alt_int alt_word Laenge naechstEintr AnzahlSp Zyklen Speicher (array) Zykluszaehler int_Wert Bitmuster Zeitstempel

V1.0

08/29/05

10/41

Principle of Operation of FB STS7

STS7 Service Tool for the Analysis of PLC Signals

Temporary data (TEMP)


Table 3-3

No. 1. 2. 3. 4. 5. 6. 7. 8.

Variable name Bit_0 bis Bit_7 Bit_8 bis Bit_15 Fehlinfo int_Wert DBreg DIreg AR1reg AR2reg

Meaning Bits of the bit pattern to be monitored in the local data byte LB 0 Bits of the bit pattern to be monitored in the local data byte LB 1 Error information of SFC1 (reading system time) is currently not evaluated. Stores the current integer value Stores the value of the DB register Stores the value of the DI register Stores the value of address register 1 Stores the value of address register 2

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

11/41

Principle of Operation of the Excel Table

STS7 Service Tool for the Analysis of PLC Signals

4
4.1

Principle of Operation of the Excel Table


Description
To prepare the logging stored in the instance data block for an Excel evaluation, the Excel workbook 21902350_ServiceToolS7_Analyse_e.xls is provided. The following spreadsheets are included in this workbook:
Table 4-1

EXCEL sheet 1 2 3

Name Description Source STS7 NW2 Bits

Description Includes a brief description with the buttons for executing the individual functions. Includes the STL source of the current instance data block DI. Includes the signals and values to be monitored. The content is simply copied from network 2 of FB STS7. (Copy & Paste function). Includes the data records of the monitored signals. The charts for the bit evaluation and the integer value are stored.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

4 5
21902350

Bit Conversion Diagrams

Opening the workbook Open the XLS workbook using a file browser to select the above-mentioned XLS file with a double-click. Alternatively you can also start MS Excel via the Windows start button Start > Programs > Microsoft Office > Microsoft Office Excel 2003.... Use the file command File > Open to select your storage folder and open the above-mentioned XLS file. The security warning is acknowledged by clicking the Enable macros button.

V1.0

08/29/05

12/41

Principle of Operation of the Excel Table

STS7 Service Tool for the Analysis of PLC Signals

Spreadsheet Description In this spreadsheet, the sequence is described and the VBA scripts are started. The flowchart shows you the necessary steps for the preparation of the STL source in an Excel table. When activated, the integrated buttons execute the corresponding VBA script. To-do lists are located between the individual buttons which have to be 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 is available as STL source.

Figure 4-1

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

13/41

Principle of Operation of the Excel Table

STS7 Service Tool for the Analysis of PLC Signals

Spreadsheet Source The user copies the current content of the instance data block previously generated as STL source into this spreadsheet. When copying the STL source, it has to be observed that the entire content from the first row DATA_BLOCK Protocol_DB up to and including the end identifier END_DATA_BLOCK is selected.
Figure 4-2

First row of the STL source

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

Last row of the STL source

V1.0

08/29/05

14/41

Principle of Operation of the Excel Table

STS7 Service Tool for the Analysis of PLC Signals

Spreadsheet STS7 NW2 Bits The user copies network 2 of the function block STS7 into this spreadsheet. The bits to be monitored and the integer value are programmed in this network. With the VBA script Quelle, the operand names are read and entered in the Source spreadsheet.
Figure 4-3

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

15/41

Principle of Operation of the Excel Table

STS7 Service Tool for the Analysis of PLC Signals

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

Figure 4-4

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

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

Operand is on 0 signal 1 signal

Bit no. 15 30 31 14 28 29 13 26 27 12 24 25 11 22 23 10 20 21 9 18 19 8 16 17 7 14 15 6 12 13 5 10 11 4 8 9 3 6 7 2 4 5 1 2 3 0 0 1

V1.0

08/29/05

16/41

Principle of Operation of the Excel Table

STS7 Service Tool for the Analysis of PLC Signals

4.2

VBA scripts
The data recording in the data block (DI) is prepared in Excel tables with the provided VBA scripts. The database for the VBA scripts is a manually created STL source from the current instance data block. The scripts delete not required strings such as variable names or comments, they delete STEP 7 type identifiers and allocate the recorded information in rows and columns. After the execution of the scripts, a table is available to the user with which he can easily evaluate the monitored signals/values or edit them graphically as charts. The preparation of the data is realized with five tables and five program modules.

VBA scripts
Table 4-3
Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

Script 1 2
21902350

Name delQuelle delBits delUmstellung Quelle Aufbereiten

Function Deletes the content of the Source table Deletes the content of the STS7 NW2 Bits table Deletes the content of the Bit Conversion table Processes the copied STL source (ASCII code), sorts and allocates the data in rows and columns. Prepares the bit pattern for a chart evaluation.

3 4 5

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

V1.0

08/29/05

17/41

Principle of Operation of the Excel Table

STS7 Service Tool for the Analysis of PLC Signals

Step 1:
String before the preparation

String after the preparation

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

Table 4-4

Program code z = 20 S6: inhalt = Cells(z, 2) If Mid(inhalt, 1, 16) = "Zykluszaehler :=" Then za = z GoTo S7 Else: z = z + 1 GoTo S6 End If S7: inhalt = Cells(z, 1) If Mid(inhalt, 1, 8) = "END_DATA" Then ze = z - 1 GoTo S8 Else: z = z + 1 GoTo S7 End If S8: Range(Cells(za, 2), Cells(ze, 2)).Select Selection.TextToColumns Destination:=Range("B20"), _ DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 9), Array(16, 1))
21902350

Explanation In the Source data sheet, searches the text entry Zykluszaehler:= from the position (row 20, column 2). The determined row no. is entered in the za variable.

----The data end is searched for and the determined row no. is entered in the ze variable.

The area is selected. Subsequently the cells are analyzed and the values, e.g. L#221456;, are copied into the columns from position B20 without the text "Zykluszaehler :=".

V1.0

08/29/05

18/41

Principle of Operation of the Excel Table

STS7 Service Tool for the Analysis of PLC Signals

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

Table 4-5

Program code 'z = 20 inn: inhalt = Cells(z, 2) If Mid(inhalt, 1, 15) = "" Then GoTo 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+1 GoTo inn out: z = 20

Explanation If the content of the cell (row 20, column 2) is not empty, the position of the ; character is searched for.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

The position is stored in the i3 variable. The cell is selected. In the selected cell, the numerical string is extracted and again copied into the same cell. This eliminates the semicolon. The row number is increased and subsequently the jump to the start of the loop takes place.

V1.0

08/29/05

19/41

Principle of Operation of the Excel Table

STS7 Service Tool for the Analysis of PLC Signals

Step 3: In this part, the last L# characters which are not required are removed from the actual numerical string. The L# character is the STEP 7 code for a 32 bit integer constant not required for the evaluation.

String before the preparation

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

String after the preparation

21902350

Table 4-7

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

Explanation The string in the inhalt variable (e.g. L#221456) is to be evaluated. The Mid function returns the first character of the string. The i variable includes the position of the # character. The i2 variable includes the entire length of the string. With the Mid function, the numerical string is assigned to the bitwert variable. The current cell is overwritten with the content of the bitwert variable.

If Mid(inhalt, 1, 1) = "L" Then i = InStr(Cells(z, 2), "#") i2 = Len(Cells(z, 2)) bitwert = Mid(Cells(z, 2), i + 1, i2 - i) Cells(z, 2) = bitwert

z=z+1 GoTo in2 End If

V1.0

08/29/05

20/41

Parameterization

STS7 Service Tool for the Analysis of PLC Signals

5
5.1

Parameterization
Adapting the function block
Before ServiceToolS7 (STS7) can be integrated into a SIMATIC STEP 7 program, it has to be adapted to the program for the analysis. These changes 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 are possible 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 the block. The integer value (integer 16bits) to be monitored is loaded instead of the load instruction (L 0). When allocating the bits, it is required that each bit to be logged is individually transferred to the local data (0.0...0.7, 1.0...1.7). The names of the symbolic identifiers for the local data are: #Bit_0...#Bit15. The relevant CLR command lines are overwritten with the operands to be monitored (e.g. U E 0.1). Logic operations or comparisons are also permissible. The CLR instructions are used as wildcards. In the status word, the CLR command sets the RLO to signal status 0. Example 1: U U = I 0.1 M 10.1 #Bit_1
Shows the allocation of an operand linking to the logging bit #Bit_1.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

Example 2: L L == I = DB10.DBW 40 MW 30 #Bit_2


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

V1.0

08/29/05

21/41

Parameterization

STS7 Service Tool for the Analysis of PLC Signals

Example 3: //bergabe des int_wertes L MW50 T #int_Wert


Transfer of the integer to be monitored (16bits).

The figure below shows network 2 in its original status, in which the allocations are later programmed.
Figure 5-1

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

22/41

Parameterization

STS7 Service Tool for the Analysis of PLC Signals

Stopping the logging (trigger event) In network 3 of the function block STS7, the user is provided with the option of stopping the logging defined by a specific trigger event. This is particularly important for sporadically occurring events. A logic operation which occurs in case of an error has to be programmed for the trigger event. If available, a fault bit is the best solution. After the occurrence of the trigger event, the next ten changes of the operands to be monitored are logged (see network 6). Due to this, also the direct effects after the occurrence of the trigger event are captured and support you during the error analysis of process sequences which, in the case of sporadic faults, are frequently difficult to analyze. If no signal is available, leave the CLR instructions.
Figure 5-2

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

Programming of the condition for stopping the logging. Overwrite the CLR instruction.

Programming of the condition for continuing the logging. Overwrite the CLR instruction.

In the lower part of network 3, you can program the condition for a continuation of the logging.
Note

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

V1.0

08/29/05

23/41

Parameterization

STS7 Service Tool for the Analysis of PLC Signals

If the preset ten entries are inadequate, this can be changed in network 6 of the function block STS7.
Figure 5-3

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

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

Defining memory location for the logging The number of storing options for the logging depends on the length of the instance 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 assigned with the following variable structure: - Zykluszhler - int_Wert - Bitmuster - Zeitstempel You can increase the number of memory locations by changing the length of 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 the memory is full, it is again overwritten from the start (circular buffer). If the number of memory locations is increased, the maximum possible length of a data block and the main memory of the respective CPU have to be considered. For a CPU315-2DP, the maximum length of a data block is 16420 bytes. Consequently, the maximum number of memory locations is limited to 1022.
Note

21902350

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

V1.0

08/29/05

24/41

Parameterization

STS7 Service Tool for the Analysis of PLC Signals

If, for instance, you want to parameterize a DI with 400 memory locations, proceed as follows: Step-by-step instructions
Table 5-1

Step 1. 2.

Procedure If not yet done, open the SIMATIC Manager and open the function block FB502 with the LAD/STL/FBD Editor. In the variable overview, click the static data and enter the value 400 instead of 100 in the ARRAY data type.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

Array [1..400] of Struct

3.

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

V1.0

08/29/05

25/41

Parameterization

STS7 Service Tool for the Analysis of PLC Signals

Step 4.

Procedure 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.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

26/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

6
6.1

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

Scenario Some operands in the function block FC100 are to be logged for a signal evaluation. The function FC100 includes simple clock generators for two outputs and a counter (C1) which is incremented depending on the Q0.0 output. The Q0.2 output indicates the end of the data recording. The following operands are captured:
Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

Table 6-1

No.
21902350

Operands Input I1.0 Input I1.1

Description With this operand, the clock generator is enabled (start) With this operand, the counter C1 is set to the count value 1 (MW32). In addition, the STOP trigger of the function block STS7 is set. This terminates the data recording after ten additional modification entries. The output remains switched on for five seconds and switched off for five seconds. The output remains switched on for ten seconds and switched off for ten seconds. An output parameter of the STS7 block. Signal 1 means: End of the data transmission. At a positive edge of the Q0.0 output, the content of MW34 is incremented by one.

1. 2.

3. 4. 5.

Output Q0.0 Output Q0.1 Output Q0.2

6.

Counter value MW34

V1.0

08/29/05

27/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

Program code excerpt The figure shows the programmed on and off time for the Q0.0 output. The switching duration for each process is 5 seconds and 10 seconds in the second clock generator (not shown).
Figure 6-1

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

28/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

The figure shows the programmed counter function. The counter is reset when count value 20 is reached and the I1. input resets the counter value to the value 1.
Figure 6-2

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

29/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

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 1.

Instruction 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 value into the int-wert variable.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

The counter value (MW34) is transferred.

V1.0

08/29/05

30/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

Step 2.

Instruction In network 3, enter the operand for the STOP trigger event. In our example, input I 1.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 the Chapter Parameterization.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

4.

21902350

Generate the instance data block DB502 for the function block STS7. You generate an instance data block when calling the STS7 block with a Call instruction (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

V1.0

08/29/05

31/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

Step 5.

Instruction If all settings have been made, the function block STS7 can be integrated into any SIMATIC STEP 7 program. Basically, it is not of importance at which point of the program STS7 is called. Ideally, it should be called directly behind the block in which the bit pattern to be monitored or the integer value is processed. The STS7 block features an output parameter. With the 1 signal, it indicates that the recording has been stopped. Optionally you can interconnect the output. In the example, 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 to the station. The time is set using the menu command PLC > Diagnostic/Setting > Set Time of Day.

6.
Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

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 module is plugged.

21902350

7.

The online instance data block is now the basis for the subsequent evaluation with Microsoft Excel. The evaluation and the preparation of the data is shown in the next chapter.

V1.0

08/29/05

32/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

6.3

Evaluation with Excel


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

Table 6-3

Step 1.

Instruction 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 command File > Generate Source. Enter an object name (e.g. DI_DB502) for the STL source and confirm the dialog box by clicking OK.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

3.

21902350

V1.0

08/29/05

33/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

Step 4.

Instruction In this dialog box, select the data block DB502 from which you want to generate the source. Use the arrow button to move the selected block to the Blocks Selected window. Confirm with OK.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

34/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

Step 5.

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

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

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. If required, you have to adapt your security setting.

7.

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

V1.0

08/29/05

35/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

Step

Instruction

8.

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

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

36/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

Step 9.

Instruction 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 Bits spreadsheet in field A1.

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

37/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

Step 10.

Instruction 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 sensible analysis of the data.

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

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

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

V1.0

08/29/05

38/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

Step 11.

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

12.

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

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

V1.0

08/29/05

39/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals

Step 13.

Instruction Copy the area into the Bit Conversion spreadsheet and click the Preparing of Bit Area button.

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

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

14.

to create the chart for the inputs and outputs. In In Excel, use the ChartWizard the Standard Types tab, select the Line chart type and the Line chart sub-type and perform the remaining steps 2 to 4. The finished chart is displayed in the Diagrams spreadsheet and stored. Figure 6-3 shows a typical graphical evaluation of the Bit Conversion spreadsheet. 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 value from the Source spreadsheet. .

15.

V1.0

08/29/05

40/41

Operating Instructions

STS7 Service Tool for the Analysis of PLC Signals


Figure 6-3

Copyright Siemens AG 2005 All rights reserved 21902350_ServiceToolS7_Analyse_V10_e.doc

21902350

Figure 6-4

V1.0

08/29/05

41/41

You might also like