application example 05/2016 creating an f(x) trend view for … · 2016. 5. 13. · warranty and...

24
https://support.industry.siemens.com/cs/ww/de/view/109481693 Application Example 05/2016 Creating an f(x) Trend View for Comfort Panels and Runtime Advanced Comfort Panels and WinCC Runtime Advanced V13 SP1

Upload: others

Post on 07-Oct-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

https://support.industry.siemens.com/cs/ww/de/view/109481693

Application Example 05/2016

Creating an f(x) Trend View for

Comfort Panels and Runtime

Advanced Comfort Panels and WinCC Runtime Advanced V13 SP1

Page 2: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

Warranty and Liability

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

Warranty and Liability

Note The Application Examples are not binding and do not claim to be complete with regard to configuration, equipment or any contingencies. The Application Examples do not represent customer-specific solutions. They are only intended to provide support for typical applications. You are responsible for the correct operation of the described products. These Application Examples do not relieve you of the responsibility of safely and professionally using, installing, operating and servicing equipment. When using these Application Examples, you recognize that we cannot be made liable for any damage/claims beyond the liability clause described. We reserve the right to make changes to these Application Examples at any time and without prior notice. If there are any deviations between the recommendations provided in this Application Example and other Siemens publications – e.g. Catalogs – the contents of the other documents shall have priority.

We do not accept any liability for the information contained in this document. Any claims against us – based on whatever legal reason – resulting from the use of the examples, information, programs, engineering and performance data etc., described in this Application Example shall be excluded. Such an exclusion shall not apply in the case of mandatory liability, e.g. under the German Product Liability Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life, body or health, guarantee for the quality of a product, fraudulent concealment of a deficiency or breach of fundamental contractual obligations (“wesentliche Vertragspflichten”). The compensation for damages due to a breach of a fundamental contractual obligation is, however, limited to the foreseeable damage, typical for the type of contract, except in the event of intent or gross negligence or injury to life, body or health. The above provisions do not imply a change of the burden of proof to your detriment. Any form of duplication or distribution of these Application Examples or excerpts hereof is prohibited without the expressed consent of Siemens AG.

Security informa-

tion

Siemens provides products and solutions with industrial security functions that support the secure operation of plants, systems, machines and networks.

In order to secure plants, systems, machines and networks against cyber threats it is necessary to implement (and to maintain continuously) a holistic, state-of-the-art industrial security concept. With this in mind, Siemens’ products and solutions are only part of such a concept.

It is the client’s responsibility to prevent unauthorized access to his plants, systems, machines and networks. Systems, machines and components should only be connected with the company’s network or the Internet, when and insofar as this is required and the appropriate protective measures (for example, use of firewalls and network segmentation) have been taken.

In addition, the recommendations by Siemens regarding the respective protective measures have to be observed. For more information on industrial security, visit http://www.siemens.com/industrialsecurity.

Siemens’ products and solutions undergo continuous development in order to make them even more secure. Siemens explicitly recommends to carry out updates as soon as the respective updates are available and always only to use the current product versions. The use of obsolete or no longer supported versions can increase the risk of cyber threats.

In order to always be informed about product updates, subscribe to the Siemens Industrial Security RSS Feed at http://www.siemens.com/industrialsecurity.

Page 3: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

Table of Contents

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 3

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

Table of Contents Warranty and Liability ................................................................................................. 2

1 Task ..................................................................................................................... 4

1.1 Overview............................................................................................... 4

2 Solution............................................................................................................... 6

2.1 Overview............................................................................................... 6 2.2 Hardware and software components ................................................... 7 2.2.1 Validity .................................................................................................. 7 2.2.2 Components used ................................................................................ 7

3 Basics ................................................................................................................. 8

4 Function Principle ............................................................................................. 9

4.1 General overview ................................................................................. 9 4.2 PLC program ...................................................................................... 10 4.3 HMI program ...................................................................................... 12 4.3.1 TrendControl ...................................................................................... 12 4.3.2 TrendControlSQL ............................................................................... 14 4.3.3 Tag management ............................................................................... 16

