46
http://support.automation.siemens.com/WW/view/en/21576581 Application Description 06/2014 PC-Based Automation: Connection of Databases via open Interfaces Using OPC- Client, Programmed with the SIMATIC NET.NET OPC Client API in C# SIMATIC NET OPC Server

Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

  • Upload
    others

  • View
    14

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

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

Application Description 06/2014

PC-Based Automation:Connection of Databases viaopen Interfaces Using OPC-Client, Programmed with theSIMATIC NET.NET OPC ClientAPI in C#SIMATIC NET OPC Server

Page 2: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

Warranty and Liability

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 2

Siem

ens

AG20

14Al

lrig

hts

rese

rved

Warranty and LiabilityNote The Application Examples are not binding and do not claim to be complete

regarding the circuits shown, equipping and any eventuality. The ApplicationExamples do not represent customer-specific solutions. They are only intendedto provide support for typical applications. You are responsible for ensuring thatthe described products are used correctly. These Application Examples do notrelieve you of the responsibility to use sound practices in application, installation,operation and maintenance. When using these Application Examples, yourecognize that we cannot be made liable for any damage/claims beyond theliability clause described. We reserve the right to make changes to theseApplication Examples at any time without prior notice. If there are any deviationsbetween the recommendations provided in these Application Examples andother Siemens publications – e.g. Catalogs – the contents of the otherdocuments 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 ofthe examples, information, programs, engineering and performance data etc.,described in this Application Example shall be excluded. Such an exclusion shallnot apply in the case of mandatory liability, e.g. under the German Product LiabilityAct (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life,body or health, guarantee for the quality of a product, fraudulent concealment of adeficiency or breach of a condition which goes to the root of the contract(“wesentliche Vertragspflichten”). The damages for a breach of a substantialcontractual obligation are, however, limited to the foreseeable damage, typical forthe type of contract, except in the event of intent or gross negligence or injury tolife, body or health. The above provisions do not imply a change of the burden ofproof to your detriment.Any form of duplication or distribution of these Application Examples or excerptshereof is prohibited without the expressed consent of Siemens Industry Sector.

Securityinforma-

tion

Siemens provides products and solutions with industrial security functions thatsupport the secure operation of plants, solutions, machines, equipment and/ornetworks. They are important components in a holistic industrial securityconcept. With this in mind, Siemens’ products and solutions undergo continuousdevelopment. Siemens recommends strongly that you regularly check forproduct updates.

For the secure operation of Siemens products and solutions, it is necessary totake suitable preventive action (e.g., cell protection concept) and integrate eachcomponent into a holistic, state-of-the-art industrial security concept. Third-partyproducts that may be in use should also be considered. For more informationabout industrial security, visit http://www.siemens.com/industrialsecurity.

To stay informed about product updates as they occur, sign up for a product-specific newsletter. For more information, visithttp://support.automation.siemens.com.

Page 3: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

Table of Contents

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 3

Siem

ens

AG20

14Al

lrig

hts

rese

rved

Table of ContentsWarranty and Liability ................................................................................................. 2

1 Task ..................................................................................................................... 5

1.1 Overview............................................................................................... 51.2 Requirements ....................................................................................... 6

2 Solution............................................................................................................... 7

2.1 Overview............................................................................................... 72.2 Description of the core functionality ..................................................... 92.2.1 Overview of the software components ................................................. 92.2.2 Sequence of the core functionality ..................................................... 102.3 Hardware and software components ................................................. 112.3.1 Validity ................................................................................................ 112.3.2 Components used .............................................................................. 11

3 Basics ............................................................................................................... 13

3.1 Basics of OPC .................................................................................... 133.2 S7 communication with OPC UA ....................................................... 143.3 Basics of the programming interface SIMATIC NET .NET OPC

Client API ........................................................................................... 153.4 Basics of ADO.NET ............................................................................ 173.5 Basics of the Microsoft Access database ........................................... 19

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

4.1 General overview ............................................................................... 204.2 OPC client "OpcClientBridge" ............................................................ 204.2.1 Flowchart ............................................................................................ 214.2.2 Description of the most important methods........................................ 224.2.3 Integration of the .NET OPC Client API ............................................. 234.3 Recipe control (S7 control program) .................................................. 254.3.1 Program flowchart .............................................................................. 254.3.2 Program structure ............................................................................... 264.3.3 Description of the program blocks ...................................................... 26

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

5.1 Configuring the PC station ................................................................. 285.1.1 Interface settings ................................................................................ 295.1.2 Communication settings ..................................................................... 305.1.3 Configuring components in the Station Configuration Editor ............. 325.2 Configuring the PC station ................................................................. 335.2.1 Configuring the components of the PC station .................................. 335.2.2 Configuring the S7 connection ........................................................... 355.2.3 Configuring the IE General properties ................................................ 365.2.4 Configuring the OPC server properties .............................................. 37

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

6.1 Installation of the hardware ................................................................ 386.2 Installation of the software.................................................................. 386.2.1 Installation of the standard software packages on the SIMATIC

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

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

Page 4: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

Table of Contents

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 4

Siem

ens

AG20

14Al

lrig

hts

rese

rved

7.1 Overview............................................................................................. 427.2 Operation of the Windows application ................................................ 437.3 Monitoring the tags using the watch table in the TIA Portal ............... 44

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

9 References ....................................................................................................... 46

10 History............................................................................................................... 46

Page 5: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

1 Task1.1 Overview

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 5

Siem

ens

AG20

14Al

lrig

hts

rese

rved

1 Task1.1 Overview

IntroductionIndustrial PCs, which are used for visualization, are frequently used in the field ofindustrial automation. A controller which controls the system exists simultaneously.A frequently occurring problem is that data of a database are to be transferred tothe controller and vice versa.This application shows a possible procedure how SIMATIC WinAC RTX caninteract with databases via the SIMATIC OPC server. The standard components ofMicrosoft .NET Framework are used for that.

Overview of the automation taskThe figure below provides an overview of the automation task.Figure 1-1-1

PC with OPC server

Process data

Data acquisition PC with OPC clientand database server

Productiondata

RecipedataRecipe download

Industrial Ethernet

Description of the automation taskThe MS Access database is to communicate with a WinAC RTX. A Windowsapplication, which is also used for visualization, is to be integrated as bridge clientbetween the database and the controller. The data are to be exchanged via thisapplication.To make the example more specific, we show you the recipe-based control of themixing process in WinAC; the recipes are read from the database and additionallyquality data are written back to the database.However, the example focuses on linking the WinAC RTX controller to a databaseusing an OPC server.

Page 6: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

1 Task1.2 Requirements

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 6

Siem

ens

AG20

14Al

lrig

hts

rese

rved

1.2 Requirements

Requirements of the automation taskThe 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. Standardized communication mechanisms are to be used.

Page 7: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

2 Solution2.1 Overview

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 7

Siem

ens

AG20

14Al

lrig

hts

rese

rved

2 Solution2.1 Overview

Schematic overviewThe figure below gives a schematic overview of the most important components ofthe solution with a remote client:Figure 2-2-1

PG/PC SIMATIC IPC427DOPC client visualization with .NET OPC Client APIAccess database

OPC serverWinAC RTXSIMATIC NET V8.x

Industrial Ethernet

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

SIMATIC IPC427DOPC serverWinAC RTXSIMATIC NET V8.xOPC client visualization with .NET OPC Client APIAccess database

Monitor

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

Page 8: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

2 Solution2.1 Overview

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 8

Siem

ens

AG20

14Al

lrig

hts

rese

rved

AdvantagesCompared to classical recipe control systems operated without a PC, this solutionoffers 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 efficientdata exchange with a standard database. Database and client application canbe installed on different computers (connected via Ethernet).

The solution demonstrated here uses the .NET OPC Client API as the interfacefor the programming of the OPC client. It allows the programmer to create OPCcommunication under .NET rather easily.

The modular structure of the C# program allows the use of code elements alsoin new projects.

DelimitationThis 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 knowledgeBasic knowledge in object-oriented programming in the programming language C# in the OPC technologies

is required.

Page 9: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

2 Solution2.2 Description of the core functionality

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 9

Siem

ens

AG20

14Al

lrig

hts

rese

rved

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)

