Sei sulla pagina 1di 46

Application Description 06/2014

PC-Based Automation:
Connection of Databases via
open Interfaces Using OPCClient, Programmed with the
SIMATIC NET.NET OPC Client
API in C#
SIMATIC NET OPC Server

http://support.automation.siemens.com/WW/view/en/21576581

Warranty and Liability

Warranty and Liability


Note

The Application Examples are not binding and do not claim to be complete
regarding the circuits shown, equipping and any eventuality. The Application
Examples do not represent customer-specific solutions. They are only intended
to provide support for typical applications. You are responsible for ensuring that
the described products are used correctly. These Application Examples do not
relieve you of the responsibility to use sound practices in application, installation,
operation and maintenance. 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 without prior notice. If there are any deviations
between the recommendations provided in these Application Examples and
other Siemens publications e.g. Catalogs the contents of the other
documents have priority.
We do not accept any liability for the information contained in this document.

Siemens AG 2014 All rights reserved

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 a condition which goes to the root of the contract
(wesentliche Vertragspflichten). The damages for a breach of a substantial
contractual obligation are, 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 Industry Sector.
Security
information

Siemens provides products and solutions with industrial security functions that
support the secure operation of plants, solutions, machines, equipment and/or
networks. They are important components in a holistic industrial security
concept. With this in mind, Siemens products and solutions undergo continuous
development. Siemens recommends strongly that you regularly check for
product updates.
For the secure operation of Siemens products and solutions, it is necessary to
take suitable preventive action (e.g., cell protection concept) and integrate each
component into a holistic, state-of-the-art industrial security concept. Third-party
products that may be in use should also be considered. For more information
about industrial security, visit http://www.siemens.com/industrialsecurity.
To stay informed about product updates as they occur, sign up for a productspecific newsletter. For more information, visit
http://support.automation.siemens.com.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

Table of Contents

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

Task ..................................................................................................................... 5
1.1
1.2

Solution............................................................................................................... 7
2.1
2.2
2.2.1
2.2.2
2.3
2.3.1
2.3.2

Siemens AG 2014 All rights reserved

3.4
3.5

Configuring the PC station ................................................................. 28


Interface settings ................................................................................ 29
Communication settings ..................................................................... 30
Configuring components in the Station Configuration Editor ............. 32
Configuring the PC station ................................................................. 33
Configuring the components of the PC station .................................. 33
Configuring the S7 connection ........................................................... 35
Configuring the IE General properties................................................ 36
Configuring the OPC server properties .............................................. 37

Installation and Startup ................................................................................... 38


6.1
6.2
6.2.1
6.2.2
6.2.3
6.2.4
6.3

General overview ............................................................................... 20


OPC client "OpcClientBridge" ............................................................ 20
Flowchart ............................................................................................ 21
Description of the most important methods........................................ 22
Integration of the .NET OPC Client API ............................................. 23
Recipe control (S7 control program) .................................................. 25
Program flowchart .............................................................................. 25
Program structure............................................................................... 26
Description of the program blocks...................................................... 26

Configuration and Settings............................................................................. 28


5.1
5.1.1
5.1.2
5.1.3
5.2
5.2.1
5.2.2
5.2.3
5.2.4

Basics of OPC .................................................................................... 13


S7 communication with OPC UA ....................................................... 14
Basics of the programming interface SIMATIC NET .NET OPC
Client API ........................................................................................... 15
Basics of ADO.NET ............................................................................ 17
Basics of the Microsoft Access database........................................... 19

Functional Principle ........................................................................................ 20


4.1
4.2
4.2.1
4.2.2
4.2.3
4.3
4.3.1
4.3.2
4.3.3

Overview............................................................................................... 7
Description of the core functionality ..................................................... 9
Overview of the software components ................................................. 9
Sequence of the core functionality ..................................................... 10
Hardware and software components ................................................. 11
Validity ................................................................................................ 11
Components used .............................................................................. 11

Basics ............................................................................................................... 13
3.1
3.2
3.3

Overview............................................................................................... 5
Requirements ....................................................................................... 6

Installation of the hardware ................................................................ 38


Installation of the software.................................................................. 38
Installation of the standard software packages on the SIMATIC
IPC...................................................................................................... 38
Installation of the standard software packages on the PG/PC........... 38
De-archiving the application software ................................................ 39
Installation of the OPC client on the PG/PC or SIMATIC IPC............ 39
Startup of the STEP 7 project ............................................................ 40

Operation of the Application .......................................................................... 42

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

Table of Contents
7.1
7.2
7.3

Overview............................................................................................. 42
Operation of the Windows application................................................ 43
Monitoring the tags using the watch table in the TIA Portal ............... 44

Further Notes, Tips & Tricks, etc. .................................................................. 45

References ....................................................................................................... 46

10

History............................................................................................................... 46

Siemens AG 2014 All rights reserved

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

1 Task
1.1 Overview

Task

1.1

Overview

Introduction
Industrial PCs, which are used for visualization, are frequently used in the field of
industrial automation. A controller which controls the system exists simultaneously.
A frequently occurring problem is that data of a database are to be transferred to
the controller and vice versa.
This application shows a possible procedure how SIMATIC WinAC RTX can
interact with databases via the SIMATIC OPC server. The standard components of
Microsoft .NET Framework are used for that.
Overview of the automation task
The figure below provides an overview of the automation task.
Figure 1-1-1

Siemens AG 2014 All rights reserved

Data acquisition
Recipe download

PC with OPC server

Recipe
data

PC with OPC client


and database server

Production
data

Industrial Ethernet

Process data

Description of the automation task


The MS Access database is to communicate with a WinAC RTX. A Windows
application, which is also used for visualization, is to be integrated as bridge client
between the database and the controller. The data are to be exchanged via this
application.
To make the example more specific, we show you the recipe-based control of the
mixing process in WinAC; the recipes are read from the database and additionally
quality data are written back to the database.
However, the example focuses on linking the WinAC RTX controller to a database
using an OPC server.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

