Application for Communication

4 downloads 0 Views 1MB Size Report
provided in these Application Examples and other Siemens publications -. e.g. Catalogs ..... languages. The absolute cycle time cannot be guaranteed on a PC.
Application for Communication

Distributed Automation with the PC The SIMATIC NET OPC Server as PROFIBUS DP Slave Program Example in C++

Warranty, Liability and Support OPC-DP-Slave

Warranty, Liability and Support We do not accept any liability for the information contained in this document.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

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 document shall be excluded. Such an exclusion shall not apply in the case of mandatory liability, e.g. under the German Product Liability Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life, body or health, guarantee for the quality of a product, fraudulent concealment of a deficiency or breach of a condition which goes to the root of the contract (“wesentliche Vertragspflichten”). However, claims arising from a breach of a condition which goes to the root of the contract shall be limited to the foreseeable damage which is intrinsic to the contract, unless caused by intent or gross negligence or based on mandatory liability for injury of life, body or health. The above provisions does not imply a change in the burden of proof to your detriment. The Application Examples are not binding and do not claim to be complete regarding the circuits shown, equipping and any eventuality. They do not represent customer-specific solutions. They are only intended to provide support for typical applications. You are responsible in ensuring that the described products are correctly used. These Application Examples do not relieve you of the responsibility in safely and professionally using, installing, operating and servicing equipment. When using these Application Examples, you recognize that Siemens cannot be made liable for any damage/claims beyond the liability clause described above. We reserve the right to make changes to these Application Examples at any time without prior notice. If there are any deviations between the recommendations provided in these Application Examples and other Siemens publications e.g. Catalogs - then the contents of the other documents have priority. Copyright© 2004 Siemens A&D. It is not permissible to transfer or copy these Application Examples or excerpts of them without first having prior authorization from Siemens A&D in writing. For questions about this document please use the following e-mail-address: [email protected]

V 1.0

Issue Feb.16th.2005

2/65

Foreword OPC-DP-Slave

Foreword Objectives of the application The international OPC standard is an optimized interface for accessing the process data from a Windows application. The application on hand shows how a PC can be used as PROFIBUS DPSlave for provision of user date while the advantages of a PC can be used for parallel visualizing in an application at the same time. Ein PC kann als PROFIBUS DP-Slave eingesetzt werden, um z.B. Daten einer PC Messkarte oder Rezeptdaten aus einer Datenbank einem PROFIBUS DP-Master zur Verfügung zu stellen. In this application, particular emphasis is placed on maximum performance and minimum resource consumption. Main contents of this application Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

The following teaching materials are provided with this application: •

Configuration of a PC station with OPC server.



Configuration of the OPC server as PROFIBUS DP Slave.



Background information on PROFIBUS DP and OPC Data Access 2.05.



Using the OPC Data Access Custom interface in a C++ application with Visual Studio .NET as development environment.



Realizing a data transfer in C++ on the PC:







Providing user data in a PROFIBUS DP Slave for a SIMATIC S7station.



Writing the process image via OPC Data Access.



Reusable framework for providing user data on the PROFIBUS.

Realization of a visualization task with OPC and C++: –

Monitoring the process variables via OPC Data Access.



Optimal OPC calls for minimum communication load.



Reusable OPC classes.

Realization of the data transfer and the visualization tasks in an application without negative mutual effects.

Delimitation This Getting Started does not contain any description of Visual Studio .NET, of C++, of the UML notation or any basics on Microsoft COM.

V 1.0

Issue Feb.16th.2005

3/65

Foreword OPC-DP-Slave

Structure of the document The documentation of this application is divided into the following main parts.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Part

Description

Application Description

Provides a general overview of the contents. You will learn about the components used (standard hardware and software components and the specially created software).

Function principles and program structures

Discusses the detailed function processes of the involved hardware and software components, the solution structures, and where sensible the concrete implementation of this application. This part is necessary if you want to learn about the interaction of the solution components, for example in order to use them as the basis for own development.

Structure, Configuration and Operation of the Application

This part leads you step by step through the structure, important configuration steps, commissioning and operation of the application.

Appendix

Here you find further information, such as bibliography, glossary etc..

Reference for Automation and Drives Service & Support This entry originates from the internet application portal of the A&D Service and Support. The following link takes you directly to the download page of this document. http://support.automation.siemens.com/WW/view/en/21040390

V 1.0

Issue Feb.16th.2005

4/65

Table of Contents OPC-DP-Slave

Table of Contents Application Description ............................................................................................... 7 1 1.1 1.2

Automation Task............................................................................................. 7 Overview........................................................................................................... 7 Requirements ................................................................................................... 8

2 2.1 2.2 2.3 2.4 2.5

Automation Solution .................................................................................... 10 Overview of complete solution........................................................................ 10 Description of the core functionality................................................................ 10 Required hardware and software components ............................................... 12 Basic Performance Data................................................................................. 14 Alternative solutions........................................................................................ 15

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Function Principles and Program Structures .......................................................... 18 3 3.1 3.2 3.3 3.4

General Function Mechanisms.................................................................... 18 Basics on PROFIBUS DP............................................................................... 18 Basics OPC .................................................................................................... 20 SIMATIC NET OPC DP-Slave ........................................................................ 22 Using OPC Data Access................................................................................. 23

4 4.1 4.2

Function Mechanisms of this Application.................................................. 29 Functionality of the OPC Client....................................................................... 29 Function mechanisms of the OPC Client........................................................ 33

5 5.1 5.2 5.3

Explanations on the Example Program ...................................................... 41 Sequence diagrams for the visualization user interface ................................. 41 Sequence diagrams for the data transfer ....................................................... 44 Error handling in the OPC Client .................................................................... 47

6 6.1 6.2 6.3

Modifications to the Example Program ...................................................... 48 Expanding the sample code of the OPC client ............................................... 48 Using OPC in own Visual Studio .NET C++ project........................................ 49 Using sample code in own Visual Studio .NET project ................................... 51

Structure, Configuration and Operation of the Application ................................... 52 7 7.1 7.2 7.3 7.4

Installation and Commissioning ................................................................. 52 Installation of Hardware and Software ............................................................ 52 Commissioning the SIMATIC S7 station......................................................... 54 Commissioning the SIMATIC PC station ........................................................ 54 Commissioning of the OPC Client .................................................................. 55

8 8.1 8.2

Configuration ................................................................................................ 56 Configuring the PC station.............................................................................. 56 Configuring the PC station.............................................................................. 57

V 1.0

Issue Feb.16th.2005

5/65

Table of Contents OPC-DP-Slave

8.3 8.4

Configuring the SIMATIC S7 station............................................................... 59 Testing with OPC Scout.................................................................................. 62

9

Operating the Application............................................................................ 63

Appendix and List of Further Literature ................................................................... 65 Literature ....................................................................................................... 65

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

10

V 1.0

Issue Feb.16th.2005

6/65

Application Description Automation Task OPC DP Slave

Application Description

Content Here an overview of this application is given. You will learn about the components used (standard hardware and software components and the specially created software). The basic performance data show how powerful this application is.

1

Automation Task

Here you will find information on … Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

the automation task discussed in the documentation on hand.

1.1

Overview

Introduction The PC is gaining ever increasing importance in the field of automation. Being easily expandable with PCI plug-in cards, more and more tasks can be solved with the PC. A special measuring card in a PC, for example, can provide measured values for a controller. In this example, the PC works as PROFIBUS DP Slave. Overview of the automation task The following figure gives an overview of the automation task. Figure 1-1

V 1.0

Issue Feb.16th.2005

7/65

Application Description Automation Task OPC DP Slave

1.2

Requirements

Requirements for the automation task The following requirements exist regarding PC based automation. •

Integrated solution on a device.



Performant and inexpensive connection of a PC as distributed I/O.



Individually generated, slim and optimized visualization via a PROFIBUS DP Slave.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Apart from these requirements which are realized in this Getting Started, there are also further advantages which are useful during the realization on the PC: •

Interaction with other PC applications such as data bases.



Load reduction for data traffic on the PROFIBUS by collecting and preprocessing data of different origin.



Simple integration into the company IT.

Requirements to data transfer: •

Providing measured data from the memory of the PC in the PROFIBUS DP Slave for transfer to a SIMATIC S7-station.



Data transfer must not be affected by the operator actions at the user interface.



Simulation of the measured data by means of an encapsulated function, in order to facilitate exchangeability.

Requirements for the visualization user interface: •

Visualization of slave data



Writing entered values to the inputs. This enables manual writing of user data to the DP master.



Display of specific DP variables and diagnostic information.



Writing the DP slave status. Changing the status to offline is meant to trigger an error OB in the controller



The user interface must be operable despite of the data transfer.

Requirements to the control program in the SIMATIC S7 station

V 1.0



Copying the user data from the slave into a data block.



Realizing an LED chaser with the frequency based on the value specified in the slave.

Issue Feb.16th.2005

8/65

Application Description Automation Task OPC DP Slave

Requirements to the development environment and programming language: •

Application of C++,



Development with Microsoft Visual Studio .NET.

Requirements for connecting the application to the process: •

