Sei sulla pagina 1di 43

Application Description  08/2014

Programming a Simple OPC DA .NET


Client with SIMATIC NET OPC Data
Control
SIMATIC NET OPC Server

http://support.automation.siemens.com/WW/view/de/21043779
Warranty and Liability

Warranty and Liability


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

We do not accept any liability for the information contained in this document.
Any claims against us – based on whatever legal reason – resulting from the use of
the examples, information, programs, engineering and performance data etc.,
described in this Application Example will be excluded. Such an exclusion will 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
 Siemens AG 2014 All rights reserved

(“wesentliche Vertragspflichten”). The compensation for damages due to a breach


of a fundamental contractual obligation is, however, limited to the foreseeable
damage, typical for the type of contract, except in the event of intent or gross
negligence or injury to life, body or health. The above provisions do not imply a
change in the burden of proof to your disadvantage.
Any form of duplication or distribution of these Application Examples or excerpts
hereof is prohibited without the expressed consent of Siemens Industry Sector.

Security Siemens provides products and solutions with industrial security functions that
informa- support the secure operation of plants, solutions, machines, equipment and/or
tion 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 product-
specific newsletter. For more information, visit
http://support.automation.siemens.com.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 2
Table of Contents

Table of Contents
Warranty and Liability ................................................................................................. 2
1 Task ..................................................................................................................... 4
1.1 Overview............................................................................................... 4
1.2 Requirements ....................................................................................... 5
2 Solution............................................................................................................... 6
2.1 Description of the core functionality ..................................................... 7
2.2 Hardware and software components used........................................... 9
2.3 Alternative solutions ........................................................................... 11
3 Functional Mechanisms of this Application ................................................. 13
3.1 Programming of the client whilst using .NET OPC Data Control ....... 13
3.1.1 Integrating the assemblies ................................................................. 13
3.1.2 Setting the compiler ............................................................................ 15
3.1.3 Creating the interface ......................................................................... 16
3.1.4 Connect the OPC data points (tags) with the control ......................... 17
3.1.5 Writing of OPC items .......................................................................... 19
3.2 Explanations on the simulation program in the controller .................. 21
3.2.1 Process of simulation ......................................................................... 21
3.2.2 Function of the blocks ........................................................................ 22
4 Configuration of an OPC Server .................................................................... 23
 Siemens AG 2014 All rights reserved

4.1 Configuration of the OPC server station ............................................ 23


4.2 Final check of the settings .................................................................. 27
5 Installation and Commissioning .................................................................... 29
5.1 Hardware and software installation .................................................... 29
5.2 Loading the PC station via STEP 7 V1x ............................................. 31
5.3 Importing the XDB file into the Station Configuration Editor .............. 36
5.4 Installation of the OPC client on the PC/PG....................................... 39
5.5 Loading the simulation to the S7 stations .......................................... 40
6 Operating the Application ............................................................................... 41
7 Glossary ........................................................................................................... 42
8 Links & Literature ............................................................................................ 43
8.1 Internet link specifications .................................................................. 43
9 History............................................................................................................... 43

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 3
1 Task
1.1 Overview

1 Task
1.1 Overview
Introduction
This application example shows the coupling of a production process to a
Windows-based PC with a very simple data exchange via OPC that can be realized
very quickly. With this principle of operation, for example, separate, specialized
user interfaces and process visualization or data acquisition can be realized.

Overview of the automation task


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

Applications on the PC
Visualization
Data acquisition DB other
Visualization
Monitoring Connection applications
Control system
Copyright  Siemens AG 2014 All rights reserved

Operating OPC Client

OPC server

Process
Logic PLC … PLC
Data
I/O I/O

Description of the automation task


A process is simulated with two different PLCs. The data from this process is to be
displayed and modified. This application shows how – whilst using SIMATIC NET
OPC Data Control for .NET - process data can be displayed on a PC, irrespective
from which process control this data comes.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 4
1 Task
1.2 Requirements

1.2 Requirements
Requirements for operating and monitoring software for visualizing
The software is to enable the fast and simple creation of an interface. For this
purpose, the following requirements have to be met:
• Use of the simplified .NET OPC DA Connector for switching with
.NET interface controls.

Requirements for the data interface between visualizing and controller


Process data are exchanged via the standardized OPC DA interface:
• Connection to the process data via Industrial Ethernet as well as
SIMATIC NET OPC Server V8.2 (or higher).
• Use of the OPC DataAccess interface
• Symbolic addressing of the process data
• Reading and writing of process data
• Monitoring of process data