SIMATIC NETOPC server

.NET OPC client libraryencapsulates reusable functions

C#OpcClientBridge

.NET Framework

OPC UA

OPC UA

Accessdatabase

ADO.NET

WinAC RTX

PC (remote client)

.NET OPC client libraryencapsulates reusable functions

C#OpcClientBridge

.NET Framework

OPC UA

Accessdatabase

ADO.NET

WinAC RTXA controller with real-time capability. It performs the actual control of the mixingprocess. The mixing process was developed with the TIA Portal.

SIMATIC NET OPC ServerThe OPC server is the central communication unit between the OPC client and therespective data source (here the WinAC).

.NET OPC Client APIFor coupling to the process, the OPC client "OPCClientBridge" uses the .NET OPCClient API, which is automatically installed with the SIMATIC NET OPC ServerV8.x.

OPC client "OPCClientBridge"Retrieves the data from the database with the aid of ADO.NET mechanisms andforwards them to the OPC server. Furthermore, the OPC client provides an easy-to-use visualization function for operator control and monitoring of the S7 program.The OPC client was developed with C#.

ADO.NETDatabase connection architecture for .NET Framework.

MS Access databaseA database for the storage of recipe and quality data.

Page 10: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

2 Solution2.2 Description of the core functionality

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 10

Siem