5 Installation and Commissioning .................................................................... 17

5.1 Installing the hardware ....................................................................... 17 5.2 Installing the software (download) ...................................................... 17 5.3 Commissioning ................................................................................... 17

6 Operating the Application ............................................................................... 20

6.1 Start screen ........................................................................................ 21 6.2 f(x) trend view – CSV file .................................................................... 22 6.3 f(x) trend display – SQL database ...................................................... 23

7 Links & Literature ............................................................................................ 24

8 History............................................................................................................... 24

Page 4: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

1 Task

1.1 Overview

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 4

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

1 Task

1.1 Overview

Introduction

It is often necessary to display technical processes of a series of value pairs (e.g. pressure and temperature in thermo-dynamic processes) in trend form. Prerequisite for this is the option to be able to display a functional correlation independent of time.

An f(x) trend view in WinCC Comfort/Advanced always offers this option. However, it its technical nature it is not independent in terms of time, since the value pairs of x and f(x) are assigned based on the recorded time stamp.

When using an f(x) trend view, the following restrictions therefore apply:

Both time stamps of the values of a pair have to be absolutely identical.

Archive tags have to be acquired “cyclically-continuously”, when archiving “On demand” (different time stamps) there is no display.

Array tags are not supported.

Page 5: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

1 Task

1.1 Overview

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 5

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

Overview of the automation task

The figure below provides an overview of the automation task:

Figure 1-1

Index

Value pair Array [0]

Value pair Array [1]

Value pair Array [2]

Value pair Array [3]

Value pair Array [n]

X value 0.0 5.0 12.5 20.0 …

Y value 25.0 40.0 50.0 40.0 …

Description of the automation task

The application example is to be implemented for Comfort Panel and RT Advanced.

Two arrays of real values (X value and Y value) in the controller are to be illustrated in an f(x) trend view.

An array includes a series of values of a tag; both arrays together illustrate a series of value pairs (data area).

The number of illustrated value pairs is specified by the length of the two arrays.

The display of the trends is to be in form of configurable mathematical functions, in order to illustrate the performance of the f(x) trend view.

Page 6: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

2 Solution

2.1 Overview

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 6

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

2 Solution

2.1 Overview

Schematic layout

The following figure shows a screenshot of the configuration at runtime.

Figure 2-1

Advantages

The solution presented here offers you the following advantages:

Time and cost savings through ready-programmed functions.

Expandability regarding own requirements

No restrictions of the f(x) trend view

Can be used for Comfort Panels and WinCC Advanced RT

Topics not covered in this application

This application does not include a description of the basic programming of controllers and HMI.

Basic knowledge of these topics is required.

Assumed knowledge

Basic knowledge of programming with VB scrip and SCL is assumed

Page 7: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

2 Solution

2.2 Hardware and software components

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 7

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

2.2 Hardware and software components

2.2.1 Validity

This application is valid for:

STEP 7 V13 SP1 or higher

WinCC Comfort V13 SP1 or higher

WinCC Advanced V13 SP1 or higher

2.2.2 Components used

The application has been created with the following components:

Hardware components

Table 2-1

Component Qty Article number Note

TP1200 Comfort 1 6AV2124-0MC01-0AX0 Not required when using WinCC Advanced R. Alternatively, any other Comfort Panel can also be used. In this case, a migration (device exchange) is required.

CPU 1516-3PN/DP 1 6ES7516-3AN00-0AB0 Alternatively, any other CPU from the S7-1200 or S7-1500 family can be used.

Software components

Table 2-2

Component Qty Article number Note

STEP 7 Professional V13 SP1

1 6ES7822-1..03-..

WinCC Engineering V13 SP1

1 6AV210.-….3-0

WinCC Runtime Advanced V13 SP1

1 6AV2104-….3-0 Only required when using a WinCC Advanced RT.

Example files and projects

The following list includes all files and projects that are used in this example.

