Beruflich Dokumente
Kultur Dokumente
https://support.industry.siemens.com/cs/ww/de/view/109481693
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,
Siemens AG 2016 All rights reserved
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 Siemens provides products and solutions with industrial security functions that support the
informa- secure operation of plants, systems, machines and networks.
tion 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 clients responsibility to prevent unauthorized access to his plants, systems,
machines and networks. Systems, machines and components should only be connected
with the companys 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.
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
Siemens AG 2016 All rights reserved
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.
Siemens AG 2016 All rights reserved
Figure 1-1
Value pair Value pair Value pair Value pair Value pair
Index Array [0] Array [1] Array [2] Array [3] Array [n]
2 Solution
2.1 Overview
Schematic layout
The following figure shows a screenshot of the configuration at runtime.
Figure 2-1
Siemens AG 2016 All rights reserved
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
Assumed knowledge
Basic knowledge of programming with VB scrip and SCL is assumed
Hardware components
Table 2-1
Component Qty Article number Note
TP1200 Comfort 1 6AV2124-0MC01-0AX0 Not required when using
WinCC Advanced R.
Software components
Table 2-2
Component Qty Article number Note
STEP 7 1 6ES7822-1..03-..
Professional
V13 SP1
WinCC Engineering 1 6AV210.-.3-0
V13 SP1
WinCC Runtime 1 6AV2104-.3-0 Only required when using a
Advanced V13 SP1 WinCC Advanced RT.
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.
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.
Siemens AG 2016 All rights reserved
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.
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
Siemens AG 2016 All rights reserved
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).
Declaration
Figure 4-1
Siemens AG 2016 All rights reserved
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
Siemens AG 2016 All rights reserved
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"
1
Const varNametagY = "LogValY"
Const splitsign = ";"
Const ForAppending = 8
'Get current datetime
2 timestring = "'" & Now & "'"
Siemens AG 2016 All rights reserved
End Function
Table 4-2
Point Script excerpt Description
1. Const varNametagX = "LogValX" The tag "LogValX" and LogValY is
Const varNametagY = "LogValY" used as archive tag. Adjust your
archive or the script accordingly.
The ; separator is used in the archive
Const splitsign = ";" (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 This is where the archive path and the
log archive name is specified. Adjust your
ObjFileName = "TrendControl_f(x)0.csv" archive or the script accordingly.
'Name of tag log
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.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
1
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
Siemens AG 2016 All rights reserved
Table 4-3
Point Script excerpt Description
1. Const ObjLoopCount = 99 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.
Const varNametagX = "LogValXSQL"
Adjust your archive or the script
Const varNametagY = "LogValYSQL" accordingly.
The ; separator is used in the archive
Const splitsign = "," (SQL database) and depends on the
country setting of the operating system.
Siemens AG 2016 All rights reserved
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 The loop serves as a break until
Next 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 Here, the database name is specified.
"Provider=MSDASQL;DSN=LogSQL" Adjust your database name or the
script accordingly.
5. ShowSystemAlarm "Problem writing to Here, the note that an error occurred
SQL. Maybe the logs are closed?" during runtime is output via the
message display in the project. Adjust
the language and the text, if required.
Figure 4-2
Siemens AG 2016 All rights reserved
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
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".
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.
Siemens AG 2016 All rights reserved
Step Description
3. Select LogSQL as data source name.
Select <Computer name>\WINCCFLEXEXPRESS as SQL server.
4
Siemens AG 2016 All rights reserved
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
5
Siemens AG 2016 All rights reserved
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.
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.
8 History
Table 8-1
Version Date Modifications
V1.0 05/2016 First version
Siemens AG 2016 All rights reserved