ens

AG20

14Al

lrig

hts

rese

rved

2.2.2 Sequence of the core functionality

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

Table 2-1

Action Note

1. Enter the "Server URL". The server URL states on which serverthe OPC client is to connect. Select"local" or "distributed" to fill in a defaultURL.

2. Click the "Connect" button. The "Connect" button serves forestablishing or terminating the OPCconnection to the server.

3. Select the MS Access database. The "MS ACCESS" field states thename of the database with which theOPC client is to connect.

4. Enter the recipe number. The "Recipe Number" field serves forentering the desired recipe.

5. Click the "START" button. Recipe processing will be started.

Note The SIMATIC NET OPC Client API used here for .NET can only be used for thecoupling with SIMATIC NET OPC Servers.

Page 11: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

2 Solution2.3 Hardware and software components

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 11

Siem

ens

AG20

14Al

lrig

hts

rese

rved

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 componentsTable 2-2

Component No. Article number Note

SIMATIC IPC427D 1 6AG4140-8....-0.B0Field PG M4 1 6ES7716-....-0... or a standard PC

Software componentsTable 2-3 SIMATIC SW components

Component No. Article number Note

STEP 7 Prof. V13Update 1

1 6ES7822-1..03-..

WinAC RTX 2010SP1

1 6ES7 611-4SB00-0YB7 WinAC package is containedin the bundle.

SIMATIC NET IESOFTNET-S7SIMATIC NET DVDV8.2

1 6GK1704-1CW08-2AA0 SIMATIC NET is contained inthe bundle and includesSIMATIC NET Software V8.2

Table 2-4 Third-party software

Component No. Article number Note

Microsoft VisualStudio 2012

1 Can be ordered via youradministrator orwww.microsoft.com

Microsoft Access2010

Page 12: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

2 Solution2.3 Hardware and software components

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 12

Siem

ens

AG20

14Al

lrig

hts

rese

rved

Sample files and projectsThe following list contains all files and projects used in this example.

Table 2-5

Component Note

21576581_WinAC_SO_CODE_V2.zip This zip file contains the STEP 7project and the source code ofthe user interface.

21576581_WinAC_SO_DOKU_V2_en.pdf This document.

Page 13: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

3 Basics3.1 Basics of OPC

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 13

Siem

ens

AG20

14Al

lrig

hts

rese

rved

3 Basics3.1 Basics of OPC

OPC is a manufacturer-independent software interface that enables data exchangebetween hardware and software from different manufacturers.

OPC serverOPC components supplying data are referred to as OPC servers. They realize theconnection to existing communication systems. Apart from services, they provideinformation from any data sources (here the S7 controller) to the OPC client.

OPC clientOPC components using an OPC server as data source are referred to as OPCclients.The following access methods are possible: Read

Write

Monitoring tags (reporting value changes)

OPC interfaceThe applications of the OPC interface are based on the client-server model. Onecomponent 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 standardssuch as Data Access, Alarm & Events, Security, Historical, Complex, and XMLData Access in one new, secure and powerful specification. For OPC UA, a newTCP-based, secure, powerful, and standardized communication protocol is used.OPC UA thus provides platform-independent communication. This facilitates thedevelopment of client applications.In this example, the OPC UA interface is used.

Page 14: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

3 Basics3.2 S7 communication with OPC UA

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 14

Siem

ens

AG20

14Al

lrig

hts

rese

rved

Connection between OPC server and controllerThe tag values are read out via the connections configured in the OPC serverusing the respective protocol. In this example, the S7 protocol is used, whichcontains two principle transmission mechanisms: the tag services and the blockservices (see also chapter 3.2 S7 communication with OPC UA).The connections are configured in the TIA Portal (see chapter 5.2.2 Configuring theS7 connection).

3.2 S7 communication with OPC UA

PropertiesThe S7 protocol for PROFIBUS and Industrial Ethernet serves for thecommunication of system components within the SIMATIC S7 automation systemand communication of SIMATIC S7 system components with programmers andPCs. The SIMATIC NET OPC Server allows for using the S7 communication viaOPC UA.The S7 communication contains two different methods of data transmission: Tag services Block services