Requirements to the development environment to be used


Copyright  Siemens AG 2014 All rights reserved

The current Windows development environment is to be used:


• Use of Microsoft Visual Studio® .NET 2008 SP1 (or higher)
• Use of the .NET programming language Visual C#

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 5
2 Solution
1.2 Requirements

2 Solution
Schematic layout
The figure below shows a schematic overview of the most important components of
the solution:
Figure 2-1

PG/PC station
STEP 7 V13
SIMATIC NET CD V12
MS Visual Studio 2010
OPC client with .NET data control

Industrial Ethernet

on S7-1200 station
Copyright  Siemens AG 2014 All rights reserved

N/DP CPU 1214C

S7 station
On the controller side, there is a SIMATIC S7-300 with a CPU 315-2 PN/DP as well
as optionally the CP 343-1. Furthermore an S7-1214C with Ethernet connection.

PC station
A PC station is connected via a switch to a S7-300 controller and a S7-1200. A
standard Ethernet network card is used for this. The SIMATIC NET OPC server as
well as the OPC client is running on the PC station. A very simply designed client
shows you all basic functions for getting started.

Advantages
The solution shown here uses the SIMATIC NET OPC DA server and can be used
irrespective of the type of used SIMATIC controller. The coupling shown of the
SIMATIC and the OPC server via S7 protocol and Ethernet is transparent for the
client. The solution shown here can also be used for all other protocols and bus
variants supported by the SIMATIC NET OPC server.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 6
2 Solution
2.1 Description of the core functionality

Delimitation
This application does not contain a complete description
• of the .NET framework,
• of C# or VB.NET,
• of the OPC specification or
• deeper level COM mechanisms

Assumed knowledge
Basic knowledge in the area of object-oriented programming, as well as in the
COM environment is assumed. Further knowledge in UML (Unified Modelling
Language) is an advantage.

2.1 Description of the core functionality


Software components involved
The figure below shows the involved software components as well as the usage
variant (1) shown in this example:
Copyright  Siemens AG 2014 All rights reserved

Figure 2-2

.NET Framework V3.5 SP1

.NET Windows application


Application
GUI using OPC Client functionality
1 2
SimaticNET.OPC.DAConnector

.NET OPC Client Connector


SimaticNET.OPC.BrowseControls

Assemblies .NET OPC Client Browser


In scope of delivery of
SIMATIC NET DVD 2011
SimaticNET.OPC.OpcClient

.NET OPC Client API


COM OPC Custom Interface

SIMATIC NET
OPC Server V8.1
Logic / Simulation OPC server
IE Softnet S7
CPU S7 protocol
PLC PG/PC
CP Ethernet NIC

PC/PG
A C# OPC client has been realized on the PC/PG for visualizing.
For coupling to the process, the OPC client uses the SIMATIC NET .NET data
controls automatically installed with the SIMATIC NET OPC server as of V8.2.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 7
2 Solution
2.1 Description of the core functionality

The two assemblies (SimaticNET.OPC.DaConnector and


SimaticNET.OPC.BrowseControls) used in this example encapsulate the OPC DA
interface and offer the client a simple usage option from .NET applications.
The SIMATIC NET OPC server establishes the connection to the controller via the
SIMATIC NET SOFTNET-S7 connection.

Control
The controller provides the data to be visualized. For this purpose, a simple
S7 program for simulating various data types is implemented.

Created software components


• C# OPC client
• STEP 7 simulation program

General application procedure


The application shows a simple application variant, to demonstrate the possibilities
for accessing. Small visualization with simple interfaces use the .NET OPC client
control with DAConnector Assembly and can “switch” OPC Items with Windows
control without programming effort.
Table 2-1
Copyright  Siemens AG 2014 All rights reserved

No. Action User interface


1 .NET OPC Client Connector:

Connection to the SIMATIC NET OPC


server:
• connecting with the OPC server
• display of the connection status
• monitoring values
• reading/writing values

Note The SIMATIC NET OPC Data Control used here for .NET can only be used for
the coupling with SIMATIC NET OPC servers.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 8
2 Solution
2.2 Hardware and software components used

2.2 Hardware and software components used


The application was created with the following components:

Hardware components for the controller


Table 2-2
Component No. Article number Note
PS307 5A 1 6ES7307-1EA00-0AA0
CPU 315-2 PN/DP 1 6ES7315-2AG10-0AB0 or a comparable S7-
300 CPU with
PROFINET interface
S7-1200 PM 1207 1 6EP1332-1SH71
CPU 1214C DC/DC/DC 1 6ES7 214-1AE30-0XB0 or a comparable S7-
1200 CPU
Standard switch 1 Depending on product