Table 2-3

Component Note

109481693_CODE_v10.zip This zip file contains STEP 7 and the WinCC project.

109481693_DOC_v10_en.pdf This document.

Page 8: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

3 Basics

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 8

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

3 Basics There are a number of particularities that has to be observed for the f(x) trend view in the TIA Portal.

The display of the data points of an archive in the f(x) trend view is carried out using a script, in order to guarantee the correct format of the archive data.

The script ensures that in the tag archive

two arrays of real values (X value and Y value) are stored in the controller as a series of individual values.

the individual value pairs are stored with an identical time stamp.

the values can be archived “On demand”.

the structure is according to a standard archive.

As a rule, a CSV archive is used for the display of archive data in the f(x) trend view since it can be easily written via script.

If you are using the WinCC Advanced RT instead of a Comfort Panel, you have furthermore the option to archive in a SQL database. In the example project both solutions have been implemented.

Note In order for the script to be able to write into the CSV archive, all archives have to be closed first. During this time, no other archive data can be stored. For the solution with the SQL database, it can be directly written into the database, without influencing other archives.

NOTICE Risk of data loss when writing in the CSV archive

In order for a script to be able to write into a CSV archive, all archives have to be closed at runtime. During this time other archives have to be buffered that are only rewritten after opening the archives.

A maximum of 300 values have to be buffered to prevent a loss of data. If you are using other archives in your project for which more than 300 values could accrue in the time of processing the script, there will be a loss of data! This is also the case for message archives!

Page 9: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

4 Function Principle

4.1 General overview

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 9

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

4 Function Principle

4.1 General overview

In this example value pairs x and f(x) of a mathematical function are calculated in the controller (CPU 1516-3PN/DP) and written into a data block. However, in principle, any other data sources can also be visualized.

The program included in the example, only serves for the creation of an exemplary value pair of x and y. Via the HMI three mathematical functions can be provided with parameters.

By pressing the appropriate buttons in HMI (exponential, parabolic, and sinus function) the functions are calculated in the “CreateDataPair” function block and the value pairs are stored in the “CreateDataPair_DB” instance data block.

The length of the data area (array) specifies the number of displayed value pairs. If a different number of value pairs are to be displayed, the length of the arrays has to be adapted:

Length of the array for x and y values (“statX” and “statY”) in the declaration part of the FB

Number of loop cycles “#statIndex” in the program part of the FB

Number of loop cycles “ObjLoopCount” in the program part of the VB script “TrendControl”

Data record per archive in the tag archive (number = 2 x number of elements)

f(x) trend view > X axis > value range

f(x) trend view > Y axis > value range

f(x) trend view > trend > data range > measuring points (do not change date/time)

Note Please note that counting within an array always starts with 0. For e.g. 100 values the last array element has number 99 (n-1).

Page 10: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

4 Function Principle

4.2 PLC program

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 10

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

4.2 PLC program

The PLC program only consists of a “CreateDataPair” function block and its assigned instance data block “CreateDataPair_DB”.

The function block calculates the value pairs x and f(x) of up to three mathematical functions and stores them in two arrays within the instance data block. Via the HMI these functions can be provided with parameters and the calculation can be triggered.

Declaration

Figure 4-1

Page 11: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

4 Function Principle

4.2 PLC program

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 11

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

Table 4-1

Name Function

E_Factor Parameter exponential function: Factor

E_TimeConstant Parameter exponential function: Time constant

E_OffsetY Parameter exponential function: Offset y

P_Form Parameter parabolic function: Form

P_OffsetX Parameter parabolic function: Offset x

P_OffsetY Parameter parabolic function: Offset y

S_Length Parameter sinus function: Wavelength

S_Amplitude Parameter sinus function: Amplitude

S_offsetX Parameter sinus function: Offset x

S_offsetY Parameter sinus function: Offset y

TriggerFunction Trigger event for calculating the function and storage of the value pairs in the arrays

statIndex Pointer for the array elements