Tag servicesTag 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 ofaccess is guided by the notation of the S7 tools. Objects in the automation deviceof 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 servicesBlock services enable program-controlled transmission of larger data blocks.Transmission is realized with tags: Tags that receive data blocks Tags that send data blocks

Page 15: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

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

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 15

Siem

ens

AG20

14Al

lrig

hts

rese

rved

3.3 Basics of the programming interface SIMATICNET .NET OPC Client API

FunctionThe SIMATIC NET .NET OPC Client API provides a programming interface fordevelopers in the languages C# and Visual Basic .NET. The simple and intuitiveinterface allows for programming OPC client applications which can process bothdata from COM DA and from UA servers.So, the application can access DA items or UA nodes transparently via the samefunctions.In the case of machine access beyond network limits, the UA interface should bechosen, since it is system-independent.

SetupThe SIMATIC NET .NET OPC Client API contained in the"SimaticNET.OPC.OpcClient.DLL" library on the SIMATIC NET DVD mainly offerstwo categories of functions: 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 namespaceThe following functionality provides the SimaticNet.OpcDaClient namespace ofthe .NET component via the "DaServerMgt" object:

Table 3-1

No. Function Explanation

1. Connection to the OPCserver

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

2. Reading and writing ofOPC data access items

With the "Read" and "Write" methods (or "ReadAsync" and"WriteAsync"), the values from OPC items can be read and writtensynchronously and asynchronously.

3. Reporting data changes The .NET component offers a mechanism for reporting valuechanges. Cyclic reading therefore becomes obsolete.With the "Subscribe" method, items can be registered for monitoringand with "SubscriptionCancel" they can be de-registered again.Changed values are reported via the "DataChanged" event.

4. Finding information onthe address space

The "Browse" method is for searching the address space of an OPCdata access server for OPC items. With the "GetProperties" method,the properties of OPC items can be determined.

Page 16: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

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

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 16

Siem

ens

AG20

14Al

lrig

hts

rese

rved

SimaticNET.OpcCmn namespaceIn the SimaticNet.OpcCmn namespace, general OPC functions are combined.This concerns in particular the searching for OPC servers and finding informationnecessary for connection establishment.In the present example, the functions of this namespace are not used!

Table 3-2

No. Function Explanation

1. Searching for OPC COMservers

With the "EnumComServers" method, the OPC servers on acomputer can be found. It is possible to differentiate between thedifferent OPC specifications such as "OPC Data Access", "OPCHistorical Data Access", or "OPC Alarm & Events".

2. Finding COM OPC servernames

The "ClsidFromPorgld" method determines – depending on thetransmitted parameters computer name and "ProgID" – thecorresponding "CLSID" of the OPC server.

3. Searching for OPC UAservers

The "getCertificateForEndpoint" method connects with the transmittedendpoint URL and loads the server certificate which is returned asOut parameter. You will get the In parameters before by browsing onthe discovery server.

4. Finding the UA endpoint The "EndpointIdentifier" class supplies all the data additionallynecessary for establishing a connection with an UA server.

5. Creating the UAcertificate

The "PkiCertificate" class encapsulates an X509 certificate and allowsfor easy creation of such a certificate. Furthermore, methods foraccess to the "WindowsCertificateStore" for loading and savingcertificates are provided. Via Properties, the fields of the certificatecan only be read.

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