1 Task
1.2 Requirements

1.2

Requirements

Requirements of the automation task


The application is to meet the following requirements:
Functionality applicable to large quantity frameworks.
The recipe program in the controller is to be fully operable from the client
application.
The connected I/O is simulated by a simulation block.
It has to be possible to transfer different dynamic recipes to the controller.
After each completed recipe process, the WinAC quality data have to be
transferred to the database.

Siemens AG 2014 All rights reserved

Standardized communication mechanisms are to be used.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

2 Solution
2.1 Overview

Solution

2.1

Overview

Schematic overview
The figure below gives a schematic overview of the most important components of
the solution with a remote client:
Figure 2-2-1
PG/PC

SIMATIC IPC427D

OPC client visualization with .NET OPC Client API


Access database

OPC server
WinAC RTX
SIMATIC NET V8.x

Siemens AG 2014 All rights reserved

Industrial Ethernet

The figure below gives a schematic overview of the most important components of
the solution with a local client:
Figure 2-2-2
SIMATIC IPC427D

Monitor

OPC server
WinAC RTX
SIMATIC NET V8.x
OPC client visualization with .NET OPC Client API
Access database

Setup
The OPC client "OPCClientBridge" developed for this application is the central
component of the connection between WinAC RTX and the database. It transmits
and receives data to and from the controller and the database. The OPC client with
the Access database can be operated on a remote Windows PC or locally on the
SIMATIC IPC.
The SIMATIC NET OPC Server runs on the SIMATIC IPC.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

2 Solution
2.1 Overview
Advantages
Compared to classical recipe control systems operated without a PC, this solution
offers the following advantages:
The solution includes simple visualization.
All quality and error data of the process are archived in the database and are
then available for error analysis.
All classic control functionalities can be realized with WinAC as usual and
communicate with other Windows applications via the OPC client connection
(locally as well as with databases via networks).
The individually implemented client application enables to achieve efficient
data exchange with a standard database. Database and client application can
be installed on different computers (connected via Ethernet).
The solution demonstrated here uses the .NET OPC Client API as the interface
for the programming of the OPC client. It allows the programmer to create OPC
communication under .NET rather easily.
The modular structure of the C# program allows the use of code elements also
in new projects.
Delimitation
Siemens AG 2014 All rights reserved

This application does not contain a complete description of


the setup of databases
the ADO.NET interface
the OPC specifications
programming in C#
Basic knowledge of these topics is assumed.

Required knowledge
Basic knowledge
in object-oriented programming
in the programming language C#
in the OPC technologies
is required.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

2 Solution
2.2 Description of the core functionality

2.2

Description of the core functionality

2.2.1

Overview of the software components


The figure below shows the involved software components.
Figure 2-2-3

IPC (local client)

PC (remote client)

.NET Framework

.NET Framework

ADO.NET
C#
OpcClientBridge

ADO.NET
C#
OpcClientBridge

Access
database

Siemens AG 2014 All rights reserved

Access
database

.NET OPC client library

.NET OPC client library

encapsulates reusable functions

encapsulates reusable functions

OPC UA

OPC UA
OPC UA
SIMATIC NET
OPC server
WinAC RTX

WinAC RTX
A controller with real-time capability. It performs the actual control of the mixing
process. The mixing process was developed with the TIA Portal.
SIMATIC NET OPC Server
The OPC server is the central communication unit between the OPC client and the
respective data source (here the WinAC).
.NET OPC Client API
For coupling to the process, the OPC client "OPCClientBridge" uses the .NET OPC
Client API, which is automatically installed with the SIMATIC NET OPC Server
V8.x.
OPC client "OPCClientBridge"
Retrieves the data from the database with the aid of ADO.NET mechanisms and
forwards them to the OPC server. Furthermore, the OPC client provides an easyto-use visualization function for operator control and monitoring of the S7 program.
The OPC client was developed with C#.
ADO.NET
Database connection architecture for .NET Framework.
MS Access database
A database for the storage of recipe and quality data.
PC-Based Automation: Connection of Databases via open Interfaces
Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

2 Solution
2.2 Description of the core functionality

2.2.2

Sequence of the core functionality


A short overview of the user interface is given below. For the exact description of
the individual functions, please see chapter 7 Operation of the Application.

Siemens AG 2014 All rights reserved

Figure 2-2-4

Table 2-1
Action

Note

Note

1.

Enter the "Server URL".

The server URL states on which server


the OPC client is to connect. Select
"local" or "distributed" to fill in a default
URL.

2.

Click the "Connect" button.

The "Connect" button serves for


establishing or terminating the OPC
connection to the server.

3.

Select the MS Access database.

The "MS ACCESS" field states the


name of the database with which the
OPC client is to connect.

4.

Enter the recipe number.

The "Recipe Number" field serves for


entering the desired recipe.

5.

Click the "START" button.

Recipe processing will be started.

The SIMATIC NET OPC Client API used here for .NET can only be used for the
coupling with SIMATIC NET OPC Servers.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

10

2 Solution
2.3 Hardware and software components

2.3

Hardware and software components

2.3.1

Validity
This application is valid for
STEP 7 from V13
SIMATIC IPC427D

2.3.2

Components used
The application was set up with the following components:

Hardware components
Table 2-2

Siemens AG 2014 All rights reserved

Component

No.

Article number

SIMATIC IPC427D

6AG4140-8....-0.B0

Field PG M4

6ES7716-....-0...

Note
or a standard PC

Software components
Table 2-3 SIMATIC SW components
Component

No.

Article number

Note

STEP 7 Prof. V13


Update 1

6ES7822-1..03-..