Connection via PROFIBUS DP as well as the SIMATIC NET OPC server



Operating the OPC server as PROFIBUS DP slave.



Using the OPC Data Access Custom Interface V2.05.



Reading and writing of process variables.



Monitoring of process variables.



Reading and writing PROFIBUS DP specific variables and diagnostic information.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

The main focus of this example is using the OPC server as PROFIBUS DP slave. The PC is integrated as distributed I/O in a DP master system.

V 1.0

Issue Feb.16th.2005

9/65

Application Description Automation Solution OPC DP Slave

2

Automation Solution

Here you will find information on … the solution selected for the automation task.

2.1

Overview of complete solution

Display The following figure displays the most important components of the solution:

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Figure 2-1

2.2

Description of the core functionality

User interface of the OPC Client Figure 2-2

V 1.0

Issue Feb.16th.2005

10/65

Application Description Automation Solution OPC DP Slave

Functionality of the user interface The user interface of this application has the following functions: Connecting to and disconnection from the OPC server and starting the data transfer.



Displaying slave specific data and diagnostic information.



Writing the Slave State



Displaying the three slave modules.



Writing two default values and 8 bit. A default value is the frequency of the LED chaser in the controller.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e



V 1.0

Issue Feb.16th.2005

11/65

Application Description Automation Solution OPC DP Slave

Display The following figure displays the most important components of the solution:

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Figure 2-2

Setup •

The SIMATIC S7 300 station is master at the PROFIBUS network and the PC with the CP 5611 is slave at the PROFIBUS network .



The OPC server encapsulates the access to the process data with a standardized interface.



The OPC Client is realized in C++.



The C++ classes for the OPC functionality and the data transfer can generally be used again.

Control functionality The following functionality for data transfer is executed cyclically: •

Simulation of two measured values.



Writing measured values via the OPC server to the inputs of the slave.

The SIMATIC S7station fulfills the following functionalities:

2.3



Copying the slave data into a data block.



Generating an LED chaser with a frequency depending on the value specified in the slave.

Required hardware and software components

Hardware components of the SIMATIC PC station A PG/PC is connected as DP master with the SIMATIC S7 station via PROFIBUS as the distributed I/O (DP). The PROFIBUS card used is the CP 5611.

V 1.0

Issue Feb.16th.2005

12/65

Application Description Automation Solution OPC DP Slave

The given FAQs are available on the A&D Support Homepage at http://support.automation.siemens.com (Please enter the ID into the search box). Table 2-1

Component

No.

MLFB / Order number

Note

Industrial PC SIMATIC Rack PC IL 40 S

1

6AG4 011-1CA21-0KX0

Configurator: see FAQ ID 17128155

Communications processor CP5611 for PROFIBUS, PCI CARD

1

6GK1 561-1AA00

In notebooks, a CP5511 can be used alternatively.

Hardware components of the SIMATIC S7 station

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

The DP master used is a SIMATIC S7 300 station, whose modules used for this example are listed below. Table 2-2

Component

No.

PS307 5A

1

MLFB / Order number

Note

6ES7 307-1EA00-0AA0

CPU315-2 DP

1

6ES7 315-2AG10-0AB0

S7 CPU

SM374

1

6ES7 374-2XH01-0AA0

Simulation module digital 8x IO

Software components of the SIMATIC PC station The SIMATIC PC station requires software components which are listed in the following table. STEP 7 can also be operated on a separate PC (socalled Engineering Station). Table 2-3

Component

No.

MLFB / Order number

Note

STEP 7 V5.3

1

6ES7 810-4CC07-0YA5

For configuration of the DP master.

PROFIBUS SOFTNETDP-Slave V6.2

1

6GK1 704-5SW62-3AA0

For using a CP 5611.

Microsoft Visual Studio .NET 2003 Professional

1

Order via your administrator of the Microsoft Homepage

(Optional) Only if changes at the example code are necessary.

Example files and projects The following list contains all files and projects used in this example.

V 1.0

Issue Feb.16th.2005

13/65

Application Description Automation Solution OPC DP Slave Table 2-4

Component 21040390_OPC_DPSlave_STEP7_v10.zip

21040390_OPC_DPSlave_CODE_v10.zip

21040390_OPC_DPSlave_DOKU_v10_d/e.pdf

2.4

Note This zip file contains the STEP 7 project (incl Hardware configuration for PC station and S7-300). This zip-file contains the executable files for the OPC client as well as the Visual C++ project. This document

Basic Performance Data

Frame conditions for measured values Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

The times given in this chapter were measured on a PC with Pentium 4 processor with 2.4 GHz. The given times always relate to a cycle of the data transfer with simulation of the measured values and writing the measured values to the inputs of the slave via OPC. The "average cycle time" was determined from a total time of 1000 cycle runs. The variation range was not determined. The pause time between the cycles were set to 0ms during measurement, which corresponds to a processor load of 100%. on cycle times.

See also chapter

Note

The measurement is only to show the relationship between the different languages. The absolute cycle time cannot be guaranteed on a PC.

Measured data The following table shows the cycle times of the data transmission with the various programming languages, the Outproc OPC server and the configuration from the example. Table 2-5

V 1.0

Programming language

Average cycle time

C++

230 μs

C#

320 μs

Visual Basic V6.0

670 μs

Issue Feb.16th.2005

14/65

Application Description Automation Solution OPC DP Slave

2.5

Alternative solutions

Here you will find information on … the existing alternatives for solving the automation task, and which characteristics the alternatives have. The solution realized in this example is respectively shaded in green. Comparison Hardnet and Softnet -S7 Table 2-1

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Component

Description

Hardnet with CP 5613



The CP 5613 cannot be operated as a PROFIBUS Slave.

Hardnet with CP 5614

• • •

Less CPU load, as the main functions are executed in the hardware. The CP 5614 has two PROFIBUS interfaces and can simultaneously be operated as master and slave. 244 bytes input data and 244 bytes output data.

• •

Favorable solution if the PC is to work as PROFIBUS slave only. Restriction to 122 bytes input data and 122 bytes output data.

SOFTNET-S7 with CP 5611 or CP 5511

Direct comparison of programming languages Table 2-2

Component Visual Basic V6.0

Description • •



.NET languages C# and Visual Basic



C++

• •

V 1.0

The advantage of Visual Basic applications is simple handling of the OPC interface via the automation interface, and the quick application generation especially with the user interfaces. The disadvantage of Visual Basic is the lower performance due to the Visual Basic runtime and the additional software layer with OPC Automation DLL. Furthermore, several functionalities cannot be executed parallel, which reduces the performance of the control and visualization task. Using the new Microsoft .NET platform enables quick and modern application development. All advantages of .NET can be used. However, for accessing the OPC the performance is restricted due to the .NET runtime and the application of an intermediate layer (Runtime Callable Wrapper, RCW) The realization with C++ enables reaching the highest performance. Direct access to the interface of the OPC server is possible. Furthermore, any number of functionalities can be executed parallel. The disadvantage of C++ is the higher expense for the implementation especially for complex user interfaces.

Issue Feb.16th.2005

15/65

Application Description Automation Solution OPC DP Slave

Direct comparison Inproc / Outproc OPC Server for solution estimation The following points must be considered when selecting the OPC server between In Process (OPC.SIMATICNET.DP) and Out of Process (OPC.SIMATICNET) (Detailed description in chapter 3.2): Table 2-3

Component

Description •

Inproc OPC Server

• Outproc OPC Server

• •

Faster calls from OPC client to server as there is no process boundary between client and server. The Inproc OPC server can only be loaded within a process, i.e. only a client can connect to this server. The Outproc OPC server can be accessed from several applications. Remote access to the Outproc OPC server possible.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Decision criteria for selecting an Iproc / Outproc OPC server The following table gives you an overview of the relevant features of an Inproc and Outproc OPC server. Table 2-6

Decision criteria

Inproc OPC Server

Outproc OPC Server

Speed

++

+

Number of connected clients

1

n

No

Yes

+

++

Yes

Yes

145 μs

230 μs

Client and server on different computers Visualization application Softnet CP5611 / CP5511 Average cycle time of data transmission in the C++ example without pause times.

Application cases and restrictions for a PC as PROFIBUS DP slave Table 2-4

Application case

Description

Provision of user data for a SIMATIC S7 station.

• • • • •

Measured data for specific PC measuring cards. Pre-processing of measured values. Gateway for other bus systems. Provision of recipes for example from a database. Swapping out of complex calculations from a SIMATIC S7 station to a PC.

Visualization via a PROFIBUS DP slave



Used analog to SIMATIC OperatorPanels or TouchPanels as PROFIBUS Slave. Visualization of data which the master has copied into the output area. Writing default values into the input area.

• •

V 1.0

Issue Feb.16th.2005

16/65

Application Description Automation Solution OPC DP Slave

A PROFIBUS DP Slave can provide a maximum of 244 bytes of input data and 244 bytes of output data. This is the maximum data amount that can be exchanged between PC and SIMATIC S7 station.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Note

V 1.0

Issue Feb.16th.2005

17/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave

Function Principles and Program Structures