Note A detailed description of the interface can be found in the Siemens IndustryOnline Support in the manual "SIMATIC NET Industrial Communication withPG/PC Volume 2 - Interfaces Programming Manual"(http://support.automation.siemens.com/WW/view/en/61630891)

Page 17: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

3 Basics3.4 Basics of ADO.NET

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 17

Siem

ens

AG20

14Al

lrig

hts

rese

rved

3.4 Basics of ADO.NETADO.NET (ActiveX Data Object .NET) is a set of classes which make data accessservices available for a great number of database systems for .NET Frameworkprogrammers. The database interface is object-oriented.The object model provides a great number of components for creating distributedapplications 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:

– establishes the connection to the database,– fills the DataSet with information,– writes changed data sets back to the database

Notes 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 simpleparameter specification.

For further information, please refer to the secondary literature.

Page 18: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

3 Basics3.4 Basics of ADO.NET

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 18

Siem

ens

AG20

14Al

lrig

hts

rese

rved

ADO.NET application modelFigure 3-3-1

.NET

prov

ider

DataAdapter

SelectCommand

InsertCommand

UpdateCommand

DeleteCommand

Command Connection

DataReader

DataSet

Datatables

DataRows

.NET application

Database

Only Readaccess

Read & Write access

Fills with data from thedata source

Updates thechanges

creates

is

needs

Executes instructionsagainst the database

Open / Closemanagestransactions

12

3

4

5

ExplanationThe numbers have the following meaning:

Table 3-3

No. Object / Action Explanation

1. "Connection" establishes aconnection with the database.

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.2. Command objects mainly execute

SQL statements in the database.3. The DataReader enables performant

reading of a forward directed datastream from the database.

The DataReader can only be used for reading data fromthe database.

Page 19: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

3 Basics3.5 Basics of the Microsoft Access database

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 19

Siem

ens

AG20

14Al

lrig

hts

rese

rved

No. Object / Action Explanation

4. The DataAdapter provides aninterface between the DataSet (5) andthe database using the respectivecommand.

The DataAdapter corresponds with a DataSet or aDataTable.

In order to execute an UpdateCommand with aDataAdapter, it must only contain one DataTable!

5. A DataSet contains the data of thedatabase.

The DataSet represents the database structure and itsdata in the memory of the PC. This enables a transient saving of selected data of

the database. Transfer of database data via XMLand WebServices is possible without greaterproblems.

The DataSet object can also be used for generatingor modifying relationships between DataTables.An adaptation of the data model in the transientmemory is hence possible.

3.5 Basics of the Microsoft Access database

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

Page 20: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

4 Functional Principle4.1 General overview

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 20

Siem

ens

AG20

14Al

lrig

hts

rese

rved

4 Functional Principle4.1 General overview

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

STEP 7 programOPC client“OpcClientBridge”

Wait “Start”

Monitor Items

Read async

Write “protocol data”to database

START

CurrentRecipeStart

“DataRequestAk”transfer recipe“DataSend”

Write async

“DataRequest”

1

2

3

4

5

Wait “DataRequest”

Write async Wait “DataSend”

“DataSendAk”Wait “DataSendAk”Read async

Update visualizationWait step endWait recipe end

Start recipeStatus information

Write “quality info” todatabase

The following chapters provide a detailed description of the individualfunctionalities.

4.2 OPC client "OpcClientBridge"

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

Page 21: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

4 Functional Principle4.2 OPC client "OpcClientBridge"

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 21

Siem

ens

AG20

14Al

lrig

hts

rese

rved

4.2.1 Flowchart

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

Figure 4-4-2

Connect with database

Datarequested?

START

Load data to DataSet

Start monitoring

No

Transfer data tocontroller

Yes

Datareceived bycontroller?

No

Yes

Start monitoring

Recipecompleted?

No

Yes

New stepstarted?

No

Yes

Logging of the reciperuntime in the DataSet

Logging of the stepruntime in the DataSet

Logging of the stepruntime in the DataSet

New datarequested?

No

Yes

Reset step chain andwait for restart

Stop buttonclicked?

No

Yes

Connect withOPC server

Page 22: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

4 Functional Principle4.2 OPC client "OpcClientBridge"

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 22

Siem

ens

AG20

14Al

lrig

hts

rese

rved

4.2.2 Description of the most important methods

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

"btnConnect_Click" methodThis button click method connects/disconnects the OPC client to/from the OPCserver.

"btnStartClient_Click" methodThis 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)

"btnSTOPClient_Click" methodThis button click method ends monitoring and terminates the connection to thedatabase.

"ConnectToACCESSDB" methodThis method establishes a connection to the Access database and writes the dataof the tables "Expiry", "Protocol", and "Quality" to the "DataSetFull" DataSet.

"startMonitoring" methodThis method registers the data to be retrieved with the OPC server.

"stopMonitoring" methodThis method de-registers the data to be retrieved with the OPC server.

"writeOneItem" methodThis method writes a tag to the OPC server.

"readOneItem" methodThis method reads a tag from the OPC server.

"DataChanged" methodIf the server identifies a change of the registered data, this method is called in theclient. With the help of this method, the changed value can be identified and acorresponding reaction can be initiated.The three most important value changes are: Data requested? TransferRecipe

Current step changed? E1_StepChanged

Current recipe completed? E2_Finish

Page 23: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

4 Functional Principle4.2 OPC client "OpcClientBridge"

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 23

Siem

ens

AG20

14Al

lrig

hts

rese

rved

"TransferRecipe" methodThe desired recipe number is transferred to the method. At the beginning of themethod call, the number of steps of the relevant recipe and the position in theExpiry table is determined. Subsequently, the client generates a list of write itemsfor the transfer of the individual data depending on the number of steps. In the nextstep, the individual values of the recipe are copied from the DataSet to the list ofwrite items. The list of write items and the number of steps are transferred to theOPC server (or controller).