WinAC RTX 2010


SP1

6ES7 611-4SB00-0YB7

WinAC package is contained


in the bundle.

SIMATIC NET IE
SOFTNET-S7
SIMATIC NET DVD
V8.2

6GK1704-1CW08-2AA0

SIMATIC NET is contained in


the bundle and includes
SIMATIC NET Software V8.2

Table 2-4 Third-party software


Component
Microsoft Visual
Studio 2012

No.
1

Article number

Note

Can be ordered via your


administrator or
www.microsoft.com

Microsoft Access
2010

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

11

2 Solution
2.3 Hardware and software components
Sample files and projects
The following list contains all files and projects used in this example.
Table 2-5
Component

Note

This zip file contains the STEP 7


project and the source code of
the user interface.

21576581_WinAC_SO_DOKU_V2_en.pdf

This document.

Siemens AG 2014 All rights reserved

21576581_WinAC_SO_CODE_V2.zip

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

12

3 Basics
3.1 Basics of OPC

Basics

3.1

Basics of OPC
OPC is a manufacturer-independent software interface that enables data exchange
between hardware and software from different manufacturers.

OPC server
OPC components supplying data are referred to as OPC servers. They realize the
connection to existing communication systems. Apart from services, they provide
information from any data sources (here the S7 controller) to the OPC client.
OPC client
OPC components using an OPC server as data source are referred to as OPC
clients.
The following access methods are possible:
Read
Write
Siemens AG 2014 All rights reserved

Monitoring tags (reporting value changes)


OPC interface
The applications of the OPC interface are based on the client-server model. One
component provides its services to other components as a server via interfaces.
Another component utilizes the services as a client.
The following specifications are currently available for automation engineering:
for data exchange on the basis of process tags: Data Access
for the handling of alarms and events: Alarms & Events
for data exchange also via the Internet: Data Access XML
for horizontal data exchange between OPC servers: Data Exchange
for the handling of recipes: Batch
for access to archived data: Historical Data Access
for a consolidation of many OPC specifications: OPC Unified Architecture
(OPC UA)
OPC Unified Architecture (OPC UA)
OPC UA consolidates the previous functionalities of the existing OPC standards
such as Data Access, Alarm & Events, Security, Historical, Complex, and XML
Data Access in one new, secure and powerful specification. For OPC UA, a new
TCP-based, secure, powerful, and standardized communication protocol is used.
OPC UA thus provides platform-independent communication. This facilitates the
development of client applications.
In this example, the OPC UA interface is used.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

13

3 Basics
3.2 S7 communication with OPC UA
Connection between OPC server and controller
The tag values are read out via the connections configured in the OPC server
using the respective protocol. In this example, the S7 protocol is used, which
contains two principle transmission mechanisms: the tag services and the block
services (see also chapter 3.2 S7 communication with OPC UA).
The connections are configured in the TIA Portal (see chapter 5.2.2 Configuring the
S7 connection).

3.2

S7 communication with OPC UA

Properties
The S7 protocol for PROFIBUS and Industrial Ethernet serves for the
communication of system components within the SIMATIC S7 automation system
and communication of SIMATIC S7 system components with programmers and
PCs. The SIMATIC NET OPC Server allows for using the S7 communication via
OPC UA.
The S7 communication contains two different methods of data transmission:
Tag services

Siemens AG 2014 All rights reserved

Block services
Tag services
Tag services enable access to and monitoring of S7 tags in the automation device.
The S7 tags are addressed using initials of the addressed objects. The kind of
access is guided by the notation of the S7 tools. Objects in the automation device
of the S7 OPC UA servers support the following objects:
Data blocks
Instance data blocks
Inputs
Outputs
I/O inputs
I/O outputs
Flags
Timers
Counters

Note

Not every S7 automation device supports all object types.


In this example, only the tag services are used.

Block services
Block services enable program-controlled transmission of larger data blocks.
Transmission is realized with tags:
Tags that receive data blocks
Tags that send data blocks

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

14

3 Basics
3.3 Basics of the programming interface SIMATIC NET .NET OPC Client API

3.3

Basics of the programming interface SIMATIC


NET .NET OPC Client API

Function
The SIMATIC NET .NET OPC Client API provides a programming interface for
developers in the languages C# and Visual Basic .NET. The simple and intuitive
interface allows for programming OPC client applications which can process both
data from COM DA and from UA servers.
So, the application can access DA items or UA nodes transparently via the same
functions.
In the case of machine access beyond network limits, the UA interface should be
chosen, since it is system-independent.
Setup
The SIMATIC NET .NET OPC Client API contained in the
"SimaticNET.OPC.OpcClient.DLL" library on the SIMATIC NET DVD mainly offers
two categories of functions:

Siemens AG 2014 All rights reserved

the namespace of the actual access to OPC process data (DA or UA interface)
SimaticNET.OPCDaClient;
a namespace with a rather general functionality for finding information about
OPC servers (DA and UA) necessary for establishing a connection
SimaticNET.OpcCmn (not used in this example).
SimaticNET.OPCDaClient namespace
The following functionality provides the SimaticNet.OpcDaClient namespace of
the .NET component via the "DaServerMgt" object:
Table 3-1
No.

Function

Explanation

1.

Connection to the OPC


server

With the "Connect" method, the connection to the OPC server can be
established; with the "Disconnect" method it can be terminated again.
The connection is monitored by the .NET component. Should there
be connection errors, the status changes are reported through the
"ServerStateChanged" event.

2.

Reading and writing of


OPC data access items

With the "Read" and "Write" methods (or "ReadAsync" and


"WriteAsync"), the values from OPC items can be read and written
synchronously and asynchronously.

3.

Reporting data changes

The .NET component offers a mechanism for reporting value