Hardware components for the PC


Table 2-3
Copyright  Siemens AG 2014 All rights reserved

Component No. Article number Note


Field PG M4 1 6ES7716-.....-0... or a standard PC with
respective software
NDIS-capable network card 1 Depending on product Integrated in field PG

Standard software components


Table 2-4
Component No. Article number Note
STEP 7 1 6ES7822-4AA03-0YA5
Professional V13
WinCC 1 6AV2103-0DA00-0AM0 Adjust the article number according
Professional V13 to the required power tags.
SIMATIC NET IE 1 6GK1704-1LW12-0AA0 LW=8 S7 connections (Lean),
SOFTNET-S7 6GK1704-1CW12-0AA0 CW=64 S7 connections
(V12)
Microsoft Visual 1 Express Edition Obtainable in the Microsoft
Studio 2010 Standard Edition store
Professional Edition (http://emea.microsoftstore.com)
.NET Framework 1 Free download at Installed by SIMATIC NET
3.5 http://www.microsoft.com/

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 9
2 Solution
2.2 Hardware and software components used

Sample files and projects


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

Table 2-5
Component Note
21043779_OPCDAConnector_CODE.zip C# Source code of the user
interface and archived STEP 7 V13
and STEP 7 V13 project
21043779_OPCDAConnector_DOKU_V1_1_e.pdf This document
Copyright  Siemens AG 2014 All rights reserved

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 10
2 Solution
2.3 Alternative solutions

2.3 Alternative solutions


Here you are given information on existing alternatives for solving the automation
problem and the characteristics of these alternatives.

Using the Standard OPC Foundation .NET Wrapper (Raw Interface)


Principally, the standard OPC .NET API can be accessed. This is described in the
“Programming an OPC DA .NET Client with C# for the SIMATIC NET OPC Server
(COM/DCOM)” document.
This has the following advantages and disadvantages:
Table 2-6
Advantages Disadvantages
• Connection to OPC servers of • Complex API complicates its use.
other manufacturers possible. • Basic functionality of a client (e.g. reconnect
• Full function of the API can be in the event of a disconnection) has to be
used (full flexibility) individually implemented.
• Administrative functions have to be
implemented individually.
• Easy switching with Standard .NET Controls
not straightforward.
Copyright  Siemens AG 2014 All rights reserved

Comparison of OPC .NET Wrapper (Raw Interface) and SIMATIC NET OPC Data Controls
(Toolkit)
Due to the data structures defined in the OPC specification, the OPC interface has
been implemented as custom interface. OPC clients that are implemented in C#
access via RCW (runtime callable wrapper). This wrapper is provided by the OPC
foundation and passes the raw OPC interface through (COM Interop). The OPC
.NET wrapper therefore offers full functionality and full flexibility. However, all
administrative functions have to be implemented from the client. Equally as generic
client behavior such as automatic reconnection after disconnection, for example.
The SIMATIC NET OPC data controls for .NET constitute a client toolkit with a
heavily simplified .NET API. This encapsulates essential administrative functions
and logic behavior in a data control and concealed from the C# programmer. This
facilitates the implementation effort considerably.

Note The SIMATIC NET OPC client controls can only connect with SIMATIC NET OPC
servers but not with OPC servers of other manufacturers.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 11
2 Solution
2.3 Alternative solutions

Decision criteria for using different library variants


The following table shows you the most important decision criteria which are
decisive for selecting the used programming language.
Table 2-7
Criterion Description
Multivendor capability Is the use of the OPC client also demanded with other
OPC servers?
Quantity framework What data volumes should be processed by the OPC
client?
OPC DA and OPC UA Should other OPC UA connections apart from OPC DA
also be used?
Simple implementation In how far is the language suitable to implement code
relatively simply and quickly?
OPC background know-how How much OPC know-how is required to realize the client?
.NET programming How much C# programming experience is required to
experience realize the client?
Use Case How complex is the application that processes OPC data,
how much flexibility is required on the OPC interface?
Copyright  Siemens AG 2014 All rights reserved

Comparison of different library variants


The following table compares the programming variants, using the above described
criteria.
Table 2-8
Criterion SIMATIC NET OPC SIMATIC NET OPC OPC Foundation .NET
Client Control Client API Wrapper
Multivendor capability - - 
Quantity framework -  
OPC DA and OPC UA  (*)  (*) only DA
Simplicity ++ + -
OPC know-how none minimum +
.NET know-how none + ++
Flexibility -  

(*) classic OPC DA and OPC UA parallel,


limited to SIMATIC NET OPC servers

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 12
3 Functional Mechanisms of this Application
3.1 Programming of the client whilst using .NET OPC Data Control

3 Functional Mechanisms of this Application


Introduction
In the following chapters we will show you details for programming in PC and the
S7-CPU.

3.1 Programming of the client whilst using .NET OPC Data


Control
Overview
In the sections below we will show you how the .NET assemblies can be integrated
in the development environment and how you can easily create a simple interface.

3.1.1 Integrating the assemblies

General information
In order to use the functionality of the .NET OPC client control, the assemblies
Copyright  Siemens AG 2014 All rights reserved

have to be referenced in MS Visual Studio first.


Table 3-1
No. Action Remarks
1 Open MSVS 2010 and
create a new project for a
Windows Forms
Application

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 13
3 Functional Mechanisms of this Application
3.1 Programming of the client whilst using .NET OPC Data Control

No. Action Remarks


2 First of all add a new tab
in the toolbox and call it
“SimaticNET”

Subsequently add the


.NET OPC client controls
in this tab

3 Select three SimaticNET


controls and add them.
Copyright  Siemens AG 2014 All rights reserved

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 14
3 Functional Mechanisms of this Application
3.1 Programming of the client whilst using .NET OPC Data Control

3.1.2 Setting the compiler

General information
The sample application to be created uses assemblies that are delivered
precompiled. They have been created for x86 systems. This means that the
sample application has to be constructed for x86. For this purpose, the Build
configuration in MS Visual Studio for debug and release has to be set to x86.

Table 3-2
No. Action Remarks
1 For release and debug set
the Build configuration to
x86 each
Copyright  Siemens AG 2014 All rights reserved

2 If x86 cannot be selected,


open the Configuration
Manager and add the x86
Build option.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 15
3 Functional Mechanisms of this Application
3.1 Programming of the client whilst using .NET OPC Data Control

3.1.3 Creating the interface

General information
In order to create a simple interface you do not have to program anything yourself.
Drag the desired controls to the form and give it a meaningful name.
Drag the “OPCDAConnector” control to the form with “drag&drop”. It has no
interface and is therefore displayed in the bottom part of the designer window. This
control contains the complete encapsulated OPC client functionality.
Table 3-3
No. Action/Remark
1 Drag the “OPCDAConnector” control to the form.
Copyright  Siemens AG 2014 All rights reserved

2 Add other standard Windows controls to the form. For this purpose, use the toolbox.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 16
3 Functional Mechanisms of this Application
3.1 Programming of the client whilst using .NET OPC Data Control

3.1.4 Connect the OPC data points (tags) with the control

Introduction
To establish an interconnection, the OPC data points with the properties of the
standard Windows controls, the OPCDAConnector has to be started.

Configuration steps
Table 3-4
No. Action/Remark
1 Select the icon of the OPCDAConnector and open the properties of the control.

Open the Connector via the button


Copyright  Siemens AG 2014 All rights reserved

2 Adding the OPC server:


The OPC server browser is located in the left top window of the OPCDAConnector. Add the
SIMATIC NET OPC Server (OPC.SimaticNET.1) here. Subsequently browse the server to select the
desired OPC items.
Notice: the SIMATIC NET OPC Data Control used here for .NET can only be used for the coupling
with SIMATIC OPC servers.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 17
3 Functional Mechanisms of this Application
3.1 Programming of the client whilst using .NET OPC Data Control

No. Action/Remark

3 Data transmission direction


Copyright  Siemens AG 2014 All rights reserved

The transmission direction of the data (data flow) is set separately for each linked pair. Possible are
• Item => Control
As soon as the OPC item changes, the process value is written in the control.
• Item <= Control
Only the values of the control are transferred in the direction of the item. This requires a trigger
event.
• Item <=> Control
A bidirectional transmission is possible, in addition a trigger event can be configured that
triggers the transmission from the control to the OPC item (e.g. a Button_Click_Event)

4 Data type conversion


When interconnecting properties and OPC items, a data type conversion is required, depending on
the transmission direction. The OPCDAConnector tries to perform the conversion automatically, as
far as possible. The validation event regarding the interconnected data types is displayed by an icon
each in the connection list.
• Green checkmark
Ok: the data types are suitable.
• Orange checkmark
Warning: the data types can be converted into each other; however, there is the risk of
exceeding the value range.
• Red cross
Error: the data types cannot be converted for the selected transmission direction.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 18
3 Functional Mechanisms of this Application
3.1 Programming of the client whilst using .NET OPC Data Control

3.1.5 Writing of OPC items

Introduction
The writing of OPC items directly from the Windows control can be performed in
different ways. Depending on the requirements to the control logic and the
application, the OPCDAConnector can be configured accordingly.

Configuration steps
An event typically triggers the write process. This can be a click event button that is
triggered when pressing a button or the key press event that is triggered when
editing a textbox.
Table 3-5
No. Action Remarks
1 Open the Connector
Configuration to configure
individual data
connections
Copyright  Siemens AG 2014 All rights reserved

2 General setting of the


behavior of this particular
data connection.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 19
3 Functional Mechanisms of this Application
3.1 Programming of the client whilst using .NET OPC Data Control

No. Action Remarks


3 Select the event that is to trigger the writing.
For example, the “KeyDown” event of a TextBox that corresponds to a “Return” when the condition
is fulfilled.

The trigger for writing a value to the controller is trigged when the “Enter” button is pressed.
Copyright  Siemens AG 2014 All rights reserved

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 20
3 Functional Mechanisms of this Application
3.2 Explanations on the simulation program in the controller

3.2 Explanations on the simulation program in the


controller
3.2.1 Process of simulation

Description of the process


The processes within the controller are quite simple.
The OB1 block calls the functions FC10, FC11, FC13 and FC14 cyclically. These
functions “move” the data in data block DB51. In addition, the function block FB100
can be called in this general simulation program which handles BSEND, BRCV in
order to send or receive a data block. The data buffer is preset to 4096 bytes. The
BSEND / BRCV function is not required in this example.
The simulation contains all simple data types and can simply be expanded by
arrays.

Call path of the blocks


The following diagram illustrates the call path:
Figure 3-1
Copyright  Siemens AG 2014 All rights reserved

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 21
3 Functional Mechanisms of this Application
3.2 Explanations on the simulation program in the controller

3.2.2 Function of the blocks

Tasks and function of the blocks


The simple simulation is to provide different data types and increment data
independently in order to, inter alia, illustrate the DataChange via OPC.

Table 3-6
Block Description
OB1 Main loop of the program, calls all subprograms
Main
OB100 Start OB is completed once at start up.
Init
FC10 Changes date and time in a tag in data block 51
ChangeDateAndTime
FC11 Increments simple data types in data block 51
ChangeSimpleTypes
FC13 Changes a string tag in the DB 51 in terms of
ChangeString content and its length
FC14 Increments a data block in DB 112
Copyright  Siemens AG 2014 All rights reserved

ChangeSendData
FB100 Calls the function blocks of the block services
InvokeBSENDandBRCV
DB50 Global data block with different simple data types
StaticDataTypes
DB51 Global data block with different simple data types
DynamicDataTypes that are moved by the simulation.
DB112 Send buffer 4096Byte
SendData
DB113 Receive buffer 4096Byte
RcvData

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 22
4 Configuration of an OPC Server
4.1 Configuration of the OPC server station

4 Configuration of an OPC Server


The main focus of this application is the usage of OPC. A number of configurations
are necessary, which can be carried out in various ways.
In this example, the configuration is shown in STEP 7 V11. The configuration in
STEP7 V13 is performed analog to this.

Note This chapter is only relevant if you are interested in details on the configuration.
In the enclosed STEP 7 project, the complete configuration has already been
performed.

4.1 Configuration of the OPC server station


The configuration and settings of the SIMATIC PC station are made via STEP 7
and are described step by step. Alternatively, a configuration can also be made
using the NCM-PC software package. The procedure is identical; however,
unilaterally configured connections are used.

Table 4-1
No. Action
Copyright  Siemens AG 2014 All rights reserved

Remarks
1. Starting STEP 7 V13.
Opening the previously created “UA-Sample” project.
2. Inserting a SIMATIC PC station and assigning a name.
The name of the PC station must be identical with the “Windows name” of the PC (see Computer
 Properties  Computer name).

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 23
4 Configuration of an OPC Server
4.1 Configuration of the OPC server station

3. Open the Device view of the PC station. There, you enter the Ethernet card and the OPC server
V8.2.
Note
If you wish to use an S7-1200 or an S7-1500 CPU with optimized data blocks, you need to use OPC
server V12.

The slot must be identical with the index assigned in the configuration console, here index “2” for
Ethernet card. The “OPC server” application was plugged into slot “1”.
Copyright  Siemens AG 2014 All rights reserved

4. For the Ethernet card, an IP address (here “192.168.172.1”) is assigned in the Properties and the
card is connected with the Ethernet network.

5. In the Properties pages of the OPC server, in the “S7” tab, the usage of symbolic addressing is
activated.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 24
4 Configuration of an OPC Server
4.1 Configuration of the OPC server station

6. In the Network view, three S7 connections from the OPC server to the S7 controllers are created.
The connections are created via Ethernet.

1
Copyright  Siemens AG 2014 All rights reserved

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 25
4 Configuration of an OPC Server
4.1 Configuration of the OPC server station

7. S7 connection via Ethernet:


After the S7 connections have been created, further settings are made by clicking on the connection
and on the Properties tab in the inspector window.
After the connection path has been selected, the connection name can be changed (here “Conn001”
for the connection to S7-300, “Conn002” for the connection to S7-400 and “Conn003” for the
connection to S7-1500).
The connection partners and the parameters of the connection are displayed.
Copyright  Siemens AG 2014 All rights reserved

8. In the Properties of the S7 connections, the “OPC” menu is selected where connection-specific
settings are made.
The connection establishment is set to permanent in order to maintain the connection even while no
communication is taking place.
The connection is configured for the transmission of alarms and diagnostic events.
Furthermore, the immediate reaction to an interrupted connection is activated in order to avoid
unnecessary wait times for timeouts.

9. After the connections have been created, the new configuration must be loaded into the stations.
The PC station can also be downloaded with the XDB-file, as described in chapter 6.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 26
4 Configuration of an OPC Server
4.2 Final check of the settings

4.2 Final check of the settings


The settings can be checked with the Communication Settings configuration
console.
Table 4-2
No. Action Remarks
1. Open the
configuration dialog
Copyright  Siemens AG 2014 All rights reserved

2. Check the set


IP address.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 27
4 Configuration of an OPC Server
4.2 Final check of the settings

No. Action Remarks


3. Check the set
protocols.
Note: enabling the S7
protocol is sufficient
for this application.

4. Check whether the


symbols have been
loaded.
Copyright  Siemens AG 2014 All rights reserved

5. If one of the settings


does not correspond
with the displayed
images, perform the
preceding
configurations again.

Close the
configuration dialog
box.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 28
5 Installation and Commissioning
5.1 Hardware and software installation

5 Installation and Commissioning


5.1 Hardware and software installation
This chapter describes which hardware and software components have to be
installed. The description and manuals and delivery information supplied with the
respective products must always be observed.

Installing the hardware


The hardware components are listed in chapter 2.2. For setting up the hardware,
please proceed according to the following table:

NOTICE Only switch on the voltage supply after the last step.

Table 5-1
No. Focus Action
1 Control Install the station in compliance with the diagram shown in chapter 2.
Copyright  Siemens AG 2014 All rights reserved

S7-300 station
2 Control Install the station in compliance with the diagram shown in chapter 2.
S7-1200 station
3 PG/PC station Install the station in compliance with the diagram shown in chapter 2.
4 Industrial Ethernet Connect the controller with the PG as shown in the illustration in chapter 2.

Installation of the standard software


STEP7 V13 and SIMATIC NET have to be installed on the PG/PC. STEP 7 V13 is
already preinstalled on SIMATIC PGs.
A description of the installation procedure for STEP 7 V13 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.

Address overview of the involved modules


If you want to operate the project on an existing Industrial Ethernet, you have to
note the following address specification:

Table 5-2
Focus Module IP address
PG/PC NDIS network card 192.168.172.1
Control CP 343-1 192.168.172.2
Control CPU 1214C 192.168.172.4

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 29
5 Installation and Commissioning
5.1 Hardware and software installation

Notes • Note the correct subnet mask 255.255.255.0.


• Alternatively, it is also possible to change the assigned IP addresses in the
STEP 7 project.

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.

Note Please ensure that the network card has the fixed IP address 192.168.172.1 (it
can be set via the network settings and the TCP/IP properties) if you want to use
the project included in delivery.
Copyright  Siemens AG 2014 All rights reserved

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 30
5 Installation and Commissioning
5.2 Loading the PC station via STEP 7 V1x

5.2 Loading the PC station via STEP 7 V1x


Installation of the STEP 7 V1x project via TIA Portal
The PC station can be loaded directly from the TIA portal. Alternatively, a PC
station can also be configured via the station configuration editor and the XDB file
(see chapter Warranty and Liability).
The description in Table 5-3 was created with TIA V11. The same procedure
applies for TIA V13.

Table 5-3
No. Action Remarks
1 Extract the TIA project from the Siemens Unzip the project in a path in which you have the
Industry Online Support. read and write permissions.
2 Open the TIA portal and navigate to the
project via the browser function
Copyright  Siemens AG 2014 All rights reserved

3 Confirm by opening. \OPCSample\OPCSample.ap11

4 Go to the project view after opening

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 31
5 Installation and Commissioning
5.2 Loading the PC station via STEP 7 V1x

No. Action Remarks


5 Load the PC station

Alternative: you can also configure the PC


station via the import of the included XDB file.
See chapter 5.3
Copyright  Siemens AG 2014 All rights reserved

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 32
5 Installation and Commissioning
5.2 Loading the PC station via STEP 7 V1x

Changing the IP address of the PC station in STEP 7 V1x

Note The IP address in the STEP7 project must match the IP address of its physical
Ethernet interface.

Table 5-4
No. Action
1 Start the TIA Portal V1x
2 Go to the project view, select the SIMATIC PC station in the project tree and open the “Device view”.
Copyright  Siemens AG 2014 All rights reserved

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 33
5 Installation and Commissioning
5.2 Loading the PC station via STEP 7 V1x

No. Action
3 Select your network card in the PC station and select the “Properties” tab in the bottom window.
You can change the IP address under “Ethernet addresses” -> “IP protocol”.
Note: In this case an IE General network card was used.
Copyright  Siemens AG 2014 All rights reserved

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 34
5 Installation and Commissioning
5.2 Loading the PC station via STEP 7 V1x

No. Action
4 In the context menu of the SIMATIC PC station you can find “Configure PC station online”.
Changes on the configuration of the PC station require the station to be reloaded.
Copyright  Siemens AG 2014 All rights reserved

5 After these configuration steps the station has to be reloaded.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 35
5 Installation and Commissioning
5.3 Importing the XDB file into the Station Configuration Editor

5.3 Importing the XDB file into the Station Configuration


Editor
Introduction
Alternatively to loading a PC station via the TIA portal (see chap 5.2), it can also be
configured via the station configuration editor and the XDB file. The XDB file
already exists in the TIA project included.

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.

Note Please ensure that the network card has the fixed IP address
192.168.172.1 (it can be set via the network settings and the TCP/IP
properties) if you want to use the project included in delivery.

Table 5-5
No. Action Remarks
1 Open the Component
Copyright  Siemens AG 2014 All rights reserved

Configurator by double-
clicking on

2 Click on the “Import Station” Confirm the task with “Yes”.


button.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 36
5 Installation and Commissioning
5.3 Importing the XDB file into the Station Configuration Editor

No. Action Remarks


3 Navigate to the project folder of
your STEP 7 V1x project. Select
the XDB file.
Click the dialog.

4 The import wizard confirms that


import is possible.

Confirm with OK.


Copyright  Siemens AG 2014 All rights reserved

Note:
If components have been
configured in a different version,
they will be exchanged by
existing compatible versions

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 37
5 Installation and Commissioning
5.3 Importing the XDB file into the Station Configuration Editor

No. Action Remarks


5 After the successful import of the
XDB file, your PC station is
ONLINE.
Copyright  Siemens AG 2014 All rights reserved

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 38
5 Installation and Commissioning
5.4 Installation of the OPC client on the PC/PG

5.4 Installation of the OPC client on the PC/PG


The application software is delivered in an archive file. Unzip the archive in a
directory on the PG/PC. Please note that you require read and write permissions.

NOTICE If you are using an older operating system than Windows 7 SP1 and if
SIMATIC NET PC software V8.x was not installed on it, you have to
install .NET-Framework 3.5 +SP1 first.
Information on this matter can be found on the Microsoft Internet pages
http://www.microsoft.com/

For installing the operator user interface proceed as follows:

Table 5-6
No. Action Remarks
1 Unzip the file: This zip file contains the STEP 7
21043779_OPCDAConnector_CODE.zip V13 project as well as the OPC
client with C# Source code.
Copyright  Siemens AG 2014 All rights reserved

2 Unzip the file:


Csharp_OPCDAConnector_CODE.zip
3 You find the OPCClientDAConnector.exe file in EXE can only be executed if the
the \OPCClientDAConnector\bin\x86\Release respective assemblies are
directory located in the same directory

Files included
The archive file contains the MS Visual Studio Solution file and the source code as
well as pre-compile binary files for x86 systems. The subfolder contains the
executable file (EXE) as well as the required assemblies.
Directory: \OPCClientDAConnector\bin\x86\Release

Table 5-7
File Belongs to...
OPCClientDAConnector.exe the OPC client application described here
OPCClientDAConnector.pdb the symbol information for debugging
OPCClientDAConnector.vshost.exe the host process for the debugger
SimaticNET.OPC.BrowseControls.dll browse control
SimaticNET.OPC.Common.dll OPC RC Wrapper
SimaticNET.OPC.DAConnector.dll connector control
SimaticNET.OPC.OpcClient.dll client API

Deinstallation
To uninstall, delete the directory.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 39
5 Installation and Commissioning
5.5 Loading the simulation to the S7 stations

5.5 Loading the simulation to the S7 stations


Loading the TIA project
To do this, proceed as follows:
Table 5-8
No. Action Remarks
1. Extract the TIA project: Unzip the project in a path in which you have the read and write
STEP7_TIA13.zip permissions.
2. Open the TIA portal and
navigate to the project
via the browser function
Copyright  Siemens AG 2014 All rights reserved

3. Compile and load the


S7-300 station

4. Compile and load the


S7-1200 station.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 40
6 Operating the Application

6 Operating the Application


Commissioning of the simulation
To operate the simulation, no other steps are required:
Table 6-1
No. Action Remarks
1 Start the user interface.
Copyright  Siemens AG 2014 All rights reserved

2 Edit the values in the text In this configuration it is written to the


boxes and trigger the write "S7-300.StaticDataTypes.My_DWord" symbol
process with the button
3 Check the data changes
with the tag table (Watch
table).

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 41
7 Glossary

7 Glossary
COM / DCOM
COM: Component Object Model: software model for communication between
components based on a standardized interface; DCOM: software model for
communicating beyond computer boundaries based on COM.

Event handler
An event handler processes occurring events or Windows messages.

Exception
An exception is referred to as an exceptional situation.
It can be generated either by the operating system (e.g. division by zero) or by the
user program.

Exception handler
An exception handler processes occurring exceptional situations. This is usually a
secured error behavior and/or a message to the user.

HRESULT
Copyright  Siemens AG 2014 All rights reserved

Return data type of COM objects.

IDL
Interface Definition Language: a Microsoft standard language for the definition of
function and parameter interfaces.

Polling
Term referring to the (mostly cyclical) polling of certain values or states.

Sink interface
Using the sink interface, messages can be sent between components. The sink
interface is based on COM mechanisms.

Thread
Within an application or a process, threads make it possible to execute several
code fragments virtually in parallel, meaning at the same time.
If an application uses several threads, this application also has the property “multi-
threaded”.
If an application only has one thread, it is called “single-threaded”. All code
fragments for these applications are always processed sequentially.

Windows message
The standard Microsoft Windows operating systems exchange messages to notify
of events, e.g. the paint event.

Wrapper
The term “wrapper” normally refers to a class group which encapsulates other
class groups for data conversion or easier handling. It can be considered an
“envelope” enclosing the “wrapped” classes, covering them from the outside.

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 42
8 Links & Literature

8 Links & Literature


Bibliographic references
This list is not complete and only represents a selection of relevant literature.
Topic Title
\1\ OPC • OPC DA 2.05 Specification at
http://www.opcfoundation.org/
• mn_opc_0.pdf and mn_opc_76.pdf of SIMATIC.NET V8.0
\2\ .NET • Inside C#, Tom Archer
• .NET Crashkurs, Clemens Vasters, Oellers, Javidi, Jung,
Freiberger, DePetrillo
• Microsoft .NET Framework Programming, Jeffrey Richter

Internet link specifications


This list is by no means complete and only presents a selection of suitable
information.
Table 8-1
Topic Title
Copyright  Siemens AG 2014 All rights reserved

\1\ Link to this http://support.automation.siemens.com/WW/view/en/21043779


document
\2\ Siemens Industry http://support.automation.siemens.com
Online Support
\3\ Examples for http://support.automation.siemens.com/WW/view/en/26548467
Alarm & Events
Server
\4\ Example client for http://support.automation.siemens.com/WW/view/en/42014088
.NET for OPC UA
Server

9 History
Table 9-1
Version Date Modifications
V1.0 12/2012 First version
V1.1 06/2014 Migration to
- STEP 7 V13
- Visual Studio 2010

.NET OPC Data Control


Entry ID:21043779, V1.1, 08/2014 43

Potrebbero piacerti anche