"E1_StepChanged" methodThis event writes the data (runtime, time stamp, filling level, etc.) of the currentlyprocessed individual workstep to the "Protocol" table of the DataSetFull.

"E2_Finish" methodThis event writes the data (runtime, time stamp, etc.) of the currently processedrecipe to the "Quality" table of the DataSetFull.

4.2.3 Integration of the .NET OPC Client API

GeneralIn order to use the functionality of the .NET OPC Client API , the correspondingassemblies have to be referenced in MS Visual Studio first.

Table 4-1

No. Action

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

Page 24: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

4 Functional Principle4.2 OPC client "OpcClientBridge"

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 24

Siem

ens

AG20

14Al

lrig

hts

rese

rved

No. Action

2. For adding the references in theproject settings, please first open the"Add Reference" dialog via the contextmenu.

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

Note The fully compiled assemblies have been made for x86 systems. This meansthat 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 tox86.

Page 25: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

4 Functional Principle4.3 Recipe control (S7 control program)

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 25

Siem

ens

AG20

14Al

lrig

hts

rese

rved

4.3 Recipe control (S7 control program)

The STEP 7 project contains the control program which provides the simulation ofthe 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 aprogram flowchart.

Figure 4-4-3

Send data request

Have databeen sent?

START

Start recipe

Determine number ofsequence steps

No

Send transmissionconfirmation

Yes

Last step?No

Yes

Reset instances andwait for restartSet tag i = 0

Read data for step i

Start processing of step i

Write status information

i = i + 1

Page 26: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

4 Functional Principle4.3 Recipe control (S7 control program)

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 26

Siem

ens

AG20

14Al

lrig

hts

rese

rved

4.3.2 Program structure

The graphic below illustrates the interaction of the individual blocks. The data arebasically transferred during block calls. In some exceptional cases, blocks accessglobal data, which is also shown in this graphic for greater clarity.

Figure 4-4-4

User program

OB_main_cycl[OB 1]

FB_Simulation

DB_Visual

DB_Command_Glob

DB_Recipe

Data blocks

FB_DBIndex

FB_WorkingOfSteps

FB_WorkStep

OPC server

4.3.3 Description of the program blocks

"OB_main_cycl" organization blockOB1 calls the "FB_WorkingOfSteps" block with the values determined from theglobal data blocks and transfers the I/O data of the "FB_WorkStep" block to theglobal data block "DB_Visual".

"FB_WorkStep" function blockThis block is used to execute one single workstep of the recipe. Execution startswith 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. Theblock 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 aPLC cycle is set and the "Busy" output is reset.

"FB_WorkingOfSteps" function blockThis function block is the core element of the recipe program. It includes the datarequest and acknowledgment after data receipt and is thus the interface to theOPC 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 thetime passed until the present stage of processing.

Page 27: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

4 Functional Principle4.3 Recipe control (S7 control program)

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 27

Siem

ens

AG20

14Al

lrig

hts

rese

rved

"FB_DBIndex" function blockThe function block serves for determining the data of a processing step from therecipe data block "DB_Recipe" based on the number of the recipe data block andthe current step number.

"FB_Simulation" function blockThis function block is used to simulate the I/O of the bottling plant. This blockprovides different input and output parameters (valves, heater switches, etc.). If, forexample, the heater input is set to 1, the temperature will rise gradually.

"DB_Recipe" data blockAs a buffer for recipe data, the "DB_Recipe" data block is the most important datablock. The complete recipe to be processed, which is transferred by the OPCclient, 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 thedata structure of a step (see Table 4-2).

Table 4-2 Data type "UDT_Recipe"

Name Data type Meaning

StepNr INT Includes the number of the step to ensure correctidentification.

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 blockThis data block serves for exchanging commands and states between thecontroller and the OPC client "OPCClientBridge". The OPC client accesses thisdata block directly.

"DB_Visual" data blockThe "DB_Visual" data block saves the current recipe processing values. The OPCclient "OPCClientBridge" retrieves the values from the data block and visualizesthem on the user interface.

Page 28: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

5 Configuration and Settings5.1 Configuring the PC station

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 28

Siem

ens

AG20

14Al

lrig

hts

rese

rved

5 Configuration and Settings5.1 Configuring the PC station

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

Focus Module IP address

PG/PC NDIS network card 192.168.115.20PC station SIMATIC IPC427D 192.168.115.10

Subnet mask: 255.255.255.0.