changes. Cyclic reading therefore becomes obsolete.
With the "Subscribe" method, items can be registered for monitoring
and with "SubscriptionCancel" they can be de-registered again.
Changed values are reported via the "DataChanged" event.

4.

Finding information on
the address space

The "Browse" method is for searching the address space of an OPC


data access server for OPC items. With the "GetProperties" method,
the properties of OPC items can be determined.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

15

3 Basics
3.3 Basics of the programming interface SIMATIC NET .NET OPC Client API
SimaticNET.OpcCmn namespace
In the SimaticNet.OpcCmn namespace, general OPC functions are combined.
This concerns in particular the searching for OPC servers and finding information
necessary for connection establishment.
In the present example, the functions of this namespace are not used!
Table 3-2

Siemens AG 2014 All rights reserved

No.

Function

Explanation

1.

Searching for OPC COM


servers

With the "EnumComServers" method, the OPC servers on a


computer can be found. It is possible to differentiate between the
different OPC specifications such as "OPC Data Access", "OPC
Historical Data Access", or "OPC Alarm & Events".

2.

Finding COM OPC server


names

The "ClsidFromPorgld" method determines depending on the


transmitted parameters computer name and "ProgID" the
corresponding "CLSID" of the OPC server.

3.

Searching for OPC UA


servers

The "getCertificateForEndpoint" method connects with the transmitted


endpoint URL and loads the server certificate which is returned as
Out parameter. You will get the In parameters before by browsing on
the discovery server.

4.

Finding the UA endpoint

The "EndpointIdentifier" class supplies all the data additionally


necessary for establishing a connection with an UA server.

5.

Creating the UA
certificate

The "PkiCertificate" class encapsulates an X509 certificate and allows


for easy creation of such a certificate. Furthermore, methods for
access to the "WindowsCertificateStore" for loading and saving
certificates are provided. Via Properties, the fields of the certificate
can only be read.

Note

With this API, only connections to OPC servers of the SIMATIC NET product
family can be established. Connections to other OPC servers or to OPC servers
of other manufacturers are not possible.

Note

A detailed description of the interface can be found in the Siemens Industry