Content Discusses the detailed function processes of the involved hardware and software components, the solution structures, and where sensible the concrete implementation of this application. Read this part if you want to know how the individual solution components interact.

3

General Function Mechanisms

Here you will find information on … Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

the general function mechanisms applying regarding PROFIBUS and OPC.

3.1

Basics on PROFIBUS DP PROFIBUS is the international standard for connecting I/O devices in the cell and process level. Some related terms are explained below. Continuous information is available in the SIMATIC NET /2/ manual and at www.profibus.com.

General information When dividing the PROFIBUS nodes, it is generally distinguished between active and passive stations. The network access corresponds to the "Token bus" method for active and the ”Master–Slave” method for passive stations established in the EN 50170, Volume 2. The access method is independent of the used transfer medium (two-wire line, fiber optics and plastic fibers) and depending on the components used, it can be operated with transmission speeds of 9.6 KBit/s up to 12MBits/s. A total of 126 nodes (including Master) can be operated at one PROFIBUS. The bus segment lengths vary between 1km and 100m depending on the transfer speed and are if necessary connected or expanded with repeaters. PROFIBUS network configurations are distinguished between single and multi-master according to the number of active stations operated at a PROFIBUS network. Furthermore it is distinguished between class 1 and class 2 or "non-DP“ masters (e.g. FMS) according to the functionality of this station. Mixed configuration is also possible on the same physical line.

V 1.0

Issue Feb.16th.2005

18/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave

PROFIBUS Class 1 Master The active stations of class 1 are PROFIBUS DP masters cyclically polling their respectively assigned slaves and are also simply referred to as DP master. Several DP masters may be present at one bus (token passing), however, each master has to process a number of exclusively assigned slaves (a so-called master system). Which slaves are part of a master system is defined in the configuration (type, address, data volume) and is verified by the master in the startup phase. In the course of time, the DP specification has been expanded step by step and there are now three main versions with different functionality.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

DPV0 describes the underlying basic functionality, the cyclic data communication between a master and its slave, as well as station, module and channel-specific diagnosis and four interrupt types e.g. diagnosis and process interrupt, or pulling and stretching of slaves. DPV1 is an expansion of the DPV0 and describes acyclic services e.g. for parameter assignment, status display and interrupt control. DPV1 services of intelligent field devices are processed parallel to the cyclic data communication. This enables accessing stations online using engineering tools. Furthermore there are three additional interrupt types: Status, update and a manufacturer specific interrupt. DPV2 is the last development stage and defines additional functionality, particularly for drives and axis control e.g. isochronous slave operation, slave to slave cross-communication, any kind of up and download of data, as well as clock synchronization. PROFIBUS Class 2 Master Active stations of the class 2 type are typically stations fulfilling engineering, diagnostics or configuration tasks. During the commissioning phase they are connected for maintenance or diagnostics purposes and can configure devices, evaluate measured values or poll the device status. Class 2 masters can be connected permanently or temporarily at a bus. PROFIBUS Slave DP slaves of different manufactures are marked according to the functions (DPV0 to DPV2) they support. Slaves, which support the basic functionality are also referred to as DP standard slaves, and are described by a standardized file (so-called GSD file). This enables uniform configuration of slaves from different manufacturers. Many Siemens Slaves have special functions exceeding the PROFIBUS standard, and which can only be used in conjunction with S7 masters (the master is an S7-300 or S7-400). If the PC cards CP 5611, CP 5613/14 are used as master, S7 slaves can only be used as standard slaves, which makes special functions unavailable.

V 1.0

Issue Feb.16th.2005

19/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave

Relationship Master - Slaves The following figure shows the relationships between master class 1 (cyclic) and master class 2 (acyclic), as well as different functions of communication which can be supported.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Figure 3-1

3.2

Basics OPC

Overview The OPC Foundation (an interest grouping of well-known manufacturers for the definition of standard interfaces) has in recent years defined a number of software interfaces, in order to standardize the information flow from process level to management level. Four different OPC specifications have evolved according to the different requirements within an industrial application. Data Access (DA), Alarm&Events (A&E), Historical Data Access (HDA) and Data eXchange (DX). Access to process data has been described in the DO specification; A&E describes an interface for event based information including acknowledgement; HAD describes functions for archived data and DX defines a server to server cross-communication. This example deals exclusively with the OPC Data Access 2.05a interface. Detailed documentation available on the SIMATIC NET CD-Rom. Further information is available at www.opcfoundation.org. What is OPC OPC is a collection of software interfaces for data exchange between PC applications and process devices. This software interface has been defined according to the rules of Microsoft COM (Component Object Model) and can therefore easily be integrated into Microsoft operating systems. COM or DCOM (distributed COM) provides the functionality fo the inter process communication and organizes the information exchange between applications even beyond computer boundaries (DCOM). An OPC client (COM client) can exchange information with an OPC server (COM Server) with it, using mechanisms of the Microsoft operating system. The OPC server provides process information of a device at its interface. The OPC client starts the server and can access the offered data.

V 1.0

Issue Feb.16th.2005

20/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave

OPC Custom and Automation interface The OPC server offers its functions at the so-called Custom interface. Clients developed in the programming languages C, C++ or Pascal, can access this interface directly. The automation interface is included in the delivery scope to enable access from Visual Basic applications. It is a DLL which compiles all calls between Visual Basic and the custom interface (wrapper). Figure 3-2 on the following page illustrates the correlations. Note

If the client is located on a different computer than the server and accesses the data "remotely", this is referred to as a DCOM connection.

OPC Server as Inproc or Outproc COM object

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

COM servers are divided into two types. At identical OPC interface a server can be realized as In Process (Inproc) or Out Of Process (Outproc). Inproc are implemented as downloadable DLL and Outproc as executable file (EXE). If a client connects with an Inproc OPC server, the OPC server DLL is loaded into the process of the client (In Process). This is the fastest variant, as for calls, no process boundaries need to be overcome. For a connection to an Outproc OPC server, the server will be started by COM in a separate process. The communication between both processes, however, runs via COM mechanisms. In this second variant, OPC client and OPC server can be started on separate computers. The process or computer boundary is illustrated in figure 3-2 as broken line. The OPC server is started with a name (ProgID). This ProgID is for the PROFIBUS DP Inproc OPC server “OPC.SIMATICNET.DP“. The ProgID of the Outproc Servers is “OPC.SIMATICNET“. Note

V 1.0

The PROFIBUS DP Inproc server can only be loaded into one OPC client process. If the OPC server is to be used by several OPC clients, or if the OPC client is to access the OPC server remotely, the Outproc OPC server must be used.

Issue Feb.16th.2005

21/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave

Variants The following figure illustrates the different variants with Inproc and Outproc OPC server and OPC clients which are using the custom or automation interface. Protocol layer and driver layer have been simplified. The architecture is explained in greater detail in the following chapter.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Figure 3-2

3.3

SIMATIC NET OPC DP-Slave

Overview For each protocol supported by Siemens, the SIMATIC NET OPC server family offers an Outproc OPC server particularly suitable for visualization applications. Supported are the S7 protocol via Ethernet and PROFIBUS, Send/Receive, PROFIBUS DP-Master, DP-Slave, FDL, FMS and SNMP. Additionally, an Inproc OPC server for fast control applications is offered for PROFIBUS DP Master. Architecture of driver layers Prior to introducing the OPC interfaces, a C interface, the DP-Slave-Lib, was used for developing DP slave applications. The OPC server is based on this interface. The functionality of the DP-Slave-Lib has been realized in DPV0 and DPV1. The following figure shows the differences between master and slave interfaces for Softnet (CP5611 und CP5511).

V 1.0

Issue Feb.16th.2005

22/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave

in this example, the Outproc DP OPC server on the Softnet DP-Slave-Lib is used, which makes a CP5611 or CP5511 obligatory. As opposed to an OPC server as DP master, the server is only configured as slave. If an OPC client connects via the ProgID “OPC.SIMATICNET“ the server is started according to its configuration. Overview of the driver layers

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Figure 3-3

Note

3.4

CP5611 or CP5511 can be operated as DP master or as DP slave. However, only one operating mode is possible at a time.

Using OPC Data Access This explains the basics of OPC Data Access (DA) necessary for the example.

3.4.1

OPC DA Data model

Address space of the OPC DA server An OPC DA server provides an address space of available variables (items) defined in the configuration. This address space can be searched by the OPC client. Most OPC servers display the items there in a tree structure. Unique identification of an item in the address space occurs via an ItemID. As for a file in a file system, not the name of the item in the directory is unique, but the name and path in the address space.

V 1.0

Issue Feb.16th.2005

23/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave

Address space of the OPC server The figure shows the address space of the PROFIBUS DP OPC server configured for the example using the example on hand. The folder structure is shown in the left hand pane of the window. The middle section of the window displays items of the selected folder M00_I with the input bytes of the module 00. The right hand section of the window shows the selected input and output variables of the slave with its ItemID. Figure 3-4 Adressraum des PROFIBUS DP OPC Servers im OPC Scout

1 2

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

3

Explanation of the structure of the address space The structure of the address space is explained in the following table. Table 3-1 Ebenen der Baumstruktur