Setting the IP addressThe Ethernet network card has to be switched to the configured operation. For thispurpose, the PC station has to be configured.

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

Page 29: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

5 Configuration and Settings5.1 Configuring the PC station

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 29

Siem

ens

AG20

14Al

lrig

hts

rese

rved

5.1.1 Interface settings

Table 5-2 Interface settings

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 accesspoint of the application.

Page 30: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

5 Configuration and Settings5.1 Configuring the PC station

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 30

Siem

ens

AG20

14Al

lrig

hts

rese

rved

5.1.2 Communication settings

Table 5-3 Communication settings

No. Action

1. Open the "Communication Settings" dialog.

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

Page 31: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

5 Configuration and Settings5.1 Configuring the PC station

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 31

Siem

ens

AG20

14Al

lrig

hts

rese

rved

No. Action

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

4. Check the set IP address.

Page 32: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

5 Configuration and Settings5.1 Configuring the PC station

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 32

Siem

ens

AG20

14Al

lrig

hts

rese

rved

5.1.3 Configuring components in the Station Configuration Editor

Table 5-4

No. Action

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

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

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

Page 33: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

5 Configuration and Settings5.2 Configuring the PC station

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 33

Siem

ens

AG20

14Al

lrig

hts

rese

rved

5.2 Configuring the PC station

5.2.1 Configuring the components of the PC station

Table 5-5

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 versionof your OPC server and add the OPC server to your PC station.In this application, the SIMATIC NET OPC Server V8.2 is used.

Page 34: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

5 Configuration and Settings5.2 Configuring the PC station

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 34

Siem

ens

AG20

14Al

lrig

hts

rese

rved

No. Action

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

5. Select "IE general" in the "Communications modules – PROFINET/Ethernet" folderunder "PC systems". In the "Information" window, select the installed version ofyour interface and add it to your PC station.

Page 35: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

5 Configuration and Settings5.2 Configuring the PC station

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 35

Siem

ens

AG20

14Al

lrig

hts

rese

rved

5.2.2 Configuring the S7 connection

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

No. Action

1. 1. Open the "Network view".2. To create a new connection, go to "Connections".3. Select "S7 connection" as the connection type.4. 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 themouse button there.

5. Configure the connection by editing the properties of the connection.

12 3

4

5

Page 36: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

5 Configuration and Settings5.2 Configuring the PC station

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 36

Siem

ens

AG20

14Al

lrig

hts

rese

rved

5.2.3 Configuring the IE General properties

Table 5-7

No. Action

1. 1. Open the "Device view" of the PC station.2. Select the network card "IE general_1".3. In the inspector window, select the "Properties" tab > "General" > "PROFINET

interface (X1)".4. Enter the IP address of the station under "Ethernet addresses" > "IP protocol".

1

2

3

4

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

Page 37: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

5 Configuration and Settings5.2 Configuring the PC station

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 37

Siem

ens

AG20

14Al

lrig

hts

rese

rved

5.2.4 Configuring the OPC server properties

Table 5-8

No. Action

1. 1. Open the "Device view" of the PC station.2. Select the OPC server "OPC Server_1".3. In the inspector window, select the "Properties" tab > "General".4. Select "Configured" under "OPC tags". This enables the "Configuring..."

button.Select "All" if you want to use all process tags.

5. Click the "Configuring..." button if you only want to access a selection ofprocess tags symbolically.

1

2

3

4 5

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

Page 38: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

6 Installation and Startup6.1 Installation of the hardware

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 38

Siem

ens

AG20

14Al

lrig

hts

rese

rved

6 Installation and Startup6.1 Installation of the hardware

The figure below shows the hardware configuration of the application.

Figure 6-6-1

24V DC

PG/PC SIMATIC IPC427D

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 SIMATICIPC.A description of the installation procedure for "WinAC RTX" and "SIMATIC NET" isnot part of this documentation. The installation takes place in the usual Windowsenvironment 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 isalready preinstalled on SIMATIC PGs.At this point, we will not go further into the installation of STEP7 V1x. Theinstallation takes place in the usual Windows environment and is self-explanatoryor described in the respective manuals.

Page 39: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

6 Installation and Startup6.2 Installation of the software

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 39

Siem

ens

AG20

14Al

lrig

hts

rese

rved

6.2.3 De-archiving the application software

Unzip the zipped "21576581_WinAC_SO_CODE_V2.zip" code folder from thedownload 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 orSIMATIC 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 thesame directory

Files includedThe "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

UninstallationTo uninstall, delete the directory.

Page 40: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

6 Installation and Startup6.3 Startup of the STEP 7 project

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 40

Siem

ens