Online Support in the manual "SIMATIC NET Industrial Communication with
PG/PC Volume 2 - Interfaces Programming Manual"
(http://support.automation.siemens.com/WW/view/en/61630891)

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

16

3 Basics
3.4 Basics of ADO.NET

3.4

Basics of ADO.NET
ADO.NET (ActiveX Data Object .NET) is a set of classes which make data access
services available for a great number of database systems for .NET Framework
programmers. The database interface is object-oriented.
The object model provides a great number of components for creating distributed
applications with data release. The most important ones being
DataSet: a central element for receiving and combining several tables
DataTable: a table in the DataSet
DataReader: for reading data
DataAdapter:

Siemens AG 2014 All rights reserved

Notes

establishes the connection to the database,

fills the DataSet with information,

writes changed data sets back to the database

The following points must be noted with regard to the ADO.NET application model:
The data volume contained in the memory must be considered.
If a client saves data to the DataSet, the other clients do not necessarily notice this
(due to the transient data management).
Changes to the database structure must additionally be made in the DataSet.
The DataSet should be resynchronized during the update in order that the data in the
database correspond with the data in the DataSet. This can be initiated with a simple
parameter specification.
For further information, please refer to the secondary literature.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

17

3 Basics
3.4 Basics of ADO.NET
ADO.NET application model
Figure 3-3-1

.NET application
Read & Write access

DataSet

Datatables
Only Read
access

DataRows
Fills with data from the
data source

Updates the
changes

DataAdapter

DataReader
SelectCommand

InsertCommand

.NET provider

Siemens AG 2014 All rights reserved

is

UpdateCommand

creates

DeleteCommand

Command
2

needs

Executes instructions
against the database

Connection
1
Open / Close
manages
transactions

Database

Explanation
The numbers have the following meaning:
Table 3-3
No.

Object / Action

1.

"Connection" establishes a
connection with the database.

2.

Command objects mainly execute


SQL statements in the database.

3.

The DataReader enables performant


reading of a forward directed data
stream from the database.

Explanation
Connections are only opened when required.
Connection pools are created as soon as "Open" is
called.
A "Close" call does not delete the connection from
the connection pool.

The DataReader can only be used for reading data from


the database.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

18

3 Basics
3.5 Basics of the Microsoft Access database
No.

Object / Action

4.

The DataAdapter provides an


interface between the DataSet (5) and
the database using the respective
command.

5.

A DataSet contains the data of the


database.

3.5

Explanation
The DataAdapter corresponds with a DataSet or a
DataTable.
In order to execute an UpdateCommand with a
DataAdapter, it must only contain one DataTable!
The DataSet represents the database structure and its
data in the memory of the PC.
This enables a transient saving of selected data of
the database. Transfer of database data via XML
and WebServices is possible without greater
problems.
The DataSet object can also be used for generating
or modifying relationships between DataTables.
An adaptation of the data model in the transient
memory is hence possible.

Basics of the Microsoft Access database

Siemens AG 2014 All rights reserved

Access is a universal desktop database for office work on a smaller scale. This
results in the problem that it provides less performance capability than a highperformance SQL database with a server-client architecture.
On the other hand, Access is integrated in the Microsoft Office Suite so that is
already installed in many office workstations and immediately available without
requiring extra installation work.
For users with basic knowledge in databases, Access is self-explanatory and easy
to use.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

19

4 Functional Principle
4.1 General overview

Functional Principle

4.1

General overview
The figure below shows the data flow and process between the OPC client and the
STEP 7 program as it was implemented in the example.
Figure 4-4-1
OPC client
OpcClientBridge

STEP 7 program

START
CurrentRecipe
Start

Write async

Read async

Wait DataRequest
DataRequestAk
transfer recipe
DataSend
Wait DataSendAk
Write protocol data
to database

Siemens AG 2014 All rights reserved

Write quality info to


database

Update visualization
Wait step end
Wait recipe end

Wait Start
DataRequest

Write async

Read async

Monitor Items

Wait DataSend
DataSendAk
Start recipe
Status information

The following chapters provide a detailed description of the individual


functionalities.

4.2

OPC client "OpcClientBridge"


The client was developed for the .NET Framework in the C# programming
language. It combines three basic functionalities exchanging data on one interface.
These functionalities are OPC access, database access using ADO.NET, and the
visualization of recipe processing. The following chapters provide a detailed
description of the individual functionalities.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

20

4 Functional Principle
4.2 OPC client "OpcClientBridge"

4.2.1

Flowchart
The flowchart below illustrates the basic functional principle of the automatic mode.

Figure 4-4-2
Connect with
OPC server
Transfer data to
controller

START

Connect with database

Data
received by
controller?

Load data to DataSet

Yes
Start monitoring

Siemens AG 2014 All rights reserved

Start monitoring

Data
requested?

Yes

No

No
New step
started?

No

Recipe
completed?

Yes

No

Yes

Logging of the step


runtime in the DataSet

Logging of the recipe


runtime in the DataSet
Logging of the step
runtime in the DataSet

New data
requested?

Yes

No
No

Stop button
clicked?

Yes
Reset step chain and
wait for restart

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

21

4 Functional Principle
4.2 OPC client "OpcClientBridge"

4.2.2

Description of the most important methods


The following section roughly explains the most important methods of the OPC
client program. For details, please refer to the source code of the sample program.

"btnConnect_Click" method
This button click method connects/disconnects the OPC client to/from the OPC
server.
"btnStartClient_Click" method
This button click method executes the following actions:
Establishes a connection to the Access database (ConnectToACCESSDB)
Fills the visualization table with the recipe from the database
Starts monitoring of the data to be retrieved from the controller
(startMonitoring)
Starts visualization (VisualizationRun)

Siemens AG 2014 All rights reserved

"btnSTOPClient_Click" method
This button click method ends monitoring and terminates the connection to the
database.
"ConnectToACCESSDB" method
This method establishes a connection to the Access database and writes the data
of the tables "Expiry", "Protocol", and "Quality" to the "DataSetFull" DataSet.
"startMonitoring" method
This method registers the data to be retrieved with the OPC server.
"stopMonitoring" method
This method de-registers the data to be retrieved with the OPC server.
"writeOneItem" method
This method writes a tag to the OPC server.
"readOneItem" method
This method reads a tag from the OPC server.
"DataChanged" method
If the server identifies a change of the registered data, this method is called in the
client. With the help of this method, the changed value can be identified and a
corresponding reaction can be initiated.
The three most important value changes are:
Data requested?

TransferRecipe

Current step changed?

E1_StepChanged

Current recipe completed?

E2_Finish

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

22

4 Functional Principle
4.2 OPC client "OpcClientBridge"
"TransferRecipe" method
The desired recipe number is transferred to the method. At the beginning of the
method call, the number of steps of the relevant recipe and the position in the
Expiry table is determined. Subsequently, the client generates a list of write items
for the transfer of the individual data depending on the number of steps. In the next
step, the individual values of the recipe are copied from the DataSet to the list of
write items. The list of write items and the number of steps are transferred to the
OPC server (or controller).
"E1_StepChanged" method
This event writes the data (runtime, time stamp, filling level, etc.) of the currently
processed individual workstep to the "Protocol" table of the DataSetFull.
"E2_Finish" method
This event writes the data (runtime, time stamp, etc.) of the currently processed
recipe to the "Quality" table of the DataSetFull.

4.2.3

Integration of the .NET OPC Client API

Siemens AG 2014 All rights reserved

General
In order to use the functionality of the .NET OPC Client API , the corresponding
assemblies have to be referenced in MS Visual Studio first.
Table 4-1
No.
1.

Action
Open MS Visual Studio and create a new project, for example for a Windows Forms Application.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

23

4 Functional Principle
4.2 OPC client "OpcClientBridge"
No.

Action
For adding the references in the
project settings, please first open the
"Add Reference" dialog via the context
menu.

3.

Select the "SimaticNET.OPC.OpcClient" in the dialog and add it.

Siemens AG 2014 All rights reserved

2.

Note

The fully compiled assemblies have been made for x86 systems. This means
that the sample application has to be constructed for x86, too. For this purpose,
the build configuration in MS Visual Studio for debug and release has to be set to
x86.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

24

4 Functional Principle
4.3 Recipe control (S7 control program)

4.3

Recipe control (S7 control program)


The STEP 7 project contains the control program which provides the simulation of
the I/O as well as the processing of the recipes.

4.3.1

Program flowchart
For a better understanding, the basic processes in the program are displayed as a
program flowchart.

Figure 4-4-3

START

Send data request

Read data for step i

Siemens AG 2014 All rights reserved

Start processing of step i


Have data
been sent?

No
Write status information

Yes
Send transmission
confirmation

i=i+1

Start recipe
Last step?
Determine number of
sequence steps

Set tag i = 0

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

No

Yes
Reset instances and
wait for restart

25

4 Functional Principle
4.3 Recipe control (S7 control program)

4.3.2

Program structure
The graphic below illustrates the interaction of the individual blocks. The data are
basically transferred during block calls. In some exceptional cases, blocks access
global data, which is also shown in this graphic for greater clarity.

Figure 4-4-4

FB_WorkStep
DB_Visual
FB_WorkingOf
Steps
DB_Command_
Glob
OB_main_cycl
[OB 1]

OPC server

FB_DBIndex
DB_Recipe

Siemens AG 2014 All rights reserved

FB_Simulation

Data blocks
User program

4.3.3

Description of the program blocks

"OB_main_cycl" organization block


OB1 calls the "FB_WorkingOfSteps" block with the values determined from the
global data blocks and transfers the I/O data of the "FB_WorkStep" block to the
global data block "DB_Visual".
"FB_WorkStep" function block
This block is used to execute one single workstep of the recipe. Execution starts
with the transfer of the setpoints to the inputs and setting of the "Start" input.
Processing of the respective step of the recipe is started with the "Start" input. The
block then executes the desired function. During the processing of the step, the
"Busy" output is set to one. After completion of the recipe step, the "Ready" bit for a
PLC cycle is set and the "Busy" output is reset.
"FB_WorkingOfSteps" function block
This function block is the core element of the recipe program. It includes the data
request and acknowledgment after data receipt and is thus the interface to the
OPC client. Having received the data, it calls the function blocks "FB_Simulation",
"FB_DBIndex", and "FB_WorkStep".
It also checks faultless processing of the individual worksteps and measures the
time passed until the present stage of processing.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

26

4 Functional Principle
4.3 Recipe control (S7 control program)
"FB_DBIndex" function block
The function block serves for determining the data of a processing step from the
recipe data block "DB_Recipe" based on the number of the recipe data block and
the current step number.
"FB_Simulation" function block
This function block is used to simulate the I/O of the bottling plant. This block
provides different input and output parameters (valves, heater switches, etc.). If, for
example, the heater input is set to 1, the temperature will rise gradually.
"DB_Recipe" data block
As a buffer for recipe data, the "DB_Recipe" data block is the most important data
block. The complete recipe to be processed, which is transferred by the OPC
client, is stored in this block.
The data block includes an array tag "step" with 20 array elements of the data type
"UDT_Recipe". The data type "UDT_Recipe" defined in the application contains the
data structure of a step (see Table 4-2).
Table 4-2 Data type "UDT_Recipe"

Siemens AG 2014 All rights reserved

Name

Data type

Meaning

StepNr

INT

Includes the number of the step to ensure correct


identification.

Proceed

INT

Includes the ID of the processing method for this step


(heating, cooling, fill-in, etc.).

Ingredient

INT

Defines the ingredient to be used.

Amount

INT

Stores the quantity of the required ingredient.

Unity

INT

Indicates the unit for the required ingredient.

Temp

INT

Indicates the temperature to be reached.

Speed

INT

Indicates the stirring speed of the mixer.

"DB_Command_Glob" data block


This data block serves for exchanging commands and states between the
controller and the OPC client "OPCClientBridge". The OPC client accesses this
data block directly.
"DB_Visual" data block
The "DB_Visual" data block saves the current recipe processing values. The OPC
client "OPCClientBridge" retrieves the values from the data block and visualizes
them on the user interface.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

27

5 Configuration and Settings


5.1 Configuring the PC station

Configuration and Settings

5.1

Configuring the PC station

Overview of IP addresses
If you want to operate the project on an existing Industrial Ethernet, you have to
note the following address specification:
Table 5-1
Focus

Module

IP address

PG/PC

NDIS network card

192.168.115.20

PC station

SIMATIC IPC427D

192.168.115.10

Subnet mask: 255.255.255.0.


Setting the IP address
The Ethernet network card has to be switched to the configured operation. For this
purpose, the PC station has to be configured.

Siemens AG 2014 All rights reserved

Note

If you want to use the project provided with the delivery, it is important that the
network card has the fixed IP address 192.168.115.10. It can be set in the
network settings and TCP/IP properties.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

28

5 Configuration and Settings


5.1 Configuring the PC station

5.1.1

Interface settings
Table 5-2 Interface settings

Siemens AG 2014 All rights reserved

No.

Action

1.

Open the properties of your network card and set the following IP address.

2.

Open the "Set PG/PC Interface" dialog and select your network card as access
point of the application.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

29

5 Configuration and Settings


5.1 Configuring the PC station

5.1.2

Communication settings
Table 5-3 Communication settings

Siemens AG 2014 All rights reserved

No.

Action

1.

Open the "Communication Settings" dialog.

2.

Set the S7 protocol for this application and activate the OPC UA server for that.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

30

5 Configuration and Settings


5.1 Configuring the PC station

Siemens AG 2014 All rights reserved

No.

Action

3.

Check whether the symbols have been activated. The "File name" specifies the
destination for symbol downloads from SIMATIC STEP 7.

4.

Check the set IP address.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

31

5 Configuration and Settings


5.1 Configuring the PC station

5.1.3

Configuring components in the Station Configuration Editor


Table 5-4

Siemens AG 2014 All rights reserved

No.

Action

1.

Open the "Station Configuration Editor" and configure the slots as shown in the
figure below.

2.

In the IE General properties, set the Ethernet network card.

3.

Close the "Station Configuration Editor" and start the WinLC RTX controller.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

32

5 Configuration and Settings


5.2 Configuring the PC station

5.2

Configuring the PC station

5.2.1

Configuring the components of the PC station


Table 5-5

Siemens AG 2014 All rights reserved

No.

Action

1.

Open your STEP 7 V13 project and go to the project view.

2.

Open the "Add new device" dialog and add a new SIMATIC PC station. Assign the
device name "PCWinAC".

3.

Open the hardware catalog and select the OPC server in the "User applications"
folder under "PC systems". In the "Information" window, select the installed version
of your OPC server and add the OPC server to your PC station.
In this application, the SIMATIC NET OPC Server V8.2 is used.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

33

5 Configuration and Settings


5.2 Configuring the PC station

Siemens AG 2014 All rights reserved

No.

Action

4.

Select the WinAC RTX in the "SIMATIC Controller Application" folder under "PC
systems". In the "Information" window, select the installed version of your WinAC
RTX and add it to your PC station.

5.

Select "IE general" in the "Communications modules PROFINET/Ethernet" folder


under "PC systems". In the "Information" window, select the installed version of
your interface and add it to your PC station.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

34

5 Configuration and Settings


5.2 Configuring the PC station

5.2.2

Configuring the S7 connection


S7 connections are used for data exchange between automation devices and are
usually configured using STEP 7.
The table below shows the configuration of the S7 connection between the OPC
server and the WinAC RTX.
Table 5-6
No.
1.

Action
1.
2.
3.
4.

5.

Open the "Network view".


To create a new connection, go to "Connections".
Select "S7 connection" as the connection type.
Connect the OPC server with the WinAC RTX by left-clicking on the OPC
server, moving the mouse pointer to the WinAC RTX, and releasing the
mouse button there.
Configure the connection by editing the properties of the connection.

Siemens AG 2014 All rights reserved

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

35

5 Configuration and Settings


5.2 Configuring the PC station

5.2.3

Configuring the IE General properties


Table 5-7
No.
1.

Action
1.
2.
3.
4.

Open the "Device view" of the PC station.


Select the network card "IE general_1".
In the inspector window, select the "Properties" tab > "General" > "PROFINET
interface (X1)".
Enter the IP address of the station under "Ethernet addresses" > "IP protocol".

Siemens AG 2014 All rights reserved

2.

Check the "Access via OPC server" check box under "OPC configuration".

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

36

5 Configuration and Settings


5.2 Configuring the PC station

5.2.4

Configuring the OPC server properties


Table 5-8
No.
1.

Action
1.
2.
3.
4.

5.

Open the "Device view" of the PC station.


Select the OPC server "OPC Server_1".
In the inspector window, select the "Properties" tab > "General".
Select "Configured" under "OPC tags". This enables the "Configuring..."
button.
Select "All" if you want to use all process tags.
Click the "Configuring..." button if you only want to access a selection of
process tags symbolically.

Siemens AG 2014 All rights reserved

2.

Select the tags for your OPC connection by checking/unchecking "Visible" for each
tag or data block.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

37

6 Installation and Startup


6.1 Installation of the hardware

Installation and Startup

6.1

Installation of the hardware


The figure below shows the hardware configuration of the application.
Figure 6-6-1
PG/PC

SIMATIC IPC427D

24V DC

Siemens AG 2014 All rights reserved

Industrial Ethernet

Note

The installation guidelines for these components must always be observed.

Table 6-1
No.

Action

1.

Connect the SIMATIC IPC427D to a 24V power supply.

2.

Connect the devices with a standard Ethernet cable.

6.2

Installation of the software

6.2.1

Installation of the standard software packages on the SIMATIC IPC


Install the software packages "WinAC RTX" and "SIMATIC NET" on the SIMATIC
IPC.
A description of the installation procedure for "WinAC RTX" and "SIMATIC NET" is
not part of this documentation. The installation takes place in the usual Windows
environment and is self-explanatory or described in the respective manuals.

6.2.2

Installation of the standard software packages on the PG/PC


Install the SIMATIC software STEP 7 V13 Update 1 on the PG/PC. STEP 7 V1x is
already preinstalled on SIMATIC PGs.
At this point, we will not go further into the installation of STEP7 V1x. The
installation takes place in the usual Windows environment and is self-explanatory
or described in the respective manuals.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

38

6 Installation and Startup


6.2 Installation of the software

6.2.3

De-archiving the application software


Unzip the zipped "21576581_WinAC_SO_CODE_V2.zip" code folder from the
download area to a folder of your choice.
In this folder, there are the subfolders:
"OpcClientBridge" with the necessary files for the OPC application,
"WinAC_OPC" for the STEP 7 project with the simulation program for the
controllers.

6.2.4

Installation of the OPC client on the PG/PC or SIMATIC IPC


Copy the unzipped folder "OpcClientBridge" to a directory on the PG/PC or
SIMATIC IPC.
In the "\OpcClientBridge\bin" directory you will find this file: OpcClientBridge.exe.
Start the user interface by executing the EXE file.

Note

The EXE can only be executed if the associated assemblies are located in the
same directory

Siemens AG 2014 All rights reserved

Files included
The "OpcClientBridge" folder contains two subfolders with the following contents:
bin

"OpcClientBridge.exe": the OPC client application described here

"SimaticNET.OPC.OpcClient.dll": client API

"DB" folder: contains the Microsoft Access database


"RecipeAdministration.mdb"

src

the Microsoft Visual Studio Solution file

the source code

Uninstallation
To uninstall, delete the directory.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

39

6 Installation and Startup


6.3 Startup of the STEP 7 project

6.3
No.

Startup of the STEP 7 project


Action
Open the TIA Portal and
click on "Browse".

2.

Navigate to the project


directory of the STEP 7
project included in the
delivery and open the
project.

3.

Go to the project view.

Siemens AG 2014 All rights reserved

1.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

Remarks

40

6 Installation and Startup


6.3 Startup of the STEP 7 project

Siemens AG 2014 All rights reserved

No.

Action

4.

Select the PC station and


click the "Download to
device" button.

5.

Set WinAC RTX to RUN


mode.

Note

Remarks

Please make sure that the station name "PCWinAC" is set correctly in the station
manager.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

41

7 Operation of the Application


7.1 Overview

Operation of the Application

7.1

Overview

Overview and description of the user interface


The figure below shows the user interface of the Windows application
"OPCClientBridge".
Figure 7-7-1
2

5
7

6
8

10
12

Siemens AG 2014 All rights reserved

11

13

The position numbers have the following meaning:


Table 7-1
Position

Element

Meaning

1.

Server URL

Input field for the OPC server URL with which the OPC client is to connect.
The URL for OPC UA is structured as follows:
opc.tcp://<computer name or IP>:4845

2.

local

With "local", the server URL "opc.tcp://localhost:4845" is defaulted to the local


OPC server.

3.

distributed

With "distributed", the server URL "opc.tcp://192.168.115.10:4845" is defaulted


to a remote OPC server.

4.

Connect /
Disconnect

This button is used to establish/terminate a connection to the OPC server.

5.

Connection
State

"Connection State" indicates the current status of the OPC connection to the
server. Possible states are:
Undefined
Disconnected
ErrorShutdown
ErrorWatchdog
Connected

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

42

7 Operation of the Application


7.2 Operation of the Windows application

Siemens AG 2014 All rights reserved

Position

Element

Meaning

6.

ACCESS
Connection

This text box indicates the name of the Access database.


Default: "..\bin\DB\RecipeAdministration.mdb"

7.

This button opens a dialog in which you can select the Access database from
your file system.

8.

START

Starts Auto mode and thus the execution of the recipe.


This includes the establishment of the connection to the Access database and
starts automatic polling of the controller's status values by means of
subscriptions.

9.

STOP

Stops Auto mode and thus the execution of the recipe.


This includes the termination of the connection to the Access database and
stops automatic polling of the controller's status values.

10.

Recipe
Number

Input field for the desired recipe number.

11.

visualization

The animated graphic and the output fields indicate the current status values,
for example, filling level, temperature, heater, cooler, mixer, etc.

12.

recipeDB

This table shows all recipes available in the database.


While the S7 program is active, it also shows the workstep currently in
progress.

13.

Status bar

The status bar displays the following client information:


Status of the S7 program
Currently processed step
Database connection status
Current date / time

7.2

Operation of the Windows application


The following steps are required for automatic recipe processing on a remote
PG/PC.

Table 7-2
No.

Action

Remarks

1.

Start the user interface.

The user interface is started by executing the


"OpcClientBridge.exe" file in the
"..\OpcClientBridge\bin" directory.

2.

Enter the "Server URL".


Default:
"opc.tcp://192.168.115.10:4845"

If the OPC client runs on the same computer as the


WinAC, the server URL "opc.tcp://localhost:4845" can
be used.

3.

Connect with the OPC server by


clicking the "Connect" button.

The current status of the OPC connection


"Connection State" changes from "Disconnected" to
"Connected".

4.

Select the Access database.

The path is defaulted to the


"RecipeAdministration.mdb" database included in the
delivery.

5.

Enter the desired recipe in the "Recipe


Number" input field.

In the "RecipeAdministration.mdb" database included


in the delivery, the recipes 1 to 3 are defined.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

43

7 Operation of the Application


7.3 Monitoring the tags using the watch table in the TIA Portal
No.
6.

Siemens AG 2014 All rights reserved

7.3

Action

Remarks

Click the "START" button.

The connection to the database is established. The


client sends the start command to the controller.
Subsequently, data are exchanged between the
controller and the client. The status bar informs you
on the program status, the current step, and the
connection status to the database. The visualization
window displays the current data of the process. In
addition, the currently active process step of the
controller is highlighted in the table listing the recipes.
After completion of the recipe, all quality and protocol
data stored in the DataSet are stored in the selected
database. The status bar displays the "recipe
finished" message.
The client now waits for the next recipe request. Click
the "STOP" button to stop the client.

Monitoring the tags using the watch table in the


TIA Portal
The control program in the WinAC controller can be monitored using the watch
table contained in the STEP 7 project.
Table 7-3
No.

Action

1.

Open your STEP 7 V13 project and go to the project view.

2.

1.
2.
3.

Open the watch table by double-clicking on "Watch table_1".


Click the "Monitor all" button.
Start recipe execution with the OPC client "OpcClientBridge". You can now
monitor the data exchange between the controller and the client.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

44

8 Further Notes, Tips & Tricks, etc.

Further Notes, Tips & Tricks, etc.

Application and functions of OPC Scout


OPC Scout, which is installed together with SIMATIC NET on your PG/PC,
supports the commissioning and testing of your OPC system.
With OPC Scout you can
search for and display the OPC servers available on your PG/PC,
test connections and objects,
monitor items,
read and write values,
display alarms,
perform S7 connection diagnostic,
create and store own views of the objects to be detected.
The figure below shows how to monitor items, for example, using OPC Scout.

Siemens AG 2014 All rights reserved

Figure 8-1

Note

You will find further details in the online help of OPC Scout.

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

45

9 References

References

Bibliography
This list is not complete and only represents a selection of relevant literature.
Table 9-1

Siemens AG 2014 All rights reserved

Subject

10

Title

\1\

Siemens Industry
Online Support

http://support.automation.siemens.com

\2\

Download page of
the entry

http://support.automation.siemens.com/WW/view/en/21576581

\3\

SIMATIC NET PC
software Industrial
Communication
with PG/PC
Volume 1 - Basics
System Manual

http://support.automation.siemens.com/WW/view/en/77376110

\4\

SIMATIC NET
Industrial
Communication
with PG/PC
Volume 2 Interface
Programming
Manual

http://support.automation.siemens.com/WW/view/en/61630891

\5\

SIMATIC
Windows
Automation
Center RTX
WinAC RTX (F)
2010

http://support.automation.siemens.com/WW/view/en/43715176

\6\

SIMATIC NET
Industrial
Communication
Commissioning
PC Stations

http://support.automation.siemens.com/WW/view/en/61630799

History
Table 10-1
Version

Date

Modifications

V1.1

05/2005

First version

V2.0

06/2014

Changeover to OPC UA and TIA Portal

PC-Based Automation: Connection of Databases via open Interfaces


Using OPC-Client, Programmed with the SIMATIC NET.NET OPC
Client API in C#Database Connection to WinAC Using OPC Client
Entry ID: 21576581, V2.0, 06/2014

46

Potrebbero piacerti anche