Level

Description

1

The connection name is defined during configuration. In this example it is CP 5611.

2

The configured PROFIBUS DP slave.

3

The modules of the slave divided into inputs and outputs.

Structure of ItemID The ItemID (e.g. DP:[CP 5611]SlaveM00_IB0) is composed of the protocol ID, the connection name, slave, module number and I/O address. DP:[]Slave M_ The address space is only defined by the configuration of the OPC server. The OPC client has no influence on this address space. OPC Server object When establishing a connection with the OPC DA server, COM object "OPCServer" is created which can be accessed via different COM interfaces. Apart from administration functions, it mainly offers access to information on the address space, and enables creating and deleting of groups. In this example only the groups are created and deleted via this object.

V 1.0

Issue Feb.16th.2005

24/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave

The OPC client can only access OPCServer objects which it has created itself. It cannot access objects of other OPC clients. This also applies to the groups described below. Groups and items The items of the OPC server must be grouped for data exchange via the COM object "OPCGroup“. Thereby the group settings apply to all items in the group. The most important properties are hereby the active status and the update rate. If the group is active, the OPC server forms an intermediate storage (cache) for values, quality and time stamp for items within this group. The OPC server updates this cache respectively after the update time has elapsed.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

An item represents a value within the process, it can be entered by the OPC client into several groups. Thereby the status of the item in the other groups cannot be influenced. Only with writing a new value onto the item does the value also change in the other groups. Unless an item is contained in a group, no data exchange occurs between the OPC server and the process. Access structure on the process variables The following figure illustrates the access structure with which you can access process variables via the OPC server. Figure 3-4

OPC Item Apart form the process value, an OPC item also has further properties. Aside from the value, this is also the quality of the value, the time stamp of the value, the data type of the item and the access privileges. On top of these properties, which each item must have, further information on the process value can be available via additional properties such as unit of the value or value range.

V 1.0

Issue Feb.16th.2005

25/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave

The properties value, quality and time stamp are provided when reading the process value. Further properties can be polled via an interface of the server object. Note

The address space of the server is defined by the configuration and cannot be changed by the OPC client. The server and group objects are created and managed by the OPC client in the OPC server. These objects are only visible for an OPC client and have no impact on the address space.

3.4.2

OPC DA data access

Types of data access The following figure gives an overview of the different types of data access used in this example. The arrows symbolize the call direction. Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Figure 3-5

Explanation of access types The following table lists the access types illustrated in the figure above. Table 3-2

No.

V 1.0

1

Polling information on the address space. (Not used in this example)

2

Reading the current values from the cache.

Issue Feb.16th.2005

26/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave 3

Cyclic reporting of changed values from server to client.

4

Writing values. Call always goes to the device.

5

Cyclic updating of values in the cache of the OPC server. (UpdateRate)

Reading values of the items from cache or device The items of a group can be read from the cache or from the device (device or process value directly at the source).

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

When reading from the cache, the communication between OPC server and device is not affected. This communication to the device is mostly the bottleneck of data throughput between device and OPC client. Updating the cache can be optimized from the OPC server independently of the read calls. Reading directly from the device takes as long until all values have been read directly from the device. For a slow communication, this may take several seconds. Reading from the device is recommended if the value is read in very irregular intervals only and therefore a cyclic update of the cache is not affecting the data exchange between OPC server and device. In this example the process image of the inputs are read from the device. In this example, this is not a problem, as the device for storage is the CP5613, in which the process image of the slaves has been stored. This makes the access to the data very fast, and the latest values for the process image of the controlling process are always available. Reporting value changes For applications in which the data must be updated cyclically in the OPC client, there is a better mechanism than reading from the cache. In this case the OPC client can have the changed values sent to it after the update time of the group. A typical application case is the visualization of process values. In order to be able to receive the OnDataChange event from the OPC server, the OPC client must implement a callback object with the IOPCDataCallback interface, and log on this object at the OPC server. This mechanism is used in the example for visualizing. Writing values to the OPC server The values of the items of a group can also be written from the client. By definition, writing is performed directly onto the device. Group calls All methods at group objects affecting the items, are group calls, i.e., one call can add for example 1000 items to the group or read 500 items within the group. This can help minimize the number of calls to the OPC server. Processing data within the OPC server is optimized, particularly writing and reading from the device. In this case the OPC server can better optimize

V 1.0

Issue Feb.16th.2005

27/65

Function Principles and Program Structures General Function Mechanisms OPC DP Slave

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

number and size of the data packages to the device than reading or writing the values individually.

V 1.0

Issue Feb.16th.2005

28/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

4

Function Mechanisms of this Application

Here you will find information on … the functionality offered by the OPC client, how PROFIBUS, OPC server and OPC client function mechanism work together, and how this has been realized in a C++ class model.

4.1

Functionality of the OPC Client

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

The OPC client application shows two different application options of OPC and its realization in a C++ application. •

One application is visualizing process values via OPC Data Access. Here it is illustrated which OPC DA functionality is required for display and writing of process values, and how they are used in C++.



The main application is the provision of I/O user data in form of a DP slave for a SIMATIC S7 station as DP master. It is to demonstrate the performant and cost-effective incorporation of a PC into a SIMATIC station as distributed, intelligent I/O.

User interface of the application The following figure shows the user interface of the OPC client. Figure 4-1

V 1.0

Issue Feb.16th.2005

29/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

Functionality of the user interface The user interface serves for visualizing process values and the PROFIBUS DP status values. Here it is possible to connect to or disconnect from the OPC server. The input and output modules of the PROFIBUS DP slave are visualized as process values. Two of the four input values of the Real type and the input byte can be changed from the user interface and be written to the OPC server as default value by clicking the button. The two further input values of the Real type are only displayed. Furthermore, the online status of the DP slave can be used manually. This helps simulate a slave error. This manual offline setting of the slave is in this example prevented by the error OB82 of the control program.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

After establishing the connection with the OPC server, the status of the DP slave, the status value SlaveConfigData and the online status of the slave are displayed. Functionality of data transmission The data provided by the PC can origin from an intermediate storage, e.g. from a measuring card in the PC or the OPC client process. In this example such data is simulated and cyclically written into a separate thread into the OPC server. In this part of the example it is shown how an own thread for the data transmission is started, and how the OPC server is ideally initialized for this. After initializing the OPC server, the data transfer is executed cyclically and the values are written to the OPC server. The functionality to the data transfer shows exemplary how values can be set. The following measured values are simulated for this:

Note

V 1.0



Measured value for input Real 8 is simulated as ramp function.



Measured value for input Real 12 is simulated as sinus function.

The values provided by the simulation function can be replaced by any user data.

Issue Feb.16th.2005

30/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

Used OPC items The following table lists the OPC items used for visualizing and in the simulation. Note

In the slave inputs are written and outputs are read as the names refer to the view of the master.

Table 4-1

ItemID

Data Type

Visualizing Name

Data

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

User interface Change

Transfer OPC

PAA

PAE

Write

Read

Write

DP:[CP 5611]SlaveSlvState

STRING

Slave State

X

DP:[CP 5611]SlaveMiscReadSlvParCfgData

STRING

Slave Config Data

X

DP:[CP 5611]&devicestate()

STRING

Device State

X

X

DP:[CP 5611]SlaveM00_IREAL0,1

REAL

Real 0

X

X

DP:[CP 5611]SlaveM00_IREAL4,1

REAL

Real 4

X

X

DP:[CP 5611]SlaveM00_IREAL8,1

REAL

Real 8

X

DP:[CP 5611]SlaveM00_IREAL12,1

REAL

Real 12

X

DP:[CP 5611]SlaveM01_IX0.0,1

BOOL

16.0 Input

X

X

DP:[CP 5611]SlaveM01_IX0.1,1

BOOL

16.1 Input

X

X

DP:[CP 5611]SlaveM01_IX0.2,1

BOOL

16.2 Input

X

X

DP:[CP 5611]SlaveM01_IX0.3,1

BOOL

16.3 Input

X

X

DP:[CP 5611]SlaveM01_IX0.4,1

BOOL

16.4 Input

X

X

DP:[CP 5611]SlaveM01_IX0.5,1

BOOL

16.5 Input

X

X

DP:[CP 5611]SlaveM01_IX0.6,1

BOOL

16.6 Input

X

X

DP:[CP 5611]SlaveM01_IX0.7,1

BOOL

16.7 Input

X

X

DP:[CP 5611]SlaveM01_QX0.0,1

BOOL

0.0 Output

X

DP:[CP 5611]SlaveM01_QX0.1,1

BOOL

0.1 Output

X

DP:[CP 5611]SlaveM01_QX0.2,1

BOOL

0.2 Output

X

DP:[CP 5611]SlaveM01_QX0.3,1

BOOL

0.3 Output

X

DP:[CP 5611]SlaveM01_QX0.4,1

BOOL

0.4 Output

X

DP:[CP 5611]SlaveM01_QX0.5,1

BOOL

0.5 Output

X

DP:[CP 5611]SlaveM01_QX0.6,1

BOOL

0.6 Output

X