statExponent Element of the exponential function

statX Array of x values

statY Array of y values

Page 12: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

4 Function Principle

4.3 HMI program

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 12

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

4.3 HMI program

Since the f(x) trend view always needs a time stamp for referencing, a fictitious time stamp is used in this example. However, this time stamp is no longer visible for the user at runtime.

A tag archive is used for the display which is also configured in TIA Portal. The archive itself is then written by a script.

4.3.1 TrendControl

With the “TrendControl” VB script, the values are written into an archive in CSV format. The configuration of the CSV file must not be changed since otherwise the trend view does no longer detect it as archive and it cannot display the values.

Function TrendControl()

Dim timestring, ObjFile, ObjFileSystem, arrx, arry, ObjFilePath,

ObjFileName, ObjLoopCount, ObjIndex, ObjTime, Objx, Objy

Const varNametagX = "LogValX"

Const varNametagY = "LogValY"

Const splitsign = ";"

Const ForAppending = 8

'Get current datetime

timestring = "'" & Now & "'"

Set ObjFileSystem = CreateObject("Scripting.FileSystemObject")

Set arrx = SmartTags("Input_X")

Set arry = SmartTags("Input_Y")

ObjLoopCount = UBound(arrx)

ObjFilePath = "C:\Logs\" 'File location for tag log

ObjFileName = "TrendControl_f(x)0.csv" 'Name of tag log

'Closing logs

CloseAllLogs

Do While SmartTags("LogsAreClosed") = False 'Wait until all logs are closed

Loop

'Deleting old file

On Error Resume Next

ObjFileSystem.DeleteFile ObjFilePath & ObjFileName, True

If Err.Number <> 0 Then

ShowSystemAlarm "Error: Deleting old file not possible. " & Err.Number & "

" & Err.Description

Err.Clear

OpenAllLogs

TrendControl = 1 'RetVal: 1= error deleting old file

Exit Function

End If

'Create new archive as csv file

Set ObjFile = ObjFileSystem.OpenTextFile(ObjFilePath & ObjFileName,

ForAppending, True)

If Err.Number <> 0 Then

ShowSystemAlarm "Error: Open file not possible. " & Err.Number & " " &

Err.Description

Err.Clear

OpenAllLogs

TrendControl = 2 'RetVal: 2= error creating new file

Exit Function

End If

'Write header into data log

ObjFile.WriteLine("VarName" & splitsign & "TimeString" & splitsign &

"VarValue" & splitsign & "Validity" & splitsign & "Time_ms")

1

2

3

Page 13: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

4 Function Principle

4.3 HMI program

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 13

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

If Err.Number <> 0 Then

ShowSystemAlarm "Error: Can not write to data log. " & Err.Number & " " &

Err.Description

Err.Clear

OpenAllLogs

TrendControl = 3 'RetVal: 3= error writing to new file

Exit Function

End If

'Write entries into data log

For ObjIndex = 0 To ObjLoopCount

'Write x element to log

Objx = arrx(ObjIndex)

ObjFile.WriteLine(varNametagX & splitsign & timestring & splitsign & Objx &

splitsign & "1" & splitsign & ObjIndex)

'Write y element to log

Objy = arry(ObjIndex)

ObjFile.WriteLine(varNametagY & splitsign & timestring & splitsign & Objy &

splitsign & "1" & splitsign & ObjIndex)

Next

ObjFile.Close

OpenAllLogs

Do While SmartTags("LogsAreClosed") = True 'Wait until all logs are opened

Loop

'End function

ShowSystemAlarm "Load new file"

Set ObjFile = Nothing

Set ObjFileSystem = Nothing

TrendControl = 0 'RetVal: 0= no error occurred

End Function

Table 4-2

Point Script excerpt Description

1. Const varNametagX = "LogValX"

Const varNametagY = "LogValY"

Const splitsign = ";"

The tag "LogValX" and “LogValY” is used as archive tag. Adjust your archive or the script accordingly.