AG20

14Al

lrig

hts

rese

rved

6.3 Startup of the STEP 7 project

No. Action Remarks

1. Open the TIA Portal andclick on "Browse".

2. Navigate to the projectdirectory of the STEP 7project included in thedelivery and open theproject.

3. Go to the project view.

Page 41: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

6 Installation and Startup6.3 Startup of the STEP 7 project

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 41

Siem

ens

AG20

14Al

lrig

hts

rese

rved

No. Action Remarks

4. Select the PC station andclick the "Download todevice" button.

5. Set WinAC RTX to RUNmode.

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

Page 42: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

7 Operation of the Application7.1 Overview

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 42

Siem

ens

AG20

14Al

lrig

hts

rese

rved

7 Operation of the Application7.1 Overview

Overview and description of the user interfaceThe figure below shows the user interface of the Windows application"OPCClientBridge".

Figure 7-7-1

12 3 4

5

67

8 9

11

10

12

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 localOPC server.

3. distributed With "distributed", the server URL "opc.tcp://192.168.115.10:4845" is defaultedto a remote OPC server.

4. Connect /Disconnect

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

5. ConnectionState

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

Page 43: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

7 Operation of the Application7.2 Operation of the Windows application

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 43

Siem

ens

AG20

14Al

lrig

hts

rese

rved

Position Element Meaning

6. ACCESSConnection

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 fromyour 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 andstarts automatic polling of the controller's status values by means ofsubscriptions.

9. STOP Stops Auto mode and thus the execution of the recipe.This includes the termination of the connection to the Access database andstops automatic polling of the controller's status values.

10. RecipeNumber

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

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 applicationThe following steps are required for automatic recipe processing on a remotePG/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 theWinAC, the server URL "opc.tcp://localhost:4845" canbe used.

3. Connect with the OPC server byclicking 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 thedelivery.

5. Enter the desired recipe in the "RecipeNumber" input field.

In the "RecipeAdministration.mdb" database includedin the delivery, the recipes 1 to 3 are defined.

Page 44: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

7 Operation of the Application7.3 Monitoring the tags using the watch table in the TIA Portal

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 44

Siem

ens

AG20

14Al

lrig

hts

rese

rved

No. Action Remarks

6. Click the "START" button. The connection to the database is established. Theclient sends the start command to the controller.Subsequently, data are exchanged between thecontroller and the client. The status bar informs youon the program status, the current step, and theconnection status to the database. The visualizationwindow displays the current data of the process. Inaddition, the currently active process step of thecontroller is highlighted in the table listing the recipes.After completion of the recipe, all quality and protocoldata stored in the DataSet are stored in the selecteddatabase. The status bar displays the "recipefinished" message.The client now waits for the next recipe request. Clickthe "STOP" button to stop the client.

7.3 Monitoring the tags using the watch table in theTIA PortalThe control program in the WinAC controller can be monitored using the watchtable 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. Open the watch table by double-clicking on "Watch table_1".

2. Click the "Monitor all" button.3. Start recipe execution with the OPC client "OpcClientBridge". You can now

monitor the data exchange between the controller and the client.

1

2

3

Page 45: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

8 Further Notes, Tips & Tricks, etc.

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 45

Siem

ens

AG20

14Al

lrig

hts

rese

rved

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

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

Page 46: Application Description y 06/2014 PC-Based Automation ... · PC-Based Automation: Connection of Databases via open Interfaces Using OPC-Client, Programmed with the SIMATIC NET.NET

9 References

PC-Based Automation: Connection of Databases via open InterfacesUsing OPC-Client, Programmed with the SIMATIC NET.NET OPCClient API in C#Database Connection to WinAC Using OPC ClientEntry ID: 21576581, V2.0, 06/2014 46

Siem

ens

AG20

14Al

lrig

hts

rese

rved

9 ReferencesBibliography

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

Subject Title

\1\ Siemens IndustryOnline Support

http://support.automation.siemens.com

\2\ Download page ofthe entry

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

\3\ SIMATIC NET PCsoftware IndustrialCommunicationwith PG/PCVolume 1 - BasicsSystem Manual

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

\4\ SIMATIC NETIndustrialCommunicationwith PG/PCVolume 2 -InterfaceProgrammingManual

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

\5\ SIMATICWindowsAutomationCenter RTXWinAC RTX (F)2010

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

\6\ SIMATIC NETIndustrialCommunicationCommissioningPC Stations

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

10 History

Table 10-1

Version Date Modifications

V1.1 05/2005 First versionV2.0 06/2014 Changeover to OPC UA and TIA Portal