DP:[CP 5611]SlaveM01_QX0.7,1

BOOL

0.7 Output

X

V 1.0

Issue Feb.16th.2005

X X

31/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

Description of the table The contents of the table are defined as follows: ItemID column The item ID is made up of: •

DP for the protocol,



CP 5611 as connection name,



M00 to M01 for the Slave module,



I for input and Q for output, REAL and X for the data types Real and Bool and the byte address in the input are or output area respectively.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Visualizing column The visualizing column specifies in which element of the user interface the value of the item is displayed and which OPC functionalities are used. The name of the user interface elements does not refer to the slave modules. As for an S7 control program, inputs and outputs are continuously numbered. •

Data Change – the OPC group for visualizing is active and all value changes are reported from the OPC server to the OPC client..



OPC Write – These output values can be written from the surface.

Transfer column The Transfer column specifies which items in the thread are used for data transmission. •

This may become necessary when the DP master writes control data into the DP slave, which in return must set its PIQ.

Note

• Note

V 1.0

In this example, no outputs (PIQ - Process Image Outputs) are read from the OPC server However, the functionality exists and may be used on demand.

The OPC items for the PII (process image inputs) or the inputs respectively are written via an inactive group. The result of this is that – as specified in 3.4.1 – certain process variable are depicted twice in different groups on different OPC items. This makes the different application purposes apparent.

Issue Feb.16th.2005

32/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

4.2

Function mechanisms of the OPC Client

4.2.1

Overview The following figure shows the function blocks in the OPC client and the interaction with the objects in the OPC server.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Figure 4-2

Explanation of the diagram Table 4-2

No.

Description

1

When connecting the user interface with the OPC server, an OPC server object and an active OPCGroup object is created in the server, and a callback connection established. The accesses to the OPC server are encapsuled in the client with an OPC management.

2

In the active group, the cache is cyclically updated with values from the driver of the CP5611. If the values have changed, they are sent to the OPC client via the callback connection.

3

If specified values are written in the user interface, then the CP5611 is written to via the OPC management.

4

Connecting with the OPC server generates a separate thread in which a separate connection with the OPC server is established with an inactive group. After this initialization, the measured data are simulated cyclically and written to the memory of the inputs.

5

The memory of the inputs is written to the device (CP 5611) via the OPC management and the group in the server.

V 1.0

Issue Feb.16th.2005

33/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

Function mechanisms PROFIBUS •

When starting the OPC server process, the CP 5611 becomes active as PROFIBUS DP slave and is thus included in the PROFIBUS cycle by the DP master.



In each PROFIBUS cycle, the master updates the outputs at the slave and reads the inputs from the slave.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Function mechanisms for the visualization user interface •

The functionality of the visualization user interface is executed in the main thread of the C++ application.



During Connect an OPC management is created for the user interface. An OPCServer object and an active OPCGroup object are generated in the OPC DA server process via this OPC management. A callback connection is established for updating the values in the user interface. (OnDataChange)



The cache in the active group is cyclically (UpdateRate) updated by reading the values from the CP 5611. If the value of an OPC Item changes within the UpdateRate, the changed values are sent to the user interface via the Callback connection.

Function mechanisms for the data transfer:

4.2.2



The data transfer functionality is executed in a separate thread.



After generating the new thread, an OPC management is created. An OPCServer object and an inactive OPCGroup object are generated for the data transfer in the OPC DA server process via this OPC management.



The inactive group has no cache. This is not required as the read and write calls are directly executed from the device.



After the initialization, the measured data is written cyclically into the inputs of the slave in a loop. In each cycle, the simulated measured values are copied to the process image of the inputs, and then the process image is written to the inputs of the slaves via OPC.

Cycle times Two cycle times can be set within the application. The setting is made via the ServerDefines.h file in the source code.

Update Rate of the data in the user interface

V 1.0



Standard value in the example is 250ms.



Using as UpdateRate of the OPC group.



Values smaller than 100 ms should be not be used for the visualizing.

Issue Feb.16th.2005

34/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

Cycle time of the data transfer •

Standard value in the example is 50 ms.



Using pause times at the and of the cycle.



At pause time 0 ms a minimal cycle time of 230 μs results on a PC with P4 2.4 GHz at 100% processor load. At a pause time of 1 ms the processor load is below 5 %.



The time for copying or simulating the measured values can be neglected in comparison with the time for the OPC call for writing the inputs.



The cycle time of the PROFIBUS is normally in the range of 1-10 ms depending on bus parameters such as number of slaves.



The resolution of the Windows operating system is 10 ms.

Composition of the cycle time

Cycle time

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Figure 4-3

Subject to fluctuation

Fixed time

Note

4.2.3

For reaching a cycle time on the PC as steady as possible, it is recommended to not select the pause times smaller than 10 ms, as the variation range in relation to the overall cycle time would hardly be noticeable. Class diagram of the OPC Client This chapter explains the static structure of the OPC client using an UML class diagram. The dynamic sequences are explained in chapter 7 using sequence diagrams. The dynamic sequences are explained in chapter 5 using sequence diagrams. The following class diagram shows the classes used in the OPC client and their relations. The following pages explain the individual classes, whereby only the most important tasks and methods are explained. For a complete list, please refer to the well commented source code.

V 1.0

Issue Feb.16th.2005

35/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Figure 4-4

V 1.0

Issue Feb.16th.2005

36/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

Overview The following table gives an overview of the C++ classes and classifies them according to task and reusability. The classes have been implemented with support of the C++ class library MFC (Microsoft Foundation Classes). The class names correspond to the file names of the files which contain the source code for the implementation. Table 4-3

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Class

Task

Reusability

CUserInterface

User interface

Generated individually for this application.

COPCItemMgt

User interface

Generally usable, however, must be adapted.

CDataCopy

Data transfer

CMemoryMapSlave

Data transfer

Allgemein für Datentransfer verwendbar. Modifications necessary for size of the process image.

CThread

Data transfer

Usable as basis for separate thread.

COPCServerMgt

OPC general

Generally usable for OPC clients.

COPCGroupMgt

OPC general

COPCDataCallback

OPC general

CDataCallback

OPC general

Class CUserInterface •

This class implements the functionality of the user interface.



CUserinterface is derived from the MFC class CDialog as well as the CDataCallback interface. The data changes are reported to the user interface via CdataCallback.



The OnBtnClick methods are called by clicking the respective buttons in the user interface.

Table 4-4

Method OnBtnConnectClick

Functionality Setup of connection to OPC server and activating the Callback connection. An instance of COPCServerMgt and COPCGroupMgt is created respectively. Starting the data transfer. This creates an instance of the CdataCopy class and the thread for executing the control functionality in the object is started.

OnBtnDisconnectClick Terminating the data transfer. Disconnecting from the OPC server. OnBtnWriteAIClick

Manual writing of input values.

OnBtnWriteDIClick DataChange

V 1.0

Receiving the value changes from the OPC server and writing the values into the user interface elements.

Issue Feb.16th.2005

37/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

Class COPCItemMgt This class manages all information on an OPC item required in the user interface. This information consists of Server Handle, ItemID, ControlID, value and data type of the item. The Server Handle is provided by the server at AddItems and is required for all calls at the group such as Read, Write and RemoveItems. ControlID writes a new value into the respective element of the user interface. The CUserInterface contains a list of the OPCItemMgt objects and saves all information on the items. The index of this list is the client handle of the item, which in AddItems is transmitted to the OPC server and is provided by the OPC server at OnDataChange.

Note

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Any amount of information can be added without changing the access mechanism.

Class COPCServerMgt COPCServerMgt encapsules the OPC object OPCServer and enables simplified access to the COM object via C++ methods with MFC data types. Table 4-5

Method ConnectOPCServer

Functionality Setting up a connection to the OPC server by transfer of ProgID.

DisconnectOPCServer Disconnecting from the OPC server. AddGroup

Generating a group. AddGroup requires previously generating and transmitting an OPCGroupMgt object.

RemoveGroup

Removing a group. Requires deleting the OPCGroupMgt object prior to the call.

Class COPCGroupMgt The COPCGroupMgt encapsules the OPC object OPCGroup and simplifies access to the COM object. Table 4-6

Method

Functionality

AddItems

Hinzufügen von Items zur Gruppe.

RemoveItems

Removing items from the group.

Read

Reading values, quality and time stamp of the items in the group.

Write

Writing new values to the items in the group.

ConnectCallback

Activating the Callback. A pointer needs to be transmitted to the IDataCallback interface. It is required for initializing the Callback object OPCDataCallback.

DisconnectCallback

Deactivating the Callback.

V 1.0

Issue Feb.16th.2005

38/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

Class COPCDataCallback This class implements the OPC interface IOPCDataCallback. Realizing the COM functionality is derived from the ATL (Active Template Libary) class CComObjectRoot. The OPC server sends the Callbacks to the OPC client via IOPCDataCallback interface. Table 4-7

Method

Functionality

Initialize

Initializes the object with a pointer to the CDataChange interface in this example implemented by CUserInterface.

OnDataChange