The “;” separator is used in the archive (CSV file) and depends on the country setting of the operating system.

2. timestring = "'" & Now & "'"

This is where the current date/time stamp for the archive entries is formed. Adjust it accordingly, if required.

3. ObjFilePath = "C:\Logs\" 'File location for tag log ObjFileName = "TrendControl_f(x)0.csv" 'Name of tag log

This is where the archive path and the archive name is specified. Adjust your archive or the script accordingly.

4. ShowSystemAlarm "Load new file" Here, a note is output via the message display in the project that the script drew a new f(x) trend. Adjust the language and the text, if required.

4

Page 14: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

4 Function Principle

4.3 HMI program

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 14

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

4.3.2 TrendControlSQL

With the “TrendControlSQL” VB script the values are written into an archive of a SQL database. The configuration of the SQL database must not be modified, otherwise the trend view no longer detects it as archive and it can no longer display the values.

Note In order to be able to use the SQL database it has to have been created in the operating system. For more information refer to chapter “Getting Started”.

Function TrendControlSQL()

On Error Resume Next

'Define constants for the script, like logfilename, tagname,...

Const ObjLoopCount = 99

Const varNametagX = "LogValXSQL"

Const varNametagY = "LogValYSQL"

Const validity = 1

Const splitsign = ","

'tablename of logs in master database

Const tableX = "[master].[dbo].[LogXSQL0]"

Const tableY = "[master].[dbo].[LogYSQL0]"

Dim arrX, arrY, fso, conn, rst,count,timeString, sql, TimeMS

'get current datetime

timeString = "'" & Now & "'"

'clear all dataset

ClearLog hmiDataLog, "LogXSQL"

ClearLog hmiDataLog, "LogYSQL"

For count = 0 To 100000

Next

'set an instance of database

Set conn = CreateObject("ADODB.Connection")

Set rst = CreateObject("ADODB.Recordset")

'open the connection to database with DataSourceName "LogSQL"

conn.Open "Provider=MSDASQL;DSN=LogSQL"

'copy array to internal tag

Set arrX = SmartTags("Input_X")

Set arrY = SmartTags("Input_Y")

'write the arrays into database

For count = 0 To ObjLoopCount

TimeMS = TimeMS + 1

sql = "INSERT INTO " & tableX &

"([VarName],[TimeString],[VarValue],[Validity],[Time_ms]) VALUES("_

& varNametagX & splitsign & timeString & splitsign &

Replace(arrX(count),",",".") & splitsign & validity & splitsign &

TimeMS & ")"

Set rst = conn.Execute(sql)

sql = "INSERT INTO " & tableY &

"([VarName],[TimeString],[VarValue],[Validity],[Time_ms]) VALUES("_

& varNametagY & splitsign & timeString & splitsign &

Replace(arrY(count),",",".") & splitsign & validity & splitsign &

TimeMS & ")"

Set rst = conn.Execute(sql)

Next

'close connection and return TimeMS value for next run

conn.Close

1

3

2

4

Page 15: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

4 Function Principle

4.3 HMI program

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 15

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

Set rst = Nothing

Set conn = Nothing

If Err.Number <> 0 Then

ShowSystemAlarm "Problem writing to SQL. Maybe the logs are

closed?"

Err.Clear

TrendControlSQL = 1

Else

TrendControlSQL = 0

End If

End Function

Table 4-3

Point Script excerpt Description

1. Const ObjLoopCount = 99

Const varNametagX = "LogValXSQL"

Const varNametagY = "LogValYSQL"

Const splitsign = ","

The “ObjLoopCount” constant is specified by the size of the array and has to be adjusted accordingly.

The tag "LogValXSQL" and “LogValYSQL” is used as archive tag. Adjust your archive or the script accordingly.

The “;” separator is used in the archive (SQL database) and depends on the country setting of the operating system.

2. timestring = "'" & Now & "'"

This is where the current date/time stamp for the archive entries is formed. Adjust it accordingly, if required.

