Beruflich Dokumente
Kultur Dokumente
http://support.automation.siemens.com/WW/view/de/21043779
Warranty and Liability
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
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.
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
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.
Applications on the PC
Visualization
Data acquisition DB other
Visualization
Monitoring Connection applications
Control system
Copyright Siemens AG 2014 All rights reserved
OPC server
Process
Logic PLC … PLC
Data
I/O I/O
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.
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
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.
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.
Figure 2-2
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.
Control
The controller provides the data to be visualized. For this purpose, a simple
S7 program for simulating various data types is implemented.
Note The SIMATIC NET OPC Data Control used here for .NET can only be used for
the coupling with SIMATIC NET OPC servers.
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
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.
General information
In order to use the functionality of the .NET OPC client control, the assemblies
Copyright Siemens AG 2014 All rights reserved
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
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.
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.
No. Action/Remark
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)
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
The trigger for writing a value to the controller is trigged when the “Enter” button is pressed.
Copyright Siemens AG 2014 All rights reserved
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
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.
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).
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.
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
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.
Close the
configuration dialog
box.
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.
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
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
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
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
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
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
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
Note:
If components have been
configured in a different version,
they will be exchanged by
existing compatible versions
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/
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
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.
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
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.
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