Is called by the OPC server if the values of the items within the group have changed. Forwards the call to the user interface.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Class CDataCallback This interface class has only an abstract DataChange method which must be implemented by the derived class. In this example this method is implemented by CUserInterface. Class CThread CThread manages a thread an enables starting and stopping this thread. Table 4-8

Method

Functionality

StartThread

Starting a new thread.

ThreadEnter

Is called at the beginning of the new thread. Can be overwritten by the derived class.

DoWork

This abstract method must be implemented in the derived class and is the starting point for the functionality to be executed in the thread.

ThreadLeave

Is called at the end of the thread. Can be overwritten by the derived class.

StopThread

Stops the thread. An event is sent to the thread for it.

V 1.0

Issue Feb.16th.2005

39/65

Function Principles and Program Structures Function Mechanisms of this Application OPC DP Slave

Class CDataCopy Class CDataCopy is derived from CThread and implements the data transfer and the simulation of the measured values. Both functionalities are executed cyclically in the separate thread. Table 4-9

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Method

Functionality

ThreadEnter

Overwrites the method of the base class. In this method the OPC connection is initialized.

DoWork

In this method the data transfer is executed in a loop until the thread is terminated.

ReadMemoryMap

In this method the output image is read from the OPC server and stored in MemoryMap.

WriteMemoryMap

Here the input image is taken from the MemoryMap and written into the OPC server.

SimulateData

In this method, the simulation of the measured values is implemented with ramp and sinus function.

ThreadLeave

Overwrites the method of the base class. In this method the OPC connection is terminated.

Note

In the data transfer, no values are read off the OPC server. If values read from the OPC server are to be used in data processing, ReadMemoryMap must also be called in DoWork. See also chapter 6.1.

Class CMemoryMapSlave CMemoryMapSlave manages the image of the inputs and the outputs of the slave during a cycle. Table 4-10

Method

Functionality

WriteOutput

This method enables writing data, read by the OPC sever, into the MemoryMap.

ReadInput

This method enables reading the simulated values from MemoryMap, in order to write them into the OPC server.

GetOut

This method enables accessing the individual input variables in the simulation.

SetIn

This method enables accessing the individual output variables in the simulation.

V 1.0

Issue Feb.16th.2005

40/65

Function Principles and Program Structures Explanations on the Example Program OPC DP Slave

5

Explanations on the Example Program

Here you will find more information on … the dynamic processes within the application. These are explained using UML sequence diagrams.

5.1

Sequence diagrams for the visualization user interface

Connecting to the OPC server. The following sequence diagram shows the sequence chart upon clicking the "Connect" button in the user interface.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Figure 5-1

1 2

3

4

5

6

7

V 1.0

Issue Feb.16th.2005

41/65

Function Principles and Program Structures Explanations on the Example Program OPC DP Slave

Explanation Table 5-1

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

No.

Description

1

Clicking "Connect“ calls the OnBtnConnectClick method at the UserInterface object. In this method, the connection to the OPC server is established and initialized.

2

In OnBtnConnectClick an instance of the COPCServerMgt class is created. This object OPCServerMgtUI manages the connection to the OPC server. For establishing the connection, ConnectOPCServer is called at this object.

3

Creating an instance of the COPCGroupMgt class in which the group is managed. The OPCGroupMgtUI object is transferred in the AddGroup method to the OPCServerMgtUI object, where from this object the properties of the group are taken for the AddGroup call to the OPC server. After the AddGroup at the OPC server the OPCGroupMgtUI object is initialized with the return values of the OPC server.

4

For including the items into the group, the necessary item information is filled into lists in the BuildItemArrays method. This information consists of ItemID, desired data type, client handle and ID of the user interface element. With these lists AddItems is called at the OPCGroupMgtUI group management.

5

After adding the item the list of the OPCItemMgt management objects for the items is created. Thereby, the OPCItemMgt objects are initialized with the information from the BuildItemArrays and the server handles delivered by the OPC server. The index of the list corresponds to the client handles transmitted to the OPC Server at AddItems.

6

Structure of the Callback connection to the OPC server. The OPC server sends data changes to the OPC client via this connection. At ConnectCallback a pointer of the CDataCallback type is transmitted to the instance of CUserInterface. In ConnectCallback an instance of COPCDataCallback is generated. With this object the Callback connection to the OPC server is subsequently initialized.

7

After generating an instance of the CdataCopz class, SartThread is called at this instance. An own thread is started in which the measured data are cyclically written into the OPC server. Details see sequence diagram "Starting the data transfer“ in chapter 5.2.

Writing output variables If the user of the application presses the "Write Input" button for the analog inputs, the event handling method OnBtnWriteAIClick is called in the UserInterface object. In this method, the values are read from the user interface and transmitted to the Write method of the OPCGroupMgtUI object and thus written to the OPC server.

V 1.0

Issue Feb.16th.2005

42/65

Function Principles and Program Structures Explanations on the Example Program OPC DP Slave

Sequence for writing the digital inputs The sequence for writing the digital inputs is analog to the sequence for the analog inputs. Figure 5-2

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

OnDataChange Callback The OnDataChange Callback is called by the OPC server, as soon as the value of one or several items has changed within the update time of the group. The changed values are contained in the call. Figure 5-3

1 2

Explanation Table 5-2

No.

Description

1

The OPC server calls the OnDataChange method at the Callback object OPCDataCallback. Here the transmitted data are packed into MFC lists and passed on to the UserInterface object via the DataChange method.

2

In UserInterface the changed values are processed in a loop. The ID of the user interface element to which the value is to be written is thereby determined via the client handle. The client handle is the index of the list of the OPCItemMgt objects. With the ID read from OPCItemMgt the value is written into the user interface element with the SetDlgItemText method. The new value is also written in OPCItemMgt via SetValue.

V 1.0

Issue Feb.16th.2005

43/65

Function Principles and Program Structures Explanations on the Example Program OPC DP Slave

5.2

Sequence diagrams for the data transfer

Starting the data transfer Figure 5-4

1 2

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

3 4

5

6 7

V 1.0

Issue Feb.16th.2005

44/65

Function Principles and Program Structures Explanations on the Example Program OPC DP Slave

Explanation Table 5-3

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

No.

Instructions

1

Clicking "Connect“ calls the OnBtnConnectClick method at the UserInterface object (see sequence diagram "Establish connection to the OPC Server“ in chapter 5.1). In this method an instance of the CDataCopy class is generated and the StartThread method called at the CDataCopy object.

2

The statistical method Run and the object pointer of DataCopy are transmitted to the new thread. This calls the statistical method run in the new thread in which the ThreadMain method can then be called at the DataCopy object via the object pointer. This functionality for starting the thread with a method of the object has been implemented in the CThread base class.

3

ThreadEnter is then first called in the ThreadMain method. The method can be overwritten from the derived class in order to perform initializations. Here the connection to the OPC server is established in the ThreadEnter method.

4

For connecting with the OPC a new instance of the COPCServerMgt class is generated and the connection established via ConnectOPCServer. Subsequently an instance is generated by COPCGroupMgt and the instance is transmitted to OPCServerMgt in the AddGroup call. In this method, the properties of the group are read and AddGroup is then called at the OPC server with these parameters. The OPCGroupMgt object is then initialized with the return value of AddGroup.

5

After adding the group the items for the process image are then added. The server handles delivered by the OPC server are stored in a list.

6

Creating and initializing an instance of the CMemoryMapSlave class for managing the process image.

7

Calling the DoWork method in which the actual functionality of the thread is processed. Here the data transfer is executed in a loop until the application is terminated. Processing the data transfer in a loop is illustrated in the following sequence diagram.

Note

V 1.0

When generating the instance of COPCGroupMgt the activeness status of the group is transmitted as inactive. This is important as the cache of the OPC server is not necessary in this application which puts load off the OPC server.

Issue Feb.16th.2005

45/65

Function Principles and Program Structures Explanations on the Example Program OPC DP Slave

Executing data transfer A cycle of the data transfer with the simulation of the measured values and writing the image of the inputs is explained in the following sequence diagram. Figure 5-5

1

2

Simulation

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

measured values

Writing inputs

3

Explanation Table 5-4

Nr.

Aktion

1

The DoWork method is called after starting the thread. (See previous sequence diagram). In this method the data transfer is executed in a loop until the thread is terminated.

2

In the SimulateData method, the measured values are simulated. The access to the process image is thereby made via the SetInX method for the inputs. Thereby each data type has its own Set And Get method. GetOutBool for example enables accessing individual output bits or SetInFloat accessing an individual word. In the example implementation, both measured values are simulated with a ramp function and a sinus function and are written to the respective input value.

3

At the end of the cycle, the image of the inputs is written via the WriteMemoryMap method. The values of the outputs are read from the MemoryMapSlave object with the ReadInputs method and written to the OPC server via the OPCGroupMgt object. Note

V 1.0

The pause time at the end of a cycle (at the end of the while loop) is realized by the Windows system call MsgWaitForMultipleObjects.

Issue Feb.16th.2005

46/65

Function Principles and Program Structures Explanations on the Example Program OPC DP Slave

5.3

Error handling in the OPC Client

Error handling in the user interface: •