3. For count = 0 To 100000 Next

The loop serves as a break until deleting the old database entries is completed.

In the process, deleting is often possible between two measurements so that this loop is not required.

4. conn.Open "Provider=MSDASQL;DSN=LogSQL"

Here, the database name is specified. Adjust your database name or the script accordingly.

5. ShowSystemAlarm "Problem writing to SQL. Maybe the logs are closed?"

Here, the note that an error occurred during runtime is output via the message display in the project. Adjust the language and the text, if required.

5

Page 16: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

4 Function Principle

4.3 HMI program

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 16

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

4.3.3 Tag management

Figure 4-2

Table 4-4

Name Function

CreateArchiveRetVal Return value of the VBS function

E_Factor Parameter exponential function: Factor

E_OffsetY Parameter exponential function: Offset y

E_TimeConstant Parameter exponential function: Time constant

Input_X Array of x values

Input_Y Array of y values

LogsAreClosed Event archive closed

Notice

This tag requires the system messages of the HMI

LogValX Archive tag for the x value (only for CSV archive)

LogValXSQL Archive tag for the x value (only for SQL database)

LogValY Archive tag for the y value (only for CSV archive)

LogValYSQL Archive tag for the y value (only for SQL database)

P_Form Parameter parabolic function: Form

P_OffsetX Parameter parabolic function: Offset x

P_OffsetY Parameter parabolic function: Offset y

S_Amplitude Parameter sinus function: Amplitude

S_Length Parameter sinus function: Wavelength

S_offsetX Parameter sinus function: Offset x

S_offsetY Parameter sinus function: Offset y

TriggerFunction Trigger event for calculating the function and storage of the value pairs in the arrays

Page 17: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

5 Installation and Commissioning

5.1 Installing the hardware

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 17

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

5 Installation and Commissioning Below you will find the required steps for the installation and commissioning of the application example.

5.1 Installing the hardware

For the hardware configuration the modules listed in chapter “Hardware and software components” have been selected. Only a TP1200 Comfort has to be connected with a CPU 1516-3PN/DP via Ethernet.

If you do not have the modules available, you can also simulate the application example. Other information on this can be found in chapter “Commissioning”.

5.2 Installing the software (download)

Table 5-1

Step Description

1. Unzip the “109481693_CODE_v10.zip” file into a directory of your choice.

2. Open the project with TIA Portal V13 SP1 or higher.

3. Adjust the configured hardware according to your requirements at “Devices & Networks”.

4. Open the STEP 7 project and generate it new.

5. Load the technology blocks into the controller and start them.

6. Open the WinCC project and regenerate it.

7. Load the WinCC project into your Comfort Panel and start Runtime.

5.3 Commissioning

Simulating the modules

If you want to test the application example without hardware, please use the following configuration instead of the provided modules:

Table 5-2

Step Description

1. Change the access point of the application in the PG/PC interface to “S7ONLINE (STEP7) -> PLCSIM S7-1200/S7-1500”.

2. Start S7-PLCSIM and download the PLC blocks with “Download to device".

3. Open the SIMATIC PC Station included in the project via “Start simulation".

Archiving with SQL database

If you are using the SIMATIC PC Station provided in the project and you select archiving in a SQL database, the ODBC data source has to be created additionally in the operating system:

Page 18: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

5 Installation and Commissioning

5.3 Commissioning

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 18

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

Table 5-3

Step Description

1. Open the “Administrative Tools” category in the control panel.

Open the “Data Sources (ODBCC)” service.

Select the “User DSN” tab.

2. Press the “Add...” button.

Select the “SQL Server” driver.

Press the “Finish” button.

Page 19: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

5 Installation and Commissioning

5.3 Commissioning

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 19

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

Step Description

3. Select “LogSQL” as data source name.

Select “<Computer name>\WINCCFLEXEXPRESS” as SQL server.

4. Press the “Next” button.

Accept all default settings in the dialogs that follow.

In the summary dialog at the end of the configuration, you can test the connection.