The user interface contains an output window for error messages.



The return values of all OPC calls are checked for errors.



In case of an error a message is output in the output window.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Error handling in the data transfer: •

Errors during initialization are reported to the user interface via a message and output in the output window.



The user interface contains a status display for the data transfer. In the error-free state the color is green and in case of an error it is red.



The return values of all OPC calls are checked for errors.



In case of an error an error flag is set in the DataCopy object.



The error flag is checked for changes after each cycle run.

At every change of the error flag a message with the new status is sent to the user interface.

V 1.0

Issue Feb.16th.2005

47/65

Function Principles and Program Structures Modifications to the Example Program OPC DP Slave

6

Modifications to the Example Program

Here you will find information on … what to do in order to expand the example code of the OPC client and use the example code in your own Visual Studio NET C++ project.

6.1

Expanding the sample code of the OPC client

Definition of the configuration data for the OPC client The configuration data for server, groups and items have been defined in the ServerDefines.h file in the following sections: Table 6-1

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

No.

Section

Note

1

OPC Server & Updaterate

OPC server ProgID and group settings for the OPC connection of the user interface.

2

Status

ItemIDs of the PROFIBUS status items in the user interface.

3

Analog Input / Output

ItemIDs of the analog input and output items.

4

Bit Input / Output

ItemIDs of the binary input and output items.

5

Simulation Function

OPC Server ProgID, cycle time of simulation function and ItemIDs of the input and output variables for the process image.

Expanding the scope of the OPC client For expanding the scope, changes to the source code must be made at the following locations: Table 6-2

No.

Source Code

Change

1

ServerDefines.h file

Supplementing definitions for additional ItemIDs and adjusting definitions for the number of items.

2

UserInterface.cpp file BuildItemArrays method

Adjusting structure of item lists to the new items.

3

DataCopy.cpp file BuildItemArrays method

Adjusting structure of item lists to the new items.

V 1.0

Issue Feb.16th.2005

48/65

Function Principles and Program Structures Modifications to the Example Program OPC DP Slave

6.2

Using OPC in own Visual Studio .NET C++ project This chapter contains a description of the steps necessary for creating a new C++ project in Visual Studio, in which the OPC is to be used. Further information is available in the documentation on Visual Studio .NET.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Table 6-3

No.

Instructions

1

Open Microsoft Visual Studio .NET 2003.

2

Create new project and select Visual C++ Æ MFC as project type in the left hand pane. On the right hand pane select the MFC Application template and specify name and storage location of the project. After clicking OK a further dialog appears named MFC Application Wizard.

3

Select Application Type on the left side in the blue field. Select Dialog based on the then displayed page. Pressing the Finish button creates the project with the settings made.

4

Copy the files opcda.h, opcda_i.c, opccomn.h, opccomn_i.c, opcerror.h into the project directory.

V 1.0

Note

The files can be taken from the delivered sample project or be obtained directly from the website of the OPC Foundation (www.opcfoundation.org).

Issue Feb.16th.2005

49/65

Function Principles and Program Structures Modifications to the Example Program OPC DP Slave

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

No.

Instructions

Note

5

Open the context menu in the Solution Explorer of the studio by right-clicking the Source Files folder. There you select Add Æ Add Existing Item.

6

If necessary browse into the project directory and select both C files (*.c). Pressing the Open buttons adds the files to the project.

7

Open the Properties Dialog for both newly added files via the context menu (right mouse button) and select the Not using precompiled Header setting in Configuration Properties Æ C/C++ Æ Precompiled Header. Pressing the OK button acknowledges the changed settings.

8

Open the stdafx.h file in the Solution Explorer with a doubleclick and include the OPC header files.

9

Compile project. Note

V 1.0

#include “opcda.h“ #include “opccomn.h“ #include “opcerror.h“

The OPC interface can be used project wide in every Code file which contains the reference #include “stdafx.h“.

Issue Feb.16th.2005

50/65

Function Principles and Program Structures Modifications to the Example Program OPC DP Slave

6.3

Using sample code in own Visual Studio .NET project If the OPC classes from the example for encapsulating the OPC interface are being used, the following steps are necessary. Note

In the project the OPC classes require ATL Support.

Table 6-4

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Nr.

Aktion

Anmerkung

1

Copy the following files into the project directory:

OPCServerMgt.cpp, OPCServerMgt.h, OPCGroupMgt.cpp, OPCGroupMgt.h, OPCDataCallback.cpp, OPCDataCallback.h, DataCallback.h.

2

Add copied files to the project.

Procedure see no.5 and no.6 in Table 6-3.

3

Open the stdafx.h file via the Solution Explorer with a doubleclick and add the following code lines.

#include typedef CArray CVARIANTArray; typedef CArray CHRESULTArray;

4

User defined arrays, which user the MFC template Carray, are used in the newly added classes.

Add ATL Support to the project. Select Add -> Add Class in the Solution Explorer via the context menu of the project (right mouse button).

5 Click C++ Æ ATL as category on the Add Class dialog, and select Add ATL Support To MFC as template. Pressing the Open button adds the STL Support to the project.

V 1.0

Issue Feb.16th.2005

51/65

Structure, Configuration and Operation of the Application Installation and Commissioning OPC DP Slave

Structure, Configuration and Operation of the Application

Content This part leads you step by step through the structure, important configuration steps, commissioning and operation of the application.

7

Installation and Commissioning

Here you will find information on … the hardware and software to be installed and which steps are necessary for commissioning the example.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

7.1

Installation of Hardware and Software This chapter describes the hardware and software components to be installed. The description and manuals as well as delivery information contained in the delivery scope of the respective products, should be followed in any case.

Hardware configuration The hardware components are available in chapter

.

For the hardware setup please proceed according to the following table:

!

Switch on the power supply after the last step only .

Warning Table 7-1

No.

Focus

Instructions

1

PC station

Install the PCI plug-in card CP 5611 into the PC station according to the attached manual /6/.

2

SIMATIC S7 station

Set up the controlling according to the figure in chapter 2.1.

3

PROFIBUS

Connect the PC station with the SIMATIC S7 station analog to the figure in chapter 2.1.

Note

V 1.0

Setup guidelines for PROFIBUS networks must generally be followed..

Issue Feb.16th.2005

52/65

Structure, Configuration and Operation of the Application Installation and Commissioning OPC DP Slave

Software The software components are available in chapter

.

Commissioning the example requires the following components from SIMATIC NET CD V6.2:

Note



SIMATIC NET PC products



SIMATIC NCM PC/S7 (not together with STEP 7)

SIMATIC NCM PC/S7 needs only be installed if no STEP 7 has been installed on the PC.

Microsoft Visual Studio .NET

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Microsoft Visual Studio .Net Professional is only required on the SIMATIC PC station if the example code needs to be changed. Alternatively the development environment can be installed on a separate PC (e.g. Engineering Station). Note

V 1.0

During the installation of Visual Studio .Net the safety settings of the Windows operating system are loosened. After installing the development environment pleas check the safety of the SIMATIC PC station and if necessary install Window updates.

Issue Feb.16th.2005

53/65

Structure, Configuration and Operation of the Application Installation and Commissioning OPC DP Slave

7.2

Commissioning the SIMATIC S7 station This chapter describes commissioning the SIMATIC S7 station for the hardware configuration described in chapter 2 via the download of the station from the STEP 7 project. Note

The STEP 7 project delivered with this example contains the completely configured SIMATIC S7 station with control program. This project can only be used without adjustment if the hardware is identical with the configuration. The configuration for deviating hardware is available in chapter 8.3.

Table 7-2

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

No.

Instructions

Note Extract the 21040390_OPC_DPSlave_STEP7_v10.zip file

1

Dearchiving the project

2

Open project in SIMATIC Manager.

3

Select station SIMATIC 315-2DP and load station into controller. The access point S7ONLINE used by STEP 7 must have been switched for loading the S7 station.

7.3

Commissioning the SIMATIC PC station This chapter describes commissioning the PC station with the configuration of the PC station via an XDB file for the hardware configuration described in chapter 2. Successful installation of all hardware and software components is a prerequisite.

V 1.0

Issue Feb.16th.2005

54/65

Structure, Configuration and Operation of the Application Installation and Commissioning OPC DP Slave

Note

The project file (XDB) delivered with this example contains the completely configured PC station. This file can only be used without adjustment if the hardware is identical with the configuration. The configuration for deviating hardware is available in chapter 8.2.

Table 7-3

No.

Instructions Open the Station Manager

1

by double-clicking the the task bar.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Note icon in

2

Click Import Station

Confirm the query with Yes

3

Select the XDB file

The XCB file is available in the XDBs sub-directory of the extracted ZIP-file.

4

After importing the XDB file the PC station has been configured.

Note

7.4

The explanations on configuring the PC station and the SIMATIC S7 station in chapter 8 are only necessary, if the hardware configuration does not correlate with he configuration described in chapter 2.3.

Commissioning of the OPC Client The user interface and the source code of the application are delivered as ZIP file. For installation of the OPC client extract the 21040390_OPC_DPSlave_CODE_v10.zip file in to any directory.

V 1.0

Issue Feb.16th.2005

55/65

Structure, Configuration and Operation of the Application Configuration OPC DP Slave

8

Configuration

Here you will find information on … the configuration steps necessary if the hardware deviates from the hardware used in the example.

8.1

Configuring the PC station The communication processor must be switched into "Configured mode". This releases it for being used with an application (here OPC server) and can be configured. This means that the configuration information from STEP 7 or HW Config can be loaded as for a hardware PLC (download).

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Table 8-1

No.

Instructions

1

Starting the Configurations Console

2

Select CP and set Configured mode.

3

Confirm selection and close the dialog.

V 1.0

Note

Issue Feb.16th.2005

56/65

Structure, Configuration and Operation of the Application Configuration OPC DP Slave

8.2

Configuring the PC station The configuration of the SIMATIC PC station is performed with STEP 7 and described step by step. Alternatively, this can also be performed using the NCM-PROFIBUS software package. The procedure is identical.

Table 8-2

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

No.

Instructions

Note

1

Starting the SIMATIC Manager and creating new project.

2

Insert SIMATIC PC Station and specify name. The name of the PC station must be identical with Windows name of the PC (see Workstation Æ Properties Æ Computername).

3

Enter SIMATIC S7 station The name can be changed, here “SIMATIC 315-2DP“

4

Open PC Station with HWConfig and insert CP. The slot must be identical with the index which was assigned in the Configuration console.

V 1.0

The name “OPCSlave“ was used here.

Issue Feb.16th.2005

57/65

Structure, Configuration and Operation of the Application Configuration OPC DP Slave

Instructions

5

Enter application (here OPC server) The used OPC Server must be selected according to the SIMATIC NET Version, here V6.2.

6

The operating mode of the CP 5611 is set to DP-Slave . The assigned application connecting as DP Slave is in this case the OPC Server.

7

Saving compiling and loading configuration (into PC station) in HW-Config .

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

No.

Note

The Station Configurator shows the current state of the SIMATIC PC Station. icon in Starting with the the taskbar. The diagnostic message in the Station Configurator indicates incorrect loading.

V 1.0

Issue Feb.16th.2005

58/65

Structure, Configuration and Operation of the Application Configuration OPC DP Slave

8.3

Configuring the SIMATIC S7 station

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Table 8-3

No.

Instructions

1

Open S7 Station with HWConfig and insert CPU. The order number of the used CPU must be correct.

2

Configure S7 station as master system. A PROFIBUS network was created (1.5 Mbit/s) and address “3“ was assigned to the master.

3

Add DP slave and assign a PROFIBUS address. The slave is contained in the module catalog as configured PC station.

V 1.0

Note

Issue Feb.16th.2005

59/65

Structure, Configuration and Operation of the Application Configuration OPC DP Slave

Instructions

4

Select slave from the list and connect with the master system. The PC station is indicated as active connection.

5

Inserting input and output modules. The PC station can take up universal modules which are then configured as inputs or outputs.

6

Allocation of addresses and configuring the stations An input module with a data length of 16 bytes and an input/output module with a data length of one byte respectively is configured. The initial address for the first module is set to “0“. The figure on the right shows the configuration of the input and output module. Note: A GSD file import is thus not necessary.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

No.

V 1.0

Note

Issue Feb.16th.2005

60/65

Structure, Configuration and Operation of the Application Configuration OPC DP Slave

Instructions

7

Enter simulation module into S7 station. The IO address “10“ is automatically assigned, as “0“ to ”9“ has already been assigned to the DP slave.

8

Checking the CP 5611 properties. The PC station has recognised to which master system it has been connected.

9

Saving compiling and loading configuration into the S7 station. Note: The access point S7ONLINE used by STEP 7 must have been switched for loading the S7 station.

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

No.

V 1.0

Note

Issue Feb.16th.2005

61/65

Structure, Configuration and Operation of the Application Configuration OPC DP Slave

8.4

Testing with OPC Scout The OPC Scout is a Standard OPC Client, contained in the delivery scope of SIMATIC NET and can be used as Test client. The correct function of the OPC-DP server is verified below.

Table 8-4

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

No.

Instructions

Note

1

Starting the OPC Scout.

Start Æ SIMATIC Æ SIMATIC NET ÆPROFIBUS Æ CP5613_CP5614 Æ OPC Scout

2

Connecting with the OPC server OPC.SIMATICNet with double-click.

During the connecting process, the OPC server is started (this also starts the DP slave) and only then is the slave ready to answer to the configuration telegram. The bus error LED of the master goes off it is switched from STOP to RUN and re-initializes the PROFIBUS.

3

Creating a group.

At least one group must be created. The OPC Scout displays all data event-controlled (for changes).

4

Browsing the address space and selecting the OPC item. The address space of the server should display one slave (according to above configuration). Click on OK to confirm.

5

Displaying items and system variables.

Note

V 1.0

The values of the items are now displayed in a list. In addition to the configured modules, the slave has the so-called system variables.

When terminating the OPC client (here the OPC Scout) the OPC server is also terminated. In the example configuration there will be no active DP master at the PROFIBUS, therefore, as the DP master the S7 CPU indicates a system/bus error . If no respective block has been programmed (OB82) to processes this state, the control goes to stop mode.

Issue Feb.16th.2005

62/65

Structure, Configuration and Operation of the Application Operating the Application OPC DP Slave

9

Operating the Application

Here you will find information on … how to operated all function of this application. Starting the OPC Client To start the OPC client, perform the following steps. Table 9-1

No.

Instructions

Note

Switch to the folder in which you have extracted the 21040390_OPC_DPSlave_CODE_v10.zip file.

See chapter 7.4

2

Double-click the OpcClientDPSlave.exe file

Starts the sample application.. The application is now runnable

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

1

V 1.0

Issue Feb.16th.2005

63/65

Structure, Configuration and Operation of the Application Operating the Application OPC DP Slave

User interface of the application The elements of the user interface are described in the figure below Figure 9-1

6

1

5

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

2

7

4

3 8 Elements of the user interface Table 9-2

No.

Description

1

Connecting to and disconnecting from OPC server and display of Slave state Starting data transmission

2

Status of data transmission. (Changes to red if an OPC error occurs in the data transmission)

3

Status of the application. This status can be manually set to ONLINE or OFFLINE. The standard value is ONLINE.

4

visualizing the digital input and output module. The inputs can be modified and be written into the OPC server via button click.

5

Visualizing two inputs. These can be modified and be written into the OPC server via button click.

6

Manual setting of input 0.0 at the 8 DI/DO module causes the STL program of the controller to generate an LED chaser at the module outputs. The speed of the LED chaser can be affected by writing the Real 0 input (value range 0-220). The data provided by the slave are at active LED chaser not considered anymore by the DP master. If input 0.0 of the module has not been set, the data provided by the slave are transferred tot he outputs.

7

Visualizing the inputs to which the measured values are copied.

8

Output field for OPC error messages.

V 1.0

Issue Feb.16th.2005

64/65

Appendix and List of Further Literature Literature OPC DP Slave

Appendix and List of Further Literature 10

Literature This list is by no means exhaustive and only gives a selection of appropriate sources. After SIMATIC NET product installation the manuals are still in the documentation directory on the target computer at: Start Æ SIMATIC Æ Documentation Æ [Language] You can find the product support in the internet under: http://support.automation.siemens.com (There enter the entry ID into the search field). Table 10-1

Copyright © Siemens AG 2005 All rights reserved 21040390_OPC_DPSlave_DOKU_v10_e

Topic

Title

1

OPC Custom Interface, Interface description On the documentation CD-Rom of SIMATICNET Or the OPC foundation website for the download www.opcfoundation.org

OPC Data Access 2.05a specification

2

Manual about standards, topologies and devices as well as installation guidelines. On the documentation CD-Rom of SIMATICNET In product support under the entry ID: 1172302

SIMATIC NET PROFIBUSnetworks

3

Description or information on: • General information on the PC tools • Functions of NCM PC Installed by SIMATIC NET, see: Start Æ SIMATIC Æ Documentation Æ [Language] In product support under the entry ID: 13542666

Commissioning of SIMATIC NET PC stations – instruction and quick start for SIMATIC NCM PC / STEP 7 from version V5.2 and up.

4

Manual for industrial communication on PG/PC with SIMATIC NET. Installed by SIMATIC NET, see: Start Æ SIMATIC Æ Documentation Æ [Language] In product support under the entry ID: 2044387

SIMATIC NET – Industrial Communication with PG/PC

Manual for SIMATIC Rack PC IL40 S V2 In product support under the entry ID: 19250619

SIMATIC Rack PC IL40 S V2 manual

5

5

5

6

Modified installation instruction for CP 5411, CP 5511 SIMATIC NET product and CP 5611 information / installation guide for CP5613, In product support under the entry ID: 284796 CP5614, CP5613 FO, CP5614 FO 5

7

Manual / Operating instruction CP5611 In product support under the entry ID: 13654902. 6

V 1.0

Issue Feb.16th.2005

SIMATIC NET CP 5611 Installation instruction / product information

65/65

Suggest Documents