5. Once this is confirmed via the “OK” button, the data source is

configured.

Page 20: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

6 Operating the Application

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 20

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

6 Operating the Application Here, you will find out how to operate the example project.

The opened or downloaded project is a prerequisite for operating the application.

The following description in this chapter relates to WinCC RT Advanced. However, the operation for a Comfort Panel is identical.

There is also the option to use a SQL database instead of a CSV file as archive. This option is only available for WinCC RT Advanced.

Page 21: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

6 Operating the Application

6.1 Start screen

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 21

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

6.1 Start screen

Figure 6-1

Table 6-1

Position Button

1. Start

The start screen of the application example.

2. f(x) trend view – CSV file

Here, you go to the application example which is used for data storage of a CSV file (for Comfort Panel and WinCC RT Advanced).

3. f(x) trend display – SQL database

Here, you go to the application example which is used for data storage of a SQL database (only for WinCC RT Advanced).

4. System

Here you can select the system functions, for example, finish RT.

5. Support

Here you find out more about the Siemens Industry Online Support.

6. Open and close navigation bar

The navigation bar is available in every screen and is always located on the right edge of the screen.

Note For reasons of clarity only the following positions are discussed

2.) “f(x) trend view – CSV file” and

3.) “f(x) trend display – SQL database”

6

1

2

3

4

5

Page 22: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

6 Operating the Application

6.2 f(x) trend view – CSV file

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 22

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

6.2 f(x) trend view – CSV file

Figure 6-2

Table 6-2

Position Button

1. Language switching

Here you can change the language.

2. Alarms view

Here, you can view all current messages. In the event of an error the respective message is output.

3. Update trend

The data points of the instance DB in the controller are written into the CSV file (archive) with a script.

The screen is reselected. The data points from the archive are written into the trend and displayed.

4. Exponential function

Specify the parameters for the exponential function:

– Factor

– Time constant

– Offset y

Write these parameters into the controller with the “exponential function” button.

In the controller, the individual data points for this function are then stored in the instance DB with the parameters specified.

4

5

6

3

1

2

Page 23: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

6 Operating the Application

6.3 f(x) trend display – SQL database

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 23

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

Position Button

5. Parabolic function

Specify the parameters for the parabolic function:

– Form

– Offset x

– Offset y

Write these parameters into the controller with the “parabolic function” button.

In the controller, the individual data points for this function are then stored in the instance DB with the parameters specified.

6. Sinus function

Specify the parameters for the sinus function here:

– Wavelength

– Amplitude

– Offset x

– Offset y

Write these parameters into the controller with the “sinus function” button.

In the controller, the individual data points for this function are then stored in the instance DB with the parameters specified.

6.3 f(x) trend display – SQL database

The display and the operation in the screen correspond to the “f(x) trend view – CSV file” screen. There are the following differences:

The “Update trend” button is assigned to another script.

The data points of the instance DB in the controller are written into the SQL database (archive) with this script.

A SQL database is assigned to the trend view as archive instead of a CSV file.

Note This screen is only available for WinCC RT Advanced.

Please note that an appropriate SQL database has to be created for the script used in the screen.

Creating the SQL database is described in chapter “Function Principle”.

Page 24: Application Example 05/2016 Creating an f(x) Trend View for … · 2016. 5. 13. · Warranty and Liability f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 2 G 6 d Warranty

7 Links & Literature

f(x) trend view for WinCC Entry ID: 109481693, V1.0, 05/2016 24

S

iem

en

s A

G 2

01

6 A

ll ri

gh

ts r

ese

rve

d

7 Links & Literature Table 7-1

Topic

\1\ Siemens Industry Online Support

https://support.industry.siemens.com

\2\ Download page of the entry https://support.industry.siemens.com/cs/ww/de/view/109481693

\3\ Accessing a SQL database via a script

https://support.industry.siemens.com/cs/ww/en/view/26283062

8 History

Table 8-1

Version Date Modifications

V1.0 05/2016 First version