Sie sind auf Seite 1von 446

SIMATIC NET

Introduction to the OPC Server for SIMATIC NET


Manual

1 2 3 4 5 6 7 8 9 10 11 12 13 14 A

Overview of the OPC Server for SIMATIC NET Quick Start Basics of OLE Basics of OPC Structure of the OPC Items for the SIMATIC NET Data Access Interface Properties of the OPC Event Server for SIMATIC NET Configuration of the OPC Server for SIMATIC NET Configuration Using Files DCOM with the OPC-Server for SIMATIC NET The OPC Custom Interface for Data Access The OPC Automation Interface for Data Access The OPC Custom Interface for Alarms & Events Where to Get Help Glossary

SIMATIC Computing

6GK1971-0BA00-0AA1

Release 3

SIMATIC NET is a trademark of Siemens Siemens Aktiengesellschaft

Wir haben den Inhalt der Druckschrift auf bereinstimmung mit der beschriebenen Hard- und Software geprft. Dennoch knnen Abweichungen nicht ausgeschlossen werden, so da wir fr die vollstndige bereinstimmung keine Gewhr bernehmen. Die Angaben in der Druckschrift werden jedoch regelmig berprft. Notwendige Korrekturen sind in den nachfolgenden Auflagen enthalten. Fr Verbesserungsvorschlge sind wir dankbar. Technische nderungen vorbehalten.

Weitergabe sowie Vervielfltigung dieser Unterlage, Verwertung und Mitteilung ihres Inhalts nicht gestattet, soweit nicht ausdrcklich zugestanden. Zuwiderhandlungen verpflichten zu Schadenersatz. Alle Rechte vorbehalten, insbesondere fr den Fall der Patenterteilung oder GM-Eintragung.

6GK1971-0BA00-0AA1 Copyright Siemens AG 1997 All Rights Reserved

We have checked the contents of this manual for agreement with the hardware described. Since deviations cannot be precluded entirely, we cannot guarantee full agreement. However, the data in this manual are reviewed regularly and any necessary corrections included in subsequent editions. Suggestions for improvement are welcome. Technical data subject to change.

The reproduction, transmission or use of this document or its contents is not permitted without express written authority. Offenders will be liable for damages. All rights, including rights created by patent grant or registration of a utility or design, are reserved.

6GK1971-0BA00-0AA1 Copyright Siemens AG 1997 All Rights Reserved

Nous avons vrifi la conformit du contenu du prsent manuel avec le matriel et le logiciel qui y sont dcrits. Or, des divergences n'tant pas exclues, nous ne pouvons pas nous porter garants pour la conformit intgrale. Si l'usage du manuel devait rvler des erreurs, nous en tiendrons compte et apporterons les corrections ncessaires ds la prochaine dition. Veuillez nous faire part de vos suggestions. Nous nous rservons le droit de modifier les caractristiques techniques.

Toute communication ou reproduction de ce support d'informations, toute exploitation ou communication de son contenu sont interdites, sauf autorisation expresse. Tout manquement cette rgle est illicite et expose son auteur au versement de dommages et intrts. Tous nos droits sont rservs, notamment pour le cas de la dlivrance d'un brevet ou celui de l'enregistrement d'un modle d'utilit.

6GK1971-0BA00-0AA1 Copyright Siemens AG 1997 All Rights Reserved

Siemens Aktiengesellschaft

Elektronikwerk Karlsruhe Printed in the Federal Republic of Germany

SIMATIC NET
Introduction to the OPC Server for SIMATIC NET
Manual C79000-B8976-C126/3

Note We would point out that the contents of this product documentation shall not become a part of or modify any prior or existing agreement, commitment or legal relationship. The Purchase Agreement contains the complete and exclusive obligations of Siemens. Any statements contained in this documentation do not create new warranties or restrict the existing warranty. We would further point out that, for reasons of clarity, these operating instructions cannot deal with every possible problem arising from the use of this device. Should you require further information or if any special problems arise which are not sufficiently dealt with in the operating instructions, please contact your local Siemens representative. General This device is electrically operated. In operation, certain parts of this device carry a dangerously high voltage.
WARNING !

Failure to heed warnings may result in serious physical injury and/or material damage. Only appropriately qualified personnel may operate this equipment or work in its vicinity. Personnel must be thoroughly familiar with all warnings and maintenance measures in accordance with these operating instructions. Correct and safe operation of this equipment requires proper transport, storage and assembly as well as careful operator control and maintenance.

Personnel qualification requirements Qualified personnel as referred to in the operating instructions or in the warning notes are defined as persons who are familiar with the installation, assembly, startup and operation of this product and who possess the relevant qualifications for their work, e.g.: Training in or authorization for connecting up, grounding or labeling circuits and devices or systems in accordance with current standards in safety technology; Training in or authorization for the maintenance and use of suitable safety equipment in accordance with current standards in safety technology; First Aid qualification.

Siemens Aktiengesellschaft

Elektronikwerk Karlsruhe Printed in the Federal Republic of Germany

Contents

Contents

Overview of the OPC Server for SIMATIC NET .......................................................13 1.1 1.2 1.3 1.4 1.5 OPC Interface ................................................................................................14 OPC Server, OPC Server for SIMATIC NET ..................................................16 Advantages of the OPC Server ......................................................................18 Background Knowledge ..................................................................................19 Guide to the Documentation ...........................................................................20

Quick Start ................................................................................................................21 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2 2.2.1 2.3 2.4 Installing and Starting up the Underlying Communications System .................22 Installing the DP Protocol ...............................................................................23 Installing the S7 Protocol ................................................................................24 Starting Up the S7 Protocol for Alarms & Events ............................................25 Installing the FMS Protocol.............................................................................26 Installing the Send/Receive Protocol for Industrial Ethernet............................28 Installing the Send/Receive Protocol for PROFIBUS (FDL) ............................30 Commissioning the DP Slave .........................................................................32 Simulation Connections of the OPC Server ....................................................33 Working with the Simulation Connection.........................................................34 Description of the Quick Start .........................................................................35 Using the Quick Start......................................................................................36

Basics of OLE ...........................................................................................................39 3.1 3.2 3.3 3.4 COM as the Basis for OPC.............................................................................40 Objects and Interfaces....................................................................................41 Standard Representation of Objects in OLE ...................................................43 Object Control Via the Automation Interface...................................................44

Basics of OPC...........................................................................................................45 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 The Role of OLE in OPC ................................................................................46 The OPC Specifications .................................................................................47 The Two Interfaces of OPC ............................................................................48 The Class Model of OPC Data Access............................................................50 The Principle of OPC Alarms & Events...........................................................52 Group Operations...........................................................................................55 The Client-Server Architecture of OPC...........................................................56 Terminology of the OPC Interface Description................................................58

Structure of the OPC Items for the SIMATIC NET Data Access Interface..............63

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Contents

5.1 5.2 5.2.1 5.2.2 5.2.3 5.2.4 5.3 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.4 5.4.1 5.4.2 5.4.3 5.4.4 5.5 5.5.1 5.5.2 5.5.3 5.6 5.6.1 5.6.2 5.6.3 5.7 5.7.1 5.7.2 5.8 6

General Information........................................................................................64 DP Protocol ....................................................................................................66 Specifications for the DP Protocol ..................................................................66 Syntax of Variable Names for DP ...................................................................67 Syntax of Variable Names for DPC1 Access...................................................70 DP-Specific Information Variables ..................................................................72 S7 Protocol.....................................................................................................76 Specifications for the S7 Protocol ...................................................................76 Syntax of Variable Names for S7 (Variable Services) .....................................78 Syntax of Variable Names for Field-Oriented Services ...................................81 Syntax of Variable Names for Messages ........................................................84 Information Variables Specific to S7...............................................................88 Special Variables for Domain and Password Services ....................................92 FMS Protocol .................................................................................................98 Specifications for the FMS Protocol................................................................98 Syntax of Variable Names for FMS ..............................................................100 Information Variables Specific to FMS..........................................................102 FMS Server Connection ...............................................................................106 Send/Receive Protocol via Industrial Ethernet ..............................................107 Specifications for the Send/Receive Protocol ...............................................107 Syntax of Variable Names for SR .................................................................111 Information Variables Specific to SR ............................................................116 Send/Receive Protocol via PROFIBUS (FDL) ..............................................117 Specifications for the Send/Receive Protocol via PROFIBUS (FDL).............117 Syntax of Variable Names for FDL ...............................................................120 Information Variables Specific to FDL...........................................................124 DPS Protocol................................................................................................126 Specifications for the DPS Protocol ..............................................................126 Syntax of Variable Names for DPS...............................................................127 Symbolic Variable Names (Aliases) ..............................................................131

Properties of the OPC Event Server for SIMATIC NET ........................................133 6.1 6.2 6.2.1 6.2.2 General Information......................................................................................134 S7 Protocol...................................................................................................135 Events and Parameters ................................................................................136 Event Attributes............................................................................................138

Configuration of the OPC Server for SIMATIC NET..............................................143 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 7.9 General Information......................................................................................144 General Settings for all Protocols .................................................................145 Protocol Settings Specifically for DP ............................................................147 Protocol Settings Specifically for S7 .............................................................149 Protocol Settings Specifically for FMS..........................................................152 Protocol Settings Specifically for Send/Receive ...........................................156 Protocol Settings Specifically for FDL...........................................................158 Protocol Settings Specifically for DPS ..........................................................160 Trace for a Specific Protocol ........................................................................162

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Contents

7.10 7.11 7.11.1 7.11.2 7.11.3 7.11.4 8

Quitting the OPC Server...............................................................................163 Symbols for the OPC Server for SIMATIC NET............................................164 The Symbol File with STEP 7 Symbols ........................................................165 Creating a Symbol File with STEP 7 Symbols ..............................................167 Entering Additional Symbols.........................................................................170 Using Symbols in OPC .................................................................................172

Configuration Using Files ......................................................................................175 8.1 8.2 8.3 8.3.1 8.3.2 8.3.3 8.3.4 8.3.5 8.4 8.4.1 8.4.2 8.4.3 8.4.4 8.4.5 8.5 8.5.1 8.5.2 8.5.3 8.5.4 8.5.5 8.5.6 8.5.7 8.6 8.6.1 8.6.2 8.6.3 8.6.4 8.7 8.7.1 8.7.2 8.7.3 8.7.4 8.7.5 8.8 8.8.1 8.8.2 8.8.3 Configuration Files .......................................................................................176 Configuring Access Rights............................................................................177 DP Protocol ..................................................................................................179 General Protocol Configuration.....................................................................180 Module-Specific Configuration......................................................................181 Slave Configuration......................................................................................183 Definition of Symbolic Names.......................................................................184 Configuration of the DP Demo Connection ...................................................185 S7 Protocol...................................................................................................187 General Protocol Configuration.....................................................................188 Connection-Specific Configuration................................................................190 Definition of Symbolic Names.......................................................................193 Settings for S7 Messages .............................................................................194 Configuration of the S7 Demo Connection....................................................195 FMS Protocol ...............................................................................................196 General Protocol Configuration.....................................................................197 Connection-Specific Configuration................................................................199 Variable Definition ........................................................................................201 Definition of Symbolic Names.......................................................................203 Configuration of the FMS Server Connection................................................204 Configuration of the FMS Demo Connection.................................................207 Creating a Local Object Dictionary ...............................................................209 Send/Receive Protocol .................................................................................210 General Protocol Configuration.....................................................................211 Connection Configuration for a Specific Access Point...................................212 Connection-Specific Configuration................................................................214 Configuration of the Demo Connection .........................................................217 Send/Receive Protocol for PROFIBUS (FDL) ...............................................218 General Protocol Configuration.....................................................................219 Connection Configuration for a Specific Access Point...................................220 Connection-Specific Configuration................................................................221 Configuration of the FDL Demo Connection .................................................223 Dynamic Connections...................................................................................224 DPS Protocol................................................................................................225 General Protocol Configuration.....................................................................226 Connection-Specific Configuration................................................................227 Configuration of the DPS Demo Connection.................................................229

DCOM with the OPC Server for SIMATIC NET ......................................................231 9.1 9.2 9.2.1 Introduction to DCOM...................................................................................232 Configuring DCOM Operation.......................................................................233 Configuration of the Server Computer ..........................................................236

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Contents

9.2.2 10

Configuration of the Client Computer............................................................241

The OPC Custom Interface for Data Access .........................................................243 10.1 10.2 10.3 10.4 10.4.1 10.4.2 10.4.3 10.4.4 10.4.5 10.5 10.5.1 10.5.2 10.5.3 10.5.4 10.6 10.6.1 10.6.2 10.6.3 Versions of the OPC Interface ......................................................................244 Creating and Using an OLE Object in C/C++ ................................................245 Further Information about the Interface Description for the OPC Custom Interface .......................................................................................................248 The OPC Server Object .............................................................................249 IOPCServer Interface ...................................................................................250 IOPCBrowseServerAddressSpace Interface .................................................252 IOPCCommon Interface (Version 2.0) ..........................................................254 IConnectionPointContainer Interface ............................................................256 IOPCItemProperties (V 2.0) Interface ...........................................................257 Objects of the OPC Group Class................................................................258 IOPCItemMgt Interface.................................................................................259 IOPCGroupStateMgt Interface......................................................................262 IOPCSyncIO Interface..................................................................................264 IOPCAsyncIO Interface ................................................................................265 IDataObject Interface ...................................................................................267 IEnumOPCItemAttributes Interface...............................................................268 IAsyncIO2 Interface (Version 2.0) .................................................................269 IConnectionPointContainer Interface ............................................................271

11

The OPC Automation Interface for Data Access...................................................273 11.1 11.2 11.3 11.4 11.4.1 11.4.2 11.4.3 Versions of the Automation Interface ............................................................274 Creating and Using an OLE Object in Visual Basic .......................................275 Further Information about the Interface Description for the OPC Automation Interface .......................................................................................................279 The OPC Server Object .............................................................................281 Properties of "OPCServer ...........................................................................281 Methods of the "OPCServer ........................................................................282 Events of "OPCServer" ................................................................................285

11.5 The "OPCBrowser Object ............................................................................286 11.5.1 Properties of "OPCBrowser .........................................................................286 11.5.2 Methods of "OPCBrowser"............................................................................287 11.6 11.6.1 11.6.2 11.6.3 11.7 11.7.1 11.7.2 11.7.3 The "OPCGroups Collection Object.............................................................289 Properties of "OPCGroups ..........................................................................290 Methods of "OPCGroups .............................................................................291 Events of "OPCGroups................................................................................292 The "OPCGroup Object...............................................................................293 Properties of "OPCGroup ............................................................................293 Methods of "OPCGroup...............................................................................295 Events of "OPCGroup .................................................................................297

11.8 The "OPCItems Collection Object ...............................................................298 11.8.1 Properties of "OPCItems .............................................................................298 11.8.2 Methods of "OPCItems................................................................................299 11.9 The "OPCItem Object..................................................................................302 11.9.1 Properties of "OPCItem...............................................................................303

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Contents

11.9.2 Methods of "OPCItem .................................................................................305 12 The OPC Custom Interface for Alarms & Events ..................................................307 12.1 Supplement to the Interface Description of the OPC Custom Interface for Alarms & Events...........................................................................................308

12.2 The "OPC Event Server" Object ...................................................................309 12.2.1 The "IOPCEventServer" Interface ................................................................310 12.3 The "OPC Event Subscription" Object ..........................................................316 12.3.1 The "IOPCEventSubscriptionMgt" Interface..................................................317 12.4 The Interfaces of the Client ..........................................................................320 12.4.1 The "IOPCEventSink" Interface ....................................................................321 12.4.2 The "IOPCShutdown" Interface.....................................................................322 13 Where to Get Help...................................................................................................323 13.1 13.2 14 Help with Technical Questions......................................................................324 Who to Contact about Training for SIMATIC NET Products..........................327

Glossary ..................................................................................................................329

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Notes for the Reader

10

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Notes for the Reader

Notes for the Reader


Guide to the Documentation The documentation for the OPC Server for SIMATIC NET consists of two parts "Introduction to the OPC Server for SIMATIC NET" (this manual) "OLE for Process Control Standard" - OPC Interface Description These manuals are available only: in English as files that are written to the "DOC" folder during installation of the product. You can read and print these files using a word processing program capable of opening Word 6.0 compatible files.

Conventions

The text includes the following symbol: This character highlights special features and dangers.

History

This manual is valid for product versions V 2.1 and higher. Descriptions of the following product properties have been added in this release of the manual:

Product Version up to V2.0 V2.1

Content of the Manual OPC Data access for DP, S7, FMS, Send/Receive Added: OPC alarms & events, extraction of STEP 7 symbols, definition of rights for OPCItems (access protection), S7 domain and password services

V2.2

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

11

Notes for the Reader

12

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Overview of the OPC Server for SIMATIC NET

Overview of the OPC Server for SIMATIC NET

The open network concept of SIMATIC NET provides industrial communications networks for automation engineering. These consist of network components and programs for network access. This chapter provides you with an overview of the functions of the OPC server. It illustrates the advantages of using OPC in industrial communication. The guide to the documentation shows you what you ought to read according to your experience and prior knowledge.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

13

Overview of the OPC Server for SIMATIC NET

1.1
OPC

OPC Interface
OPC is an acronym for OLE for Process Control and is used as the name for a standard interface for communication in automation engineering. OLE itself means the component model of Microsoft. Components are the software objects or applications that provide their functionality to other applications.

OPC Interface

The OPC interface is the specification of a uniform and vendorindependent software interface based on OLE. It was developed as an industrial standard by leading firms in the field of automation with the support of Microsoft.

Previously, applications that access process data were restricted to the access techniques of the communication networks of one manufacturer. The standardized OPC interface now allows a user, who, for example, operates control and monitoring software, uniform access to communication networks of any vendor via the OPC interface.

14

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Overview of the OPC Server for SIMATIC NET

OPC Specification:

Apart from the specification for access to process data (data access), the OPC standard includes further specifications for other areas of automation engineering: Alarms & Events Historical Data Access

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

15

Overview of the OPC Server for SIMATIC NET

1.2

OPC Server, OPC Server for SIMATIC NET


An OPC server is a program that provides the standardized OPC interface for applications from various manufacturers. Communication via industrial networks is possible with simple calls. The, at times, complicated handling of vendor-specific characteristics on communications networks is disguised by the OPC server. Regardless of the communications network and protocol being used, access to the process via the OPC interfaces is always uniform. An OPC server forms an intermediate layer between the applications allowing process data, the various network protocols and interfaces for access to this data to be processed.

OPC Server

OPC Server for SIMATIC NET

The OPC server of SIMATIC NET allows Windows applications access to SIMATIC NET products for industrial communication. The requirement for connecting your applications with SIMATIC NET products is the use of the open OPC interface. The interface to the products of SIMATIC NET is implemented by the OPC server for SIMATIC NET.

The OPC server for SIMATIC NET supports the interface "OPC Data Access" for all protocols. The "OPC Alarms & Events" interface is available for those protocols whose protocol mechanisms support the sending of events. (For details of the product version, refer to the section "Notes for the Reader").

Additional SIMATIC NET Components Required

To access process variables and receive events via the OPC server for SIMATIC NET, you also require a protocol software belonging to SIMATIC NET and a SIMATIC NET communications processor.

16

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Overview of the OPC Server for SIMATIC NET

OPC Server for SIMATIC NET with OPC Client

The following diagram illustrates an OPC server for SIMATIC NET along with an application known as the OPC client. The OPC server for SIMATIC NET provides the OPC client with the values of process variables or signals events from the partner device. The OPC server for SIMATIC NET accesses the partner device via the communications network using the protocol software and the SIMATIC NET communications processor.

Application OPC client (e.g. operator control and monitoring) OPC server for SIMATIC NET Data Access Alarms & Events

heterogeneous OPC interface

Protocol software from SIMATIC NET Communications processor from SIMATIC NET Comm. network from SIMATIC NET

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

17

Overview of the OPC Server for SIMATIC NET

1.3

Advantages of the OPC Server


If you use the OPC server for SIMATIC NET along with the SIMATIC NET protocols, you have the following benefits: You use a protocol-independent interface. You obtain simple access to the communications networks of SIMATIC NET. You can connect your programmable controllers to a wide variety of automation engineering applications via a SIMATIC NET communications network. Communication is also possible with office applications such as Microsoft Excel, Access etc. Using the OLE mechanism DCOM, applications installed on other computers can access the services provided by the OPC server via a local or global network (Internet).

Advantages when Installing a System

Benefits for the Developer

When you develop an application that accesses process data via the OPC interface of an OPC server for SIMATIC NET, you have the following benefits: The OPC interface is a heterogeneous (vendor-independent) interface. This opens up a larger market for your product, increases the usability of your developments, and makes your investment more viable. The developed applications are not dependent on the communications system of one manufacturer and with appropriate programming can communicate unchanged with the OPC servers of other manufacturers. The OPC interface provides applications with a powerful means of access to OPC servers and the underlying communications networks. OPC has a high-performance interface for the C/C++ programming language. Convenient and simple access to process data is possible with development environments such as Visual Basic (Microsoft). The developer no longer needs to be involved with protocol and vendor-specific interfaces. Troubleshooting is simplified with the option of a trace output.

18

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Overview of the OPC Server for SIMATIC NET

1.4

Background Knowledge
The OPC server for SIMATIC NET is used by the following user groups: Developers of client applications (products for automation engineering) Installation personnel If you are using OPC client applications exclusively, the following information is unnecessary. The OPC client-server architecture is transparent for the user.

User Groups

Background Knowledge

The following table shows the required background knowledge for different user groups. Background Knowledge Knowledge of PCs Knowledge of the C/C++ programming languages Knowledge of the development environments (for example, Visual Basic) Application-specific knowledge of OLE mechanisms Configuration of the communications protocol being used Configuration of the underlying communications module Knowledge of the partner stations on the network Developers of Client Applications yes yes, if the custom interface is used yes, if the automation interface is used yes Installation personnel yes no no

yes, limited knowledge yes

yes

yes

yes

yes

yes

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

19

Overview of the OPC Server for SIMATIC NET

1.5

Guide to the Documentation


Not everyone needs to read everything! A programmer naturally requires more information than installation personnel. The following table recommends what each user group should read.

Who Should Read What?

Source of Information README FAQ (Frequently Asked Questions) This manual (completely) OPC specification: Basics OPC specification: Data Access Custom Interface OPC specification: Data Access Automation Interface OPC Specification Alarms & Events

Developers of Client Applications yes yes yes yes yes, if developing with C/C++ yes, if developing, for example, with Visual Basic yes

Installation personnel yes yes yes no no

no

no

20

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Quick Start

Quick Start

This chapter explains the following: How to install and start up the underlying communication system required for the OPC server How to use the FMS OPC server with a simulation connection without an underlying communications network. How to familiarize yourself with the OPC server for SIMATIC NET with a quick start using OPC Scout.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

21

Quick Start

2.1

Installing and Starting up the Underlying Communications System


The OPC server provides uniform access via various industrial communications systems. To use the OPC server, the underlying communications system must be installed and configured. The following sections list the steps necessary for the various protocols.

Introduction

The following sections describe the standard operation of a protocol. Special situations such as multiple communications processors are not included in this introduction.

For details of the individual steps necessary, refer to the relevant product documentation.

Requirements

Before you can work through the procedures outlined below, you require the software products as described in the installation instructions.

Configuring

The communications partner is configured for the SIMATIC NET protocol software using the protocol-specific tools of the communications modules. The configuration tools are shipped with the underlying protocol software, for example COM PROFIBUS for the DP protocol.

22

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Quick Start

2.1.1 Installing the DP Protocol

Step 1

Procedure Installing the Communications Processor Insert the communications processor as described in the installation instructions for the module. Now start the "Setting the PG/PC Interface configuration program and click the "Install" button. Select the module you want to install.

Creating the Configuration Along with the software for the DP protocol, the "COM PROFIBUS configuration tool was also installed. Start this program so that you can create a description of your DP communications system in a database. When you have completed your configuration, create a binary database that can be downloaded to the CP using the "Export => NCM File menu item.

Assigning an Interface Parameter Set Start the "Setting the PG/PC Interface configuration program. Select the access point of the application "CP_L2_1:". Assign the interface parameter set for the DP mode corresponding to your module to this access point (for example CP5412A2 (PROFIBUS) or CP 5511 (DP master )).

Configuring the Communications Processor Click the "Properties button. Select the tab for configuring the DP protocol and enter the path and name of the loadable binary database (*.ldb) you have just created in the dialog that is displayed. Some modules also require explicit activation of the DP protocol ("DP check box). Close the configuration program.

Testing the Communications Processor Start the "Setting the PG/PC Interface configuration program again. Select the access point of the application "CP_L2_1:" and click the "Diagnostics" button. Check that the module is functioning correctly.

Using the OPC Scout Follow the steps outlined in Section 2.4 for the quick start.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

23

Quick Start

2.1.2 Installing the S7 Protocol

Step 1

Procedure Installing the Communications Processor Insert the communications processor as described in the installation instructions for the module. Now start the "Setting the PG/PC Interface configuration program and click the "Install" button. Select the module you want to install.

Creating the Configuration Along with the software for the S7 protocol, the "COM S7 configuration tool was also installed. Start this program so that you can create a description of your S7 communications system in a database. When possible, use only one VFD for all connections. When you have completed your configuration, create a binary database that can be downloaded to the CP using the "File => Generate Binary DB ... menu item. As an alternative, you can also use the NCM configuration tool.

Assigning an Interface Parameter Set Start the "Setting the PG/PC Interface configuration program. Select the access point of the application. If you communicate via PROFIBUS or MPI, select "CP_L2_1:", If you work with Industrial Ethernet, select "CP_H1_1:". Assign the interface parameter set for the S7 mode corresponding to your module to this access point (for example CP 5412A2(PROFIBUS), CP 1613 or similar).

Configuring the Communications Processor Click the "Properties button. Select the tab for configuring the S7 protocol and enter the path and name of the loadable binary database (*.ldb) you have just created in the dialog that is displayed. If required, activate the S7 protocol using the "S7 check box. Close the configuration program.

Testing the Communications Processor Start the "Setting the PG/PC Interface configuration program again. Select the access point of the application used previously and click the "Diagnostics" button. Check that the module is functioning correctly.

Configuring the OPC Server Start the configuration program for the OPC server ("OPC Settings). Select the "S7 Protocol" tab. Select the CP/VFD pairs containing the access points corresponding to your network type. ("CP_L2_1: or "CP_H1_1:). Close the configuration program.

Using the OPC Scout Follow the steps outlined in Section 2.4 for the quick start.

24

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Quick Start

2.1.3 Starting Up the S7 Protocol for Alarms & Events

Step 1

Procedure Installing and starting up the S7 protocol Install and start up the S7 protocol for access to process variables as described in Section 2.1.2. Close all OPC clients to quit the OPC server.

Opening the configuration file Start the configuration program for the OPC server and open the "S7 Protocol" tab. Click the "Edit S7 Configuration File" button; the text database for configuring the S7 OPC server is opened ( default: SscoreS7.txt").

Entering the connection configuration In the section for the connection, enter the following for the connection via which the alarms and events will be received (for example [MyAlarmCon|MyOPCVFD|CP_L2_1:]: Events=3 InitiateReq=2 ; Activate Alarm&Event mechanism ; Maintain connection permanently

Severity entry For each alarm and each scan event, you can select the severity in a range from 1 to 1000 (optional). You can also define a default value for alarms and scans: DefaultScan=300 DefaultAlarm=600 Scan123=200 Alarm222=900 ; Severity of the scan events is 300 ; Severity of the alarms is 600 ; The scan with ID 123 has severity 200 ; The alarm with ID 222 has severity 900

Saving the configuration file Save the configuration file and start a client for OPC Alarm & Events.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

25

Quick Start

2.1.4 Installing the FMS Protocol

Requirements

The partner devices to be accessed on the PROFIBUS network are configured and can provide a short object dictionary.

26

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Quick Start

Step 1

Procedure Installing the Communications Processor Insert the communications processor as described in the installation instructions for the module. Now start the "Setting the PG/PC Interface configuration program and click the "Install" button. Select the module you want to install.

Creating the Configuration The "COM PROFIBUS configuration tool was installed along with the software for the FMS protocol. Start this program so that you can create a description of your FMS communications system in a database. When possible, use only one VFD for all connections. When you have completed your configuration, create a binary database that can be downloaded to the CP using the "Export => NCM File menu item.

Assigning an Interface Parameter Set Start the "Setting the PG/PC Interface configuration program. Select the access point of the application "CP_L2_1:". Assign the interface parameter set for the FMS mode corresponding to your module to this access point (for example "CP5412A2 (PROFIBUS) ).

Configuring the Communications Processor Click the "Properties button. Select the tab for configuring the FMS protocol and enter the path and name of the loadable binary database (*.ldb) you have just created in the dialog that is displayed. Activate the FMS protocol in the "FMS check box. Close the configuration program.

Testing the Communications Processor Start the "Setting the PG/PC Interface configuration program again. Select the access point of the application "CP_L2_1:" and click the "Diagnostics" button. Check that the module is functioning correctly.

Configuring the OPC Server Start the configuration program for the OPC server ("OPC Settings). Select the "FMS Protocol" tab. Click the "Select..." button to select the CP/VFD pairs to be used by the OPC server. By selecting the relevant check boxes in the lower part of the dialog, select the CP/VFD pairs you require that have the access point "CP_L2_1:".

Using the OPC Scout Follow the steps outlined in Section 2.4 for the quick start.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

27

Quick Start

2.1.5 Installing the Send/Receive Protocol for Industrial Ethernet

Requirements

The partner devices are configured on the Industrial Ethernet network and the required handling blocks or function blocks are called.

28

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Quick Start

Step 1

Procedure Installing the Communications Processor Insert the communications processor as described in the installation instructions for the module. Now start the "Setting the PG/PC Interface configuration program and click the "Install" button. Select the module you want to install.

Assigning an Interface Parameter Set Start the "Setting the PG/PC Interface configuration program. Select the access point of the application (CP_H1_1: ). Assign the interface parameter set corresponding to your module to this access point (for example CP 1613).

Testing the Communications Processor Start the "Setting the PG/PC Interface configuration program again. Select the access point of the application used previously ("CP_H1_1:") and click the "Diagnostics" button. Check that the module is functioning correctly.

Configuring the OPC Server Start the configuration program for the server ("OPC Settings). Select the "SR Protocol" tab. Select the access point "CP_H1_1:. Close the configuration program in the lower part of the dialog.

Starting the OPC Scout Carry out steps 1 and 2 in Section 2.4 to start the SR-OPC server for the first time using the OPC Scout. When it is first started, the SR-OPC server enters default values in the text database (see Section 8.6) that make subsequent configuration easier. Close the OPC Scout.

Configuring the OPC Server Start the configuration program for the SR-OPC server and click the "Edit SR Configuration File". The text database for configuring the SR-OPC server is opened with a text editor. In the section "[CP_H1_1: (Connections)], enter the definitions for the required connections using the following notation: (see Section 9.3.2 in this manual) Connection name=LocalTSAP, HostID, RemoteTSAP, ActiveFlag. With this information about the connection, the OPC server can access the configured send or receive buffers on the partner device. Finally, save the text file.

Using the OPC Scout Follow the steps outlined in Section 2.4 for the quick start.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

29

Quick Start

2.1.6 Installing the Send/Receive Protocol for PROFIBUS (FDL)

Requirements

The partner devices are configured on the PROFIBUS network and the required handling blocks or function blocks are called.

30

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Quick Start

Step 1

Procedure Installing the Communications Processor Insert the communications processor as described in the installation instructions for the module. Now start the "Setting the PG/PC Interface configuration program and click the "Install" button. Select the module you want to install.

Assigning an Interface Parameter Set Start the "Setting the PG/PC Interface configuration program. Select the access point of the application (CP_L2_1: ). Assign the interface parameter set corresponding to your module to this access point (for example CP 5611 (PROFIBUS) ).

Testing the Communications Processor Start the "Setting the PG/PC Interface configuration program again. Select the access point of the application used previously ("CP_L2_1:") and click the "Diagnostics" button. Check that the module is functioning correctly.

Configuring the OPC Server Start the configuration program for the server ("OPC Settings). Select the "FDL Protocol" tab. Select the access point "CP_L2_1:. Close the configuration program in the lower part of the dialog.

Starting the OPC Scout Carry out steps 1 and 2 in Section 2.4 to start the FDL-OPC server for the first time using the OPC Scout. When it is first started, the FDL-OPC server enters default values in the text database (see Section 8.7) that make subsequent configuration easier. Close the OPC Scout.

Continuing OPC Server Configuration Start the configuration program for the OPC server and click the "Edit FDL Configuration File" button. The text database for configuring the FDL-OPC server is opened with a text editor. In the section "[CP_L2_1: (Connections)], enter the definitions for the required connections using the following notation: (See Section 8.7 in this manual) Connection name=LocalTSAP, Station, RemoteSAP. With this information about the connection, the OPC server can access the configured send or receive buffers on the partner device. Finally, save the text file.

Using the OPC Scout Follow the steps outlined in Section 2.4 for the quick start.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

31

Quick Start

2.1.7 Commissioning the DP Slave

Step 1

Procedure Installing the Communications Processor Insert the communications processor as described in the installation instructions for the module. Now start the "Setting the PG/PC Interface configuration program and click the "Install" button. Select the module you want to install.

Assigning an Interface Parameter Set Start the "Setting the PG/PC Interface configuration program. Select the access point of the application "DPSONLINE". Assign the interface parameter set for the DP mode corresponding to your module to this access point (for example "CP 5611 (PROFIBUS DP Slave) ).

Testing the Communications Processor Start the "Setting the PG/PC Interface configuration program again. Select the access point of the application "DPSONLINE" and click the "Diagnostics" button. Check that the module is functioning correctly.

Processing the GSD File The configuration of the DP slave is specified in a GSD file (*.gsd). Along with the software for the DP slave, a sample file was also installed. If you want to modify the configuration of the slave, you must adapt this file. For more information on the structure of a GSD file, refer to the "DP Slave Programming Interface for CP 5411, CP 5511 and CP 5611" manual.

Configuring the OPC Server Start the configuration program for the server ("OPC Settings). Select the "DP Slave" tab. Select the access point "DPSONLINE". Now click the "Edit DPS Configuration File" button. The text database for configuring the DP slave OPC server is opened with a text editor. Enter the path and file name of the GSD file of your slave in the section [DPSONLINE]. Finally, save the text file. Close the configuration program.

Using the OPC Scout Follow the steps outlined in Section 2.4 for the quick start.

32

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Quick Start

2.2

Simulation Connections of the OPC Server


The OPC server allows you to use simulated connections for all protocols. This connection with the fixed name "DEMO" simulates a connection to a partner device.

Description

Requirements

The simulation variant of the OPC server for SIMATIC NET can be used without a communications processor. This simulation connection can be activated at any time by the configuration program.


Properties

The simulation connection has the name DEMO. The simulated device provides several variables depending on the particular protocol. You can configure some of the properties of the simulation connection yourself. For further information about configuring properties, refer to Chapter 8

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

33

Quick Start

2.2.1 Working with the Simulation Connection

How the Connection Works

Before you can work with the simulation connection, this must be activated (see below). If you have not installed underlying protocol software, the simulation connection is detected automatically. In this case, the configuration program cannot be started. After activating the simulation connection, a virtual partner station with several variables is available. You can use all the OPC functions with these slaves. The simulation connection can also be started parallel to a real network, as long as the connection name DEMO does not exist in the real network.

Activating the Simulation Connection


Step 1 Procedure

Carry out the following steps to activate the simulation connection of the OPC server for SIMATIC NET.

Close the OPC server If the OPC server for SIMATIC NET is already activated, close this application.

Start the Configuration Program Start the OPC Settings program in the Start menu of Windows (taskbar (Start => SIMATIC => SIMATIC NET => OPC Server => OPC Settings)

Activate the Simulation Connection Change to the tab for the relevant protocol and activate the "Activate simulation connection" check box. When you no longer require the simulation connection, deselect this check box.

34

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Quick Start

2.3

Description of the Quick Start


For the quick start, you use the program OPC Scout to test the OPC server for SIMATIC NET. This OPC client is a powerful Visual Basic application for testing and installing a system.

Introduction

Range of Functions

With the sample program OPC Scout, you can do the following: Investigate the process area of your communications network Generate OPC groups Select and include process variables as items in a group Read and write values

Sample Programs

Once you have got to know the OPC server with the OPC Scout, you can get to know the principles of programming the OPC server using the supplied sample programs for Visual Basic and for C++ in the "SAMPLES" folder. The sample programs are described in the file "EXAMPLE" in the "SAMPLES" folder.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

35

Quick Start

2.4

Using the Quick Start


Follow the steps outlined below to familiarize yourself with the OPC server for SIMATIC NET using the OPC Scout sample program:

Procedure

Step 1

Procedure Starting the OPC Scout Program Now start the "OPC Scout" program (Start => Programs => SIMATIC NET => OPC Server => OPC Scout) Connecting to the OPC Server Select the OPC server in the left-hand box "Servers and Groups using the mouse. For SIMATIC NET (OPC.SimaticNet) Select the "Connect" menu command from the "Server" menu. Reaction: The selected OPC server is started. This can take several seconds.

Creating a Group In the "Add Group dialog, you can enter any name for a group and confirm your entry with OK. Reaction: The name of the newly created group is displayed in the "Servers and Groups box below the selected server.

Investigating the Process Area Select the group you created in the "Servers and Groups box and click the "Add Item" command in the "Group menu. Reaction: In the "OPC Navigator" dialog that appears now, you can investigate the process area of the OPC server. The left column shows the hierarchical structure of the process area. If you double-click an entry, the next level is displayed. The middle column lists the variables available at a level.

Adding OPC Items Select the variables displayed in the middle column. Now click the arrow "=>. The selected variables are displayed in the right column and are therefore selected for inclusion in the current group. Click "OK to insert the variables in the current group. Reaction: The dialog is closed. In the table in the main window, you will see the selected variables and their attributes (for example value, time stamp).

36

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Quick Start

Step 6

Procedure Writing a Value If you have selected a writeable variable (W or RW attribute), you can assign a new value to this process variable. Click the line containing the variable to be modified and click the "Write Values" command in the "Item menu. Enter a new value in the dialog and confirm your entry with "OK. Reaction: The dialog is closed. The table displays the new value and the result of the operation (write result).

Getting to Know the Rest of the Program

You should experiment with the functions of the OPC Scout. Try out the right mouse button when you have selected an object. With many elements, a context-sensitive menu is displayed that illustrates which operations you can perform with the particular object.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

37

Basics of OLE

38

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Basics of OLE

Basics of OLE

The OPC interface uses OLE mechanisms to provide communication services to applications under Windows. To develop applications either with Visual Basic or with C/C++, you must be familiar with the basic architecture of OLE. This chapter provides you with the basic information you require about OLE to allow you to develop OPC programs.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-AA1

39

Basics of OLE

3.1

COM as the Basis for OPC


With OLE 1, it was possible for the first time under Microsoft Windows 3.1 to combine different and basically independent applications with each other. This represented a significant step towards modularization of user software. With the OLE 2 standard used by OPC, Microsoft has not only extended OLE 1 but has also introduced a new far-reaching architecture and has changed the thinking behind the development of software under Microsoft Windows.

Introduction

COM

The basis of all OLE mechanisms is COM, the Component Object Model from Microsoft. COM defines a standard that allows objects to be defined as separate units in Windows and to access these units beyond the limits of a process. Objects can be understood as extensions of the operating system. They are not dependent on programming languages and are available in principle to all applications. The COM component model is a clientserver architecture. The server is the object that provides services. The client is an application that uses the services of an object. Clients are often also known as container applications.

DCOM

With Windows NT, Version 4, the COM specification was extended to allow objects to be accessed outside a local computer. The objects used by an application are distributed within a network. This extension of COM is known as DCOM (Distributed COM).

40

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Basics of OLE

3.2

Objects and Interfaces


OLE objects are units in Windows that provide other objects with defined functions via their interfaces. OLE objects provide their services via defined interfaces. The content of the object, data and code, remains hidden to the object user. OLE objects are defined by their interfaces. The term object in the sense of OLE is not the same as the object definition in object-oriented programming languages. OLE objects, for example, do not support inherit functions.

The Term OLE Object

Structure of an OLE Object

The following diagram illustrates an OLE object with 4 interfaces (as an example). The object is accessed via only one of the interfaces. It is not possible to access the actual object as a whole, nor the data or code it contains. The interfaces hide the methods assigned to them.

M1

M2

M3

M4

Method 1

OLE Object
Data and code

M1

M2

M3

M4

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

41

Basics of OLE

The Term Interface

Objects can have more than one interface and are described completely by their interfaces. The methods (object functions) can only be executed via the interfaces and object data can only be accessed via the interfaces. Objects can be used by more than one application. An interface consists of a table of pointers to the actual functions.

Structure of an Interface

The following diagram illustrates the basic structure of an interface. A pointer to an interface in OLE 2.0 is a pointer to a jump table with function pointers. The caller uses a pointer to the required interface. This in turn contains a pointer to a list of function pointers. These now reference the actual methods in the OLE object.

Caller
Interface pointer

Pointer to list

Function pointer M1 Function pointer M2 Function pointer M3 Function pointer M4 Object data and code

Interface

42

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Basics of OLE

3.3

Standard Representation of Objects in OLE


A graphic representation of OLE objects is usual in OLE documentation. This representation is also used in this manual. The functions supported by an interface are grouped together and only the interface itself is symbolized by a circle with a line. The interface is shown together with the object that it supports. Object-specific interfaces point to the side of the object. The IUnknown interface supplied with all objects is linked to the upper edge of the object.

Description

Representation of an OLE Object

The diagram below clearly shows that an object is defined by its interfaces. The user of an object can only ever obtain access to the object via the interfaces. A pointer to the object itself does not exist.

IUnknown

Interface A Interface B Interface C Interface D

Object X

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

43

Basics of OLE

3.4

Object Control Via the Automation Interface


Automation is an extension of OLE 2 that is based on the COM component model. Automation makes the commands understood by objects visible to the outside using a distributor interface. Originally, the automation interface was intended to control objects, for example the embedding of a graphic in a word processing program using macro languages.

Automation

Access for Script Languages

The interfaces of COM described up to now are less suitable for the range of functions of development tools based on script languages. By extending the OLE objects with a distributor interface, the methods of the objects are accessible for simple script languages. This allows the simple embedding of an OLE object, for example in development environments such as Visual Basic, Delphi or Power Builder. The development tools disguise all details of the object calls. Programmable access to OLE automation servers is defined by properties and methods.

44

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Basics of OPC

Basics of OPC

This chapter explains the concept of OPC. You will see the role of OLE in OPC. The chapter also explains the concept of the OPC interface and the class model on which it is based. The chapter also provides you with more detailed information about the clientserver architecture of OPC.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

45

Basics of OPC

4.1

The Role of OLE in OPC


An OPC server provides a vendor-independent interface. By using the COM component model, the OPC server becomes similar to part of the Windows operating system and is therefore independent of file names, storage locations and versions.

OPC Server as Part of the Operating System

Why OLE?

These characteristics and, not least, the widespread use of Microsoft Windows operating systems prompted the development of a vendorindependent interface based on COM and therefore also on OLE.

Powerful Development Environments

A further advantage of OLE is the possibility of editing the OLE objects in a powerful development environment (Visual Basic, Delphi and others).

46

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Basics of OPC

4.2

The OPC Specifications


The OPC Data Access specification is the fundamental and first specification of the OPC Foundation. The OPC Data Access specification offers functions for management of process variables and various opportunities for access to variables. Variables can be read and written synchronously and asynchronously. OPC Data Access also defines the possibility of sending a message to a client if a variable changes.

Data Access

To use an OPC variable, a client must first register the variable with the OPC server. The client therefore defines the values and the points in time that are of interest to it.

The application gets a "snapshot" of the process values from the point in time at which the read job was executed. Values between these points may not be acquired by the application. When monitoring variables, internal cyclic read jobs are sent.

The source of the process values is not specified by the specification. Any information can be provided by DataAccess. The data source is vendor-specific and effectively defines an OPC server product.

The possible variables of an OPC Data Access server could be control values of a programmable controller, measured values of a data acquisition system, or status variables of the communication system.

Alarms & Events

OPC Alarms & Events is an additional specification for the transfer of process alarms and events. It is basically independent of the Data Access specification.

Events are particular states in the process that need to be signaled to a receiver. All received events are signaled to the applications according to the selected filter criteria.

The OPC Alarms & Events specification makes a distinction between simple events and complex status messages. Status messages can also require confirmation.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

47

Basics of OPC

4.3

The Two Interfaces of OPC


An OLE component provides objects and their methods for other components or applications. These objects are accessed via the OLE interfaces. An interface in the sense of OLE is a group of logically related functions.

OLE Interfaces

Two Types of Interface

The OPC server for SIMATIC NET supports two different types of OLE interface: Automation interface Custom interface Both interfaces are used for the communication between objects. The automation and custom interfaces differ from each other in the way in which the methods of an interface are called internally. This means that there are also two different interface specifications for the OPC server: Interface specification of the automation interface Interface specification of the custom interface

OPC Specification:

Both types of interface are possible in principle for all OPC specifications. Both interface types are available for the basic specification "OPC Data Access". Only the custom interface is available for "OPC Alarms & Events".

Representation of the OPC Server

The following schematic shows an example of the types of applications can by used via which interfaces of the OPC server.

C/C++ application Custom interface OPC server Specific vendor hardware Automation interface

Visual Basic application

48

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Basics of OPC

When is Which Interface Used?

Client applications based on a script language such as Visual Basic or VBA must use the automation interface. Applications in the C/C++ programming language should use the custom interface for maximum performance. It is also possible to use the automation interface in C/C++.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

49

Basics of OPC

4.4

The Class Model of OPC Data Access


The OPC specification for data access groups the interfaces and their methods into three hierarchical classes. This structure is known as a class model. Both the automation and the custom interface of OPC Data Access are based on this class model. The classes are implemented by OLE objects simply called objects in the following text.

Structure

Class Model

The class model consists of three object classes: OPC server OPC group OPC item The following diagram illustrates the OPC class model:

OPC-Server

1:n

OPC-Group

OPC-Item

OPC Server Class

The highest class is the OPC server class. The OPC server class has various attributes that contain information about the status, the version etc. of an OPC server object. The OPC server class also has methods with which the client can manage the objects of the OPC group class. A client application addresses only an object of this class directly using COM mechanisms. The other objects are created by corresponding OPC methods.

50

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Basics of OPC

"OPC Group Class

The OPC Group class manages the individual process variables, the OPC items. Using these group objects, a client can form semantically meaningful units of OPC items and execute operations with them. All the process variables of machine A could, for example, be put in one group and the process variables of machine B in a second group. On the other hand, all the process variables of a screen page of an operator interface system could be put together in one group. When the page is displayed, the group would be activated.

OPC Item Class

An object of the class OPC item represents a link to a process variable, for example to the input module of a programmable controller. A process variable is data of the process I/Os that can be written and/or read, for example the temperature of a tank. An object of the server class can be considered as a container for objects of the OPC group class. An object of the OPC group can be considered as a container for objects of the OPC item class.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

51

Basics of OPC

4.5

The Principle of OPC Alarms & Events


To be able to use the OPC Alarms & Events interface for widely differing sources of events, it has an extremely flexible structure. It can be used for simple event sources that, for example, provide information about the failure of a system component or for complex events requiring status messages and confirmation. Such events are specified using conditions. Example of a condition: The temperature in a process exceeds a defined limit value.

Structure

The OPC specification defines the possible status changes for conditional events in a state diagram. For more detailed information about the state diagram, refer to the OPC specification.

Event Messages

An event is the occurrence of a situation that is of interest to the user. The user is informed of such an event in a message.

Along with the message, the parameters defined by the OPC specification and (where necessary) associated values specified by the vendor are also supplied.

The specification for OPC Alarms & Events defines three types of messages:

Condition-Related Events signal the state changes defined in the OPC state model and are linked to defined conditions Tracking Events signal changes in the process, for example resulting from user intervention. (Example: The user modifies the setpoint of a controller) Simple Events Simple events include all other events. These do not have a state. A typical simple event is the failure of a system component.

52

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Basics of OPC

OPC Event Server 1 1:n OPC Event Subscription 1 0:n OPC Event Area Browser

"OPC Event Server" Class

A client application accesses the objects of the "OPC Event Server" class using COM mechanisms. This means that the application can receive events supplied by the OPC Event server. The most important task of the OPC Event server is to manage the logging on of various clients for events. The OPC Event server also provides information about the supported event categories and parameters.

"OPC Event Subscription" Class

Using the OPC Event server, a client creates one or more OPC Subscription objects. A subscription can be understood as the client subscribing to a group of events. Using the subscriptions, filters and other attributes are managed for the specific client.

"OPC Event Area Browser" Class

OPC Alarms & Events provides the option of structuring large systems into areas. Areas can be used to filter events. The use of the optional object "OPC Event Area Browser" allows the areas to be investigated.

Connection Between Client and Server

The following schematic illustrates the steps taken by an application to log on for receiving messages:

111 Client

1 2 3

OPC Event Server


OPC Event Subscription
Connection Point Container

On Event

Connection Point

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

53

Basics of OPC

Step 1: Step 2:

Using COM mechanisms, the client creates an OPC Event server object. Using the "CreateEventSubscription" method, the client creates an OPC Event Subscription object on the server. When it is created, the subscription object in turn creates a Connection Point Container. The client uses the connection point container to localize the connection point for messages (IID_IOCEventSink). Using an advise, the client logs on its return call object "OnEvent" at this connection point. If an event occurs, the OPC Event server calls the return call object of the client.

Step 3:

Step 4:

54

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Basics of OPC

4.6

Group Operations
The OPC specification supports group operations with various methods for objects of the OPC group class. A group operation means that more than one object can be addressed with a single method call.

Definition

Benefits for the OPC User

It is, for example, possible to read all OPC item objects of a group with a single command by calling the OPC Data Access method Read. In the OPC Alarms & Events specification, all events are transferred by calling the "OnEvent" function. Group operations have the advantage that the number of process changes that occur when methods of a software component are called is kept low. This improves the execution speed of method calls and is particularly advantageous when the software components are located on different computers or in different processes

A further advantage is that in many situations the SIMATIC NET OPC server optimizes the access to OPC item objects in group operations and reduces the load on the network.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

55

Basics of OPC

4.7

The Client-Server Architecture of OPC


Like all OLE implementations, OPC has a client-server architecture. The OPC server provides the OPC clients with interfaces and therefore with defined functionality. The client can create, use and delete objects on the server via these interfaces.

Description

Types of OLE Servers

Depending on the way in which the server is linked, an OLE server can be divided into three types: In-Process Server Local Server Remote Server The calling application does not need to distinguish the type of server it addresses. The syntax of the method calls is the same for all.

In-Process Server

An In-Process Server is in the same process area as the client and is only available for this process. Normally In-Process Servers are implemented as DLLs. Only the OPC automation interface of the OPC server for SIMATIC NET is implemented an In-Process Server that implements the automation interface. The In-Process Server accesses the local server via the OPC custom interface.

Local Server

A Local Server runs on the same computer as the client. Like every independent application, it has its own process and address area. The OPC server for SIMATIC NET is a local server and is implemented as an EXE file.

Remote Server

A Remote Server is located on a different computer but can be accessed by the client via a network connection.

With the implementation, the provider of an OPC server specifies whether the server is an in-process server or a local server. Operation as a remote server must be configured by the user.

56

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Basics of OPC

Access to Components

The following diagram shows which components of the OPC server for SIMATIC NET are accessed by various types of clients:

Visual Basic client

OPC In-Proc server

Automation interface (as DLL)

OPC local server

Custom interface (as EXE) C/C++ client SIMATIC NET OPC Server

Protocol software and hardware linking

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

57

Terminology of the OPC Interface Description

4.8

Terminology of the OPC Interface Description

This chapter explains certain terms used in the description of the interfaces. For a complete description of the OPC terminology, refer to the OPC specifications located as files in the DOC directory of the OPC server for SIMATIC NET. Where this is useful, special features of the OPC server for SIMATIC NET are pointed out in this chapter.

58

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Terminology of the OPC Interface Description

Structure of the List

The terms are sorted alphabetically. For each turn, you can also see which environment the turn belongs to: OLE, OPC Data Access, OPC Alarms & Events (A&E) or Windows (see Figure Page 13).

Special Features of the OPC Server from SIMATIC NET

Notes relating to the characteristics of the OPC server for SIMATIC NET are enclosed in a box like this and should be read carefully.

OLE, OPC and Windows Terminology


Active State (OPC Data Access) Apart from the possibility of reading or writing the values of a process variable, an OPC server also allows process variables to be monitored. Monitoring means that the server checks whether the value of the process variable has changed after a time interval (see monitoring interval) has elapsed. If the value has changed, the new value is sent automatically to the client. The client can control the monitoring of a process variable by setting the active state. Each group and each OPC item object has the active state attribute. If a client wants to monitor a process variable, it sets the active state of the OPC item that represents the link to this process variable to TRUE. The active status of the group must also have the value TRUE . If a group is not active, there is no monitoring of the process variables in this group.

Alarm (OPC A&E) Area (OPC A&E)

An alarm is an event triggered by a condition that no longer describes the normal state. For this reason, alarms are not given special handling since they are a special form of a condition. Using areas, an OPC Event server can divide up the production plant being monitored. The details and configuration of this division is up to the vendor of the server. The implementation of the area concept is optional. The OPC Event server for SIMATIC NET does not support the concept of areas.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

59

Terminology of the OPC Interface Description

Cache (OPC Data Access)

The cache is a buffer for all variables that are referenced via OPC items. The cache is global for all users. This means that if more than one user references the same variable, this is stored only once in the cache. Read operations (read or refresh) can read the data from the server cache with the option OPC_DS_CACHE. The SIMATIC NET OPC Server manages a cache.

Categories (OPC A&E)

Using categories, the events supported by an OPC Event server can be grouped and therefore selected. The definition of the categories is left up to the vendor of an OPC Event server; the OPC specification defines a list of recommended event categories. The categories supported by the OPC Event server for SIMATIC NET are listed in Section 6.2.

Condition (OPC A&E)

A condition is a defined state of the OPC Event server. Conditions can include subconditions. Example: A condition of the "Level" variable is the level alarm with the subconditions HighAlarm, HighHighAlarm, LowAlarm and LowLowAlarm. The OPC Event server for SIMATIC NET does not support conditions and subconditions.

Enumerator (Windows) Events (OPC A&E)

Using an enumerator, it is possible to run through a collection of objects. An event is an occurrence that could be of interest to the client. Although events can be generated by the occurrence of a condition, they do not need to be linked to conditions. Example of events that are not linked to conditions, are for example error messages from the communication system. The OPC Item ID is a string that identifies the process variable uniquely. The syntax of the ID depends on the server. The OPC item ID informs the server unequivocally which process variable is assigned to the OPC item. The value of the OPC item ID for the OPC server for SIMATIC NET depends on the protocol. Section 5 describes the structure of the OPC item ID for the OPC server for SIMATIC NET.

OPC Item-ID (OPC Data Access)

60

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Terminology of the OPC Interface Description

LCID (Windows)

Abbreviation for Local ID. The LCID provides information about the regional setting selected by the user for the Windows operating system. This information affects the way in which certain regional information is displayed. You can query the LCID using a Windows API call. The OPC server for SIMATIC NET displays error texts either in German or in English.

OPCHANDLE (OPC)

OPCHANDLEs are used for groups and OPC items. They allow fast access to the various objects both for clients and for the server. The value of a handle depends on the particular implementation. Clients cannot make any assumptions about the range of values. In the same way, servers cannot make assumptions regarding client handles. Server OPCHANDLEs are only valid during the existence of an OPC server object. It is therefore not possible to save them and use them again after starting a client. A server group handle is always unique within a server. An OPC item group handle is unique within a group. Client handles must be used for asynchronous operations since they are returned in the callback as an OPC item identification.

REFIID (Windows)

REFIID is a reference or pointer to an interface ID ( IID). An interface ID is a unique key for an interface; with OPC for example interface "IOPCItemMgt". To obtain a pointer to a particular interface, the IID of the required interface must be specified as the parameter.

Requested Data Type (OPC Data Access)

By specifying the requested data type, a user can determine the data type of a variable. If the data type is not specified explicitly by the user, the variable has the canonical data type. The OPC specification specifies the conversion only for scalar types. The OPC server for SIMATIC NET can also convert all data types (including arrays) to VT_BSTR. Time bias specifies the difference between the UTC time and the local time zone. This takes into account the possibility that an OPC server and OPC client can be distributed in a world-wide network.

Time Bias (OPC)

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

61

Terminology of the OPC Interface Description

UpdateRate (OPC Data Access)

The monitoring interval UpdateRate specifies the interval at which the server checks whether the value of an OPC item has changed when it is monitoring this item (see Active State). The update rate is an attribute of a group object. The user can set an update rate for each group. The value 0 requests the fastest permitted UpdateRate. If the required rate is not supported, the server sends back an alternative rate (RevisedUpdateRate) as close as possible to the required rate.

VARIANT (Windows)

A VARIANT is a special data type that is used primarily in OLE automation. A variable of the type VARIANT can represent values of various variable types and the special values Empty, Error and Null.

Canonical Data Type (OPC Data Access) Access Path (OPC Data Access)

The canonical data type means the original data type of a variable, as represented internally and supplied by the OPC server.

The access path contains optional information for objects of the OPC Item class. The need for an access path and its interpretation depends on the particular server. When it is required, the access path indicates the path to be used by the server when reading or writing the data of a process variable. The access path can, for example be a path or connection name. The value for the access path for the OPC Server for SIMATIC NET depends on the protocol. Chapter 5 describes the structure of the access path for the OPC server for SIMATIC NET.

62

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Structure of the OPC Items for the SIMATIC NET Data Access Interface

The OPC Server for SIMATIC NET provides standardized access to the SIMATIC NET industrial communications networks via the OPC interface. This provides the OPC user with an open, comprehensive, and coordinated system for communication in automation engineering. This chapter explains how the vendor-specific characteristics of SIMATIC NET communication networks are put to good use due to the structure of the names of OPC variables.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

63

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.1

General Information
The only class in OPC that creates a reference to a real variable from the process is the OPC Item class. An object of the OPC Item class represents a process variable. The properties of an OPC item that are transferred to the created object with the AddItem call describe which variable is to be addressed. The OPC specification contains no information about how the parameters should be structured. This information depends on the server and the connected communication system.

OPC Item Represents Process Variable

Description

To describe the syntax, the following notation is used: Conventions (not part of actual syntax) Pointed brackets ( < > ) Braces ( { } ) Meaning Texts in pointed brackets are mandatory Texts in braces are optional

Square brackets ( [ ] ) are part of the syntax and must be included.

ItemID Parameter

The ItemID parameter contains all the information necessary to identify a process variable. This involves a string with the following structure: <Protocol ID>:[<Connection name>]<Variable name> Example 1: Example 2: Example 3: Example 4: Example 5: Example 6: DP:[CP_L2_1:]Slave005M00AW00 S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:]EB0 FMS:[FMS_CON|VFD_OPC|CP_L2_1:]&vfdstate() SR:[SROPC_1||CP_H1_1:]Motor FDL:[SROPC_1||CP_H1_1:]Motor DPS:[DPSONLINE]Motor

64

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Protocol ID

The protocol ID specifies the protocol to be used when accessing the process variable. This information is absolutely necessary. The protocol ID can be specified as an alternative with the connection name in the AccessPath parameter.

The following protocol IDs apply to the available protocols: DP S7 FMS SR FDL DPS DP master class 1 (incl. DP-C1) S7 functions via PROFIBUS and Ethernet FMS protocol via PROFIBUS S5-compatible communication via Ethernet ("Send/Receive") S5-compatible communication via PROFIBUS DP slave (cyclic services)

Connection Name

The connection name identifies the connection or communication access via which the partner (DP slave or PLC) can be reached. The connection name must be unique within a protocol. This information depends on the selected protocol. The connection name can also be included in the AccessPath parameter.

Variable Name

The variable name specifies the variable to be addressed and must be unique for the specified connection. The format of this parameter also depends on the protocol. If the protocol ID and connection name are specified in the AccessPath parameter, the ItemID parameter only contains the variable name.

AccessPath Parameter

The AccessPath is optional information. The protocol ID and connection name can be entered in the AccessPath parameter for the OPC server for SIMATIC NET. If the AccessPath parameter is used, it is a string with the following structure: <Protocol ID>:[<Connection name>]

Please note that in this case the information specified above must not be part of the "ItemID" parameter.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

65

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.2

DP Protocol

5.2.1 Specifications for the DP Protocol

Master and Slaves

The DP for PROFIBUS protocol also specifies multi-master operation. Generally (to improve performance) it is used in single-master systems. For the OPC server for SIMATIC NET, the DP master is a PC with the appropriate communications processor, for example CP 5412 (A2). A master addresses slaves cyclically via the fieldbus. Slaves are generally input/output modules located in a distributed configuration and equipped with a passive communications module.

Properties of the DP-OPC Server

The DP-OPC server from SIMATIC NET has the following characteristics: Variable services DPC1 services Diagnostic evaluation access and monitoring of DP inputs and outputs acyclic transfer of data fields automatic evaluation of static diagnostics

Protocol ID

The protocol ID for the DP protocol is always DP.

Connection Name

For the DP protocol, the connection name specifies the communication access by specifying the communications processor that communicates with the slaves as the DP master. The connection name for the DP protocol is as follows: CP_L2_x: Example: CP_L2_1: x = 1, 2, 3 or 4

Access to DP Variables

Access to a DP variable (an I/O area of a slave) is achieved by specifying the slave number (PROFIBUS address), the module number and the I/O area. DP slaves have a modular structure. A DP slave can have more than one module with different I/O areas. The modules are assigned during configuration.

66

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.2.2 Syntax of Variable Names for DP

Overview

The variable name identifies the input or output area in the module of a slave. Status information of the slaves and the DP master is also available using variable names. To describe the syntax, the following notation is used: Conventions (not part of actual syntax) Pointed brackets ( < > ) Braces ( { } ) Meaning Texts in pointed brackets are mandatory Texts in braces are optional

Syntax

The syntax of the slave inputs and outputs is defined as follows (upper and lower case irrelevant): Inputs: Slave<address>M<number>E<format><element>{.bit}{,quantity} Outputs: Slave<address>M<number>A<format><element>{.bit}{,quantity}

Description of the Parameters

The individual parameters have the following meaning:

<address>

PROFIBUS address of the slave. Range 0 to 126

<number>

Number of the module containing the input or output area

{format}

The "format" element specifies the format in which the data are supplied. Specifying the format also specifies the data type. In principle, all specified OLE data types can be read via the automation interface of OPC. However, certain development tools (for example Visual Basic) only offer a restricted number of data types. The following table therefore lists the corresponding Visual Basic type in which the variable value can be represented.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

67

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Format ID X BYTE or B CHAR WORD or W INT DWORD or D DINT REAL BK WK

Description Bit Byte (unsigned 8) Character (signed 8) Word (unsigned 16) Integer (signed 16) Double word (unsigned 32) Double integer (signed 32) Floating-point number (IEEE 4 bytes) Consistent data as an array of bytes (unsigned 8) Consistent data as an array of words (unsigned 16)

OLE Data Type VT_BOOL VT_UI1 VT_I1 VT_UI2 VT_I2 VT_UI4 VT_I4 VT_R4 VT_ARRAY of VT_UI1 VT_ARRAY of VT_UI2

VB Type Boolean Byte Integer Long Integer Double Long Single Byte() * Long() *

* Default setting in Visual Basic BSTR <element{.bit}> Number of the element to be accessed (not possible for BK and WK). The byte address of an element is decided by the data type. Example: B2 supplies a byte starting at byte address 2, W2 ,on the other hand, supplies a word starting at word address 2, corresponding to byte address 4! Specification of a bit is only permitted for type X. The address to be specified is a byte address. Example: X2.3 means the 3rd bit of the 2nd byte.

{,quantity}

Number of elements (not possible for BK, WK and X). The data type of the variable is an array with elements (data type VT_ARRAY) of the specified format. If this part of the name is omitted, the quantity 1 is assumed and the data type of the variable is not an array.

68

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Syntax Examples

Several examples of syntax are listed below to illustrate the above definition. Do not forget, that you must always precede the variable with the protocol ID and the module identifier (for example "DP:[CP_L2_1:]" )!
Example of Syntax Slave005M003EB0 Slave005M003EB1,3 Slave005M003ED0 Slave005M007AB1 Slave005M007AX2.5 Slave004M007EBK Slave004M003AWK Slave004M003IReal0 Description Input byte 0 of module 3 of slave 5 Array with 3 bytes starting at input byte 1 Double word starting at input byte 0 Output byte 1 of module 7 Bit 5 in output byte 2 of slave 5, module 7 All input data of module 7 of slave 4 as byte array All output data of module 3 of slave 4 as array of data type word The input area of slave 4, module 3 as floating-point number

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

69

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.2.3 Syntax of Variable Names for DPC1 Access

General

The DPC1 protocol allows access to memory areas of the DPC1 slave. The meaning of this memory area is specified by the vendor of the slave. Memory areas can, for example, be used for configuration data. When a DPC1 variable is logged on, the OPC server only check the correctness of the syntax but not whether the variable is valid on the partner device based on the configuration of the DPC1 slave.

Syntax

With access to DPC1 variables, the variable names are formed with the following syntax: Slave<address>M<slot> DPC1,{format}<index>{,quantity}

Description of the Parameters

The individual parameters have the following meaning:

<address>

PROFIBUS address of the slave. Range 0 to 126

<slot>

Slot of the slave, typically a module

{format}

The "format" element specifies the format in which the data are supplied. If no format is specified, the "byte" format is used.

Format ID BYTE or B CHAR WORD or W INT DWORD or D DINT REAL

Description Byte (unsigned 8) Character (signed 8) Word (unsigned 16) Integer (signed 16) Double word (unsigned 32) Double integer (signed 32) Floating-point number

OLE Data Type VT_UI1 VT_I1 VT_UI2 VT_I2 VT_UI4 VT_I4 VT_R4

VB Type Byte Integer Long Integer Double Long Single

<index>

Index of the data on the slave

70

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

{,quantity}

Number of elements. The data type of the variable is an array with elements (data type VT_ARRAY) of the specified format. If this part of the name is omitted, the quantity 1 is assumed and the data type of the variable is not an array.

The data length specified by the parameters <format> and {,quantity} must match the real data length on the slave. This depends on the slave and cannot be checked by the OPC server.

Syntax Examples

It is assumed that the slave supports DPC1 data with a length of 4 bytes in slot 3 with index 7.

Example 1: Slave005M003DPC1,DWORD7 1 double word = 4 bytes Example 2: Slave005M003DPC1,B7,4 4 bytes

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

71

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.2.4 DP-Specific Information Variables

Introduction

In DP, the OPC server for SIMATIC NET has variables available for diagnostic purposes with which information about the DP master and the connected DP slaves can be queried. The name of the information variable must be specified in the parameter ItemID of an OPC item. The following information can be obtained: DP master mode Event messages of the DP master Sign of life monitoring of the CP Mode of a DP slave DP slave type Other information

DP Master Mode

Using the MasterState information variable, you can query and set the current mode of the DP master. It is only possible to set the mode dependent on the DP application environment. The following table describes the possible values (data type VT_BSTR, in Visual Basic: String): Return Value OFFLINE STOP CLEAR OPERATE Description No communication between master and slave No communication between master and slave except for diagnostic data Parameter assignment and configuration phase Productive phase

Event Messages of the DP Master

Using the information variables EvAutoclear, EvWatchdog and EvClass2Master, unexpected events (system events) can be queried during operation. The following table describes the possible values (data type VT_BOOL, in Visual Basic: Boolean):

72

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Return Value True False

Description Event occurred Event did not occur

For further information on these events, refer to the "DP Programming Interface" manual.

Sign of Life Monitoring of the CP

Using the WatchdogTimeout information variable, the sign of life monitoring can be set on the CP: The following table describes the possible values (data type VT_UI4, in Visual Basic: Double): Return Value 0 400-102000 6000 Description Monitoring off Any value in ms. The value is rounded to a multiple of 400 Default

Mode of a DP Slave

Using the SlaveXXXSlvState information variable, the current mode of the DP slave with number XXX can be queried. The following table describes the possible values (data type VT_BSTR, in Visual Basic: String): Return Value OFFLINE NOT_ACTIVE READY READY_DIAG NOT_READY NOT_READY_DIAG Description No communication between master and slave DP slave is not activated DP slave is in the data transfer phase DP slave is in the data transfer phase; diagnostic data also exist DP slave is not in the data transfer phase DP slave is not in the data transfer phase; diagnostic data also exist

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

73

Structure of the OPC Items for the SIMATIC NET Data Access Interface

DP Slave Type

With the SlaveXXXMiscSlvType information variable, the type of the DP slave with number XXX can be queried. The following table describes the possible values (data type VT_BSTR, in Visual Basic: String): Return Value NO_SLV NORM ET200_U ET200K_B ET200_SPM UNDEFINED Description No DP slave Standard DP slave Non-standard slave: ET 200 U Non-standard slave: ET 200 K/B Non-standard slave: General SPM station Unknown DP slave

74

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

SlaveXXXAllInputs

The AllInputs variable supplies all input bytes of a slave as an array of bytes (data type VT_ARRAY of VT_UI1), in Visual Basic: Byte() ). The inputs of non-standard slaves can be read using this variable. The AllOutputs variable supplies all output bytes of a slave as an array of bytes (data type VT_ARRAY of VT_UI1), in Visual Basic: Byte() ). The outputs of non-standard slaves can be set using this variable. The following information variables are not intended for productive operation. If problems occur, it may, nevertheless, be useful to evaluate the variables listed below. All variables are generally assigned directly to low level DP services. These variables are read in the same way as other information variables. The result of the call is the byte dump of the particular low level DP service. For more information about evaluating the result, refer to the manual describing the DP interface. The following variables are supported by the OPC server for SIMATIC NET for DP: Information Variable Name MiscReadBusPar MiscReadCfg MiscReadSysInfo MiscDpnRoleCentral MiscDpnSysCentral MiscOnTriggerWatchdog Meaning Bus parameters Types of all slaves State of all slaves Central role for this application (1,0) Central application logged on (1,0) Value is incremented by 1 each time the watchdog timer is triggered Configuration data User data Add-Tab list Parameter assignment data SI flag, type, octet string Diagnostic data

SlaveXXXAllOutputs

Other Information

SlaveXXXMiscReadSlvParCFGData SlaveXXXMiscReadSlvParUserData SlaveXXXMiscReadSlvParAddTab SlaveXXXMiscReadSlvParPrmData SlaveXXXMiscReadSlvParTyp SlaveXXXMiscSlvDiag

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

75

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.3

S7 Protocol

5.3.1 Specifications for the S7 Protocol

Communication with S7 Components of SIMATIC

The S7 for PROFIBUS and Industrial Ethernet protocol was specially developed for communication between S7 system components and between S7 system components and programming devices and PCs. This is a layer 7 communication protocol according to the ISO/OSI reference model. The OPC server for SIMATIC NET requires underlying S7 protocol software from SIMATIC NET and a suitable communications processor. Before starting S7 communication, an S7 database must be created. Suitable configuration tools are shipped with the protocol software.

Properties of the S7-OPC Server

The S7-OPC server from SIMATIC NET has the following characteristics: Variable services Field-oriented services S7 messages Server functionality access and monitoring of S7 variables program-controlled transfer of larger fields of data processing of S7 messages (S7 scans) In field-oriented services, the PC can also be used as server. Transfer of a loadable data area from and to S7 Setting a password to access protected domains Processing of S7 messages (S7 scans, S7 alarms) as OPC Alarms & Events

Domain services S7 password functions Events

76

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Establishing Connections

The S7 protocol is a connection-oriented transport protocol. A connection-oriented protocol provides a virtual channel for the user. Communication consists of the following: Logon Connection establishment Data exchange Connection termination Logoff The management of connections is handled by the OPC server for SIMATIC NET automatically and is not visible for the OPC user. When an OPC item is accessed or as a result of browsing, the OPC server establishes the connection to the partner device, as necessary. The connection name must be specified in the ItemID or in the AccessPath of the OPC item and must be configured in the S7 database.

Protocol ID

The protocol ID for the S7 protocol is always S7.

Connection Name

The connection name consists of three parts: The configured name of the S7 connection The configured local VFD, at which the OPC server will log on The name of the communications processor or the access point of the application These parts are separated by the | character. The name of the S7 connections and the VFDs are specified during configuration. If only one CP/VFD pair is selected, the information on the access point and VFD can be omitted. The name of the communications processor or the access point of the application is specified by configuration tools of the protocol software. Typical names are: "CP_L2_1: "CP_H1_1:" "S7ONLINE

Examples of Connection Names

Three examples of connection names are listed below: My_connection|My_VFD|CP_L2_1: S7-OPC_conn|VFD1_OPC|CP_H1_1: PLC_314_conn|VFD2|S7ONLINE

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

77

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.3.2 Syntax of Variable Names for S7 (Variable Services)

Overview

The variable name identifies the variable to be accessed on the programmable controller. The type of access is based on the notation of the S7 tools. Objects supported on the S7 OPC server are as follows: Data blocks (DB) Inputs (E) Outputs (A) Peripheral inputs (PE) Peripheral outputs (PA) Memory bits (M) Timers (T) Counters (Z) Note that not all object types are supported by every S7 programmable controller.

Syntax

The syntax is defined as follows (upper and lower case irrelevant): DB<no>,<type><byte address>{,<quantity>} DI<no>,<type><byte address>{,<quantity>} <object><type><byte address>{,<quantity>} To describe the syntax, the following notation is used: Conventions (not part of actual syntax) Pointed brackets ( < > ) Braces ( { } ) Meaning Texts in pointed brackets are mandatory Texts in braces are optional or or

78

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Description of the Parameters


Parameter DB or DI <no> <object>

The individual parameters have the following meaning:

Description Data or instance data block Number of the data or instance data block The following objects exist: Object A Z E M PA PE T Description Outputs Counters Inputs Memory bits Peripheral outputs Peripheral inputs Timers

{type}

If you specify "type" the S7 data type is specified. This is converted to the corresponding OLE data type in the OPC server for SIMATIC NET. S7 Data Types X B W D CHAR INT DINT REAL STRING Description Bit (bool), bit number must be specified Byte (unsigned) Word (unsigned) Double word (unsigned) Character (signed) Word (signed) Double word (signed) Floating point Character string, character string length must be specified OLE Data Type VT_BOOL VT_UI1 VT_UI2 VT_UI4 VT_I1 VT_I2 VT_I4 VT_R4 VT_BSTR VB Type Boolean Byte Long Double Integer Integer Long Single String

<byte address> {quantity}

<Byte number>, for example MD5 or <byte number>.<bit> for example, EX1.1 or <byte number>.<string length>, for example DB10,STRING4.20 Number of variables of a type to be addressed starting at the address specified in the "byte address" parameter. It is not possible to specify a quantity for data type X.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

79

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Syntax Examples

Several examples of syntax are listed below to illustrate the above definition. Do not forget that you must always precede the variable with the protocol ID and the connection!
Example of Syntax DB5,X12.1 DB5,B12 DB5,W10 EX1.1 EB0 MB9,3 DB5,W10,9 DB5,STRING7.30 Description Data block 5, data byte 12, bit 1 Data block 5, data byte 12 Data block 5, data word starting at address 10 Input bit 1 in byte 1 Input byte 0 3 memory bytes starting at memory byte 9 Data block 5, 9 words starting at address 10 Data block 5, string with maximum 30 characters (= 32 bytes incl. length prefix) from

address 7

80

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.3.3 Syntax of Variable Names for Field-Oriented Services

Overview

With the field-oriented services for the S7 protocol, the OPC server provides the following advantages: Transfer of larger amounts of data The transfer can be triggered by the SIMATIC S7 PLC

For data exchange between a SIMATIC S7 PLC and PG/PC, the connection must be configured at both ends. In contrast to the nonfield-oriented services, the connection configuration created with STEP 7 NETPRO must be downloaded to the PLC. In the field-oriented services, a pair of blocks BSEND and BRCV are always required. Either there is a BSEND block on the SIMATIC S7 PLC that communicates with a BRCV variable of the OPC server (PLC sends to OPC server) or a BRCV block is programmed on the SIMATIC S7 PLC that receives data from the BSEND variable of the OPC server. The amount of data that can be transferred in this way is up to 65534 bytes, regardless of the size of the CPU. The segmentation of the data is handled by the function itself. Syntax Block Receive The syntax for variables that can receive fields of data is defined as follows: (the part in braces is optional) BRCV,<RID>{,<type><byte address>{,<quantity>}} Syntax Block Send The syntax for variables with which data fields can be transferred from the PG/PC to the partner is as follows: BSEND<length>,<RID>{,<type><byte address>{,<quantity>}} BRCV A BRCV variable contains the last data field received from the partner. The structure and length of the received data are specified by the sending partner. For this reason, the data field is transferred as default in the data type "VT_ARRAY | VT_UI1" (byte array). The variable can only be read. There is no practical value in monitoring this variable. The reception of a data field by the OPC server is reported to a client application. A BSEND variable contains a field of data to be sent to a partner device. The buffer is only transferred to the partner when the variable itself or a subvariable is written. The value of the send variable that is read is the last value entered in the send buffer. The data are not read from the partner device. By default, the variable has the data type "VT_ARRAY | VT_UI1" (byte array) with the specified length. Appending the length information to the variable name "BSEND" specifies the length of the send buffer.

BSEND

Length

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

81

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Addressing Parameter RID

The addressing parameter R_ID is fixed for a block pair (BSEND/ BRCV) and is specified uniquely within a connection. This means that several BSEND blocks can send on one connection but always with their own R_ID. The same R_IDs can be used on other connections. To support the structuring of the received data field, one or more sections of the data field can be selected and assigned to individual variables. When accessing data blocks, a defined notation can be used. Since the length of a received field is unknown, it is also permissible to define variables outside the received field. If variables are not filled out or are filled out only partly by the received data field, the quality of the item changes to "BAD". If a subvariable is written, the complete buffer is always transferred to the partner device. When writing with structured access, subvariables should always be created on a send field in an OPC group. To prevent the transfer of uninitialized areas, the subvariables should always cover the entire send field and all items of a group should be written at the same time.

Structured Access

{type}

If you specify "type" the S7 data type is specified. This is converted to the corresponding OLE data type in the OPC server for SIMATIC NET. S7 Data Types X B W D CHAR INT DINT REAL Description Bit (bool), bit number must be specified Byte (unsigned) Word (unsigned) Double word (unsigned) Byte (signed) Word (signed) Double word (signed) Floating point OLE Data Type VT_BOOL VT_UI1 VT_UI2 VT_UI4 VT_I1 VT_I2 VT_I4 VT_R4 VB Type Boolean Byte Long Double Integer Integer Long Single

<byte address>

Address in bytes within the send or receive data field, <byte number>, for example DWORD5 or <byte number>,<bit>, for example X1.1. The address starts at 0. Number of variables of a type to be addressed starting at the address specified in the <byte address> parameter. It is not possible to specify a quantity for data type X.

{quantity}

82

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Syntax Examples

Several examples of syntax are listed below to illustrate the above definition. Do not forget that you must always precede the variable with the protocol ID and the connection!
Example of Syntax BRCV,1 BRCV,1,X1.1 BRCV,1,B2,4 BRCV,1,W2,4 BSEND16,1,D2 BSEND32,1,CHAR2,4 BSEND32,1,DINT2,8 BSEND32,1,REAL2,2 Description Entire receive buffer with the R_ID 1 Bit 1 in byte 1 of the receive buffer with R_ID 1 4 bytes from byte 2 in the receive buffer with R_ID 2 4 words (unsigned 16) from byte 2 in the receive buffer with R_ID 1 Double word (unsigned 32) starting at byte 2 in send buffer with R_ID 1 with size 16 4 characters (signed 8) starting at byte 2 in send buffer with R_ID 1 with size 32 8 Double words (unsigned 32) starting at byte 2 in send buffer with R_ID 1 with size 32 2 floating-point (real) numbers starting at byte 2 in send buffer with R_ID 1 with size 32

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

83

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.3.4 Syntax of Variable Names for Messages

Overview

S7-400 controllers allow automatic monitoring of bits and the transfer of a message to a communications partner if the monitored data change. Along with the event message, up to 10 associated values can be transferred depending on the S7-CPU. The OPC server provides the received message information and the associated values as variables. With the possibility of monitoring variables, user programs can be informed of the occurrence of messages. The use of messages has the following advantages: No bus load from cyclic polling of variables; load only when a change has really occurred Transfer of additional information with the message

Configuring

S7 messages must be configured with STEP 7 and downloaded to the S7 controller. For information on configuring, refer to the STEP 7 documentation.

Message Data

When an S7 message is received, a data record is transferred to the OPC server containing the following information: Event state Acknowledgment state Number of additional values Associated values (0 to 10)

For each associated value, information about the data type and the length of the data record is also available.

84

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Syntax of Message Variables

The message data can be accessed via the following OPC items:
Syntax scan,<EvID>,eventstate Description State of the bit to be monitored. Data type VT_UI2, VB type long Bit Description Current state of the event 1 to 15 scan,<EvID>,state irrelevant

General message state, data type VT_UI2, VB type long Value 0x00 0x81 Meaning OK No message

scan,<EvID>,ackstate

Acknowledgment state, message could be acknowledged via a different system, the acknowledgment state is shown here. Data type VT_UI2, VB type long Important note: The OPC server does not provide any means of acknowledging these messages, however, other "display devices" could do this. Bit 0 8 Meaning Acknowledgment of messages (entered state) Acknowledgment of messages (left state)

Explanation of the term entered state/left state with messages: Message entered state: e.g. limit value exceeded Message left state: scan,<EvID>,noaddvalue e.g. limit value no longer violated

Number of associated values supplied with this message. Data type VT_UI2, VB type long Time the message was received by the OPC server. All message variables contain the value generated by the S7 controller as the time stamp. This variable allows the clocks of the S7 controller and the PC to be compared. Data type VT_DATE (VB type date)

scan,<EvID>,pctime

<EvID>

Normalized message number assigned for this message during configuration with STEP 7.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

85

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Syntax of Associated Values

Access is possible to the associated values via the following OPC items:
Syntax scan,<EvID>,data<N>,datatype Description Data type of the nth associated value. Data type VT_UI2, (VB type long) Possible values are as follows: Value Meaning 0 3 4 5 6 scan,<EvID>,data<N>,value Error in associated value acquisition Boolean Bit string Integer Octet string

Value of the nth associated value. Data type VT_Array with the possible types VT_BOOL, VT_I2, VT_I4, VT_UI1, VT_ERROR (VB types Boolean, integer, long, byte, error). If a single value is transferred, the array has only one entry. Length of the nth additional value in bytes. Data type VT_UI2, (VB type long) Value of the nth additional value in a preset data type. Alternate access is also possible. The S7 syntax is described, for example in Section 7.3.3.

scan,<EvID>,data<N>,valuelen scan,<EvID>,data<N>{,S7 syntax}

<N>

The name part <N> specifies the associated value to be accessed. The permitted range is from 0-9. When a message is received, only the associated values are updated that were actually transferred with the message. The "quality" of the associated values not supplied with the message is set to "bad". The number of associated values supplied with a message is provided by the variable "scan,<EvID>, noaddvalue".

86

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Syntax Examples

Several examples of syntax are listed below to illustrate the above definition for messages. Do not forget that you must always precede the variable with the protocol ID and the connection!
Example of Syntax scan,1,eventstate scan,2,ackstate scan,3,Noaddvalue scan,4,pctime scan,1,data0 scan,1,data0,value Description State of the monitored bit for message 1 Acknowledgment state for message 2 Number of associated values that arrived with the last message for ID 3 Time stamp of the arrival of message 4 Value of the associated value 0 of the message 1, represented as a byte array Value of the associated value 0 of the message 1, represented as an array with a data type corresponding to the associated value Value of the 9th associated value of the message 1, represented as DWORD (starting at byte address 0 of the data buffer) Value of the 8th associated value of the message 1, bit 1 of the byte address 0 is evaluated and represented as Boolean Length of the data buffer supplied as associated value 7 for message 1 S7 data type of the associated value 7 for message 1

scan,1,data9,dword0

scan,1,data8,X0.1

scan,1,data7,valuelen scan,1,data7,datatype

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

87

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.3.5 Information Variables Specific to S7

Introduction

For monitoring purposes, the OPC server for SIMATIC NET provides variables for S7 with which information about the S7 communication and the established connections can be queried. The name of the information variable must be specified in the parameter ItemID of an OPC item. The following information can be obtained: Attributes of a virtual device (VMD/VFD) Status of an S7 connection Status of a virtual device Status of the logon for messages

Attributes of a Virtual Device

A virtual device (VFD - virtual field device) is the model of a real device. The &Identify() information variable provides information about the vendor attributes of a device. The type of the information variable &Identify() is a VT_ARRAY of VT_BSTR (VB type string) and contains 3 components: <vendor> <model> <revision> Example The item "S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:]&identify()" supplies the following information as an array with 3 VT_BSTR via "VFD1_OPC": {"SIEMENS AG"|GES7413-1AE0-0AB0"|"V1.0"}

88

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Status of a Virtual Device

The &vfdstate() information variable is used to query the status of a device. The status value (type VT_ARRAY of VT_VARIANT, VB type string with 3 components) consists of a logical status (type VT_BSTR) physical status (type VT_BSTR) and detailed information about the local VFD status (type VT_ARRAY of VT_BSTR).

The parts of the &vfdstate() information variables can have the following values: Logical Status The logical status indicates which services are supported:
Return Value S7_STATE_CHANGES_ALLOWED Description All services are permitted.

Physical Status The physical status indicates the operating status of the real device.
Return Value S7_OPERATIONAL S7_NEEDS_COMMISSIONING Description The real device is operational. The real device is only operational after local settings have been made.

Detailed local status The detailed local status as an octet string with the structure "hh.hh.hh" where h = 0..f provides detailed about the local VFD status. The description of the local VFD must be used to interpret this value.

Example The item "S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:]&vfdstate()", represented as VT_BSTR, returns the following value: {"S7_STATE_CHANGES_ALLOWED"|"S7_OPERATIONAL"|"02.00.00 "}

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

89

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Connection Status

The "&statepath()" and "&statepathval()" information variables provide the state of a communication connection to a partner device. While the variable &statepath (type VT_BSTR, VB type string) represents the result as a string, &statepathval provides a number (type VT_UI1, VB type byte). The possible values of the information variables &statepath and &statepathval are as follows:
Return Value &statepath() DOWN UP RECOVERY ESTABLISH Return Value &statepathval() 1 2 3 4 Description Connection is not established Connection is established Connection being established (Reserved for future expansions)

Example The Item "S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:] &statepath()" could, for example, provide the following: "RECOVERY"

State of the Logon for Messages

The "&stateevent() information variable provides the status of the logon for the message services. While the variable &stateevent represents the result as a string, &stateeventval returns a number (type VT_UI1, VB type byte).

The possible values of the information variable &stateevent() (type VT_BSTR, VB type string) are as follows:
Return Value &stateevent()

Return Value &stateevent val()


0 1 2 3 4

Description

NONE ESTABLISH_SCAN SCAN ESTABLISH_ALARM ALARM

No logon for message services Logon for ALARM message services active SCAN message services are logged on Logon for alarm services active ALARM message services are logged on

90

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Example The Item "S7:[OPC_1|VFD1_OPC|CP_L2_1:]&stateevent()" could, for example, provide the following: "SCAN"

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

91

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.3.6 Special Variables for Domain and Password Services

Introduction

A domain represents a loadable data area on a programmable controller. In SIMATIC systems these are the following loadable blocks: Organization blocks (OB), Function blocks (FB), Functions (FC), Data blocks (DB).

A block transferred to a programmable controller is stored in a buffer. This means that the block is not yet available for an S7 program. Although the block is visible in the list of data blocks that can be viewed using the online functions of STEP 7, the block cannot be opened. This is first possible after the block has linked into the list of active blocks. Available Services Using special variables of the S7-OPC server, the following services are available for handling loadable areas: Application Downloading blocks from the PC to the programmable controller. Uploading blocks from a programmable controller to the PC. Deleting, linking blocks and compressing memory of the programmable controller.

The domain services allow the transfer and retransfer of data and program elements between the PC and programmable controller. On the PC, the loadable areas are saved in files. To allow a program element to be transferred to the programmable controller, it must first be downloaded from the programmable controller to the PC. It is only possible to create blocks with STEP 7. For example, to change the algorithms of a function block running on a programmable controller from an operator control and monitoring station, the algorithms could be stored in different variants of a function block. The function block is swapped over during operation using the domain services controlled from an operator station to obtain a different program function on the programmable controller. The various variants of the function block must be generated when the system is created and stored in different files.

Password Services

Write and read access to the CPU can be made dependent on the knowledge of a password. The priority of the password is higher than that of the keyswitch of the CPU. With the password service, a password can be transferred to a programmable controller as legitimization.

92

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Read block

With the special variable &blockread(), a block can be transferred from a programmable controller to a file on the PC. This variable can only be written. Writing a value triggers the transfer service. The written value contains the parameter assignment of the service. It is represented as an array of variant with the following elements: Flags Block File

Element Data Type Description Flags String One of the following hexadecimal numbers: 0x0040 Reads a linked block, if a destination file already exists, this is not overwritten (error message) 0x1001 Reads an unlinked block, an existing block is overwritten. 0x1040 Reads a linked block, an existing block is overwritten. Block String Block type and number. The following types are possible: OB, DB, FC and FB. Example: DB10 Full path of the file in which the block will be stored.

File

String

Example To read the OB1 block in a file "c:\temp\ob1.blk", the item "S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:]&blockread()" must be written with the following value: {0x0040|OB1|c:\temp\ob1.blk}

(To be able to specify the value as in this example, the type "string" must be requested as the "requested data type". This string is converted to the canonical data type by the OPC server.)

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

93

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Write block

With the special variable &blockwrite(), a block can be transferred from a PC to a programmable controller. This variable can only be written. Writing a value triggers the transfer service. The written value contains the parameter assignment of the service. It is represented as an array of variant with the following elements: Flags File

Element Data Type Description Flags String One of the following hexadecimal numbers: 0x0000 An unlinked block with the same name already on the programmable controller is not overwritten. File String Full path of the file in which the block is stored.

Example To send the block in file "c:\temp\ob1.blk" to the programmable controller, the item "S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:]&blockwrite()" must be written with the following value: {0x0000|c:\temp\ob1.blk}

(To be able to specify the value as in this example, the type "string" must be requested as the "requested data type". This string is converted to the canonical data type by the OPC server.)

Note

Link in block

After transfer to the programmable controller, the block is not yet active. It must first be linked into the list of active blocks by using the special variable &blocklinkin(). Using the special variable &blocklinkin(), a block can be linked in from the passive state into the active program of the programmable controller. The block is then available for the active program. Remember that by linking in a block, an existing active block is overwritten without an error message. This variable can only be written. Writing a value triggers the service. The value written specifies the block to be linked as the parameter for this service. Element Data Type Description Block String Block type and number. The following types are possible: OB, DB, FC and FB. Example: DB10

94

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Example To link block DB1 in the program execution of the programmable controller, the item "S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:]&blocklinkin()" must be written with the following value: DB1

Delete block

Using the special variable &blockdelete(), a block can be deleted on the programmable controller. Both the passive blocks and those linked into the program can be removed. This variable can only be written. Writing a value triggers the service. The written value contains the parameter assignment of the service. It is represented as an array of variant with the following elements: Flags Block

Element Data Type Description Flags String One of the following hexadecimal numbers: 0x0001 Deletes the unlinked block 0x0040 Deletes the linked block 0x0041 Deletes the linked and unlinked block Block String Block type and number. The following types are possible: OB, DB, FC and FB. Example: DB10

Example To delete the linked block DB1, the item "S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:]&blockdelete()" must be written with the following value: {0x0040|DB1}

Compress

Using the special variable &blockcompress(), the memory on the programmable controller can be compressed. Fragmented memory areas are shifted together and space created for the transfer of new blocks. This variable can only be written. Writing an empty string triggers the service. Example To compress memory, the item "S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:]&blockcompress()" must be written with an empty string ("").

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

95

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Transfer password

Using the special variable &password(), the password for a connection can be sent to legitimize and cancel the level of protection. For an S7 programmable controller, three levels protection can be activated for the domain services using the configuration tool STEP 7: Protection due to setting of the keyswitch Write protection Write and read protection By transferring the correct password, all the protection levels listed above are canceled for the connection on which the password was sent. By sending an empty string as password, the protection function is activated again on the connection. On bilaterally configured connections, all services can be executed even in the RUN key position.

Connections configured at one end

Resulting active protection level

Protection Password was not level transferred configured by Keyswitch setting STEP 7 RUN RUN-P STOP Keyswitch RUN - can be canceled by password Keyswitch RUN - cannot be canceled by password Write protection with password Write/read protection with password Legend: Resulting active protection level 2 1

Correct password was transferred Keyswitch setting RUN RUN-P STOP 1 1

3/3

3/3

1: No restriction (read, write, link, delete block, and compress possible). 2: Read block only 3: No block function allowed.

96

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

The &password() variable can only be written. Writing a variable triggers transfer of the password. The data type of the variable is string. The password can be transferred in the following representations Representation Description Octet string A string with the hexadecimal codes of the characters of the password (maximum 8 characters), separated by a period Example 31.32.33.34.35.36.37.38

String

Any alphanumeric &12345678 string with a maximum length of 8 characters preceded by the character "&".

OPC Error Codes

If the following error codes occur in conjunction with passwords, they have the following significance: The OPC server returns the error code OPC_E_BADRIGHTS when an invalid password was sent. Otherwise, the error code OPC_E_COMMUNICATION is returned. Further error codes are also possible.

Example To send the password "SetMeFre" to a programmable controller, the variable "S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:]&password()" must be written with the following value: &SetMeFre

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

97

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.4

FMS Protocol

5.4.1 Specifications for the FMS Protocol

Open Communication with FMS

The FMS for PROFIBUS protocol is an open layer 7 communications protocol based on the ISO/OSI reference model. With FMS, communication at the fieldbus level is possible not only with S5 and S7 programmable controllers from Siemens but also with all other devices that meet the FMS standard. The FMS-OPC server of SIMATIC NET requires an underlying FMS protocol software from SIMATIC NET and a suitable communications processor. Before starting FMS communication, an FMS database must be created. Suitable configuration tools are shipped with the protocol software.

Characteristics of the FMS-OPC Server

The FMS-OPC server from SIMATIC NET has the following characteristics: Automatic analysis of the configuration Reading and writing of FMS variables FMS server functionality Support of arrays and structures, including alternate access Support of connections via which no object dictionary (OD), a short OD or long OD can be downloaded. Support of the FMS services Identify and VfdState Support of the SAPI service Lifelist Display and monitoring of the connection state Browsing of the local variables and variables on the server

98

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Establishing Connections

The FMS protocol is a connection-oriented communication protocol. A connection-oriented protocol provides a virtual channel for the user. The normal sequence of communication is as follows: Logon Connection establishment Load object dictionaries Data exchange Connection termination Logoff The management of connections is handled by the OPC server for SIMATIC NET automatically and is not visible for the OPC user. When an OPC item is accessed or as a result of browsing, the OPC server establishes the connection to the partner device, as necessary. The connection name must be specified in the ItemID or in the AccessPath of the OPC item and configured in the FMS database.

Protocol ID Connection Name

The protocol ID for the FMS protocol is always "FMS. The connection name consists of three parts: The configured name of the FMS connection The configured local VFD, at which the OPC server will log on The name of the communications processor or the access point of the application These parts are separated by the | character. You specify the names of the FMS connections and the VFDs during configuration. If an element of the connection name in the configuration is unique, it can be omitted. If, for example, you have only configured the access point "CP_L2_1: with one VFD_OPC, it is adequate to specify only the FMS connection. The name of the communications processor or the access point of the application is specified by configuration tools of the protocol software. Typical names are: "CP_L2_1: "CP_L2_2:

Examples of Connection Names

Three examples of connection names are listed below: Simocode|VFD_OPC|CP_L2_1: S5_5431|VFD1_S5|CP_L2_2: Connection|VFD1|access

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

99

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.4.2 Syntax of Variable Names for FMS

Function

The variable name identifies the variable to be accessed on the partner device. FMS variables are accessed using the names that exist in the object dictionary of the partner device. If the partner device provides a short object dictionary, it is only possible to access variables using indexes. If a long object dictionary is provided, the symbolic names contained in the object dictionary can also be used.

Syntax of the Variable Names

The syntax of a variable is defined as follows, upper and lower case characters are irrelevant: <index> <symbolic name> For alternate access to structure elements, the syntax is defined as follows: <index>:<subindex> <symbolic name>:<subindex> or or

Syntax Examples

Several examples of syntax with the connection component are listed below to illustrate the above definition.
Example of Syntax FMS:[DEMO]100 FMS:[DEMO]Valve_In FMS:[CR1|VFD1|CP_L2_1:] 200 FMS:[CR1|VFD1|CP_L2_1:] Count FMS:[CR1|VFD1|CP_L2_1:] 200:2 Description Variable with Index 100 of the Demo connection Variable with the name "Valve_In" of the demo connection Variable with Index 200 of the connection CR1 via VFD1 to module CP_L2_1: "Count" variable of the connection CR1 via VFD1 to the module CP_L2_1: Access to 2 structure elements of the variable with index 200

100

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

FMS Types

The following table describes the FMS data types and the corresponding VARIANT data types. Canonical VB Type OLE data type VT_UI1 VT_UI2 VT_UI4 VT_I1 VT_I2 VT_I4 VT_R4 VT_BOOL VT_BSTR VT_BSTR Byte Long Double Integer Integer Long Single Boolean String String Meaning
unsigned char (1 byte) unsigned short (2 bytes) unsigned long (4 bytes) signed char (1 byte) signed short (2 Byte) signed long (4 bytes) real (4 bytes) signed short (True = -1; False = 0) Visible String, X: Number of characters Bit string, X: Number of bits, structure: "b.b.b.b.b.b" where b=0 or 1 Octet string, X: Number of octets, structure: "hh.hh.hh.hh.hh" where h=0..f time of day date time difference

FMS data type unsigned8 unsigned16 unsigned32 integer8 integer16 integer32 float boolean vstringX bstringX

ostringX

VT_BSTR

String

time_of_day date time_difference data type[N]

VT_DATE VT_DATE VT_DATE VT_ARRAY of element type VT_ARRAY of VT_VARIANT

Date Date Date

Array of the VB FMS array as a safearray with N elements of the type element type. elementary * type Array with elements of the respective elementary types
FMS structure with 4 different data types Type1..Type4. *

{Type1|Type2|Type3|Ty pe4}

* Default setting VT_BSTR

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

101

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.4.3 Information Variables Specific to FMS

Introduction

The OPC server for FMS provides variables for with which information about the FMS communication system and the connection states can be queried. The name of the information variable must be specified in the parameter ItemID of an OPC item. The following information can be obtained: Attributes of a virtual device (VMD/VFD) Status of a virtual device Status of an FMS connection Station addresses of the obtainable nodes (LifeList)

Attributes of a Virtual Device

A virtual device (VFD - virtual field device) is the model of a real device. The &Identify() information variable provides information about the vendor attributes of a device. Type of the information variable &Identify() is a VT_ARRAY of VT_BSTR (VB type: string array ) and contains 3 components: <Hersteller> <Modell> <Revision> Example The item "FMS:[FMS_CON|VFD1_OPC|CP_L2_1:]&identify()" supplies the following information as an array with 3 VT_BSTR via "VFD1_OPC": "SIEMENS AG" "ET 200U-DP/FMS" "V1.0"

102

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Status of a Virtual Device

The &vfdstate() information variable is used to query the status of a device. The status value (type VT_ARRAY of VT_VARIANT, VB type: array with 3 string elements) consists of a logical status (type VT_BSTR) physical status (type VT_BSTR) and detailed information about the local VFD status (type VT_BSTR, formatted).

The parts of the &vfdstate() information variables can have the following values: Logical Status The logical status indicates which services are supported:
Return Value FMS_STATE_CHANGES_ALLOWED FMS_LIMITED_SERVICES_PERMITTED Description All services are permitted. Only the services Status virtual device and Identify virtual device are permitted Loading an object dictionary is not permitted. An object dictionary is currently being loaded on the interface module.

FMS_OD_LOADING_NON_INTERACTING

FMS_OD_LOADING_INTERACTING

Physical Status The physical status indicates the operating status of the real device.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

103

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Return Value FMS_OPERATIONAL FMS_PARTIALLY_OPERATIONAL

Description The real device is operational. The real device is operational with certain restrictions. The real device is only operational after local settings have been made. The real device is not operational.

FMS_NEEDS_COMMISSIONING

FMS_INOPERABLE

Detailed local status The detailed local status as an octet string with the structure "hh.hh.hh" where h = 0..f provides detailed about the local VFD status. The description of the local VFD must be used to interpret this value.

Example The item "FMS:[FMS_CON|VFD1_OPC|CP_L2_1:]&vfdstate()", represented as VT_BSTR, returns the following value: {"FMS_STATE_CHANGES_ALLOWED"|"FMS_OPERATIONAL"|"00.00 .00"} Connection Status The "&statepath()" and "&statepathval()" information variables provide the state of a communication connection to a partner device. While the variable &statepath (type VT_BSTR, VB type string) represents the result as a string, &statepathval provides a number (type VT_UI1, VB type byte). The possible values of the information variables &statepath and &statepathval are as follows:
Return Value &statepath() DOWN UP RECOVERY ESTABLISH Return Value &statepathval() 1 2 3 4 Description Connection is not established Connection is established Connection has broken down Connection being established

Example 1 The item "FMS:[FMS_CON|VFD1_OPC|CP_L2_1:]&statepath() could, for example, provide the following: "UP"

104

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Example 2 The item "FMS:[FMS_CON|VFD1_OPC|CP_L2_1:]&statepathval() could, for example, provide the following: 2 (corresponds to "UP"):

Lifelist

The "&lifelist() information variable provides information about the nodes available on the bus. The value of these variables is provided as VT_ARRAY of VT_UI1 (VB type: array with 127 elements of the type byte). The array with its 127 elements includes information about every possible station address. Each station address is assigned an index of the array. Possible values for one entry are as follows:
Return Value FMS_STATION_NONEXISTENT FMS_STATION_PASSIVE FMS_STATION_READY_FOR_RING FMS_STATION_ACTIVE Description No node exists (value 0) Passive node (value 1) Node ready for entry in the token ring of PROFIBUS (value 2) Active node (value 3)

Example The item "FMS:[FMS_CON|VFD1_OPC|CP_L2_1:]&lifelist()", represented as VT_BSTR, might return the following value: {0|1|0|0|1|0|0|1|0|2|1|0|1|0|1|0|3|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|2|0| 1|2|0|0|0|0|0|0|0|1|1|1|0|1|1|0|1|0|1|0|1|0|1|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|3 |0|0|0|0|0|0|0|0|0|1|0|1|0|1|0|1|0|1|0|0|1|0|0|1|0|0|1|0|0|1|0|1|3|0|3|0|1|0| 3|1|0|0|3|0|3|0|3|0|0|0|0|0|0|0|0|0}

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

105

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.4.4 FMS Server Connection

Introduction

The FMS-OPC server can itself operate as a server in the sense of the FMS protocol. As an FMS server, it provides variables and an object dictionary that other FMS partner devices can access. In this way, FMS communication between PCs can be established. A server connection is implicitly assigned to every CP/VFD pair of an FMS configuration. The variables of this server connection that can access other FMS partner devices must be described in a configuration file. For details of configuring a server connection, refer to Section 8.5.5.

Uses

Please note the following: So that an FMS server is available, the OPC server on this computer must be started by using an OPC clients (for example OPC Scout). The variable stipulated in the server connection are available via the OPC interface as OPC items in the same way as the variables of another device. If a server variable is written via the OPC interface, the value of the variable is only changed locally. This new value is transferred to the querying device the next time an FMS client queries the value. Reading a server variable via OPC returns the current, local value. This value can be modified by write access from an FMS client. Changes to values made by an FMS client are reported to an OPC client using the OPC mechanisms for reporting value changes.

Diagram

The following diagram illustrates how an FMS partner device can access variables defined on the OPC server. Access to FMS variables Local access PC with OPC server Text data base

Partner device

OD

FMS server

FMS client

PROFIBUS network

106

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.5

Send/Receive Protocol via Industrial Ethernet

5.5.1 Specifications for the Send/Receive Protocol

Communication via Industrial Ethernet

The Send/Receive (SR) protocol for Industrial Ethernet is a layer 4 transport protocol according to the ISO/OSI reference model standardized for SIMATIC devices. With Send/Receive, communication is possible via Industrial Ethernet to S5 and S7 programmable controllers from Siemens and to PCs on which the SR protocol is installed. The SR-OPC server of SIMATIC NET requires an underlying SR protocol software from SIMATIC NET and a suitable communications processor. The SR protocol software is part of the S7 products of SIMATIC NET.

Principle of Communication

The SR protocol communicates with handling or function blocks that are running on a programmable controller. The following block types or job types are available: SEND (without WRITE function) SEND (with WRITE function only SIMATIC S5) RECEIVE FETCH (SIMATIC S5 only) With SEND and RECEIVE, the data exchange is between the SEND block and the RECEIVE block. The SEND block always initiates communication. For bi-directional communication, both a SEND and a RECEIVE block must be called at both ends. If FETCH is selected as the job type (corresponds to the READ function in S5), source parameters can be provided with a send job that are used by the S5 communications processor to read and read back data directly from the CPU. With this type of job, direct access to objects such as inputs, outputs, data blocks, memory bits (flags) and counters is possible. For more detailed information about the Send/Receive interface, refer to the manual "Send/Receive Programming Interface and the documentation of the programmable controller.

Configuring

The configuration of Send/Receive communication is not created using an additional configuration program on the PC. The communication parameters must be configured in a text file used by the SR-OPC server. A SIMATIC S5 partner device handles communication using handling blocks (HDBs). The handling blocks must be called in the S5 program.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

107

Structure of the OPC Items for the SIMATIC NET Data Access Interface

For communication via a SIMATIC S7 PLC, the function blocks FC5 (SEND) and FC6 (RECEIVE) must be called in the S7 program. In addition to the use of the handling or function blocks, a suitable connection configuration of the communications processor of the programmable controller is necessary. Characteristics of the SR-OPC Server The SR-OPC server of SIMATIC NET has the following characteristics: Communication via SIMATIC S5 handling blocks and S7 function blocks Support of the services "SEND with WRITE function" and "FETCH (S5 only) Support of the "Expedited Data service (S5 only) Fast access to large data packets Definition of variables within a data packet Display and monitoring of the connection state Functionality for browsing defined variables Protocol ID The protocol ID for the Send/Receive protocol is always "SR.

108

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Connection Name

The connection configuration for the Send/Receive protocol is not created as with the other protocols in a database assigned to the CP and written with special configuration tools, but must be created specifically for each user program. The SR-OPC server uses a text file for connection configuration in which the connections and variables to be used by the OPC server are entered by the user. A symbolic name is declared for each connection that must also be used in the designations of the OPC items. For further information about the structure of the text file, refer to Section 8.6. The connection name consists of the following parts: The symbolic name of the connection as specified in the text file The connection parameters for this connection The name of the communications processor or the access point of the application These parts are separated by the | character. The symbolic name or the connection parameters are used as alternatives. The pipe character to separate them must always be specified.

Connection Parameters

The information for the connection parameters is made up as follows: <LocalTSAP>,<HostID>,<RemoteTSAP>,<ActiveFlag> Name of the local TSAP. Two notations are possible: 1) Hexadecimal notation: xx.xx.xx.xx.xx.xx.xx.xx Maximum 8, two digit, hexadecimal values separated by periods. 2) String notation: &TTTTTTTT Leading & character followed by a maximum 8 printable characters. The comma must not be used. If you want the TSAP to contain nonprintable characters, the comma or the pipe character, use the hexadecimal notation.

LocalTSAP

HostID

Ethernet or TCP/IP address of the partner station. Depending on the network type, two different notations are distinguished: 1) Ethernet address: xx.xx.xx.xx.xx.xx Exactly 6 2-digit hexadecimal numbers, separated by periods 2) TCP/IP address: yyy.yyy.yyy.yyy e.g. 142.011.045.197 Exactly 4 3-digit decimal values, separated by periods

RemoteTSAP

TSAP of the partner station. The notation is the same as for the LocalTSAP parameter

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

109

Structure of the OPC Items for the SIMATIC NET Data Access Interface

ActiveFlag

Controls the connection establishment. Possible values: 0 Passive connection establishment, the partner establishes the connection. Active connection establishment, the partner waits for connection establishment.

Access Point

The name of the communications processor or the access point of the application is specified by the configuration tools of the protocol software. Typical names are: "CP_H1_1:" "CP_H1_2: "S7ONLINE

Examples of Connection Names

Examples of connection names are listed below: |&PC4711,142.011.045.197,&RECVS5,0|CP_H1_1: (Passive connection establishment, TCP/IP via access CP_H1_1:) |65.ff.43.ff,08.00.06.01.26.70,&SENDSEEX,1|S7ONLINE Active connection establishment, ISO protocol via S7ONLINE access, alternative notation of the TSAP MyConnection||CP_H1_1: Use of a symbolic name "MyConnection from the text file via access point CP_H1_1:

110

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.5.2 Syntax of Variable Names for SR

Function

The variable name identifies the variable to be accessed on the partner device. SR variables are accessed using fixed names or aliases corresponding to the job types. If this is supported by the partner device, direct access to the address area is possible. This functionality is currently only available for S5 programmable controllers and is identified by the job types FETCH and WRITE in the S5 connection configuration.

Variable Names

The following variable names are specified for each connection: RECEIVE receiveexp send sendexp

receive / receiveexp

The complete syntax for the variables for reading out the receive buffer is as follows: receive{,validvariablesyntax} receivexp{, validvariablesyntax} The "receive variable contains the last data buffer received from the partner. The structure and length of the data buffer is not fixed. The buffer is therefore always supplied as an array of bytes (data type VT_ARRAY|VT_UI1, VB type: array with elements of the type byte). The "receiveexp variable contains the last, high priority data buffer received from the partner. Analogous to the "receive function, the buffer is an array of bytes, its length is, however, restricted to 16 bytes. High-priority data buffers are not supported by all partner devices!

Since these variables correspond to a receive buffer, they can only be read. If the device is to be read ("DEVICE), an explicit receive request block is sent to the protocol. It is therefore advisable to simply monitor these variables or to read them from the cache.

Valid Variable Syntax

To support the user when structuring the data to be received, specific sections of the buffer can be selected. The following syntax is mandatory for describing the variables: Receive{,}<type><byte address>{,quantity} Receiveexp{,}<type><byte address>{,quantity}

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

111

Structure of the OPC Items for the SIMATIC NET Data Access Interface

<type>

With "type", you specify the data type. This is converted to the corresponding OLE data type in the OPC server for SIMATIC NET.
Data Types X Description Bit (Boolean) Only for objects I,Q,M,P and OY (read only) and Send / Receive! Byte (unsigned 8) Byte (signed8) Word (unsigned 16) Word (signed16) Double word (unsigned 32) Double word (signed32) Floating-point, IEEE representation Floating-point, S5 representation OLE Data Type VT_BOOL VB Type Boolean

B or BYTE CHAR W or WORD INT D or DWORD DINT REAL S5REAL

VT_UI1 VT_I1 VT_UI2 VT_I2 VT_UI4 VT_I4 VT_R4 VT_R4

Byte Integer Long Integer Double Long Single Single

<byte address>

Byte address of the variables in the range: <byte number>, e.g. 5 For the bit data type, the requested bit is addressed by <byte number>.<bit number>. (e.g.: 3.3)

{quantity}

Number of variables of a type to be addressed starting at the address specified in the "byte address" parameter. Bit arrays are not supported. For the data type X (Boolean), the specification of a number is omitted or it must be 1.

Syntax Examples

Several examples of syntax are listed below to illustrate the above definition:
Example of Syntax receive,w0,6 receive,dword7 receiveexp,REAL0,2 Description 6 data words from byte 0 in the receive buffer A double word starting at byte 7 Two real values from byte 0 onwards in the high-priority receive buffer.

112

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Send / sendexp

The complete syntax for the variables for writing the send buffer is as follows: send{n}{,validvariablesyntax} sendexp{n}{, validvariablesyntax} The "send variable contains a permanently available send buffer that can be transferred to the connection partner. A default value is specified for the size of the send buffer by the "LenSend entry in the configuration file. The buffer is always supplied as an array of bytes (data type VT_ARRAY|VT_UI1, VB type: array with elements of the type byte). Alternatively, the size can also be set using the n parameter in the variable name. The "sendexp variable contains the permanently existing, high priority send buffer. Analogous to the "send function, the buffer is an array of bytes, its length is, however, restricted to 16 bytes. The value of the send variable that is read is the last value entered in the send buffer. The data are not read from the partner device.

Write access to these and derived variables cause the send buffer to be transferred to the partner.

These variables and variables derived from them cannot be read. They must therefore be neither read nor activated. Read access to these variables may well be responded to by the partner terminating the connection.

Valid Variable Syntax

To support the user when structuring the data to be sent, specific sections of the buffer can be selected. The following syntax is mandatory for describing the variables: send{n}{,}<type><byte address>{,quantity} sendexp{n}{,}<type><byte address>{,quantity} The notation of the variable syntax corresponds to the syntax for the receive buffer.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

113

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Syntax Examples

Several examples of syntax are listed below to illustrate the above definition.
Example of Syntax send30,dword7 send,B20 SendExp8,DINT0 Description A double word starting at byte 7 in a 30-byte long send buffer An array with 20 bytes in a send buffer with the default size A signed double word starting at byte address 0 in the high-priority send buffer

Direct Access (S5 only)

Apart from communication using fixed send and receive buffers, the SR-OPC server also supports direct access to the address area of the CPU of the partner device. The sender transfers the required address information to the receiver and this then returns the requested data. The notation of the variable names for direct access is as follows: <area>{,}<type><byte address>{,quantity}

<area>

The area specifies which object will be accessed. Possible values are as follows:
Obtainable Objects DBnn A E M PAE Z T BS AS DXnn Denn QB Description Data block no. nn Outputs Inputs Memory bits Peripheral inputs Counters Timers System area Absolute start address Extended data block Data block in the external memory Extended I/Os

<type> <address>

The notation for the type corresponds to the syntax or the receive buffer. The address of the variables in the range. Please note the following: Depending on the area, the address specified is either a byte or word address. When accessing the following areas, the specified address is interpreted as a word address: DBnn, BS, AS, DXnn, DEnn, C, T

114

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

{quantity}

Number of variables of a type to be addressed starting at the address specified in the "Address" parameter.

Please note the following:

The configuration of the partner device must be consistent. Depending on the configuration of the partner device, access to certain areas will lead to communication errors. The SR-OPC server can only check the syntax when a variable logs on. Based on the configuration of the partner, it is not possible to determine whether the variable is valid on the partner device.

Syntax Examples

Several examples of syntax are listed below to illustrate the above definition:
Example of Syntax eb2 DB10,real6,2 Z12 Description Input byte 2 2 floating-point values starting at data word (!) 6 in data block 10 Counter 12

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

115

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.5.3 Information Variables Specific to SR

Introduction

The OPC server for Send/Receive provides variables for with which information the connection states can be queried. The name of the information variable must be specified in the parameter ItemID of an OPC item. The following information can be obtained: Status of a connection Versions of the Protocol Software The "&statepath()" and "&statepathval()" information variables provide the state of a communication connection to a partner device. While the variable &statepath (type VT_BSTR, VB type string) represents the result as a string, &statepathval provides a number (type VT_UI1, VB type byte). The possible values of the information variables &statepath and &statepathval are as follows:
Return Value &statepath() DOWN UP RECOVERY ESTABLISH Return Value &statepathval() 1 2 3 4 Description Connection is not established Connection is established Connection has broken down (Reserved for future expansions)

Connection Status

Example 1 The item "SR:[SR_CONNECTION||CP_H1_1:]&statepath()" supplies for example the following: "UP"

Example 2 The item "SR:[SR_CONNECTION||CP_H1_1:]&statepathval()" could, for example, supply the following: 2 (corresponds to "UP"):

116

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.6

Send/Receive Protocol via PROFIBUS (FDL)

5.6.1 Specifications for the Send/Receive Protocol via PROFIBUS (FDL)

Communication via PROFIBUS

The Send/Receive protocol for PROFIBUS (FDL) is a simple, frameoriented protocol for SIMATIC devices. It uses the services of the Fieldbus Data Link (FDL), of layer 2 of the ISO/OSI reference model in PROFIBUS. With Send/Receive, communication is possible via PROFIBUS to S5 and S7 programmable controllers from Siemens and to PCs on which the FDL protocol is available. The FDL-OPC server of SIMATIC NET requires an underlying FDL protocol software from SIMATIC NET and a suitable communications processor. The FDL protocol software is part of the DP products of SIMATIC NET.

FDL is used

Although the Send/Receive OPC server for PROFIBUS is called the FDL-OPC server below, it uses only the services of the FDL protocol for convenient access to communication data. Please note that the entire functionality of the FDL layer cannot be mapped to the OPC server. The FDL protocol communicates with handling or function blocks that are running on a programmable controller. The following block types or job types are available: SEND (without WRITE function) RECEIVE With SEND and RECEIVE, the data exchange is between the SEND block and the RECEIVE block. The SEND block always initiates communication. For bi-directional communication, both a SEND and a RECEIVE block must be called at both ends. For more detailed information about the Send/Receive interface, refer to the manual "FDL Programming Interface and the documentation of the programmable controller.

Principle of Communication

Configuring

The configuration of Send/Receive communication is not created using an additional configuration program on the PC. The communication parameters must be configured in a text file used by the FDL-OPC server. A SIMATIC S5 partner device handles communication using handling blocks (HDBs). The handling blocks must be called in the S5 program.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

117

Structure of the OPC Items for the SIMATIC NET Data Access Interface

For communication via a SIMATIC S7 PLC, the function blocks FC5 (SEND) and FC6 (RECEIVE) must be called in the S7 program. In addition to the use of the handling or function blocks, a suitable connection configuration of the communications processor of the programmable controller is necessary. Properties of the FDL-OPC Server The FDL-OPC server of SIMATIC NET has the following characteristics: Communication via SIMATIC S5 handling blocks and S7 function blocks Fast access to large data packets Definition of variables within a data packet Display and monitoring of the connection state Functionality for browsing defined variables Protocol ID The protocol ID for the FDL protocol is always FDL.

118

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Connection Name

The FDL-OPC server uses a text file for connection configuration in which the connections and variables to be used by the OPC server are entered by the user. A symbolic name is declared for each connection that must also be used in the designations of the OPC items. For further information about the structure of the text file, refer to Section 8.7. The connection name consists of the following parts: The symbolic name of the connection as specified in the text file The connection parameters for this connection The name of the communications processor or the access point of the application These parts are separated by the | character. The symbolic name or the connection parameters are used as alternatives. The pipe character to separate them must always be specified.

Connection Parameters

The information for the connection parameters is made up as follows: <LocalSAP>,<RemoteStation>,<RemoteSAP> Name of the local SAP activated for communication: Decimal number in the range from 0 to 62 and 255 (for default SAP).

LocalSAP

RemoteStation

PROFIBUS address of the partner station: Decimal number in the range from 0 to 126 or 127 for muliticast/broadcast

RemoteSAP

Name of the SAP of the partner station to which the frames are sent: Decimal number in the range 0 to 63

Access Point

The name of the communications processor or the access point of the application is specified by the configuration tools of the protocol software. Typical names are: "CP_L2_1: "CP_L2_2:

Examples of Connection Names

Examples of connection names are listed below: |15,7,15|CP_L2_1: (Communication with station address 7 from SAP 15 to SAP 15 via access "CP_L2_1:") MyConnection||CP_L2_1: Use of a symbolic name "MyConnection from the text file via access point CP_L2_1:

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

119

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.6.2 Syntax of Variable Names for FDL

Function

The variable name identifies the variable to be accessed on the partner device. Variables are accessed using fixed names or aliases corresponding to the job types.

Variable Names

The following variable names are specified for each connection: Receive Send SendSDA SendSDN

(access to receive buffer) (send a buffer) (send a buffer using SDA service) (send a buffer using SDN service)

Receive

The complete syntax for the variables for reading out the receive buffer is as follows: receive{,validvariablesyntax} The "receive variable contains the last data buffer received from the partner. The structure and length of the data buffer is not fixed. The buffer is therefore always supplied as an array of bytes (data type VT_ARRAY|VT_UI1, VB type: array with elements of the type byte). Since these variables correspond to a receive buffer, they can only be read. It is therefore advisable to simply monitor these variables or to read them from the cache.

Valid Variable Syntax

To support the user when structuring the data to be received, specific sections of the buffer can be selected. The following syntax is mandatory for describing the variables: Receive{,}<type><byte address>{,quantity}

120

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

<type>

With "type", you specify the data type. This is converted to the corresponding OLE data type in the OPC server for SIMATIC NET.
Data Types X B or BYTE CHAR W or WORD INT D or DWORD DINT REAL S5REAL Description Bit (Boolean) Byte (unsigned 8) Byte (signed8) Word (unsigned 16) Word (signed16) Double word (unsigned 32) Double word (signed32) Floating-point, IEEE representation Floating-point, S5 representation OLE Data Type VT_BOOL VT_UI1 VT_I1 VT_UI2 VT_I2 VT_UI4 VT_I4 VT_R4 VT_R4 VB Type Boolean Byte Integer Long Integer Double Long Single Single

<byte address>

Byte address of the variables in the range: <byte number>, e.g. B5 For the bit data type, the requested bit is addressed by <byte number>.<bit number>. (e.g.: AX3.3)

{quantity}

Number of variables of a type to be addressed starting at the address specified in the "byte address" parameter. Bit arrays are not supported. For the data type X (Boolean), the specification of a number is omitted or it must be 1.

Syntax Examples

Several examples of syntax are listed below to illustrate the above definition:
Example of Syntax receive,w0,6 receive,dword7 Receive,REAL0,2 Description 6 data words from byte 0 in the receive buffer A double word starting at byte 7 Two real values from byte 0 onwards in the high-priority receive buffer.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

121

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Send

The complete syntax for the variables for writing the send buffer is as follows: send{n}{,validvariablesyntax} The "send variable contains a permanently available send buffer that can be transferred to the connection partner. A default value is specified for the size of the send buffer by the "LenSendSDA" or "LenSendSDN" entry in the configuration file. The buffer is always supplied as an array of bytes (data type VT_ARRAY|VT_UI1, VB type: array with elements of the type byte). Alternatively, the size can also be set using the n parameter in the variable name. Write access to these and derived variables cause the send buffer to be transferred to the partner. The value of the send variable that is read is the last value entered in the send buffer. The data are not read from the partner device. These variables and variables derived from them cannot be read. They must therefore be neither read nor activated.

Send Services Used

Depending on the combination of the station address and the SAPs specified in the connection part, a special FDL service is used when writing a send item: LocalSAP Remote Station 0 to 126 Remote SAP 0 to 62, 255 63 Meaning/Service Used for "Send" Send and receive/SDA

0 to 62, 255 0 to 62, 255 63

0 to 126

Send only/SDA

0 to 126

0 to 62, 255 63

Receive only (no send)

0 to 62, 255 63

127

Broadcast: Only send to all/SDN Receive broadcast (no send) Multicast: Only send to all that have activated the RemoteSAP/SDN

127

0 to 62, 255 0 to 62, 255

0 to 62, 255

127

122

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Valid Variable Syntax

To support the user when structuring the data to be sent, specific sections of the buffer can be selected. The following syntax is mandatory for describing the variables: send{n}{,}<type><byte address>{,quantity} The notation of the variable syntax corresponds to the syntax for the receive buffer.

SendSDA SendSDN

In special situations, it may be desirable that the service used is not dependent on the combination of the address of the partner station and the SAPs. By using the names "SendSDA" and "SendSDN", an OPC client can specify that only the relevant services SDA or SDN are used for sending. The syntax corresponds to the syntax of "Send". These special names are not displayed in the OPC Browser. Several examples of syntax are listed below to illustrate the above definition:
Example of Syntax send30,dword7 send,B20 send8,DINT0 Description A double word starting at byte 7 in a 30-byte long send buffer An array with 20 bytes in a send buffer with the default size A signed double word starting at byte address 0

Syntax Examples

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

123

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.6.3 Information Variables Specific to FDL

Introduction

The OPC server for Send/Receive via PROFIBUS (FDL) provides variables for with which information about the connection states can be queried. The name of the information variable must be specified in the parameter ItemID of an OPC item. The following information can be obtained: Status/Configuration of the Communication Network Versions of the Protocol Software The module-specific information variable FDL:[||<module>]&busparameter() supplies the bus parameters of the PROFIBUS network operated on the specified module. The values are returned as a field of the data type VT_UI1 and correspond to the results returned by the FDL service FDL_READ_VALUE. To interpret the results of this low-level service, refer to the manual for the FDL programming interface. Example: FDL:[CP_L2_1:||]&busparameter()

Bus Parameters

Local Station Address

The module-specific variable FDL:[||<module>]&ts() returns the station address of the specified module. The data type of this item is VT_UI1. Example: FDL:[CP_L2_1:||]&ts()

Node Identification of the Local Station

The module-specific variable FDL:[||<module>]&ts() supplies the node identification of the specified module. The value is supplied in the "VT_ARRAY|VT_BSTR. The elements of this field contain the following information: "Vendor" "Controller" "Hardware Version" "Software Version"

List of the Nodes on the Bus

The module-specific variable FDL:[||<module>]&lifelist() supplies the list of PROFIBUS nodes obtainable by the specified module. This information is obtained using the FDL service FDL_LIFE_LIST_CREATE_REMOTE. Note that this service creates a significant load on the bus so that this variable should not be monitored. The data type of this variable is a field with 127 elements with the index of each element standing for a PROFIBUS address. Each element can have one of the following values:

124

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Return Value

Description Station does not exist, i.e. address not used. The station is an active node and is ready for inclusion in the logical ring of the PROFIBUS network. The station is an active node and is already in the logical ring. The station is a passive PROFIBUS node (for example DP slave)

0x10 0x20 0x30 0x00

Node Identification of the Partner Device

The connection-specific variableFDL:[<connection>]&identify() supplies the node identification of the partner device that can be obtained via the specified connection. The value is supplied in the "VT_ARRAY|VT_BSTR. The elements of this field contain the following information: "Vendor" "Controller" "Hardware Version" "Software Version"

Example: FDL:[MyConnection||CP_L2_1:]&identify()

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

125

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.7

DPS Protocol

5.7.1 Specifications for the DPS Protocol

Master and Slaves

The DPS protocol for PROFIBUS basically specifies a single master system. For the OPC server for SIMATIC NET, the DP master is a PC with the appropriate communications processor, for example CP 5412 (A2). A master addresses slaves cyclically via the fieldbus. Slaves are generally input/output modules located in a distributed configuration and equipped with a passive communications module. The OPC server represents the inputs and outputs of a slave.

Properties of the DP-OPC Server

The DP-OPC server from SIMATIC NET has the following characteristics: Variable services and outputs Diagnostic evaluation access and monitoring of DP automatic evaluation of static diagnostics inputs

Protocol ID

The protocol ID for the DPS protocol is always DPS.

Connection Name

For the DPS protocol, the connection name specifies the communication access by specifying the communications processor that communicates with the slaves as the DP master. The connection name for the DP protocol is DPSONLINE

Access to DP Variables

The inputs and outputs of the slave are accessed by specifying the module number and the I/O area. DP slaves have a modular structure. A DP slave can have more than one module with different I/O areas. The modules are assigned during configuration.

126

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.7.2 Syntax of Variable Names for DPS

Overview

The variable name identifies the input or output area in the module of a slave. Status information of the slaves and the DP master is also available using variable names. To describe the syntax, the following notation is used: Conventions (not part of actual syntax) Pointed brackets ( < > ) Braces ( { } ) Meaning Texts in pointed brackets are mandatory Texts in braces are optional

Syntax

The syntax of the slave inputs and outputs is defined as follows (upper and lower case irrelevant): Inputs: SlaveM<number>E<format><element>{.bit}{,quantity} Outputs: SlaveM<number>A<format><element>{.bit}{,quantity}

Description of the Parameters

The individual parameters have the following meaning:

<number>

Number of the module containing the input or output area.

{format}

The "format" element specifies the format in which the data are supplied. Specifying the format also specifies the data type. In principle, all specified OLE data types can be read via the automation interface of OPC. However, certain development tools (for example Visual Basic) only offer a restricted number of data types. The following table therefore lists the corresponding Visual Basic type in which the variable value can be represented.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

127

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Format ID X BYTE or B CHAR WORD or W INT DWORD or D DINT REAL BK WK

Description Bit Byte (unsigned 8) Character (signed 8) Word (unsigned 16) Integer (signed 16) Double word (unsigned 32) Double integer (signed 32) Floating-point number Consistent data as an array of bytes (unsigned 8) Consistent data as an array of words (unsigned 16)

OLE Data Type VT_BOOL VT_UI1 VT_I1 VT_UI2 VT_I2 VT_UI4 VT_I4 VT_R4 VT_ARRAY of VT_UI1 VT_ARRAY of VT_UI2

VB Type Boolean Byte Integer Long Integer Double Long Single Byte() * Long() *

* Default setting in Visual Basic BSTR

<element{.bit}>

Number of the element to be accessed (not possible for BK and WK). The byte address of an element is decided by the data type. Example: B2 supplies a byte starting at byte address 2, W2 ,on the other hand, supplies a word starting at word address 2, corresponding to byte address 4! Specification of a bit is only permitted for type X. The address to be specified is a byte address. Example: X2.3 means the 3rd bit of the 2nd byte.

{,quantity}

Number of elements (not possible for BK, WK and X). The data type of the variable is an array with elements (data type VT_ARRAY) of the specified format. If this part of the name is omitted, the quantity 1 is assumed and the data type of the variable is not an array.

128

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Syntax Examples

Several examples of syntax are listed below to illustrate the above definition. Do not forget, that you must always precede the variable with the protocol ID and the module identifier (for example "DPS:[DPSONLINE]" )!
Example of Syntax SlaveM003EB0 SlaveM003EB1,3 SlaveM003AW3 SlaveM003ADWORD2 SlaveM003EX0.0 SlaveM003AX3.7 SlaveM003EBK SlaveM001AWK Description Input byte 0 (offset 0) 3 bytes starting at input byte 1 (offset 1) Output word 3 (offset 6) Output double word 2 (offset 8) Input bit 0 in byte 0 Output bit 7 in byte 3 All input bytes in module 3 All output words in module 1

Predefined DPS Item of the Module

The following predefined DPS item is used to query and control the status of the module:
Item DPS:[ DPSONLINE]&devicestate Description Status of the module hosting the slave. Data type: VT_BSTR with the values "ONLINE" and "OFFLINE". By writing these values, the module can be set to the corresponding status.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

129

Structure of the OPC Items for the SIMATIC NET Data Access Interface

Predefined OPC Items of the Slave

The following predefined OPC items exist:

Item DPS:[DPSONLINE]SlaveSlvState

Description Current status of the DPS slave. The data type is VT_BSTR with the possible values "DATA_EXCHANGE" and "NO_DATA_EXCHANGE". All input bytes of all input modules of the slave. The data type is VT_ARRAY|VT_UI1. All outputs bytes of all output modules of the slave. The data type is VT_ARRAY|VT_UI1. Configuration data of the slave. The data type is VT_ARRAY|VT_UI1.

DPS:[DPSONLINE]SlaveAllInputs

DPS:[DPSONLINE]SlaveAllOutputs

DPS:[DPSONLINE]SlaveMiscReadSl vParCfgData

130

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Structure of the OPC Items for the SIMATIC NET Data Access Interface

5.8

Symbolic Variable Names (Aliases)


The SIMATIC NET OPC servers allow the definition and use of symbolic variable names. This means that OPC applications can be developed without specific reference to a system configuration and can be adapted to the variable names and connections of a system. The symbols are defined within a connection. To specify an item completely, the connection information must also be provided. AccessPath="" ItemID = "FMS:[Pump_1]voltage" Pump_1 is configured in the FMS database, voltage is a symbolic name for an FMS index. Since the VFD and communications processor are unique, they can be omitted. AccessPath = FMS:[ FMS_CON|VFD1_OPC|CP_L2_1:] ItemID1 = Flow ItemID2 = Fill The AccessPath contains the complete connection information and is used for all items.

Introduction

Examples

Definition

Symbolic definitions (aliases) can be defined in a text file before the OPC server is started. For further details about defining aliases using a text file, refer to Section 8.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

131

Properties of the OPC Event Server for SIMATIC NET

132

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Properties of the OPC Event Server for SIMATIC NET

Properties of the OPC Event Server for SIMATIC NET

The OPC Event specification gives the vendor of an OPC Event server a great deal of freedom to map the properties of the programmable controllers on the OPC interfaces for alarms and events. This chapter describes the options provided by the OPC specification for Alarm & Events used by the OPC server for SIMATIC NET, which events are provided by the OPC server and which additional information is available as attributes.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

133

Properties of the OPC Event Server for SIMATIC NET

6.1

General Information
The OPC Event server for SIMATIC NET does not have any configuration information relating to alarm/event handling in an operator control and monitoring system.

Simple Event Server

Since the configuration information is missing, the OPC Event server for SIMATIC NET can only be operated as a "Simple Event Server". A Simple Event Server passes on only simple messages to the underlying components. A higher level Alarm/Event Management Server processes the messages of the lower level Simple Server taking into consideration configuration information (see next section).

Operator station 2

Operator station 2

Log printer

Alarm/Event Management Server

Simple Alarm/ Event Server

Simple Alarm/ Event Server

Attachment to communication system

Other device with alarm information

Restrictions

As a Simple Alarm/Events Server, the OPC Event server for SIMATIC NET has the following restrictions:

No conditions No state-related events No confirmation No areas No area browsing

134

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Properties of the OPC Event Server for SIMATIC NET

6.2

S7 Protocol
The S7 protocol provides two protocol mechanisms for transferring events.

Services Used

Configured messages (SCAN) Programmed messages (ALARM)

Both message types are used by the OPC Event server for the S7 protocol.

Supported Alarm Categories

In keeping with the message types, the OPC Event server provides the following alarm categories:

S7_PROCESS_SCAN S7_PROCESS_ALARM.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

135

Properties of the OPC Event Server for SIMATIC NET

6.2.1 Events and Parameters

Parameter

By calling the "OnEvent" callback function of the client, the client obtains a list of events. The OPC Event server for S7 supplies serverspecific parameters that are explained in this section.

"szSource" Parameter

As the source of the message, the OPC Event server for S7 specifies the connection information of the reporting S7 device. This corresponds to the connection portion of an S7 variable for OPC Data Access: The connection information is made up of three parts: The configured name of the S7 connection The configured local VFD, at which the OPC server will be logged on The name of the communications processor or the access point of the application These parts are separated by the | character. You specify the names of the S7 connections and VFDs during configuration. Example: S7:\AG1|VFD_OPC|CP_L2_1:

Parameter "szMessage"

The name of a message is made up of the message mechanism and the configured message number: SCAN<message number> ALARM<message number> SCAN83 ALARM55

Examples:

"dwEventType" Parameter

The OPC Event server supports only the type: OPC_SIMPLE_EVENT This constant has the value 0x0001.

"dwEventCategory " Parameter

The following values are possible as event categories: S7_PROCESS_SCAN = 1 S7_PROCESS_ALARM = 2

136

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Properties of the OPC Event Server for SIMATIC NET

"dwSeverity" Parameter

The return value provides information about the importance of the event. This return value can be modified in the configuration file for individual message numbers of a communication partner (see Section 8.4).

"dwNumEventAttrs " Parameter "pEventAttributes" Parameter

The number of attributes supplied with the message depends on the number of supplied associated values. This structure contains the attributes supplied with the event. The attributes also include the associated values of the message supplied by the partner device. The structure is described in the OPC specification.

Other Parameters

The other parameters contain information relevant to the conditionrelated events or tracking events. Since these event types are not supported by the OPC Event server for SIMATIC NET, the remaining parameters are irrelevant.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

137

Properties of the OPC Event Server for SIMATIC NET

6.2.2 Event Attributes

Supplied Attributes

An S7 station can send up to 10 associated values with a message or an alarm. These associated values are available in the event attributes via the OPC Alarm & Event interface. This section describes the attributes supplied with an event by the OPC Event server for SIMATIC NET. Configured messages (SCAN) and programmed messages (ALARM) provide the following attributes:

138

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Properties of the OPC Event Server for SIMATIC NET

Name EVENT_ATTR_S7_ PCTIME EVENT_ATTR_S7_ S7TIME EVENT_ATTR_S7_ STATE

Value 6000 6001 6002

Type VT_DATE VT_DATE VT_UI2

Description Time at which the OPC Event Server received the message. Time at which the message was generated on the partner device. With SCAN messages: Indicates the general status, whether the message exists or not. Possible values: S7_SCAN_MSG_EXIST OK (value 0x0) S7_SCAN_NO_MSG message does not exist (value 0x81) With ALARM messages: 0x00H Bit 0 1 2 3 to 5 6 7 OK Meaning Initialization Overflow signal Overflow instance 0, reserved No additional values possible (size) Additional values not obtainable

EVENT_ATTR_S7_ ACK_STATE

6003

VT_UI2

Acknowledgment status of the scan object: It is not possible to acknowledge messages using the OPC Event Server for SIMATIC NET. Messages can, however, be acknowledged by other user interface systems. With SCAN messages: Bit 0 1 to 7 8 9 to 15 Description Acknowledgment entered state irrelevant Acknowledgment left state irrelevant

With ALARM messages: Bit 0 ... 7 8 ... 15 Description Acknowledgment 1 entered state ... Acknowledgment 8 entered state Acknowledgment 1 left state ... Acknowledgment 8 left state

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

139

Properties of the OPC Event Server for SIMATIC NET

Name EVENT_ATTR_S7_ EVENT_STATE

Value 6004

Type VT_UI2 Event state

Description

Bit 0: Current status (1 = active) Remaining bits: irrelevant

EVENT_ATTR_S7_ NO_DATA

6005

VT_UI2

Number of associated values Range of values: 1..10

EVENT_ATTR_S7_ DATA00_DATATYPE

6006

VT_UI2

Data type of associated value no. 0 Parameter Value S7_DATATYPE_ERROR S7_DATATYPE_BOOLEAN S7_DATATYPE_INTEGER S7_DATATYPE_FLOAT Description Error (0x0) Boolean (0x03) Integer (0x05) Float (0x07)

S7_DATATYPE_OCTET_STRING String (0x09) S7_DATATYPE_BITSTRING Bit string (0x04) Note: Length in bytes instead of bits! S7_DATATYPE_ DATE Date (0x30) Note: Days since 01.01.1990 Time (0x31) Note: ms since start of day Time (0x32) Note: In ms

S7_DATATYPE_TIME_OF_DAY

S7_DATATYPE_TIME

S7_DATATYPE_S5TIMETime (0x33) Note: BCD coded EVENT_ATTR_S7_ DATA00_VALUE_ LEN EVENT_ATTR_S7_ DATA00 EVENT_ATTR_S7_ DATA01_DATATYPE EVENT_ATTR_S7_ DATA01_VALUE_ LEN EVENT_ATTR_S7_ DATA01 ... 6007 VT_UI2 Number of relevant bytes of associated value no. 0

6008 6010 6011

VT_ARRAY | VT_UI1 VT_UI2 VT_UI2

The relevant bytes of associated value no. 0 as array of bytes. Data type of associated value no. 1 Number of relevant bytes of associated value no. 1

6012

VT_ARRAY | VT_UI1

The relevant bytes of associated value no. 1 as array of bytes.

140

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Properties of the OPC Event Server for SIMATIC NET

Name EVENT_ATTR_S7_ DATA09_DATATYPE EVENT_ATTR_S7_ DATA09_VALUE_ LEN EVENT_ATTR_S7_ DATA09

Value 6042 6043

Type VT_UI2 VT_UI2

Description Data type of associated value no. 9 Number of relevant bytes of associated value no. 9

6044

VT_ARRAY | VT_UI1

The relevant bytes of associated value no. 9 as array of bytes.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

141

Configuration of the OPC Server for SIMATIC NET

142

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

Configuration of the OPC Server for SIMATIC NET

The OPC server for SIMATIC NET must be configured before it can use the underlying communication systems. This chapter explains the basic configuration using the configuration program.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

143

Configuration of the OPC Server for SIMATIC NET

7.1

General Information

Introduction

The way in which the OPC server for SIMATIC NET operates can be adapted to the requirements of the area of application. After installing the OPC server for SIMATIC NET, the configuration parameters have default values. To install and start up the OPC server without problems, the configuration program should be started, the default parameters checked and necessary parameters must be set.

Configuration Files

For more detailed information about the settings, refer to the configuration files described in Chapter 9. The configuration program of the OPC server for SIMATIC NET can be called via the Control Panel or from the Start menu in two different ways: First Possibility Double-click the SIMATIC NET OPC Server icon in the Control Panel. Second Possibility Start the OPC Settings program in the taskbar of Windows (taskbar Start => SIMATIC => SIMATIC NET => OPC Server => OPC Settings). After starting the configuration program, you can make general and protocol-specific settings in various tab pages.

Call

Entering Changes

The settings of the configuration program are updated when you click the OK button or the Apply button. The settings (apart from the trace settings) only become active when you restart the OPC server. Close all clients to quit the OPC server and then start an OPC client.

144

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

7.2

General Settings for all Protocols


In the "OPC Parameters tab, you can set general parameters for operating the OPC server for all protocols.

Overview

Active Protocols

The OPC server for SIMATIC NET supports simultaneous operation of more than one protocol. By marking the check boxes "DP Protocol", "S7 Protocol", "SR Protocol" or "FMS Protocol" you specify the protocols to be used by the OPC server for communication. If the underlying communication system does not exist or is incorrectly configured, this is indicated by error messages when the OPC server starts up. In this case, eliminate the problem or deactivate the protocol.

Symbol File

With the OPC server, apart from the connection-specific alias, a protocol-independent symbol file can be used. If you intend to use a symbol file, you must activate the "Symbol File" check box and enter the path and name of the file in the input box. For detailed information on creating the symbol file, refer to Section 7.11.

Licenses

To operate a protocol, you require the license for the corresponding SIMATIC NET OPC product. The simulated connections can, however, be operated without a license.

Trace

To debug your own applications it is often extremely useful to be able to evaluate the correct response of the underlying components. Particularly errors in the dynamic activities involved in communication can be traced much more easily. Using trace outputs, a program logs the actions it has performed.

The OPC server allows OPC-specific (Data Access or Alarms & Events) and protocol-specific actions to be recorded separately.

Activating Trace Output

To activate the trace output of the OPC-specific actions for Data Access, activate the "Activate OPC Data Access Trace" check box. To activate the trace output of OPC-specific actions for Alarms & Events, activate the "Activate OPC Alarms&Events Trace" check box. The activation of trace outputs slows down program execution considerably.

Trace File

Enter the path and name of the file in which the trace log will be written in the Trace file text box.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

145

Configuration of the OPC Server for SIMATIC NET

Number of Entries in the File

To avoid overtaxing your system with an ever-growing trace file, the size of the trace file is limited. With the Number of entries in file parameter, you decide how many entries the trace file can hold. If the trace file is full, it is renamed by changing the file name extension and a new file is created. This allows you to see the last trace entries in the renamed file after reaching the maximum number of entries.

146

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

7.3

Protocol Settings Specifically for DP


In the DP Protocol tab page, you can set parameters for operating the DP protocol.

Overview

"Request Cycle" Parameter

The "request cycle" parameter specifies the smallest possible interval for querying the values of OPC items. Only active items in active groups are checked. When this time has elapsed, the server checks whether the value of the OPC items has changed. Changed active OPC items are then updated in the cache and notified to the user. The user can set an update rate for each group. If the selected rate is not supported, the server reports back with an alternative rate (RevisedUpdateRate) that represents the closest permitted value. The value 0 requests the fastest permitted UpdateRate. The value of the request cycle set is returned as the minimum update rate. The value of the minimum update rate must match the timing of the underlying communications system. It must not be significantly lower than the time required by the communication system to acquire new process data.

"Activate Simulation Connection"

The DP OPC server can be operated for tests, presentations and development without an underlying communications processor. For such situations, there is a configurable simulation module. This simulation module always has the name DEMO. This connection can be activated and deactivated with the "Activate Simulation Module" check box. For details of configuring the simulation module, refer to Section 8.3.5.

Activating "Access Rights Configuration"

With the OPC server, you can specify the access rights of individual variables or variable groups. By specifying access rights, you can, for example, prevent variables used for internal calculation from being overwritten. You configure access rights either in the Tag File Configurator for symbolic variables or in a protocol-specific text file. Setting the "Activate Access Rights Configuration" check box means that the configuration file for access rights is evaluated when the OPC server starts up. The configuration file for access rights is then opened along with the general configuration file when you click the "Edit DP Configuration File" button. For details of the structure of the configuration file, refer to Section 8.2.

"Edit DP Configuration File"

Clicking this button opens a text editor with the active configuration file. In this file, you can now make changes to the configuration.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

147

Configuration of the OPC Server for SIMATIC NET

Saving and Activating

The configuration program also makes changes to the configuration file that can be overwritten by your changes. Recommendation:

Click the "Edit DP Configuration File" button only when you have applied the changes made by the configuration program with the "Apply" button.

Selecting Access Points

An access point is a name that refers unequivocally to a communication module. The names of the access points are specified by the configuration program of the underlying protocol software. The following access points are possible for the DP protocol: CP_L2_1: CP_L2_2: CP_L2_3: CP_L2_4:

You select the access point to be used by the OPC server by activating the check box of the relevant line in the list of available access points.

Unavailable Access Points

The configuration program recognizes when the access points specified in an earlier configuration are no longer valid. Such access points are then indicated by a red check box. Access points that are no longer valid are removed from the list of selected access points by the configuration program. The removal of invalid access points is prevented, if you activate the check box "Keep unavailable access points".

Entering your Selections

Remember that a selected access point is only entered after you confirm the properties page with "Apply" or "OK". These modifications only take effect after you restart the OPC server for SIMATIC NET.

148

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

7.4

Protocol Settings Specifically for S7


In the S7 Protocol tab page, you can set general parameters for operating the S7 protocol.

Overview

"Request Cycle" Parameter

The "request cycle" parameter specifies the smallest possible interval for querying the values of OPC items. Only active items in active groups are checked. When this time has elapsed, the server checks whether the value of the OPC items has changed. Changed active OPC items are then updated in the cache and notified to the user. The user can set an update rate for each group. If the selected rate is not supported, the server reports back with an alternative rate (RevisedUpdateRate) that represents the closest permitted value. The value 0 requests the fastest permitted UpdateRate. The value of the request cycle set is returned as the minimum update rate. The value of the minimum update rate must match the timing of the underlying communications system. It must not be significantly lower than the time required by the communication system to acquire new process data.

Activate the Simulation Connection

The S7 OPC server can be operated for tests, presentations and development without an underlying communications processor. For such situations, there is a configurable simulation connection. This simulation connection always has the name DEMO. This connection can be activated and deactivated with the "Activate simulation connection" check box.

Activate "Access Rights Configuration"

With the OPC server, you can specify the access rights of individual variables or variable groups. By specifying access rights, you can, for example, prevent variables used for internal calculation from being overwritten. You configure access rights either in the Tag File Configurator for symbolic variables or in a protocol-specific text file. Setting the "Activate Access Rights Configuration" check box means that the configuration file for access rights is evaluated when the OPC server starts up. The configuration file for access rights is then opened along with the general configuration file when you click the "Edit S7 Configuration File" button. For details of the structure of the configuration file, refer to Section 8.2.

"Edit S7 Configuration File"

Clicking this button opens a text editor with the active configuration file. In this file, you can make changes to the configuration.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

149

Configuration of the OPC Server for SIMATIC NET

Saving and Activating

The configuration program also makes changes to the configuration file that can be overwritten by your changes. Recommendation:

Click the "Edit S7 Configuration File" button only when you have applied the changes made by the configuration program with the "Apply" button.

Selecting CP/VFD Pairs

A VFD is a "Virtual Field Device". It is a simulation of one or more real field devices and is used to provide a uniform view of the real plant. Its function is to provide a unique assignment of real devices to an application. The number of available VFDs is specified by the configuration of the communications system. A VFD contains the connections configured for this VFD. A separate set of VFDs can be configured for each communications processor. An application can log on at one or more VFDs and at one or more communications processors (CPs). A CP/VFD pair must be assigned to exactly one application. By selecting a CP/VFD pair, you specify which module and which VFD (and consequently which connections) are used in an application for communication. The FMS OPC server for SIMATIC NET uses all the VFDs configured on a computer for communication without previous configuration. Querying and obtaining the existing configuration can take some time. Since a communications processor can be accessed using several names, VFDs occur more than once in the list of CP/VFD pairs.

Before you install and start up the S7 OPC server, you should always select the CP/VFD pairs that are really necessary. When VFDs are listed in more than one CP/VFD pair, it is advisable to select the pairs that include an access point (for example CP_L2_1:) . This means that you can switch over to other CPs without changing the OPC configuration. If other applications on this computer use the S7 protocol at the same time, these programs require their own VFD not used by the OPC server.

Sample Configuration

Configuration sample: You only want to use the S7 OPC server for S7 communication with 5 partner devices. You would therefore configure 5 connections in the S7 database that all use the same VFD<1>. You use a CP 5412 (A2). In the list of CP/VFD pairs, you see for example "CP_L2_1:|VFD<1>" and "CP 5412 (A2) PROFIBUS|VFD <1>". Select only the CP/VFD pair "CP_L2:1|VFD <1>".
You specify the CP/VFD pairs to be used by the S7 protocol by activating the check box in the relevant line.

150

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

Unavailable CP/VFD Pairs

The configuration program recognizes when the CP/VFD pairs specified in an earlier configuration are no longer valid. The reason for this could be the use of a different S7 database or that an access point has been changed or deleted. Such CP/VFD pairs are then indicated by a red check box. CP/VFD pairs that are no longer valid are removed from the list of selected CP/VFD pairs by the configuration program. The removal of invalid CP/VFD pairs is prevented if you activate the check box "Keep unavailable VFD/CP pairs".

Entering your Selections

Remember that the selected CP/VFD pairs become valid only after you confirm the Properties page with Apply or OK. These modifications only take effect after you restart the OPC server for SIMATIC NET.

Modifying the Configuration

If the configuration is modified or you enter a different database for the S7 protocol, remember that the selected CP/VFD pairs may no longer be valid. When you restart the OPC server, you will then receive error messages. After modifying the S7 configuration in a way that affects the VFDs or the CPs being used, check the selected CP/VFD pairs.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

151

Configuration of the OPC Server for SIMATIC NET

7.5

Protocol Settings Specifically for FMS


In the FMS Protocol tab page, you can set general parameters for operating the FMS OPC server.

Overview

"Repetitions of Sequential Services" Parameter

FMS sequential services are handled by the FMS OPC server. If an error occurs in a single job, it is repeated several times. With the "Repetitions of sequential services parameter, the number of repetitions can be set in the range from '0' to '65535'. The default value is 20. The "request cycle" parameter specifies the smallest possible interval for querying the values of OPC items. Only active items in active groups are checked. When this time has elapsed, the server checks whether the value of the OPC items has changed. Changed active OPC items are then updated in the cache and notified to the user. The user can set an update rate for each group. If the selected rate is not supported, the server reports back with an alternative rate (RevisedUpdateRate) that represents the closest permitted value. The value 0 requests the fastest permitted UpdateRate. The value of the request cycle set is returned as the minimum update rate. The value of the minimum update rate must match the timing of the underlying communications system. It must not be significantly lower than the time required by the communication system to acquire new process data.

"Request Cycle" Parameter

"Activate Simulation Connection"

The FMS-OPC server can be operated for tests, presentations and development without an underlying communications processor. For such situations, there is a configurable simulation connection. This simulation connection always has the name DEMO. This connection can be activated and deactivated with the "Activate simulation connection" check box. For details of configuring the simulation connection, refer to Section 8.5.6

Activating "Access Rights Configuration"

With the OPC server, you can specify the access rights of individual variables or variable groups. By specifying access rights, you can, for example, prevent variables used for internal calculation from being overwritten. You configure access rights either in the Tag File Configurator for symbolic variables or in a protocol-specific text file. Setting the "Activate Access Rights Configuration" check box means that the configuration file for access rights is evaluated when the OPC server starts up. The configuration file for access rights is then opened along with the general configuration file when you click the "Edit FMS Configuration File" button. For details of the structure of the configuration file, refer to Section 8.2.

152

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

"Edit FMS Configuration File"

Clicking this button opens a text editor with the active configuration file. In this file, you can make changes to the configuration.

Saving and Activating

The configuration program also makes changes to the configuration file that can be overwritten by your changes. Recommendation:

Click the "Edit FMS Configuration File" button only when you have applied the changes made by the configuration program with the "Apply" button.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

153

Configuration of the OPC Server for SIMATIC NET

Selecting CP/VFD Pairs

A VFD is a "Virtual Field Device". It is a simulation of one or more real field devices and is used to provide a uniform view of the real plant. Its function is to provide a unique assignment of real devices to an application. The number of available VFDs is specified by the configuration of the communications system. A VFD contains the connections configured for this VFD. A separate set of VFDs can be configured for each communications processor. An application can log on at one or more VFDs and at one or more communications processors (CPs). A CP/VFD pair must be assigned to exactly one application. By selecting a CP/VFD pair, you specify which module and which VFD (and consequently which connections) are used in an application for communication. The FMS OPC server for SIMATIC NET uses all the VFDs configured on a computer for communication without previous configuration. Querying and obtaining the existing configuration can take some time. Since a communications processor can be accessed using several names, VFDs occur more than once in the list of CP/VFD pairs.

Before you install and start up the FMS-OPC server, you should select the CP/VFD pairs that are really necessary. When VFDs are listed in more than one CP/VFD pair, it is advisable to select the pairs that include an access point (for example CP_L2_1:) . This means that you can switch over to other CPs without changing the OPC configuration. If other applications on this computer use the FMS protocol at the same time, these programs require their own VFD not supported by the OPC server.

Sample Configurations

Configuration samples:
1. You only want to use the FMS OPC server for FMS communication with 5 FMS partner devices. You would therefore configure 5 connections in the FMS database using COM PROFIBUS that all use the same VFD<1>. You use a CP 5412 (A2). In the list of CP/VFD pairs, you see for example "CP_L2_1:|VFD<1>" and "CP 5412 (A2) PROFIBUS|VFD <1>". Select only the CP/VFD pair "CP_L2:1|VFD <1>".

You want to use the FMS OPC server as a program based on SAPI FMS at the same time with 3 FMS partner devices. You have a CP 5412 (A2). You configure the FMS database with COM PROFIBUS for this CP: - In the FMS master system 2 VFDs (for example "VFD <1> and "VFD <2>) - 3 partner devices each with 2 connections. The first connection is assigned to VFD <1> the second connection to VFD <2>. In the list of CP/VFD pairs in the OPC settings, you see for example "CP_L2_1:|VFD <1>, "CP_L2_1::|VFD <2>", "CP 5412 (A2) PROFIBUS|VFD <1>" and "CP 5412 (A2) PROFIBUS|VFD <2>". For the OPC server, select only the pair "CP_L2_1:|VFD <1>" and use VFD <2> in your program.

154

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

You specify the CP/VFD pairs to be used by the FMS protocol by activating the check box in the relevant line.

Unavailable CP/VFD Pairs

The configuration program recognizes when the CP/VFD pairs specified in an earlier configuration are no longer valid. The reason for this could be the use of a different FMS database or that an access point has been changed or deleted. Such CP/VFD pairs are then indicated by a red check box. CP/VFD pairs that are no longer valid are removed from the list of selected CP/VFD pairs by the configuration program. The removal of invalid CP/VFD pairs is prevented if you activate the check box "Keep unavailable VFD/CP pairs".

Entering your Selections

Remember that the selected CP/VFD pairs become valid only after you confirm the Properties page with Apply or OK. These modifications only take effect after you restart the OPC server for SIMATIC NET.

Modifying the Configuration

If the configuration is modified or you enter a different database for the FMS protocol, remember that the selected CP/VFD pairs may no longer be valid. When you restart the OPC server, you will then receive error messages. After modifying the FMS configuration in a way that affects the VFDs or the CPs being used, check the selected CP/VFD pairs.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

155

Configuration of the OPC Server for SIMATIC NET

7.6

Protocol Settings Specifically for Send/Receive


In the SR Protocol tab page, you can set general parameters for operating the SR-OPC server.

Overview

"Request Cycle" Parameter

The "request cycle" parameter specifies the smallest possible interval for querying the values of OPC items. Only active items in active groups are checked. When this time has elapsed, the server checks whether the value of the OPC items has changed. Changed active OPC items are then updated in the cache and notified to the user. The user can set an update rate for each group. If the selected rate is not supported, the server reports back with an alternative rate (RevisedUpdateRate) that represents the closest permitted value. The value 0 requests the fastest permitted UpdateRate. The value of the minimum update rate should be selected to suit the time involved in the underlying communication system. It should not be significantly lower than the time required by the communication system to acquire new process data.

Activate the Simulation Connection

The SR-OPC server can be operated for tests, presentations and development without an underlying communications processor. For such situations, there is a configurable simulation connection. This simulation connection always has the name DEMO. This connection can be activated and deactivated with the "Activate simulation connection" check box. For details of configuring the simulation connection, refer to Section 8.6.4

Activating "Access Rights Configuration"

With the OPC server, you can specify the access rights of individual variables or variable groups. By specifying access rights, you can, for example, prevent variables used for internal calculation from being overwritten. You configure access rights either in the Tag File Configurator for symbolic variables or in a protocol-specific text file. Setting the "Activate Access Rights Configuration" check box means that the configuration file for access rights is evaluated when the OPC server starts up. The configuration file for access rights is then opened along with the general configuration file when you click the "Edit SR Configuration File" button. For details of the structure of the configuration file, refer to Section 8.2.

"Edit SR Configuration File"

Clicking this button opens a text editor with the active configuration file. In this file, you can now make changes to the configuration.

156

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

Saving and Activating

The configuration program also makes changes to the configuration file that can be overwritten by your changes. Recommendation:

Click the "Edit SR Configuration File" button only when you have applied the changes made by the configuration program with the "Apply" button.

Selecting Access Points

An access point is a name that refers to a communication module. The names of the access points are specified by the configuration program of the underlying protocol software. A particular module is linked with this access point. A typical access point set up by installing the protocol software is CP_H1_1:. Prior to installing and starting the SR-OPC server, you must specify which access points are used.

If access points are not specified, the SR-OPC server cannot be started up.

You select the access point to be used by the OPC server by activating the check box of the relevant line in the list of available access points.

Unavailable Access Points

The configuration program recognizes when the access points specified in an earlier configuration are no longer valid. Such access points are then indicated by a red check box. Access points that are no longer valid are removed from the list of selected access points by the configuration program. The removal of invalid access points is prevented, if you activate the check box "Keep unavailable access points".

Entering your Selections

Remember that a selected access point is only entered after you confirm the properties page with "Apply" or "OK". These modifications only take effect after you restart the OPC server for SIMATIC NET.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

157

Configuration of the OPC Server for SIMATIC NET

7.7

Protocol Settings Specifically for FDL


In the FDL Protocol tab, you can set general parameters for operating the FDL-OPC server.

Overview

"Request Cycle" Parameter

The "Request Cycle" parameter specifies the shortest possible interval for checking the values of the active OPC items of an active OPC group. When this time has elapsed, the server checks whether the value of the OPC items has changed. All changed OPC items are then updated in the cache and signaled to the user. The user can set an update rate for each group. If the selected rate is not supported, the server reports back with an alternative rate (RevisedUpdateRate) that represents the closest permitted value. The value 0 requests the fastest permitted UpdateRate. The value of the minimum update rate should be selected to suit the time involved in the underlying communication system. It should not be significantly lower than the time required by the communication system to acquire new process data.

Activate the Simulation Connection

The FDL-OPC server can be operated for tests, presentations and development without an underlying communications processor. For such situations, there is a configurable simulation connection. This simulation connection always has the name DEMO. This connection can be activated and deactivated with the "Activate simulation connection" check box. For more detailed information in the simulation connection, refer to Section 8.7.4.

Activating "Access Rights Configuration"

With the OPC server, you can specify the access rights of individual variables or variable groups. By specifying access rights, you can, for example, prevent variables used for internal calculation from being overwritten. You configure access rights either in the Tag File Configurator for symbolic variables or in a protocol-specific text file. Setting the "Activate Access Rights Configuration" check box means that the configuration file for access rights is evaluated when the OPC server starts up. The configuration file for access rights is then opened along with the general configuration file when you click the "Edit FDL Configuration File" button. For details of the structure of the configuration file, refer to Section 8.2.

"Edit FDL Configuration File"

Clicking this button opens a text editor with the active configuration file. In this file, you can now make changes to the configuration.

158

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

Saving and Activating

The configuration program also makes changes to the configuration file that can be overwritten by your changes. Recommendation:

Click the "Edit FDL Configuration File" button only when you have applied the changes made by the configuration program with the "Apply" button.

Selecting Access Points

An access point is a name that refers to a communication module. The names of the access points are specified by the configuration program of the underlying protocol software. A particular module is linked with this access point. A typical access point set up by installing the protocol software is CP_H1_1:. Prior to installing and starting the FDL-OPC server, you must specify which access points are used.

If access points are not specified, the FDL-OPC server cannot be started up.

You select the access point to be used by the OPC server by activating the check box of the relevant line in the list of available access points.

Unavailable Access Points

The configuration program recognizes when the access points specified in an earlier configuration are no longer valid. Such access points are then indicated by a red check box. Access points that are no longer valid are removed from the list of selected access points by the configuration program. The removal of invalid access points is prevented, if you activate the check box "Keep unavailable access points".

Entering your Selections

Remember that a selected access point is only entered after you confirm the properties page with "Apply" or "OK". These modifications only take effect after you restart the OPC server for SIMATIC NET.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

159

Configuration of the OPC Server for SIMATIC NET

7.8

Protocol Settings Specifically for DPS


In the DPS Protocol tab, you can set general parameters for operating the DPS-OPC server.

Overview

"Request Cycle" Parameter

The "Request Cycle" parameter specifies the shortest possible interval for checking the values of the active OPC items of an active OPC group. When this time has elapsed, the server checks whether the value of the OPC items has changed. All changed OPC items are then updated in the cache and signaled to the user. The user can set an update rate for each group. If the selected rate is not supported, the server reports back with an alternative rate (RevisedUpdateRate) that represents the closest permitted value. The value 0 requests the fastest permitted UpdateRate. The value of the minimum update rate should be selected to suit the time involved in the underlying communication system. It should not be significantly lower than the time required by the communication system to acquire new process data.

Activate the Simulation Connection

The DPS-OPC server can be operated for tests, presentations and development without an underlying communications processor. For such situations, there is a configurable simulation connection. This simulation connection always has the name DEMO. This connection can be activated and deactivated with the "Activate simulation connection" check box. For more detailed information in the simulation connection, refer to Section 8.8.3.

Activating "Access Rights Configuration"

With the OPC server, you can specify the access rights of individual variables or variable groups. By specifying access rights, you can, for example, prevent variables used for internal calculation from being overwritten. You configure access rights either in the Tag File Configurator for symbolic variables or in a protocol-specific text file. Setting the "Activate Access Rights Configuration" check box means that the configuration file for access rights is evaluated when the OPC server starts up. The configuration file for access rights is then opened along with the general configuration file when you click the "Edit DPS Configuration File" button. For details of the structure of the configuration file, refer to Section 8.2.

"Edit DPS Configuration File"

Clicking this button opens a text editor with the active configuration file. In this file, you can now make changes to the configuration.

160

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

Saving and Activating

The configuration program also makes changes to the configuration file that can be overwritten by your changes. Recommendation:

Click the "Edit DPS Configuration File" button only when you have applied the changes made by the configuration program with the "Apply" button.

Selecting Access Points

An access point is a name that refers to a communication module. The names of the access points are specified by the configuration program of the underlying protocol software. A particular module is linked with this access point. A typical access point set up by installing the protocol software is CP_H1_1:. Prior to installing and starting the DPS-OPC server, you must specify which access points are used.

If access points are not specified, the DPS-OPC server cannot be started up.

You select the access point to be used by the OPC server by activating the check box of the relevant line in the list of available access points.

Unavailable Access Points

The configuration program recognizes when the access points specified in an earlier configuration are no longer valid. Such access points are then indicated by a red check box. Access points that are no longer valid are removed from the list of selected access points by the configuration program. The removal of invalid access points is prevented, if you activate the check box "Keep unavailable access points".

Entering your Selections

Remember that a selected access point is only entered after you confirm the properties page with "Apply" or "OK". These modifications only take effect after you restart the OPC server for SIMATIC NET.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

161

Configuration of the OPC Server for SIMATIC NET

7.9

Trace for a Specific Protocol


To debug your own applications it is often extremely useful to be able to evaluate the correct response of the underlying components. Particularly errors of dynamic activities involved in communication can be traced much more easily. Using trace outputs, a program logs the actions it has performed.

Introduction

Call

The dialog for configuring the protocol-specific trace is opened by clicking the "Protocol Trace" button in the tab for the protocol you want to investigate.

Activating Trace Output

To activate trace output, select the "Activate OPC trace" check box. The activation of trace outputs slows down program execution considerably.


Trace File

Enter the path and name of the file in which the trace log will be written in the Trace file text box. Different files must be specified for the OPC trace and the protocol-specific trace.

Create new file...

If you select the option "create new file", an existing trace file is overwritten when you start the OPC server. If you select the alternative option "append to existing file", the existing trace file has new entries added to it.

Closing the File Following Each Entry

By closing the protocol-specific trace file following each entry, there is a physical transfer of the data to hard disk. This means that trace information is retained even if a program crashes. Activating this option slows down program execution significantly.

Maximum Number of Entries

To avoid overtaxing your system with an ever-growing trace file, the size of the trace file is limited. With the Number of entries in file parameter, you decide how many entries the trace file can hold. If the trace file is full, it is renamed by changing the file name extension and a new file is created. This allows you to see the last trace entries in the renamed file after reaching the maximum number of entries.

Trace Depth

The amount of information to be recorded can be specified for the protocol-specific trace.

162

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

7.10 Quitting the OPC Server


Introduction The OPC server for SIMATIC NET is started automatically by the operating system when a client wants to use it. The OPC server includes reference counters to be able to recognize when the last client is closed. The OPC server then closes itself. This is, however, only possible when the clients increment and decrement the reference counters correctly. If a client terminates abnormally, so that the reference counter cannot be reset, the OPC server does not close even when no further client is active. The server then continues to maintain the communications connections.

Quitting the OPC Server

If you click the Quit OPC Server button in the OPC Reset tab page, you reset the OPC server to a defined status without having to restart the system. The OPC server terminates all communications connections and closes itself. Both an active OPC Data Access server and an OPC Alarms & Events server is closed. You should first close all the OPC clients that work with the server otherwise any OPC calls from the clients will be rejected with RPC errors.


Reason

In the "Reason" text box, a reason can be specified that can be evaluated by a client. Evaluating this information is interesting particularly in DCOM operation. The OPC server is closed only after the time specified in the "Delay" box has expired.

Delay

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

163

Configuration of the OPC Server for SIMATIC NET

7.11 Symbols for the OPC Server for SIMATIC NET


Introduction The ItemIDs of the OPC servers for SIMATIC NET contain information about the communication path of the variables. The syntax of the variables specifies the protocol, the connection and possibly also the service with which the data will be delivered.

It is, however, often useful to select names of variables that are not dependent on the configuration of the communication system but rather reflect the structure of a plant.

With the OPC Event server for SIMATIC NET, it is possible to enter a symbolic name that is valid for all protocols.

The OPC server for the S7 protocol can also use the symbols created with the STEP 7 configuration tool in the symbol table and in the blocks.

Note: The use of symbols as described in this chapter has nothing to do with the concept of aliases.

Examples

The symbolic names can be selected freely. e.g.

Assembly.Drive.Controller.Setpoint S7300(1)_CPU416.Motor.Limitswitch

164

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

7.11.1 The Symbol File with STEP 7 Symbols

STEP 7 Symbols

A symbol file is used to store the symbolic names. This file contains information about the internal assignment of symbolic names to valid S7 variable names.

Note: When using symbols with the OPC server, the symbols are read out once when the "AddItem" method is called. In subsequent calls, the client uses the handle generated by the server and can therefore access the variable directly.

Note:

To be able to access STEP 7 projects, the configuration program for the symbol file ("Tag File Configurator") must run on the computer with the "STEP 7" configuration program. The symbol file itself, can be transferred to the computer with the OPC server during runtime. The "STEP 7" program is no longer necessary when the OPC server is running.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

165

Configuration of the OPC Server for SIMATIC NET

The Files "*.wsd" and "*.ssd"

The symbolic names of several S7 programs created with STEP 7 can be entered in the symbol file (*.wsd). The symbol file contains the symbols of the global symbol table of an S7 program and the symbolic information stored in blocks.

Along with the file with the extension *.wsd, a file with the extension *.ssd is also created when the symbol information is stored. While the wsd file contains all symbols (including the entries marked as invisible), the ssd file only contains the symbols to be used. Invisible symbols are not entered in the ssd file. The wsd file is used as the basis for editing the symbols with the tag file configuration program. The ssd file is used by the OPC server and is entered in the configuration program for the OPC server.

166

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

7.11.2 Creating a Symbol File with STEP 7 Symbols

Requirements

The Tag File Configurator must run on the computer on which the "STEP 7" configuration tool is installed. If necessary, install the "OPC Server" product on the configuration computer with STEP 7.

Starting the Tag File Configurator

Start the Tag File Configurator and create a new project:

Step 1

Procedure Starting the Tag File Configurator Select the following menu command in the start menu of the Windows taskbar: (Start => SIMATIC => SIMATIC NET => OPC Server => Tag File Configurator)

Creating a new Symbol File Click the "New" button or select the menu command "File => New". You can open an existing project by clicking the "Open" button or selecting the menu command "File => Open".

The following screenshot shows the Tag File Configurator with an empty symbol file. You can now enter STEP 7 programs and other symbols in this symbol file.

Now insert the symbols of a STEP 7 program in the symbol file:

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

167

Configuration of the OPC Server for SIMATIC NET

Step 1

Procedure Select a STEP 7 project Select the menu command "Insert => Program" . A browser is displayed in which you can select the STEP 7 project and program.

Navigate through the projects In the left-hand box, click the "+" character to open the next level. The schematic below describes the meaning of the levels in the program hierarchy.

Select one or more programs Select one or more S7 programs and click the " " to enter the symbols of the selected program in the symbol file.

STEP 7 projects

PC station in project

SIMATIC stations networked with PC station CPU of SIMATIC station Program in this CPU

Applications of PC station, if more than one application is defined for a PC station:

As a result, the Tag File Configurator enters the symbols in the righthand list box (see following page).

A symbol file is always created for one Simatic PC station and must later be initialized on this PC station. If a STEP 7 project does not contain a PC station, no symbol file can be created for the project.

In this case, first create a SIMATIC PC station with STEP 7 and configure the connections to the SIMATIC S7 stations whose symbols you want to access from the PC station.

168

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

Note

The symbol file contains the connection information created with STEP 7/NetPro. This connection information must also be adopted on the PC as the configuration. See also Section 7.11.4.

Assigning Connections

To distribute the communication load, it is possible to configure several parallel connections between two partner devices using STEP 7/NetPro. The information about which of the possible connections can be used to access a variable with a symbolic name is stored in the symbol file. As default, all variables with symbolic names are read via the connection configured last. To assign a variable to a different connection, follow the steps outlined below:

Step 1

Procedure Select the variable Select the list of variables in the left window. Click the row containing the required variable in the right-hand window.

Open the selection dialog Click the arrow button in the cell containing the connection information to display the possible connections in a combo box.

Select a connection Select the required connection in the dialog box.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

169

Configuration of the OPC Server for SIMATIC NET

7.11.3 Entering Additional Symbols

Introduction

Note

Apart from the symbols imported from STEP 7, you can also create new symbols for existing variables using the Tag File Configurator. To structure your symbols, you can create blocks. A block, in turn, can contain lower-level variables or further blocks. Fields and symbols cannot be entered in the CPUs and programs extracted from STEP 7. It is only possible to create new symbols and blocks at the lowest level within blocks that have already been created.

Creating blocks

In the name space, you can now create blocks for structuring the name space.

Step 1

Procedure Select the insertion position Click the lowest level in the tree or click an existing block.

Open the input dialog Click the right mouse button to open the context-sensitive menu. Select the "New Block" menu command. If you select an insertion position incorrectly within a STEP 7 project, this menu command cannot be activated. As an alternative, you can select the "New Block" menu command from the "Insert" menu.

Enter the block name Enter a unique name for the block at this position in the dialog box.

Entering Symbols

You can now enter symbols in the block you have created. Follow the steps outline below:

170

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

Step 1

Procedure Select the insertion position Click the block in the tree in which you want to insert a symbol.

Open the input dialog Click the right mouse button to open the context-sensitive menu. Select the menu command "New Symbol". As an alternative, you can select the "New Symbol" menu command from the "Insert" menu.

Entering or Selecting the Runtime Names Enter the runtime names for the specific protocol in the "Runtime Name" column (as described in Section 5). You can enter the names directly in this table or by clicking the "Browse" button you can start a browser to search through the names on the OPC server. In the "Browse" dialog, you can also select several items.

Specifying the Symbol Names Enter a unique name for the symbol in the "Symboli Name" column for each runtime name.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

171

Configuration of the OPC Server for SIMATIC NET

7.11.4 Using Symbols in OPC

Activating Symbols

To be able to use the symbolic variables of a symbol file in an OPC client, you must activate the use of symbolic names and enter the path of the file to be used. Use the configuration program described in Section 7.11.2.

Entering a Symbol File

In the steps described below, you configure the OPC server for the use of a symbol file:

Step 1

Procedure Transfer the Symbol File Transfer the previously created symbol file to the PC station, for example by copying the symbol file to diskette.

Open the OPC configuration program Start the program "OPC Settings" from the Windows taskbar (taskbar Start => SIMATIC => SIMATIC NET => OPC Server => OPC Settings).

Activating Symbols Activate the "Symbol File" check box in the "OPC Parameters" tab. Enter the path and name of the symbol file transferred to this PC station in the input box below.

Inclusion in the Network Configuration

In STEP 7, when you compile the network configuration with NetPro, databases for the PC stations are created. These databases contain configuration information that describes the access path of the PC station to an S7 station. The databases have the extension "XDB".

A symbol file created from STEP 7 relates to the corresponding XDB file for the PC station. The connection settings for a symbol in the symbol file uses the connection information stored in the XDB file.

Note

This functionality is only available from STEP 7 V5.0 and higher.

Entering the XDB File

The steps outlined below explain how to specify an XDB file for a PC station:

172

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration of the OPC Server for SIMATIC NET

Step 1

Procedure Identify and copy the XDB file Start STEP 7 and open the project from which you created the symbol file. Select the PC station that will use the symbol file. Display the object properties of the PC station and the "Configuration" tab. Here, you can see the location of the configuration file. Transfer the file to the PC station, for example by copying the configuration file to diskette.

Open the configuration program Start the "Set PG/PC Interface" configuration program on the PC station, for example from the taskbar Start => Simatic => SIMATIC NET => Set PG/PC Interface).

Enter the configuration file Select "STEP 7 Configuration" in the configuration program. Enter the path and name of the configuration file transferred to this PC station in the input box "Name of the Configuration File".

Name Space

The symbolic variables are visible beside the protocol-specific variables in the name space of the OPC server.

Structure of the ItemIDs

The ItemID of the symbolic name consists of the name of the control engine, the name of the blocks and the name of the symbol. The individual elements are separated by a period.

For example, the ItemID of a symbolic name "Setpoint" in the "ConveyorBelt" block of the "Factory1" control engine is made up as follows:

Factory1.ConveyorBelt. Setpoint

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

173

Configuration Using Files

174

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

Configuration Using Files

Further settings for the OPC server for SIMATIC NET to allow optimum use must be entered in configuration files. For the send/receive protocol and the Alarms & Events interface, the configuration file must be edited to define the connections. This chapter explains the structure and meaning of the entries in the configuration files for specific protocols.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

175

Configuration Using Files

8.1

Configuration Files
Along with the OPC server for SIMATIC NET, configuration files are installed for specific protocols. The configuration files must be processed to allow optimum use of the products.

Overview

Structure of the Files

The text files for configuring the OPC server are structured based on the principle of the ini files of Windows. These are divided into sections indicated by section names set in [ ]. Following the section name, there are two assignments of the type "parameter=value". Comments within the file are preceded by a semicolon.

File Location

When you install the OPC server, two configuration files are entered in the protocol-specific binary folder. DP S7 FMS SR

<installation path> \ OPC2.NT \ binDP \ SCoreDP.txt <installation path> \ OPC2.NT \ binDP \ SCoreDP.sec <installation path> \ OPC2.NT \ binS7 \ SCoreS7.txt <installation path> \ OPC2.NT \ binS7 \ SCoreS7.sec <installation path> \ OPC2.NT \ binFMS \ SCoreFMS.txt <installation path> \ OPC2.NT \ binFMS \ SCoreFMS.sec <installation path> \ OPC2.NT \ binSR \ SCoreSR.txt <installation path> \ OPC2.NT \ binSR \ SCoreSR.sec

Content of the .txt Files

The configuration files with the extension txt contain a section for general protocol definition. This is followed by sections for assigning parameters for access points or connections and for specifying symbolic names (aliases). A simulation connection can also be configured with which access is possible when no communications processor is installed.

Content of the .sec files

The configuration files with the extension sec allow the access rights to individual variables or variable groups to be influenced.

To avoid the possibility of manipulation of the configuration files, it is advisable for the administrator to restrict write access to these files.

176

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.2

Configuring Access Rights


In operator control and monitoring systems, it must not be possible for any user to be able to monitor and manipulate variables that can be accessed via the protocol. The unintentional writing of internal flag variables of a programmable controller could have fatal consequences. With the OPC server for SIMATIC NET, it is possible to restrict the access rights of the variables that can be accessed using the OPC server.

Overview

The rights specified in the protocol (for example write permission to peripheral inputs can be further restricted but not extended).

Structure

The structure of the sec files for configuring access rights to variables is the same for all protocols. On the one hand, the global settings for controlling access rights for a protocol are specified in the sec files. The sec files also contain the definition of rights for variables and variable groups.

Entry Section [Security] SecurityLevel

Meaning General settings are made in this section. 0 No restriction of access rights 1 Access rights are restricted for all users as specified in the following section. Default 0

Definition of Access Rights

The global access rights for OPC variables are defined in the section "GlobalSecurityItems". To define areas for variables (all variables of a connection or a block), you can use placeholders. Areas can be specified in greater detail using the following definitions.

Entry Section [GlobalSecurityItems] DefaultAccessRights

Meaning Definitions of global rights are defined in this section. Standard specification of the access rights for all variables of the protocol not covered in the following definitions. (empty) R W RW No access to any OPC items of the protocol Read-only access to all OPC items Write-only access to all OPC items Full access to all OPC items

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

177

Configuration Using Files

Default RW
<OPCItem>=<special rights> New definition of the access rights for a variable. All previously defined rights are ignored; in other words, it is also possible to restrict existing rights. Specification of one or more OPC items according to the syntax defined in Chapter 5. This must also include the connection information. The use of aliases is possible. The following placeholders can be used: * any number of characters are irrelevant ? exactly one character is irrelevant <special rights> (Empty) R W RW No access to the OPC item Read-only access to the OPC item Write-only access to the OPC item Full access to the OPC item

<OPCItem>

Examples

DefaultAccessRights=R S7:[appl1|VFD1|CP_L2_1:]*=RW S7:[appl1|VFD1|CP_L2_1:]M*=W

All variables are read-only All items of this connection can be read and written. The memory bit area of the device accessible on this connection is write-only

S7:[appl1|VFD1|CP_L2_1:]MW3=RW Memory word 3 can be read and written.

178

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.3

DP Protocol
Editing the configuration file for the DP protocol becomes necessary in the following situations: when you want to change the DP application environment of the OPC server, when you want to restrict access rights to individual DP slaves, when you want to create aliases or when you want to configure the demo connection

Overview

File Location

The file location for the configuration file for the DP protocol set during installation is as follows:

<installationpath> \ OPC2.NT \ binDP \ SCoreDP.txt

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

179

Configuration Using Files

8.3.1 General Protocol Configuration

General Protocol Configuration

The following table shows the parameters for configuring the general properties of the DP protocol.

Entry Section [PROTOCOL] CycleTime

Meaning The general protocol settings are made in this section. This value specifies how quickly the job waiting list is checked through for pending jobs. Default 100 ms (is set as "Request Cycle" by the configuration program) Number of the module at which the DP OPC server logs on. Several numbers are separated by commas. A logged on module has the name CP_L2_n, where n corresponds to the module number. Caution: The last module number must be terminated by a comma. Example: UseOnlyThisBoard =1,2, Default: 1,2,3,4, (set by the configuration program) 1 The DP OPC server generates a simulation connection with which slave access can be simulated without a functioning protocol. 0 No simulation connection is provided. Default 0 (set by the configuration program) reserved

UseOnlyThisBoard

UseDemoBoard

CycleNet

180

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.3.2 Module-Specific Configuration

Overview

Each module has up to 3 sections in the configuration file. In the first section, module-specific parameters are configured, in the second section special slave settings can be made and in the third section aliases can be defined for variables. The configuration is evaluated when the OPC server starts up. The following table describes the module-specific configuration parameters.

Entry 1st module section [module name] e.g. [CP_L2_1:] ReferenceAccess

Meaning Configuration parameters for this module

Setting for the DP application type and the DP application environment. The permitted values correspond to the DP structure element reference.access (see DP documentation). 0x50 (DPN_SYS_NOT_CENTRAL | DPN_ROLE_NOT_CENTRAL) Several equal ranking DP applications are possible, The OPC server changes automatically to the "OPERATE" mode. 0xA0 (DPN_SYS_CENTRAL | DPN_ROLE_CENTRAL) The OPC server is a master application and must set the mode explicitly. The OPC server variable "Masterstate" must have suitable value set. 0x60 (DPN_SYS_CENTRAL | DPN_ROLE_NOT_CENTRAL) There is another master application and this must set the mode explicitly. The OPC server is a subordinate application. Access to slaves is possible only in the "OPERATE" mode.

Default 0x50
WatchdogTimeout Configuration of the watchdog of the module. If the OPC server no longer accesses the DP programming interface (due to a problem), the module reacts automatically as described in the documentation of the module. (For example the CP 5412 (A2): data with the value 0 is sent to all

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

181

Configuration Using Files

Entry

Meaning slaves assigned to the OPC server). 0 The watchdog is off. n The watchdog responds after n milliseconds without any access to the programming interface. For example, the OPC server accesses programming interface periodically when DP variables are monitored. The watchdog can be modified during operation with the variable DP:[CP_L2_n:]WatchdogTimeout.

Default 6000 ms
Timeout Error monitoring time: If a pending DPC1 job cannot be processed within this monitoring time, the job is acknowledged with an error.

Default 15000 ms
AutoDiag 0 The diagnostic monitoring and evaluation is off. N Lock time for error diagnostics. The OPC server monitors the diagnostic flag automatically when the slave inputs/outputs are accessed and evaluates the diagnostic data of the standard slaves. If errors or problems are detected in the diagnostic data, access to the slave inputs/outputs is locked for n ms; in other words, read/write jobs are acknowledged with errors.

Default 500 ms

182

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.3.3 Slave Configuration

Overview

The entries in the 2nd section specify the access rights of the slaves in the database. Meaning Settings for access rights

Entry 2nd module section [module name(slaves)] e.g. [CP_L2_1:(slaves)] AccessSlaveDefault e.g. AccessSlaveDefault=1

If there are other DP applications on the same module, access to individual DP slaves must be specified. If access to the individual slaves by the DP applications is inconsistent (for example 2 applications have write access to the same slave), the logon of the entire module fails and none of the slaves are available. This entry defines how the default access to slaves is set when you log on. Access can be adapted for individual slaves (see below). The following values are possible: 1 2 As default, only read access to all slaves is possible As default, read and write access to all slaves is possible

Default 2 AccessSlave<no> e.g. AccessSlave003=0 AccessSlave063=1 AccessSlave107=2 Normally, all available slaves of the module are set for read/write access when the module logs on. A different default can be set for each slave, as follows: 0 1 2 No access to slave Read-only access to slave Read/write access to slave

The slave number is always 3 digits, and must be padded with leading zeros. The OPC server does not enter any values in this section. If there is no entry, the default is used. Default 2

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

183

Configuration Using Files

8.3.4 Definition of Symbolic Names

Defining Aliases

The third section of the configuration file allows the definition of symbolic names for a valid DP variable. An alias is a purely textual substitute for an otherwise valid DP variable name. Nesting of aliases is not supported, in other words an alias must always refer directly to a valid DP variable. The following table describes the section for defining aliases.

Entry 3rd module section [module name (aliases)] e.g. [CP_L2_1:(Aliases)] Alias=DPVariable e.g. Motor=Slave012M002EX0.3 Heatingpower=Slave23M003AW3 Alias

Meaning Predefined aliases for this module. The section name is made up of the module name and "(Aliases)". This section contains any number of alias definitions. The symbolic name "Motor" references the 3rd input bit of slave 12. The name "Heatingpower" references an output word of slave 23. The alias can be used just like a normal DP variable on the OPC interface. Range of values: Length maximum 32 characters permitted characters: a-z A-Z 0-9 $ _ (underscore) . (period) & (), ANSI > 127

DPVariable

Internally, the OPC server replaces the variable name of the alias with this DP variable.

184

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.3.5 Configuration of the DP Demo Connection

Introduction

For demonstrations, for testing, or during development it is useful to be able to operate the OPC server for the DP protocol without additional hardware. The OPC server therefore allows you to simulate a module with several slaves. The configuration of the demonstration module is described below. The demo module can be activated by the configuration program or using the "UseDemoBoard parameter in the "PROTOCOL section of the configuration file. The simulated module always has the name "DEMO". Just like a normal module, the demo module also has three configuration sections.

Requirements

Name

Entry 1st section of the demonstration module [DEMO] Entry 2nd connection section [DEMO(Slaves)] Slave<no>=configuration data e.g. Slave003=|R|unsigned8[2]|{00|19} (corresponds to ET200B 32DI} Slave004=|R|unsigned8[2]|{35|00} (corresponds to ET200B 32DO} Slave<no>

Meaning Connection-specific parameters. No parameters are defined within this section. Meaning Configuration of the simulated slaves

Specification of the Demonstration Slaves based on the Slave Configuration Data.

Configuration Data

The slave number is always 3 digits, and must be padded with leading zeros. Read/write access is always possible to a simulated slave. The syntax of the configuration data is always |R|unsigned8[ll]|{dd|....|dd} where ll specifies the length of the configuration data in bytes, dd are the decimal values of the configuration data For information on interpreting the configuration data see the "DP Programming Interface" manual.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

185

Configuration Using Files

Entry 3rd connection section [DEMO(Aliases)] Alias=DPVariable e.g. Motor=Slave012M2EX0.3 Heatingpower=Slave23M01AW3 Alias

Meaning Predefined aliases for the simulated module. This section contains any number of alias definitions. Alias Motor input bit of a slave Alias Heatingpower refers to an output word of a slave. The alias can be used just like a normal DP variable on the OPC interface. Range of values: Length maximum 32 characters permitted characters: a-z A-Z 0-9 $ _ (underscore) . (period) & (), ANSI > 127 On the OPC interface, the occurrence of the alias is replaced by this DP variable.

DPVariable

186

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.4

S7 Protocol
Editing the configuration file for the S7 protocol becomes necessary in the following situations: when you want to change connection parameters when you want to create aliases when you want to configure the demo connection when you want to configure S7 Alarms & Events

Overview

File Location

The file location for the configuration file for the OPC server for the S7 protocol set during installation is as follows:

<installationpath> \ OPC2.NT \ binS7 \ SCoreS7.txt

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

187

Configuration Using Files

8.4.1 General Protocol Configuration

General Protocol Configuration

The following table shows the parameters for configuring the general properties of the S7 OPC server.

Entry Section [PROTOCOL]

Meaning The general protocol settings are made in this section. You can also make parameter settings for the trace of the underlying protocol software (SAPI-S7).

S7_MINI_DB_PERSISTENCE_COUNT For selectable SAPI-S7 mini-dB parameters, see SAPI documentation Default 5 S7_MINI_DB_ABORT_TIMEOUT For selectable SAPI-S7 mini-dB parameters, see SAPI documentation Default 300 SAPI-S7 trace parameters are set Default 0 Selectable SAPI-S7 trace parameter, see SAPI documentation

ConfigProtocolTrace S7_MINI_DB_TRACE_TARGET S7_MINI_DB_TRACE_SELECT S7_MINI_DB_TRACE_DEPTH S7_MINI_DB_TRACE_FILENAME CycleTime

This value specifies how quickly the job waiting list is checked through for pending jobs. Default 100 ms (is set as "Request Cycle" by the configuration program) 1 The S7-OPC server logs on at all available VFD|CP pairs. Since the search for VFD|CP pairs in particular can take some time, the VFD|CP pairs that are actually required should be set using the configuration program. 0 The S7-OPC server logs on only at the VFD|CP pairs specified in the UseOnlyThisVFD parameter. Default: 1 (set by the configuration program)

UseAllAvailableVFD

188

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

Entry UseOnlyThisVFD

Meaning VFD|CP pairs at which the S7-OPC server logs on. Several pairs are separated by commas. Caution: The last VFD|CP pair must be terminated by a comma. Example: UseOnlyThisVFD=VFD1|CP_L2_1:,VFD2|CP_L2_2:, (set by the configuration program) 1 The S7-OPC server generates a simulation connection with which variable access can be simulated without a functioning protocol. 0 No simulation connection is provided. Default 0 (set by the configuration program) Time after which a pending protocol alarm is removed from the internal waiting list if it cannot be passed on to an OPC Alarms & Events client. Default 60000 ms Maximum number of waiting protocol alarms in the internal waiting list, that cannot be passed on to an OPC Alarms & Events client immediately after the protocol alarm occurred. Default 500

UseDemoConn

StoreEventsTime

StoreEventsCount

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

189

Configuration Using Files

8.4.2 Connection-Specific Configuration

Overview

Each S7 connection has up to 3 sections in the configuration file. The connection-specific parameters are configured in the first section, in the second section, aliases for variables can be defined. The configuration is evaluated when the OPC server starts up. The following table describes the connection-specific configuration parameters.

1. Connection section Entry [Connection|VFD|CP] e.g. [AG1|VFD1|CP_L2_1:] S7_MINI_DB_INIT_REQ_AMQ_CALLING S7_MINI_DB_INIT_REQ_AMQ_CALLED S7_MINI_DB_INIT_REQ_AMQ_SIZE S7_MINI_DB_INIT_REQ_RSP_CALLING S7_MINI_DB_INIT_REQ_RSP_CALLED S7_MINI_DB_INIT_REQ_RSP_SIZE InitiateReq Meaning Connection-specific parameters, the section names correspond to the connection names. SAPI-S7 parameters that are set by the client during connection establishment, refer to the SAPI documentation.

0 The connection is never established 1 The connection is established when required; in other words when a variable is accessed via this connection. The connection is always established actively.

Default 1

190

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

Entry Passive

Meaning 0 The OPC server actively establishes the connection to the partner device 1 The partner device establishes the connection. The InitiateReq parameter is ignored in this case. Default 0

AbortConnectionAfter

0 The OPC server only terminates a connection to a partner when the OPC server is closed down. During operation of the OPC server, once a connection has been established it remains even when it is no longer used. n>0 The OPC server terminates a connection automatically n milliseconds after the last use of the connection. This property must not be used if the parameter Passive=1 is set. Default 0

Timeout

Error monitoring time: If a pending job cannot be processed within this monitoring time, the connection is reset and the job is acknowledged with an error.

Default 15000 ms
Events Administrating Messages (logon) 0 Never 1 SCAN messages as soon as appropriate OPC items are used 2 SCAN messages always after connection establishment 3 ALARM messages always after connection establishment One of the settings 2 or 3 is necessary for passing on S7 messages to OPC Alarms & Events clients. At the same time, it is recommended to set the parameter InitiateReq to 2 so that the connection is maintained permanently.

Default 1
OptimizeS7Write 0 1 No optimization of S7 write access Optimization of S7 write access

Optimization of S7 write access is recommended when a lot of (> 50) small S7 items (for example bits or bytes) of an S7 area (for example memory bit area or data block) must be written SIMULTANEOUSLY and WITHOUT GAPS (entire bytes) (for example MX0.0 MX10.7). In this case, the write jobs are put together to form one single write job for the larger area bringing

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

191

Configuration Using Files

Entry

Meaning about a reduction in load on the network and on the partner. If the conditions SIMULTANEOUSLY and WITHOUT GAPS are not met, the performance of the core server may deteriorate. Default 0 0 No optimization of S7 read access n Optimization of S7 read access with gap area n-1 e.g. n = 3 -> 2 bytes gap area permitted. Optimization of S7 read access is recommended when a large number (> 50) of S7 items of an S7 area (for example bit memory area or data block) must be read or monitored actively SIMULTANEOUSLY. In this case, the read jobs are put together to form one single read job for the larger area bringing about a reduction in load on the network and on the partner. S7 items covering the same area (for example MB0 and MW0) are put together. The larger area to be read can have n small gaps according to the setting. We recommend that you set the value 11 for "n" (10 bytes gap). If the condition SIMULTANEOUSLY is not met, the performance of the core server may deteriorate.

OptimizeS7Read

AutoPasswordReset

Default 11 0 No automatic resetting of the S7 domain password 1 Automatic resetting of the S7 domain password after connection establishment
Default 0

192

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.4.3 Definition of Symbolic Names

Defining Aliases

The second section of the configuration file allows the definition of symbolic names for a valid S7 variable. An alias is a purely textual substitute for an otherwise valid S7 variable name. Nesting of aliases is not supported, in other words an alias must always refer directly to a valid S7 variable. The following table describes the section for defining aliases.

2. Connection section Entry [Connection|VFD|CP(Aliases)] e.g. [AG1|VFD1|CP_L2_1:(Aliases)] Alias=S7Variable e.g. Motor=AB0 Heatingpower=DB10,W0 Alias Meaning Predefined aliases for this connection. The section name is made up of the connection name and the additional "(Aliases)". This section contains any number of alias definitions. The symbolic name "Motor" references output byte 0; the name "Heatingpower" references data word 0 in data block 10. The alias can be used just like a normal S7 variable on the OPC interface. Range of values: Length maximum 32 characters permitted characters: a-z A-Z 0-9 $ _ (underscore) & (), ANSI > 127 S7Variable Internally, the OPC server replaces the variable name of the alias with this S7 variable.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

193

Configuration Using Files

8.4.4 Settings for S7 Messages

To pass on S7 messages to the OPC Alarms & Events clients, the severity of the event is required as the event parameter. This information is, however, not supported by the protocol and is not contained in the S7 messages themselves. The following table describes the section for settings for S7 messages expected via an S7 connection. Entry 3rd connection section [Connection|VFD|CP(Severities)] e.g. [AG1|VFD1|CP_L2_1:(Severities)] DefaultScan Meaning S7 message severities specified for this connection The section name is made up of the Connection name and "(Severities)". Range of values: 1 <= n <= 1000 Severity for scan messages for which no explicit severity was specified

Default 300
DefaultAlarm Range of values: 1 <= n <= 1000 Severity for scan messages for which no explicit severity was specified Default 500 This section contains any number of severity settings for individual S7 messages. S7 scan message ID546 has severity 200 S7 alarm message ID333 has severity 900 Either Scan (S7 scan message) Alarm (S7 alarm message) S7 ID of the message, range of values 0 <= NN <= 2^32 - 1 Severity, range of values 1 <= n <= 1000

MessageNN=Severity e.g. Scan456=200 Alarm333=900 Message

NN Severity

194

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.4.5 Configuration of the S7 Demo Connection

Introduction

For demonstrations, for testing, or during development it is useful to be able to operate the S7-OPC server without additional hardware. For this reason, the S7-OPC server provides the option of using simulated S7 variables in a demo connection via the OPC interface. The demo connection can be activated by the configuration program or using the "UseDemoCon parameter in the "PROTOCOL section of the configuration file. This demonstration connection always has the name DEMO. Make sure that no other connection with this name exists in your network configuration. The demonstration connection contains the objects E, A, PE ,PA ,M and data block 10. Variables can be created using alias definitions.

Requirements

Name

Entry [DEMO(Aliases)] Alias=S7Variable e.g. Motor=AB0 Heatingpower=DB10,W0 Alias

Meaning Aliases predefined for the demo connection. This section contains any number of alias definitions. The symbolic name "Motor" references output byte 0; the name "Heatingpower" references data word 0 in data block 10. The alias can be used just like a normal S7 variable on the OPC interface. Range of values: Length maximum 32 characters permitted characters: a-z A-Z 0-9 $ _ (underscore) & (), ANSI > 127

S7Variable

Internally, the OPC server replaces the variable name of the alias with this S7 variable.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

195

Configuration Using Files

8.5

FMS Protocol
Editing the configuration file for the FMS protocol becomes necessary in the following situations: when you want to change the handling of the object dictionary for a connection. As default, a short object dictionary is loaded. when you want to change connection parameters when you want to change variable definitions or create aliases, when you want to configure the server connection or when you want to configure the demo connection

Overview

File Location

The file location for the configuration file of the FMS-OPC server set during installation is as follows:

<installationpath> \ OPC2.NT \ binFMS \ SCoreFMS.txt

196

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.5.1 General Protocol Configuration

General Protocol Configuration

The following table shows the parameters for configuring the general properties of the FMS-OPC server.

Entry Section [PROTOCOL]

Meaning The general protocol settings are made in this section. You can also make parameter settings for the trace of the underlying protocol software (SAPI-FMS). Selectable SAPI-FMS Mini-DB parameter, see SAPI documentation Default 20 (set by the configuration program) Selectable SAPI-FMS Mini-DB parameter, see SAPI documentation Default 32 SAPI-FMS trace parameters are set Default 0 Selectable SAPI-FMS trace parameter, see SAPI documentation. The numeric values corresponding to the constants in the SAPI header files must be entered. This value specifies how quickly the job waiting list is checked through for pending jobs. Default 100 ms (is set as "Request Cycle" by the configuration program) 1 The FMS-OPC server logs on at all available VFD|CP pairs. Since the search for VFD|CP pairs in particular can take some time, the VFD|CP pairs that are actually required should be set using the configuration program. 0 The FMS-OPC server logs on only at the VFD|CP pairs specified in the UseOnlyThisVFD parameter. Default: 1 (set by the configuration program)

FMS_MINI_DB_SEQ_REPEAT_CNT

FMS_MINI_DB_OD_NAME_LENGTH

ConfigProtocolTrace FMS_MINI_DB_TRACE_TARGET FMS_MINI_DB_TRACE_SELECT FMS_MINI_DB_TRACE_DEPTH FMS_MINI_DB_TRACE_FILENAME CycleTime

UseAllAvailableVFD

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

197

Configuration Using Files

Entry UseOnlyThisVFD

Meaning VFD|CP pairs at which the FMS-OPC server logs on. Several pairs are separated by commas. Caution: The last VFD|CP pair must be terminated by a comma. Example: UseOnlyThisVFD=VFD1|CP_L2_1:,VFD2|CP_L2_2:, (set by the configuration program) 1 The FMS-OPC server generates a simulation connection with which variable access can be simulated without a functioning protocol. 0 No simulation connection is provided. Default 0 (set by the configuration program) >0 The FMS-OPC server sends an fms_receive() call to the protocol cyclically. This is intended to eliminate protocol bottlenecks. 0 The FMS-OPC server only sends an fms_receive() call to the protocol when it receives a WM_SINEC message from the driver. Default 1000 ms 0 A timeout error is generated if the read OD job cannot be executed in the timeout time. 1 If a job for reading the OD cannot be executed because there is another OD job pending on another connection, the job is delayed until it can be executed. This does not cause a timeout error. Default 1

UseDemoConn

CycleNet

WaitMultipleOD

198

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.5.2 Connection-Specific Configuration

Overview

Each FMS connection has up to 3 sections in the configuration file. In the first section, connection-specific parameters are configured, in the second section variables can be predefined and in the third section aliases can be defined for variables. The configuration is evaluated when the FMS-OPC server starts up. The following table describes the connection-specific configuration parameters.

Entry 1st connection section [Connection|VFD|CP] e.g. [AG1|VFD1|CP_L2_1:] FMS_MINI_DB_INIT_REQ_PASSWORD FMS_MINI_DB_INIT_REQ_ACCESS_GR OUPS FMS_MINI_DB_INIT_RSP_PASSWORD FMS_MINI_DB_INIT_RSP_ACCESS_GRO UPS FMS_OD

Meaning Connection-specific parameters, the section names correspond to the connection names.

SAPI-FMS parameter set at the client end during connection establishment, refer to the SAPI documentation (for example for passwords).

1 Following connection establishment, the object dictionary is read by the partner and the variables it contains are evaluated. Since reading the object dictionary puts a considerable load on the network and delays the connection establishment, whenever possible this should be omitted and local object dictionaries used. 0 No object dictionary is read from the partner. Caution: If no object dictionary is read, access to variables on this connection is only possible when a local object dictionary exists or variables are configured in the [connection(variables)] section of the text database. Default 1

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

199

Configuration Using Files

Entry FMS_MINI_DB_OD_FORMAT

Meaning 0 A short object dictionary is read from the partner. 1 A long object dictionary is read from the partner. The long object dictionary contains additional information such as the variable name and access rights. The long object dictionary can only be read when the connection configuration is suitable. Default 0

FMS_OD_LOCALFILE InitiateReq

Path and file name of the local object dictionary. 0 The connection is never established actively 1 The connection is established actively when the partner device is accessed. 2 The connection is always established actively regardless of its use.

Default 1
AcceptInitiateInd 1 A connection establishment request from the partner is always accepted. 2 The connection establishment request of the partner is not accepted, the FMS-OPC server can, however, attempt to establish the connection to the partner itself.

Default 1
AbortConnectionAfter 0 The FMS-OPC server never terminates a connection itself (except when the FMS-OPC server is closed down)

n>0 The FMS-OPC server terminates a connection automatically after n ms after the last use of the connection.
Default 0 Timeout Error monitoring time: If a pending job cannot be processed within this monitoring time, the connection is reset and the job is acknowledged with an error.

Default 15000 ms

200

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.5.3 Variable Definition

Overview

The following section of the configuration file allows the definition of the FMS variables valid for this connection. For access to variables, the FMS protocol requires information about the properties of the variables, for example, data type, access rights etc. Variables of a connection that are required often can be predefined in this section so that, for example, the data type is known prior to connection establishment. An alternative to defining variables in this section is the use of a local object dictionary. The following table describes the parameters for variable definition.

Entry 2nd connection section [Connection|VFD|CP(Variables)] e.g. [AG1|VFD1|CP_L2_1:(Variables)] Name=Index|AccessRights|Type e.g. NAME100=100|RW|boolean NAME101=101|RW|integer8|NAME102=10 2|RW|integer16|NAME103=103|RW|integer 32 NAME104=104|RW|unsigned8 NAME105=105|RW|unsigned16 Power=106|RW|unsigned32 Temperature=107|RW|float NAME108=108|RW|vstring5 NAME109=109|RW|bstring8 NAME112=112|RW|integer8[4] NAME119=119|RW|ostring5[3] NAME120=120|RW|{integer8|float|vstring3} |

Meaning Variables predefined for this connection. The section name consists of the connection name and the additional part "(Variables)". This section contains any number of variable definitions Boolean 1 byte integer 2 bytes integer 4 bytes integer 1 byte unsigned integer 2 bytes unsigned integer 4 bytes unsigned integer 4 bytes floating point Character string 5 characters Bit string 8 bits Array of 4 integers Array of 3 octet strings with a length of 5 bytes Structure with integer, floating point and character string with 3 characters Structures can have a maximum of 10 components. FMS-Date FMS-TimeOfDay

NAME130=130|RW|fmsdate NAME131=131|RW|fmstimeofday4 FMS-TimeDifference NAME132=132|RW|fmstimedifference4 FMS-TimeOfDay (with days from 01.01.1984) NAME133=133|RW|fmstimeofday6 NAME134=134|RW|fmstimedifference6 FMS-TimeDifference (with days from 30.12.1899)

The individual elements of the variable definition must be separated with the pipe character '|' and

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

201

Configuration Using Files

Entry Name

Meaning must not contain blanks. Name in the long object dictionary Range of values: Length maximum 32 characters, however not longer than defined in the FMS_MINI_DB_OD_NAME_LENGTH parameter in the [PROTOCOL] section. Permitted characters: a-z A-Z 0-9 $ . (period) _ (underscore), ANSI >127

Index AccessRights Type

FMS variable index, must be higher than 15. R means read access, W means write access, RW means read and write access. FMS types: The string types vstring, ostring, bstring, fmstimeofday and fmstimedifference require additional length information, with bstring this is always a multiple of 8. Arrays require the number of array elements in square brackets, structures can only contain simple data types in the braces (in other words no arrays or structures).

202

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.5.4 Definition of Symbolic Names

Defining Aliases

The third section of the configuration file allows the definition of symbolic names for a valid FMS variable. An alias is a purely textual substitute for an otherwise valid FMS variable name or FMS variable index. Nesting of aliases is not supported, in other words an alias must always refer directly to a valid FMS variable. The following table describes the section for defining aliases.

Entry 3rd connection section [Connection|VFD|CP(Aliases)] e.g. [AG1|VFD1|CP_L2_1:(Aliases)] Alias=FMSVariable e.g. Motor=100 Heatingpower=Power Alias

Meaning Predefined aliases for this connection. The section name is made up of the connection name and the additional "(Aliases)". This section contains any number of alias definitions. The symbolic name "Motor refers to FMS Index 100, the "Heatingpower name refers to the FMS name "Power". The alias can be used just like a normal FMS variable on the OPC interface. Range of values: Length maximum 32 characters permitted characters: a-z A-Z 0-9 $ _ (underscore) & (), ANSI > 127

FMSVariable

Internally, the OPC server replaces the variable name of the alias with this FMS variable.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

203

Configuration Using Files

8.5.5 Configuration of the FMS Server Connection

Introduction

The FMS-OPC server can also be operated as an FMS server as well as an FMS client. Via an FMS server connection, the FMS-OPC server provides variables that can be accessed by other FMS devices. To be able to act as an FMS server, the OPC server must be started with the help of an OPC client (for example OPC Scout). Each FMS VFD|CP pair implicitly has one server connection. All the communications partners of a VFD|CP pair can access the variables defined on the server connection via the communication system. The variables of the server connection are addressed like normal FMS variables on the OPC interface of the FMS-OPC server. Just like a normal FMS connection, the server connection also contains three configuration sections. The name of the connection section is made up of the name of a VFD|CP pair. In this section, a symbolic name can be defined for the server connection that is then used in further sections.

Configuration

Entry 1st connection section [|VFD|CP] e.g. [|VFD1|CP_L2_1:] Server

Meaning General server parameters The connection name of the server connection is empty unless otherwise configured, in other words it consists only of the VFD and CP name. Activating the server connection 1 The VFD-specific server connection is created. 2 The VFD-specific server connection is not created.

Default 1
ServerConnectionName The server connection can be assigned a connection name. This must be different from the FMS connection name of this VFD. If a connection name is entered here, all the names of the sections are changed correspondingly.

Default empty

204

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

Entry 2nd connection section [|VFD|CP(Variables)] e.g. [|VFD1|CP_L2_1:(Variables)]

Meaning Contains defined variables for the server connection. If a name is entered in "ServerConnectionName" in the 1st connection section, this name must precede the entries here. Example: [MyServer|VFD1|CP_L2_1:(Variables)] This section contains any number of variable definitions

Name=Index|AccessRights|Type|Initialvalue e.g. 100=100|RW|boolean|-1 101=101|RW|integer8|-123 102=102|RW|integer16|-12345 103=103|RW|integer32|-1234567 104=104|RW|unsigned8|234 105=105|RW|unsigned16|23456 Power=106|RW|unsigned32|2345678 Temperature=107|RW|float|1,345 108=108|RW|vstring5|"abcde" 109=109|RW|bstring8|1.0.0.1.1.0.0.0 112=112|RW|integer8[4]|{10|20|30|40} 119=119|RW|ostring6[3]|{00.01.02.03.04.0 5|40.41.42.43.44.45|d0.d1.d2.d3.d4.d5} 120=120|RW|{integer8,float,vstring3}|{55|3|5|"xyz"} 130=130|RW|fmsdate|23:59:59 01.01.1999 131=131|RW|fmstimeofday4|12:00:00 132=132|RW|fmstimedifference4|01:10:22 133=133|RW|fmstimeofday6|17:12:59 01.01.1985 134=134|RW|fmstimedifference6|17:12:45 01.01.1901

Boolean 1 byte integer 2 bytes integer 4 bytes integer 1 byte unsigned integer 2 bytes unsigned integer 4 bytes unsigned integer 4 bytes floating point Character string 5 characters Bit string 8 bits Array of 4 integers Array of 3 octet strings with a length of 6 bytes Structure with integer, floating point and character string with 3 characters FMS date FMS time of day FMS time difference FMS time of day (with days from 01.01.1984) FMS time difference (with days from 30.12.1899) Structures can have a maximum of 10 components. The individual elements of the variable definition must be separated with the pipe character '|' and must not contain blanks (exception: initial value of a vstring).

Name Index AccessRights

Name in the long object dictionary FMS variable index, must be higher than 15. R W Read access Write access

RW Read and write access. The access rights refer only to access by the communications partner to this variable via FMS connections. Read and write access to these variables via the OPC interface is always possible.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

205

Configuration Using Files

Entry Type

Meaning FMS types: The string types vstring, ostring, bstring, fmstimeofday and fmstimedifference require additional length information, with bstring this is always a multiple of 8. Arrays require the number of array elements in square brackets, structures can only contain simple data types in the braces (in other words no arrays or structures). The initial value must always correspond to the particular data type. All initial values of arrays or structures must be enclosed in braces and be separated by the pipe symbol "|". The initial value is optional but should always be used.

Initialvalue

Entry 3rd connection section [|VFD|CP(Aliases)] e.g. [|VFD1|CP_L2_1:(Aliases)] Alias=FMSVariable e.g. Motor=100 Heatingpower=Power

Meaning Aliases predefined for the server connection.

This section contains any number of alias definitions. Alias Motor references FMS index 100. Alias Heatingpower references FMS name Power. The alias can be used just like a normal FMS variable on the OPC interface. On the OPC interface, the occurrence of the alias is replaced by this FMS variable.

Alias FMSVariable

206

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.5.6 Configuration of the FMS Demo Connection

Introduction

For demonstrations, for testing, or during development it is useful to be able to operate the FMS-OPC server without additional hardware. For this reason, the FMS-OPC server has the option of defining variables in a demo connection and using these simulated FMS variables via the OPC interface. The demo connection can be activated by the configuration program or using the "UseDemoCon parameter in the "PROTOCOL section of the configuration file. This demonstration connection always has the name DEMO. Make sure that no other connection with this name exists in your network configuration. Just like a normal FMS connection, the demo connection also has three configuration sections.

Requirements

Name

Entry 1st connection section [DEMO] Entry 2nd connection section [DEMO(Variables)] Name=Index|AccessRights|Type|Initialvalue see Server Connection (8.5.5) Name Index AccessRights

Meaning Connection-specific parameters. No parameters are defined within this section. Meaning Variables defined for the demo connection.

This section contains any number of variable definitions. see Server Connection Name in the long object dictionary FMS variable index, must be higher than 15. R W Read access Write access

RW Read and write access. Read and/or write access to these variables via the OPC interface is possible depending on the access rights. Type FMS types, the string types vstring, ostring and bstring also require length information. Arrays require the number of array elements in square brackets, structures in braces must only contain simple data types (in other words no arrays or structures).

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

207

Configuration Using Files

Initialvalue

The initial value must always correspond to the particular data type. All initial values of arrays or structures must be enclosed in braces and be separated by the pipe symbol "|". The initial value is optional but should always be used. Meaning Aliases predefined for the demo connection. This section contains any number of alias definitions. Alias Motor references FMS index 100. Alias Heatingpower references FMS name Power. The alias can be used just like a normal FMS variable on the OPC interface. On the OPC interface, the occurrence of the alias is replaced by this FMS variable.

Entry 3rd connection section [DEMO(Aliases)] Alias=FMSVariable e.g. Motor=100 Heatingpower=Power

Alias FMS Variable

208

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.5.7 Creating a Local Object Dictionary

Introduction

The defined variables are contained in an object dictionary of an FMS server. Normally, FMS devices can make this object dictionary available to the partner device via the communication system. An FMS client requires information from the object dictionary (for example defined indexes and access rights) to access variables. Depending on the partner device, loading an object dictionary can take a considerable amount of time. If high indexes were configured within an object dictionary, the connection establishment can be considerably delayed. There is also a significant increase in load on the network. The situation is made worse since the communication software cannot query the object dictionaries of different devices at the same time. If a system consists of several FMS servers that are accessed by the PC as FMS client, the startup phase of the system can take an extremely long time and it is even possible that no reliable connection establishment is possible. For this reason, the FMS-OPC server provides the option of using an object dictionary loaded at a different time and maintained in local storage.

Local Object Dictionary

Creation

To create a local object dictionary, you require the ODUPLOAD.EXE program. This is installed in the same folder as the configuration file. <installationpath> \ OPC2.NT \ binFMS \ ODUPLOAD.EXE To start the program, open an MS DOS box with the system prompt and change to the relevant folder with "cd <installationpath>opc2.nt \ binFMS. Start the program with the following syntax:

odupload "conn|vfd|cp" filename [odformat [timeout]]


The "conn" parameter identifies the connection; "vfd" and "cp" specify the CP|VFD pair. The "filename parameter specifies the path and file name of the local object dictionary to be created. The optional parameter "odformat decides whether a long (value 1) or a short (0) object dictionary is requested. The standard value for this parameter is 0. With the "timeout parameter, the time is specified in milliseconds after which an error is detected. The standard value is 120000 for 2 minutes. Example: odupload "AG <1>|VFD <1>|CP_L2_1:" myconn.od 1 240000 Uses To allow the local object dictionary to be used for a connection, the path and file name of the created file must be entered as the value for the parameter "FMS_OD_LOCALFILE in the connection section. The "FMS_OD parameter must also be set to 0 to prevent the transfer of the object dictionary via the network.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

209

Configuration Using Files

8.6

Send/Receive Protocol
Editing the configuration file for the Send/Receive protocol becomes necessary in the following situations: when you want to use symbolic connection names in each variable name instead of specifying connection parameters completely. when you want to modify variable definitions or create aliases when you want to configure the demo connection

Overview

File Location

The file location for the configuration file for the SR-OPC server set during installation is as follows:

<installationpath> \ OPC2.NT \ binSR \ SCoreSR.txt

210

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.6.1 General Protocol Configuration

General Protocol Configuration

The following table shows the parameters for configuring the general properties of the SR-OPC server.

Entry Section [PROTOCOL] CycleTime

Meaning The general protocol settings are made in this section. This value specifies how quickly the job waiting list is checked through for pending jobs. Default 100 ms (set by the configuration program) Access points (devices) at which the SR-OPC server logs on. Several access points are separated by commas. Caution:The last access point must be terminated by a comma. Example: UseOnlyThisDevice=TCPIP:, CP_H1_1:,

UseOnlyThisDevice

UseDemoConn

1 The SR-OPC server generates a simulation connection with which variable access can be simulated without a functioning protocol. 0 No simulation connection is provided. Default 0 (set by the configuration program) Segmentation of the data buffer Range of values 512 4096 A change in the default maximum value is only required when you are operating a TF database of the SIMATIC NET TF communication protocol at the same time. The maximum value must be matched with the buffer pool of the TF database (PDU size setting in the COML TF configuration tool, refer to the TF documentation). Default 4096

BufferLength

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

211

Configuration Using Files

8.6.2 Connection Configuration for a Specific Access Point

Overview

Each access point used by the SR-OPC server has a section in the text database file in which connections to network partners including symbolic names can be predefined. The advantage of this is that when the configuration is changed, (for example changed Ethernet address on the communication partner) the address only needs to be changed at one central point if the symbolic name was also used by the OPC application in the SR variables.

The following table describes the configuration parameters for the access points:

Entry Access point section [Access point(Connections)] e.g. [CP_H1_1:(Connections)] Name=LocalTSAP,HostID,RemoteTSAP,ActiveFla g e.g.

Meaning Connection predefined for this access point. During operation, further connections can be used with suitable SR variable notations. This section contains any number of connection definitions.

Passive connection establishment, S5Receive=&PCPCPCPC,142.11.45.150,&RECVR TCPIP ECV,0 S5Send=FF.FF.FF.FF, 142.11.45.150,AA.AA.AA,1 Active connection establishment, TCPIP, as alternative TSAP S5Fetch=&PCPCPCPC,08.00.06.01.26.70,&PCPC Active connection establishment, ISO PC01,1 S5Write=&PCPCPCPC,08.00.06.01.26.70,&PCPC Active connection establishment, ISO PC02,1 S5ReceiveExp=&PCPCPCPC,08.00.06.01.26.70,& Passive connection establishment, ISO RECVREEX,0 S5SendExp=&PCPCPCPC,08.00.06.01.26.70,&SE Active connection establishment, ISO NDSEEX,1 The individual elements of the connection definition must be separated by commas and must not contain blanks. Name Symbolic connection name, Range of values: Length maximum 32 characters, permitted characters: a-z A-Z 0-9 $ _ (underscore) LocalTSAP Local TSAP, two notations are possible: 1. Hex Notation xx.xx.xx.xx.xx.xx.xx maximum 8 two-digit hexadecimal values separated by periods. 2. Alternative String Notation &TTTTTTTT preceding & symbol followed by a maximum of 8 printable characters. The comma must not be used. If you want non-printable characters or

212

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

Entry

Meaning commas in the TSAP name, you must use hexadecimal notation. Ethernet or TCP/IP address of the partner station. 1. Ethernet xx.xx.xx.xx.xx.xx exactly 6 two digit, hexadecimal values separated by periods. 2. TCP/IP yyy.yyy.yyy.yyy exactly 4 3-digit decimal values between 0 and 255 separated by periods. TSAP of the partner station, the notation is the same as for LocalTSAP. 0 Passive establishment, the partner establishes the connection 1 Active establishment, the partner waits for connection establishment

HostID

RemoteTSAP ActiveFlag

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

213

Configuration Using Files

8.6.3 Connection-Specific Configuration

Overview

Each SR connection has up to two sections in a text database file. The connection-specific parameters are configured in the first section, in the second section, aliases for variables can be defined. The configuration is evaluated when the SR-OPC server starts up. The following table describes the configuration parameters for the connections:

Entry 1st connection section [Connection Name|Address|Access Point] e.g. [LocalClient||TCPIP:] [|&TCP2,142.11.45.150,&TCP1,1|TCPIP:] Conn_persistance_count

Meaning Connection-specific parameters If no symbolic name exists for a connection, this must be used, otherwise the symbolic address. They must not both be used at the same time. SR parameter of the SR variable field 1, see SR documentation Default 0

Conn_abort_timeout

SR parameter of the SR variable field 1, see SR documentation Default 0

Conn_negot_options

SR parameter of the SR variable field 1, see SR documentation

Default 0x0000
AbortConnectionAfter 0 The SR-OPC server never terminates a connection itself (except when the SR-OPC server is closed down) n > 0 The FMS-OPC server terminates a connection automatically n ms after the last use of the connection. Default 0 S5Access Controls the access rights to variables for the "FETCH" and "SEND with WRITE function" modes. By using this parameter, you can, for example, prevent a read job being requested on a SEND connection which would lead to a connection close by the partner. 0 S5 variables are not permitted on this connection. 1 S5 variables are permitted only with read access 2 S5 variables are permitted only with write access

Default 0 (If direct access to S5 variables is required

214

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

Entry

Meaning

with FETCH or SEND with WRITE function, this parameter must be set.)
Initiate Controls the point in time at which a connection is established 1 The connection is established actively where necessary when the partner is accessed 2 The connection is established actively as soon as the connection is closed. (For example when the program starts up)

Default 1
Timeout Error monitoring time: If a pending job cannot be processed within this monitoring time, the connection is reset and the job is acknowledged with an error.

Default 15000 ms
LenSend Preset size of the default send buffer During operation, further additional send buffers of any length (maximum 65535 bytes) can be used.

Default 256
LenSendExp Preset size of the default send buffer for high priority data. During operation, additional send buffers of any length (max. 16 bytes) can be used.

Default 16

Entry 2nd connection section [Connection Name|Address|Access Point(Aliases)] e.g. [LocalClient||TCPIP:(Aliases)] [|&TCP2, 142.11.45.150,&TCP1,1| TCPIP:(Aliases)] Alias=SRVariable e.g. Motor=Receive,w0 Heatingpower=Send10,dword3

Meaning Predefined aliases for this connection. An alias is a purely textual substitute for an otherwise valid SR variable name. Nesting of aliases is not supported, in other words an alias must always refer directly to a valid SR variable of this connection. This section contains any number of alias definitions.

Alias motor refers to a word in the receive block. Alias heatingpower refers to a double word within a send buffer.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

215

Configuration Using Files

Entry Alias

Meaning The alias can be used like a normal SR variable on the OPC interface. Range of values: Length maximum 32 characters permitted characters: a-z A-Z 0-9 $ _ (underscore) & (), ANSI > 127

SRVariable

On the OPC interface, the occurrence of the alias is replaced by this SR variable.

216

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.6.4 Configuration of the Demo Connection

Introduction

For demonstrations, testing, or development it is useful to be able to run the SR-OPC server without additional hardware. The SR-OPC server therefore has the option of defining variables in a demo connection and using these simulated SR variables via the OPC interface. The demo connection can be activated by the configuration program or using the "UseDemoConn parameter in the "PROTOCOL section of the configuration file. This demonstration connection always has the name DEMO. Make sure that no other connection with this name exists in your network configuration. Apart from the SR variables that are always present, the demo connection has the following variables: RECEIVE receiveexp send sendexp Also the simulation of a direct S5 access. The following areas are simulated: E A P M DB10 (Inputs, 4 bytes) (Outputs, 4 bytes) (Peripheral I/Os, 8 bytes) (Flag, 256 bytes) (Data block number 10, 256 bytes). Meaning Connection-specific parameters, this section is not currently supported. Meaning Aliases predefined for the demo connection. This section contains any number of alias definitions. Alias motor refers to a word in the receive block. Alias heatingpower refers to a double word within a send buffer. The alias can be used like a normal SR variable on the OPC interface. Range of values: Length maximum 32 characters permitted characters: a-z A-Z 0-9 $ _ (underscore) & (), ANSI > 127 On the OPC interface, the occurrence of the alias is replaced by this SRvariable.

Requirements

Name

Default Variables

Entry 1st connection section [DEMO] Entry 2nd connection section [DEMO(Aliases)] Alias=SRVariable e.g. Motor=Receive,w0 Heatingpower=Send10,dword3 Alias

SRVariable

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

217

Configuration Using Files

8.7

Send/Receive Protocol for PROFIBUS (FDL)


You must edit the configuration file for the Send/Receive protocol in PROFIBUS (FDL) in the following situations: when you want to use symbolic connection names in each variable name instead of specifying connection parameters completely. when you want to modify variable definitions or create aliases when you want to configure the demo connection

Overview

File Location

The file location for the configuration file for the FDL-OPC server set during installation is as follows:

<installation path> \ OPC2.NT \ binFDL \ SCoreFDL.txt

218

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.7.1 General Protocol Configuration

General Protocol Configuration

The following table shows the parameters for configuring the general properties of the FDL-OPC server.

Entry Section [PROTOCOL] CycleTime

Meaning The general protocol settings are made in this section. Default 100 ms. This value specifies how quickly the job waiting list is checked through for pending jobs.

UseOnlyThisDevice

Access points (devices) at which the FDL core logs on. Several access points are separated by commas. Caution: The last access point must be terminated by a comma. Example: UseOnlyThisVFD=CP_L2_1:,CP_L2_2:,

UseDemoConn

0 Default. No simulation connection is provided. 1 The FDL core generates a simulation connection with which item access can be simulated without a functioning protocol.

AutoDefineConnection

0 Default 1 The FDL core server detects all connected partners when it is started up and creates a connection for each of them via the default SAPs. Since these connections are entered in the text database, the core server resets this flag to 0 again after it has been used once.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

219

Configuration Using Files

8.7.2 Connection Configuration for a Specific Access Point

Overview

Each FDL access point has a further section in the text database file in which connections to network partners including symbolic names can be predefined. The advantage of this is that when the configuration is changed, (for example changed PROFIBUS station address on the communication partner) the address only needs to be changed at one central point if the symbolic name was also used by the OPC application in the FDL items.

The following table describes the configuration parameters for the connections:

Entry Access point section [Access point(Connections)] e.g. [CP_L2_1:(Connections)] Name=LocalSAP,STATION,RemoteSAP e.g. PLC1=15,11,14 STATION_10=255,10,255

Meaning Connection predefined for this access point. During runtime, further connections can be created using suitable FDL item notations. This section contains any number of connection definitions.

The individual elements of the connection definition must be separated by commas and must not contain blanks. Name Symbolic connection name, Range of values: Length maximum 32 characters. Permitted characters: a-z A-Z 0-9 $ _ (underscore) LocalSAP Local SAP Range of values: 0-63, 255 STATION RemoteSAP Profibus station address SAP of the partner station. Range of values: 0-126,127

220

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.7.3 Connection-Specific Configuration

Overview

Each FDL connection has up to two sections in a text database file. The connection-specific parameters are configured in the first section, in the second section, aliases for FDL items can be defined. The configuration is evaluated when the FDL core starts up.

The following table describes the configuration parameters for the connections: Entry 1st connection section [Connection Name|Address|Access Point] e.g. [PLC1|CP_L2_1:] [|255,10,255|CP_L2_1:] Timeout Meaning Connection-specific parameters If no symbolic name exists for a connection, this must be used, otherwise the symbolic address. They must not both be used at the same time. Default 15000 ms Error monitoring time: If a pending job cannot be processed within this monitoring time, the connection is reset and the job is acknowledged with an error. MaxSendCredits Default 3 Maximum number of parallel send jobs on this connection MaxRetryNoRessources Default 5 Maximum number of repeated send attempts if the partner is temporarily unable to receive due to a lack of resources Conn_negot_options Default 0x0000 FDL parameter of the FDL variable field 1, see FDL documentation LenSendSDA Default 244 or 246 (with default SAPs) Preset size of the default send buffer for acknowledged sending. During operation, further additional send buffers of any length (maximum 244 or 246 bytes) can be used. LenSendSDN Default 244 or 246 (with default SAPs) Preset size of the default send buffer for unacknowledged sending. During operation, further additional send buffers of any length (maximum 244 or 246 bytes) can be used. Entry Meaning

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

221

Configuration Using Files

2nd connection section [Connection Name|Address|Access Point(Aliases)] e.g. [PLC1|CP_L2_1:] [|255,10,255|CP_L2_1:]

If no symbolic name exists for a connection, this must be used, otherwise the symbolic address. They must not both be used at the same time. Predefined aliases for this connection. An alias is a purely textual substitute for an otherwise valid FDL item. Nesting of aliases is not supported, in other words an alias must always refer directly to a valid FDL item of this connection.

Alias=FDLItem e.g. Motor=Receive,w0 Heatingpower=Send10,dword3 Alias

This section contains any number of alias definitions. Alias motor refers to a word in the receive block. Alias heatingpower refers to a double word within a send buffer. The alias can be used just like a normal FDL item on the IVar interface. Range of values: Length maximum 32 characters permitted characters: a-z A-Z 0-9 $ _ (underscore) & (), ANSI > 127

FDLItem

On the Ivar interface, the occurrence of the alias is replaced by this FDL item.

222

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.7.4 Configuration of the FDL Demo Connection

Overview

For demonstrations, for testing, or during development it is useful to be able to operate the FDL-OPC server without additional hardware. For this reason, the FDL-OPC server has the option of defining variables in a demo connection and using these simulated FDL variables via the OPC interface.

Requirements

The demo connection is activated when the "UseDemoConn" parameter is set to 1 in the section "[PROTOCOL]".

Name

This demonstration connection always has the name DEMO. Make sure that no other connection with this name exists in your network configuration.

Entry 1st connection section [DEMO] Entry 2nd connection section [DEMO(Aliases)] Alias=FDLItem e.g. Motor=Receive,w0 Heatingpower=Send10,dword3

Meaning Connection-specific parameters, this section is not currently supported. Meaning Aliases predefined for the demo connection. The section contains any number of alias definitions, see above. Alias motor refers to a word in the receive block. Alias heatingpower refers to a double word within a send buffer.

The demo connection always contains the following FDL variables: Receive Send

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

223

Configuration Using Files

8.7.5 Dynamic Connections

Managing Connections

The FDL core can create and manage new connections during operation using an FDL variable with a suitable connection definition using a symbolic address via the IVar interface, for example: FDL:[|255,33,255|CP_L2_1:]receive The notation of the symbolic connection address was described above.

224

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.8

DPS Protocol
You must edit the configuration file for the DPS protocol in PROFIBUS (DPS) in the following situations: when you want to use symbolic connection names in each variable name instead of specifying connection parameters completely. when you want to modify variable definitions or create aliases when you want to configure the demo connection

Overview

File Location

The file location for the configuration file for the DPS-OPC server set during installation is as follows:

<installation path> \ OPC2.NT \ binDSP \ SCoreDPS.txt

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

225

Configuration Using Files

8.8.1 General Protocol Configuration

General Protocol Configuration

The following table shows the parameters for configuring the general properties of the DPS-OPC server.

Entry Section [PROTOCOL] CycleTime

Meaning The general protocol settings are made in this section. Default 20 ms This value specifies how quickly the job waiting list is checked through for pending jobs.

UseOnlyThisBoard

Default DPSONLINE, Board at which the DPS core logs on.

UseDemoBoard

0 Default No simulation connection is made available. 1 The DPS core generates a simulation connection with which slave access can be simulated without a functioning protocol. The slaves available in the demo connection can be configured.

CSWatchThread

0 Default. Debug monitoring deactivated. For debugging purposes; not intended to be documented for the user. 1 The DPS core creates the files WatchCS.ini and WatchCS2.ini cyclically in the Windows NT root folder. These files contain information about the most important internal critical sections.

ClearAlarms

Default 60000 ms Time after which a pending protocol alarm is removed from the internal waiting list if it cannot be passed on to an IAlarm client. Alarms are not currently supported and this parameter should therefore not be documented for the user.

226

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.8.2 Connection-Specific Configuration

Overview

Each DPS connection has up to 2 sections in the configuration file. The connection-specific parameters are configured in the first section, in the second section, aliases for items can be defined. The configuration is evaluated when the DPS core starts up; Softnet DP slave currently only supports the simultaneous operation of a single slave.

Generally, the user must modify almost all board-specific configurations since these largely determine the behavior of the slave.

The following table contains the configuration parameters for the board.

Entry 1st Board Section [Boardname] e.g. [CP_L2_1:] GSD

Meaning Logon parameters set for this board.

Standardized PROFIBUS GSD file that identifies the slave. The core server, however, only uses the information PNO_Ident and the first module description. PROFIBUS station address for the slave Baudrate used, the following values are possible: Baudrate=BD_9K6 Baudrate=BD_19K2 Baudrate=BD_93K75 Baudrate=BD_187K5 Baudrate=BD_500K Baudrate=BD_1M5 Baudrate=BD_3M Baudrate=BD_6M Baudrate=BD_12M Baudrate=BD_45K45

StationAddr Baudrate

AutoOnline

1 Default: The core server switches the slave online when it starts up. 0 The core server does not switch the slave online when it starts up, the slave is then only ready for operation when the item &devicestate() is written.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

227

Configuration Using Files

Entry 2nd Board Section [Boardname(Aliases)] e.g. [DPSONLINE(Aliases)]

Meaning Predefined alias for this board An alias is a purely textual substitute for an otherwise valid DPS item. Nesting of aliases is not supported, in other words an alias must always refer directly to a valid DPS item of the board. This section contains any number of alias definitions.

Alias=DPSItem

e.g. Motor=SlaveM2EX0.3 Heatingpower=SlaveAW3 Alias

Alias Motor input bit of a slave Alias Heatingpower refers to an output word of a slave. The alias can be used just like a normal DPS item on the IVar interface. Range of values: Length maximum 32 characters permitted characters: a-z A-Z 0-9 $ _ (underscore) . (period) & (), ANSI > 127

DPSItem

On the Ivar interface, the occurrence of the alias is replaced by this DPS item.

228

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Configuration Using Files

8.8.3 Configuration of the DPS Demo Connection

Introduction

For demonstrations, for testing, or during development it is useful to be able to operate the DPS-OPC server without additional hardware. For this reason, the DPS-OPC server has the option of defining variables in a demo connection and using these simulated DPS variables via the OPC interface.

Requirements

The demo board is activated when the "UseDemoBoard" parameter is set to 1 in the section "[PROTOCOL]".

Name

The demo board always has the name "DEMO".

Sample Slaves

Due to the complicated structure of the slave configuration data, this section should not be made public to the user but a text database containing several useful sample slaves should be made available.

Entry 1st Demo Board Section [DEMO] GSD

Meaning Connection-specific parameters, this section is not currently supported. Standardized PROFIBUS GSD file that identifies the slave. The core server DPS, however, uses only the first module description. Meaning Predefined aliases for the demo board. An alias is a purely textual substitute for an otherwise valid DPS item. Nesting of aliases is not supported, in other words an alias must always refer directly to a valid DPS item of the demo board.

Entry 3rd Demo Board Section [DEMO(Aliases)]

Alias=DPSItem e.g. Motor=SlaveM2EX0.3 Heatingpower=SlaveAW3

This section contains any number of alias definitions, see above. The "Motor" alias references an input bit of a slave. Alias "Heatingpower" references an output word of a slave.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

229

DCOM with the OPC Server for SIMATIC NET

230

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

DCOM with the OPC Server for SIMATIC NET

DCOM with the OPC Server for SIMATIC NET

With Windows NT, version 4.0 or higher, the client can run COM objects on another computer. This functionality that allows the COM objects of an application to be distributed on several computers is known as DCOM (Distributed COM). This chapter explains how to set up the OPC server for SIMATIC NET to operate with the DCOM functionality.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

231

DCOM with the OPC Server for SIMATIC NET

9.1

Introduction to DCOM
COM objects such as the OPC server do not necessarily need to be on the same computer as the client. With DCOM (Distributed COM), a client can create and use COM objects both on its own system and on other computers. This allows the components of an application to be distributed within a network.

What is DCOM?

COM Library

A client does not address an object directly to start it or use it but accesses the COM library. This is part of the operating system. The COM library manages information in the registry about the COM object known in the system.

The following schematic illustrates how a COM object is used on the local machine or on another computer.

OPC client

OPC server

COM library

Computer

OPC-Client OPC client

OPC server

COMCOM Bibliothek library Computer A Network

COM library Computer B

Transparency

For the client, the use of a COM object with DCOM or with local COM mechanisms is transparent. The operating system internal COM library manages the object and recognizes where the object should be created based on the object configuration.

232

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

DCOM with the OPC Server for SIMATIC NET

9.2

Configuring DCOM Operation


Before a client can use a COM object on another computer, the properties of the COM object must be configured on the client computer and on the remote computer. DCOM and the COM objects required on the computer are configured using the system program dcomcnfg from the "Windows\System32" folder. After starting the program, for example by entering "dcomcnfg" in the "Run" dialog (Start menu), three tabs are available for configuring DCOM:

Program "dcomcnfg"

Please note the following: If you lower the security settings, the system must be restarted to activate the changes. Caution: The settings listed in this description guarantee simple installation and startup of the DCOM protocol. Some of the security settings of Windows NT are reduced. To meet stricter security requirements, you must increase the settings according to the DCOM guidelines.

This text describes the situation in which exactly one client connects to an OPC server running on a different computer. If you want to use more than one OPC server from a client, please refer to the DCOM documentation.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

233

DCOM with the OPC Server for SIMATIC NET

Default Properties

In the "Default Properties" tab, you specify basic properties of DCOM. For DCOM operation with the OPC server within a workgroup (no domain server available for authentication) make the settings as shown. If a domain server can be used for authentication, the default authentication level can be set to "Connect" and the Default Impersonation Level to "Identify" for security reasons. For installation and startup, however, the settings shown below are also recommended for this mode.

Default Security

In the "Default Security" tab, you can specify the rights for DCOM operation. These settings make sure that only clients with the correct permissions can use the server. The following default permissions are relevant in conjunction with DCOM: Access permissions Launch permissions Configuration permissions These permissions can be set individually for each object and the default properties are then ignored.

234

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

DCOM with the OPC Server for SIMATIC NET

Access Permissions Launch Permissions Configuration Permissions Applications

The default access permissions for all COM objects specify which accounts are allowed to access the object; in other words call the methods and which accounts are explicitly denied access. The default launch permissions for all COM objects specify which accounts have the right to create the object and which accounts are explicitly denied this permission. The default configuration permissions specify which accounts can modify the information in the registry about COM objects; in other words can also install new objects on the computer. The "Applications" tab displays all the COM objects available on the computer. Here, you select a COM object you want to configure and open the configuration dialog by clicking the "Properties" button. The OPC server for SIMATIC NET is listed as "OPC.SimaticNET".

Select the object "OPC Server for SIMATIC NET"

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

235

DCOM with the OPC Server for SIMATIC NET

9.2.1 Configuration of the Server Computer

Different Configurations

The DCOM configuration for the computer with the OPC client differs from that of the computer with the OPC server: For the computer with the OPC client, you must set the computer in the network on which the server will be activated and the account for the server. For the computer with the OPC server, you must set the accounts that have the right to use the server. In addition to the special permissions in conjunction with OPC, the account of the user of the OPC servers must also have user permissions.

"Location" Tab

The "Location" tab is used to specify the computer on which the server is started. Since the configuration of the computer with the OPC server is described in this section, you must specify "Run application on this computer".

236

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

DCOM with the OPC Server for SIMATIC NET

"Identity" Tab

The settings made in the "Identity" tab specify the account to be accessed to check the permissions of the user of the object. Here, various settings are possible: Interactive user Launching user This user "Interactive User" The account of the currently logged on user is used. If, however, no user uses the computer, there is no interactive user and the COM object cannot be created. For server operation, use the setting "This user". "Interactive user" is the default setting for the OPC server for SIMATIC NET.

"The Launching User"

The account of the user that launched the OPC client is used. This user must then also have the required permissions; in other words, must be entered in the "Security" tab. The user must also have the default permissions entered for the group of users on this computer; in other words, must belong to the group of users. This mode must not be used with the OPC server for SIMATIC NET since the OPC server cannot be started more than once (by different users).

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

237

DCOM with the OPC Server for SIMATIC NET

This User

The account of a specified user is used. This user must have the required permissions; in other words, must be entered in the "Security" tab. The user must also have the default permissions entered for the group of users on this computer; in other words, must belong to the group of users. This setting must be used for the server mode of the OPC server for SIMATIC NET (no user logged on).

"Security" Tab

You specify the access permissions for the OPC server in the "Security" tab. For the three aspects relevant to COM objects, you can either use the default permissions or user-defined permissions for the selected COM object. When using the default permissions, the account entered in the "Identity" tab must have the required permissions in the settings for default security (default access permission, default launch permission). If you do not want a particular user to have all COM objects of the system available, you must configure user-defined permissions. To operate the OPC server, only the access permission and the launch permission need to be configured.

238

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

DCOM with the OPC Server for SIMATIC NET

Selecting Users

The users that are allowed to use the OPC server must be entered in the default access permissions. Several users have been entered as examples of the required permissions: Please note the following:

Workgroup Operation

Both on the server and on the client machine, the logons and therefore the information about permissions in the logon must exist on the other machine. Example: User "Alpha" is logged on at the computer with the server and "Beta" is logged on at the computer with the client user. For DCOM operation an account "Beta" is required on the server computer (with the same password as on the client machine) and an account "Alpha" is required on the client computer (same password). The use of a group with logons is advisable when using a domain. The information about permissions is then fetched from the domain server.

Type of access: Allow access

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

239

DCOM with the OPC Server for SIMATIC NET

Type of access: Allow launch

Access to registry: HKEY_CLASSES_ ROOT

240

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

DCOM with the OPC Server for SIMATIC NET

9.2.2 Configuration of the Client Computer

The application that will use the OPC server runs on the client computer. The OPC server itself is started on another computer when using DCOM, which is why there is no process for the OPC server visible in Windows NT Task Manager. The OPC server must nevertheless be registered on the client computer so that the COM library knows the required object and so that configuration is possible. You should also read the notes on client installation in the Installation Instructions.

For the computer with the OPC client, you must set the computer in the network on which the server will be activated and the account for the server.

"Location" Tab

The location of the server must be specified in this tab. For DCOM operation, only the check box "Run application on the following computer:" must be selected. Click "Browse" to locate the server computer.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

241

DCOM with the OPC Server for SIMATIC NET

"Identity" Tab

In the "Identity" tab, you specify which user account should be used for the client computer. For the client computer, it makes sense to specify the currently interactive user; in other words the logged on user.

"Security" Tab

The security settings should be made as they are configured on the server computer. Please note the following:

DCOM always uses the secure settings. If, for example "connect" and "anonymous" are set on the client and "none" and "identify" are set on the server, the combination "connect" and "identify" will be used for the DCOM protocol.

242

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

10

The OPC Custom Interface for Data Access

This chapter explains how the OPC Custom interface for Data Access is used. It also lists the interfaces and methods of the OPC customer interface. This is not a detailed interface description but contains supplementary information and notes relating specifically to SIMATIC NET.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

243

The OPC Custom Interface for Data Access

10.1 Versions of the OPC Interface


Introduction There is now an extended version of the OPC custom interface, specification 2.0. Version 2.0 supplements the existing OPC custom interface in several aspects particularly those simplifying the handling of asynchronous calls.

The interfaces of Version 1.0 of the OPC interface are completely upwards compatible with Version 2.0.

the OPC server for SIMATIC NET supports version 2.0 of the OPC Custom Interface.

244

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

10.2 Creating and Using an OLE Object in C/C++


Introduction The following sections illustrate step-by-step how you can call the methods of an instance of an OLE class in C++. Note the difference between the term class in OLE and in C++.

OLE Classes, C++ Classes

A Windows object is an instance of an OLE class. The term OLE class differs from the class in C++. A class in C++ is a type definition. An OLE class is, however, an object description and does not contain types.

Class Identification Code

Each OLE class can be identified uniquely by a 128 bit long identification code, the CLSID. This is used by the operating system for the unique assignment of a DLL or EXE file that implements this class. A client that wishes to use an object of a class requires only the CLSID.

ProgID

To simplify the identification of OPC servers, there is normally a readable name, the ProgID assigned in the CLSIDs. While a CLSID is always unique due to the algorithm for compilation, it is possible that a ProgID exists more than once. Just like the CLSID, the ProgID is specified by the vendor of an OPC server.

The following applies to the OPC server for SIMATIC NET for all protocols:

OPC.SimaticNET

Procedure

A COM object is created in five steps. Step 1 2 3 4 5 Description Initialize COM Query the CLSID Create an Object Call an OPC function Release the interfaces used

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

245

The OPC Custom Interface for Data Access

Step 1: Initialize COM

Before you can use the functions of COM, the COM library must be initialized with the following call: #include "opc.h" HRESULT r1; r1 = CoInitialize(NULL);

Step 2: Query the CLSID

If the name of an object is known, the CLSID can be queried using the OLE function CLSIDFromProgID. Example The following program section illustrates how to query the CLSID for the OPC server for SIMATIC NET: CLSID clsid; // Get the CLSID from the Name r1 = CLSIDFromProgID((L"OPC.SimaticNET"),&clsid);

Step 3: Create an Object

If a client wants to use an object, it transfers the CLSID to the operating system and requests an object instance. Regardless of where the server is located, the object request is always directed to COM. The CoCreateInstance function creates an object belonging to the required class. This function encapsulates several interim steps via the interface "IClassFactory". Generating objects using IClassFactory is more efficient if you want to create several objects of one class. Example The following lines show how an object of the class OPC server with reference to the IUnknown interface can be created: IUnknown * pOPCUnknown; r1 = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**)&pOPCUnknown );

246

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

Step 4: Call an OPC function

In this step, a method of the IOPCServer interface of the created object will be used to learn the status of the server. First, a pointer to the IOPCServer interface is made available via IUnKnown. Finally, the GetStatus method is called. Example The program shown below outputs the status of the server and the vendor information. If the GetStatus method is called successfully, the OPC server allocates the memory areas for the return information via the IMalloc interface. The user must release these memory areas again. IOPCServer *pOPCServer; IMAlloc *pIMalloc; OPCSERVERSTATUS *pss;

r1 = pOPCUnknown->QueryInterface(IID_IOPCServer, (void**)&pOPCServer); r1 = pOPCServer ->GetStatus(&pss); printf("Status.szVendorInfo = %ls\n", pss-> szVendorInfo); // Remember to release the memory returned by the method CoGetMalloc( 1, &pIMalloc); pIMalloc->Free(pss->szVendorInfo); pIMalloc->Free(pss);

Step 5: Release the interfaces used

Objects include reference counters to detect when the object is no longer required and can remove itself from memory. Each time the QueryInterface function is called, the reference counter is incremented. To release the object, the counter must be reset. Example Using the following commands, the reference counter for the interfaces IUnknown and IOPCServer is reset: pOPCServer->Release(); pOPCUnknown->Release(); pIMalloc->Release();

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

247

The OPC Custom Interface for Data Access

10.3 Further Information about the Interface Description for the OPC Custom Interface
Introduction A detailed interface description of the OPC interfaces is beyond the scope of this manual. This is supplied as a file along with this product as an original English document from the OPC Foundation. You will find the documents in the "DOC" folder in the product folder of the OPC servers for SIMATIC NET.

Structure of the Description

The following supplementary information about the interfaces lists the objects of OPC, their interfaces and the methods defined in these interfaces and points out particular characteristics of the OPC server for SIMATIC NET.

Return Values

All the listed methods return a result of the type HRESULT.

Overview of the Objects and Interfaces

Object "OPCServer IOPCServer IOPCServerPublicGroups (optional) IOPCBrowseServerAddressSpace (optional) IOPCItemProperties (new with V 2.0) IConnectionPointContainer (new with V 2.0) IOPCCommon (new with V 2.0) IPersistFile (optional) Object "OPCGroup IOPCGroupStateMgt IOPCPublicGroupStateMgt (optional) IOPCASyncIO2 (new with V 2.0) IOPCAsyncIO (no longer necessary with V2.0) IOPCItemMgt IConnectionPointContainer (new with V 2.0) IOPCSyncIO IDataObject (no longer necessary with V2.0) Object "EnumOPCItemAttributes IEnumOPCItemAttributes

248

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

10.4 The OPC Server Object


Description The OPC server class has various attributes that contain information about the status, the version etc. of an OPC server object. The OPC server class also has methods with which the client can manage the objects of the OPC group class. A client application addresses only an object of this class directly using COM mechanisms. The other objects are created by corresponding OPC methods. The methods of the IOPCServer interface are used to manage the objects in the OPC group class. The interface IOPCBrowseServerAddressSpace allows the address space of the server to be investigated.

Schematic

The following schematic illustrates the OPC server object with its interfaces.

IUnknown

IOPCServer IOPCBrowseServerAddressSpace

IOPCCommon (V2.0) IConnectionPointContainer (V2.0) IOPCItemsProperties (V2.0)

OPC server object

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

249

The OPC Custom Interface for Data Access

10.4.1 IOPCServer Interface

Overview

This interface contains methods to manage groups within a server object. It is also possible to obtain information about the current status of the server.

AddGroup

( szName, bActive, dwRequestedUpdateRate, hClientGroup, pTimeBias, pPercentDeadband, dwLCID, phServerGroup, pRevisedUpdateRate, riid, ppUnk ) Description: Creates a group in the server object. Notes: The "pTimeBias" parameter is not evaluated by the OPC server for SIMATIC NET. "LCID" is irrelevant for the OPC server for SIMATIC NET. The "UpdateRate" is specified by the configuration parameter Minimum Update Rate as a multiple of the configuration value. The pPercentDeadband parameter has no significance for the OPC server for SIMATIC NET. If the "szName" parameter is empty, a name is generated beginning with the underscore character (for example _123456). Userdefined names should therefore not begin with the underscore character.

CreateGroupEnumerator ( dwScope, riid, ppUnk ) Description: Creates various enumerators for the group. Notes: Since there are no public groups in the OPC server for SIMATIC NET, the return values for the parameter dwScope ...PRIVATE and ...PUBLIC are identical.

250

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

GetErrorString

( dwError, dwLocale, ppString ) Description: Supplies the error message for a specific error code. Notes: The OPC server for SIMATIC NET supports German and English error texts. Errors detected by the Windows operating system are explained in the language in which the operating system was installed.

GetGroupByName

( szName, riid, ppUnk ) Description: Supplies an additional interface pointer for the name of a private group, in other words the reference counter is incremented.

GetStatus

( ppServerStatus ) Description: Supplies the status information of the server. Notes: The return value of the OPC server for SIMATIC NET is the name and the version of the OPC server.

RemoveGroup

( hServerGroup, bForce ) Description: Deletes a group on the server.

Notes: The OPC server for SIMATIC NET does not support the use of the "bForce parameter. It is not possible to delete groups to which references are still active.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

251

The OPC Custom Interface for Data Access

10.4.2 IOPCBrowseServerAddressSpace Interface

Overview

This interface contains methods with which the address area of the server can be queried. The address area contains all the OPC items known to the server.

BrowseAccessPaths ( szItemID, ppIEnumString ) Description: This provides the possibility of querying the access path of an ItemID. Notes: Not required for the OPC server for SIMATIC NET.

BrowseOPCItemIDs ( dwBrowseFilterType, szFilterCriteria, vtDataTypeFilter, dwAccessRightsFilter, ppIEnumString ) Description: Supplies a string of the type IEnumString whose content is specified by the call parameters. The position from which the list is created can be set using the ChangeBrowsePosition method. Notes: BRANCH excludes the filters for Type and AccessRights. The rules for creating a filter are as follows: Asterisk (*) Plus (+) however at least Question marks (?) Square brackets ( [ ] ) Any character string, including empty strings Any string of characters, one character Any single character One single character from the specified set

To use one of the filter characters, this must be preceded by a back slash (\).

252

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

ChangeBrowsePosition ( dwBrowseDirection, szString ) Description: Allows you to browse through the address area. You can change to the higher level or to a branch.

GetItemID

( szItemDataID, szItemID ) Description: Creates a complete ItemID in the hierarchical address area. This function is necessary since browsing itself only provides the designations below the current node. Notes: The description of GetItemID in OPC specification is inconsistent with the description of ChangeBrowsePosition. With ChangeBrowsePosition, it is not possible to specify a complete ItemID. For this reason, the OPC server for SIMATIC NET only currently supports the command GetItemID for single leaves (LEAF).

QueryOrganization

( pNameSpaceType ) Description: Supplies the structure of the address area. The address area can be organized with a flat or hierarchical structure. Notes: The structure of the address area of the OPC server for SIMATIC NET is structured hierarchically.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

253

The OPC Custom Interface for Data Access

10.4.3 IOPCCommon Interface (Version 2.0)

Overview

This interface of version 2.0 of the OPC Custom Interface contains methods allowing the language settings and the name of the client to be made known to the server.

SetLocaleID

( dwLcid ) Description: Sets the language code of the server. The language code specifies the language in which the server outputs text. Notes: The OPC server for SIMATIC NET supports English and German.

GetLocaleID

( pdwLcid ) Description: Fetches the language code of the server. Notes: The OPC server for SIMATIC NET supports English and German.

QueryAvailableLocaleIDs ( pdwLcid ) Description: Provides all the available language codes of the server. Notes: The OPC server for SIMATIC NET supports English and German.

GetErrorString

( dwError, ppString ) Description: Provides the error text for a specific error code in the set language.

254

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

SetClientName

( szName ) Description: Transfers a descriptive text for the client to the server. The descriptive text can be used for any purpose by the server, for example for logging in trace files.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

255

The OPC Custom Interface for Data Access

10.4.4 IConnectionPointContainer Interface

Overview

This interface is a standard COM interface for reporting asynchronous events via connection points. For more detailed information about using connection points, refer to the documentation of OLE/COM.

256

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

10.4.5 IOPCItemProperties (V 2.0) Interface

Overview

This interface of version 2.0 contains methods allowing specific server information to be queried about an item.

QueryAvailableProperties ( szItemID, pdwCount, ppPropertyIDs, ppDescriptions, ppvtDataTypes ) Description: Returns a list of available properties for an item.

GetItemProperties

( szItemID, dwCount, pdwPropertyIDs, ppvData, ppErrors ) Description: Provides the values of the properties of an item transferred in a list of PropertyIDs.

LookupItemIDs

( szItemID, dwCount, pdwPropertyIDs, ppszNewItemIDs, ppErrors ) Description: Provides (whenever possible for the propertyID) a list of ItemIDs for a list of PropertyIDs. These ItemIDs can be included in a group simplifying and speeding up access to the data. Notes: The OPC server for SIMATIC NET does not support this function. The call is rejected with error message 0x8004001 (not implemented).

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

257

The OPC Custom Interface for Data Access

10.5 Objects of the OPC Group Class


Description The OPC Group class manages the individual process variables, the OPC items. Using these group objects, a client can form semantically meaningful units of OPC items and execute operations with them.

Schematic

The following schematic illustrates an object of the OPC Group class and its interfaces.

IUnknown

IOPCItemMgt IOPCGroupStateMgt IOPCSyncIO IOPCAsyncIO IDataObject IEnumOPCItemAttributes IOPCAsyncIO2 (V 2.0) IConnectionPointContainer (V2.0)

OPC group object

258

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

10.5.1 IOPCItemMgt Interface

Overview

This interface provides methods to manage more than one item in a group.

Time Stamp

With each value read, OPC supplies a time stamp. This indicates when this value was received or when it was changed. Since the SIMATIC systems do not use a time stamp, the time at which the value is received on the server is used as the time stamp.

AddItems

( dwNumItems, pItemArray, ppAddResults, ppErrors ) Description: Adds one or more items to a group. Notes: A unique name of an item for the OPC server for SIMATIC NET is as follows:

[<protId>:<connName>]VariableName (for DP and S7)


or

<protId>:[<connName>]VariableName (for FMS and SR)


Examples: S7:[S7-OPC_1|VFD1_OPC|CP_L2_1:]EB0 DP:[CP_L2_1]Slave063SlaveState FMS:[CR1|VFD1|CP_L2_1:]100 SR:[MyConnection||CP_H1_1:]receive

This name can be specified completely in the ItemID. The AccessPath must then be empty. As an alternative, the part of the name in square brackets can be included in the AccessPath. Example: AccessPath: DP:[CP_L2_1:] ItemID: Slave063SlaveState

Refer to Chapter 7 for a definition of the ItemIDs! It is possible to add the same OPC item to the same group more than once. In this case each of these items nevertheless has its own server handle. The server handles of the items are only unique within a group and not for all items of all groups. Valid data types are as follows: VT_UI1, VT_UI2, VT_UI4, VT_I1, VT_I2, VT_I4, VT_R4, VT_BOOL, VT_BSTR

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

259

The OPC Custom Interface for Data Access

CreateEnumerator

( riid, ppUnk ) Description: Creates an enumerator for the items of a group.

RemoveItems

( dwNumItems, phServer, ppErrors ) Description: Deletes one or more items from a group.

SetActiveState

( dwNumItems, phServer, bActive, ppErrors ) Description: Sets the active state of one or more items in a group.

SetClientHandles

( dwNumItems, phServer, phClient, ppErrors ) Description: Sets the client handle of one or more items in a group.

SetDatatypes

( dwNumItems, phServer, pRequestedDatatypes, ppErrors ) Description: Sets the requested data type of one or more items in a group. Notes: See AddItem

260

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

ValidateItems

( dwNumItems, pItemArray, bBlobUpdate, ppValidationResults, ppErrors ) Description: Checks the validity of an OPC item, for example whether it was added to a group without any error occurring, and supplies information such as the canonical data type. Notes: See AddItem

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

261

The OPC Custom Interface for Data Access

10.5.2 IOPCGroupStateMgt Interface

Overview

The IOPCGroupStateMgt interface provides methods with which groups can be managed. It is possible to edit group-specific parameters and to copy groups.

CloneGroup

( szName, riid, ppUnk ) Description: Creates a copy of a group. All group attributes are copied except for the following: The active state is set to FALSE A new server handle is assigned Notes: The szName parameter can be empty. In this case a unique name is generated (see AddGroup).

GetState

( pUpdateRate, pActive, ppName, pTimeBias, pPercentDeadband, pLCID, phClientGroup, phServerGroup ) Description: Fetches the status of the group. The client application must inform the OPC server where the results are to be stored using a pointer. Notes: The "pTimeBias" parameter is irrelevant for the OPC server for SIMATIC NET. The pPercentDeadband parameter has no significance for the OPC server for SIMATIC NET. The LCID parameter, in other words language-specific textual values in read/write, has no significance for SIMATIC variables.

SetName

( szName ) Description: Allows the name of a group to be changed. The name must always be unique.

262

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

SetState

( pRequestedUpdateRate, pRevisedUpdateRate, pActive, pTimeBias, pPercentDeadband, pLCID, phClientGroup ) Description: SetState allows various properties of the group to be changed. Notes: The "pTimeBias" parameter is irrelevant for the OPC server for SIMATIC NET. The pPercentDeadband parameter has no significance for the OPC server for SIMATIC NET. The LCID parameter, in other words language-specific textual values in read/write, has no significance for SIMATIC variables. The "UpdateRate" is specified by the configuration parameter Minimum Update Rate as a multiple of this value.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

263

The OPC Custom Interface for Data Access

10.5.3 IOPCSyncIO Interface

Overview

This interface provides methods for synchronous reading and writing. Synchronous means that the client waits until the read or write operation is completed and only then continues execution.

Use

The use of synchronous calls is recommended when the client requires the result for further processing. Other clients are not blocked since the OPC server for SIMATIC NET starts a separate thread for each client. In general, it is advisable to use the IData interface for processing variable changes (or IAdviseSink on the client side). This interface guarantees the highest possible data throughput and also reduces the actual number of calls to the absolute minimum (only when changes occur).

Read

( dwSource, dwNumItems, phServer, ppItemValues, ppErrors ) Description: Reads the values, status information or time stamp of one or more items in a group. The values can be read from the cache of the server or directly from the hardware. Reading from the cache is, however, only possible when the group is activated. Notes: The call is monitored by the timeout monitoring on the server. The corresponding configuration parameter is Read/Write Timeout (see Section 7.4).

Write

( dwNumItems, phServer, pItemValues, ppErrors ) Description: Writes values for one or more items of a group to the hardware. Notes: The call is monitored by the timeout monitoring on the server. The corresponding configuration parameter is Read/Write Timeout (see Section 7.4).

264

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

10.5.4 IOPCAsyncIO Interface

Overview

This interface of the Group class provides methods for asynchronous reading and writing of items. Asynchronous means that the client triggers a read or write operation and then continues operation. Asynchronous operations provide a transaction ID. When the server has completed the read or write operation, the client receives a message sent to its IAdviseSink interface.

Cancel

( dwTransactionID ) Description: Cancels an outstanding job.

Read

( dwConnection, dwSource, dwNumItems, phServer, pTransactionID, ppErrors ) Description: Sends an asynchronous read command. The result is sent to the IAdviseSink interface of the client. Notes: The call is monitored by the timeout monitoring on the server. The corresponding configuration parameter is Read/Write Timeout (see Section 7.4). If the timeout monitoring is aborted, there is a callback with hrStatus=E_ABORT.

Refresh

( dwConnection, dwSource, pTransactionID ) Description: Requests a current value for every active OPC item.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

265

The OPC Custom Interface for Data Access

Write

( dwConnection, dwNumItems, phServer, pItemValues, pTransactionID, ppErrors ) Description: Sends an asynchronous write command. Notes: The call is monitored by the timeout monitoring on the server. The corresponding configuration parameter is Read/Write Timeout (see Section 7.4). If the timeout monitoring is aborted there is a callback with hrStatus=E_ABORT.

266

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

10.6 IDataObject Interface


Overview The IDataObject interface is the standard interface of OLE for data transmission. It contains methods for establishing a message connection between the client and a server group.

Description of the Mechanism

If the server wants to send a message to a client, the client must provide a partner for the server. This partner is the IAdviseSink interface of the client. A server sends a message to a client by calling the OnDataChange method of the IAdviseSink interface of the client.

Schematic of the Mechanism

The following schematic illustrates how the IAdviseSink interface on the client and IDataObject on the server interact.

Client IDataObject::DAdvise IAdviseSink

Server

IDataObject

IAdviseSink::OnDataChange

DAdvise

( pFmt, adv, pSnk, pConnection ) Description: Establishes a connection between a server and the client. If a client wants to receive a message, it must establish a connection using this method. It transfers a pointer to its IAdviseSink interface to the server.

DUnadvise

( Connection ) Description: Terminates an existing connection between a client and server.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

267

The OPC Custom Interface for Data Access

10.6.1 IEnumOPCItemAttributes Interface

Overview

This interface based on the IEnum standard interface returns the items of a group. The interface is supplied only by IOPCItemMgr:CreateEnumerator. It is not obtainable with QueryInterface.

Clone

( ppEnumItemAttributes ) Description: Creates an identical copy of the enumerator.

Next

( celt, ppItemArray, pceltFetched ) Description: Fetches the next OPC item of the group. Notes: The OPC server for SIMATIC NET does not support engineering units. EUType and EUInfo are therefore irrelevant.

Reset

( void ) Description: Resets the list to the first item of the group.

Skip

( celt ) Description: Skips a number of items in the list.

268

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

10.6.2 IAsyncIO2 Interface (Version 2.0)

Overview

This interface in version 2.0 provides methods for asynchronous reading and writing of items. Asynchronous means that the client triggers a read or write operation and then continues operation. Version 2 of the interface for asynchronous communication uses connection points. This simplifies the processing of the transferred data.

Read

( dwCount, phServer, dwTransactionID, pdwCancelID, ppErrors ) Description: Sends an asynchronous read command. The result is sent to the client via a connection point. Notes: The call is monitored by the timeout monitoring on the server. If the set time is exceeded, this is indicated by the status E_ABORT.

Write

( dwCount, phServer, pItemValues, dwTransactionID, pdwCancelID, ppErrors ) Description: Sends an asynchronous write command. The message indicating completion of the job comes via the specified connection point. Notes: The call is monitored by the timeout monitoring on the server. If the set time is exceeded, this is indicated by the status E_ABORT.

Cancel2

( dwCancelID ) Description: Cancels an outstanding job.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

269

The OPC Custom Interface for Data Access

Refresh

( dwSource, dwTransactionID, pdwCancelID ) Description: Requests a current value for every active OPC item.

SetEnable

( bEnable ) Description: Activates messages via connection points. Messages generated by the Refresh method are sent regardless of these settings.

GetEnable

( pbEnable ) Description: Returns the current value of the flag for messages via connection points.

270

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Data Access

10.6.3 IConnectionPointContainer Interface

Overview

This interface is a standard COM interface for reporting asynchronous events via connection points. For more detailed information about using connection points, refer to the documentation of OLE or COM.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

271

The OPC Custom Interface for Data Access

272

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11

The OPC Automation Interface for Data Access

This chapter explains how the OPC Automation interface for Data Access is used. It also lists the properties and methods of the OPC automation interface. This is not a detailed interface description but contains supplementary information and notes relating specifically to the OPC server of SIMATIC NET.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

273

The OPC Automation Interface for Data Access

11.1 Versions of the Automation Interface


Introduction The OPC automation interface was specified by the OPC Foundation in version 1.0. Certain aspects in this specification were unclear and it was not approved. Some weaknesses of version 1.0 became particularly clear with the introduction of Visual Basic 5.0.

New Version

Since the start 1999, there is an approved version of the specification of the automation interface available with version number 2.02. The following descriptions relate to version 2.02 of the specification of the OPC automation interface.

274

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.2 Creating and Using an OLE Object in Visual Basic


Overview Visual Basic from Microsoft is a development environment which supports the automation interface for the simple linking of OLE objects. The following sections show how the OPC server is used via the automation interface 2.02 in Visual Basic. At least version 5 of Visual Basic is required.

Procedure Step 1 2 3 4 5 Description


Declaring the Variables Connecting to the OPC Server Generating an OPC Group Adding OPC Items Synchronous Reading

Preparations

Create a new Visual Basic project and the activate the reference for the automation interface 2.02 of the OPC server in the "Project References" menu.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

275

The OPC Automation Interface for Data Access

Step 1: Declaring a Variable of the Object Type

In Visual Basic or Visual Basic for Applications, a variable of the type Object refers to an OLE object. The DIM statement declares an object instance. Example

Dim ObjServer As OPCServer

Step 2: Creating and Assigning the Object

Creating an OPC Server Object Visual Basic programs are also OPC clients. To be able to access a process variable, the client must first create a server object and then connect to an OPC server. Example The following code section shows how a Visual Basic client can connect to the OPC server for SIMATIC NET: Set ObjServer = New OPCServer ObjServer.Connect ("OPC.SimaticNET")

Step 3: Generating an OPC Group

The next step is to create a group object to accommodate process variables. First, the group object is declared. A server object contains a collection object as a property with the name "OPCGroups". A group is created by calling the Add method of the collection object.

Example The following lines show how a group is created in Visual Basic:

'Declarations Dim GroupObj As OPCGroup Dim GroupCollection As OPCGroups Set GroupObj = ObjServer.OPCGroups.Add("MyGroup")

276

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

Step 4: Adding OPC Items

OPC items will now be inserted in the created group object. The items represent the connections to the process variables, their parameter ItemID specifies which variable will be addressed. The syntax of this parameter is shown in Chapter 5. The AddItems method allows several items to be inserted into a group in one call. The transfer parameters and the return values are therefore one-dimensional arrays with identical sizes. The "lNumItems variable contains the number of items to be inserted. When the method is called, the server initializes the values of the arrays "lServerHandles, "lErrors and "ItemsObj. The "IErrors array contains status information for each item inserted that indicated whether or not the item was successfully inserted. Example The following example creates two items in the previously created OPC group "GrpObj. The first item represents a DP variable, the second an FMS variable. 'Declaration Dim ItemServerHandles() As Long Const MAX_INDEX = 2 Const OPC_DS_CACHE = 1 Const OPC_DS_DEVICE = 2 Dim lNumItems As Long Dim lClientHandles(MAX_INDEX) As Long Dim perror() As Long Dim szItemIDs(MAX_INDEX) As String Dim AccPath(MAX_INDEX) As String Dim ReqDataTypes(MAX_INDEX) As Integer 'Definition of ItemIDs szItemIDs(1) = "FMS:[DEMO]101" szItemIDs(2) = "DP:[DEMO]MyMotor" AccPath(1) = "" AccPath(2) = "" ' Set requested datatypes for the Items ReqDataTypes(1) = vbVLong ReqDataTypes(2) = vbVString ' Set Client handles lClientHandles(1) = 1 lClientHandles(2) = 2 'Add Items to Group GroupObj.OPCItems.AddItems MAX_INDEX, szItemIDs, _ lClientHandles, ItemServerHandles, perror, _ ReqDataTypes, AccPath

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

277

The OPC Automation Interface for Data Access

Step 5: Synchronous Reading

In the last step, a synchronous read operation to read the process variables of a group is executed. Synchronous means that the server only returns control to the Visual Basic program after the required results have been returned via the communications system. This means that the flow of communication is delayed by the time required for this communication. The OPCDevice constant means that the values should be read directly from the device and not from the cache of the OPC server. Example Just like the AddItems command, OPCRead is also a group operation, in other words several process variables within a group can be accessed with one call. The "lNumItems parameter specifies the number of variables to be read. The individual variables themselves are described in the array "lServerHandles by the handle assigned by the server. The values are returned as long and as string according to the "ReqDataTypes" parameter of the "AddItems" method. 'Definition of the Variables for OPCRead 'Out Parameter Dim vValues() As Variant Dim pErrors() as Long ' Synchronous reading of 2 items GroupObj.SyncRead OPC_DS_Device, _ 2, _ ItemServerHandles, _ vValues, _ pErrors

278

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.3 Further Information about the Interface Description for the OPC Automation Interface
Introduction A detailed interface description of the OPC interfaces is beyond the scope of this manual. This is supplied as a file along with this product as an original English document from the OPC Foundation. You will find the documents in the "DOC" folder in the product folder of the OPC servers for SIMATIC NET.

Object Model for the Automation Interface

The object model for the OPC automation interface according specification 2.0 differs from the model described in Section 4.4: Separate collection objects manage the objects OPC Group and OPC Item. The collection objects provide functions for counting the objects assigned to them. The browsing functions are also brought together in a separate "OPC browser" object.

OPCServer 1:1 1:n

OPCGroups (Collection) 1:n

OPC-Browser

OPCGroup

1:1

OPCItems (Collection)

1:n

OPCItem

Structure of the Description

The following supplementary information about the interfaces lists the objects of the automation interface of OPC, their properties, methods and events and points out particular characteristics of the OPC server for SIMATIC NET.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

279

The OPC Automation Interface for Data Access

Note: Optional parameters must be transferred as variants for the automation interfaces. In Visual Basic, the optional parameters should, however, be declared directly with the destination type. This ensures that the variant has the correct data type. The data types can be found in the descriptions of the methods in the OPC specification. Example: Dim ReqDataTypes(MAX_INDEX) As Integer ReqDataTypes(1) = vbVLong ReqDataTypes(2) = vbVString

Remember that according to the OPC specification, arrays always begin with the index 1. This must be defined in your program as follows (as "General"): Option Base 1 'ARRAYs are always Option Base 1 '(see SPEC Chapter 2.6)

280

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.4 The OPC Server Object


Description Objects of the OPC server class are created by the client. The properties of an OPC server contain general information about the server. When an OPC server object is created, an OPCGroup collection is also created as a property of the OPC server object.

11.4.1 Properties of "OPCServer

Property
StartTime CurrentTime LastUpdate Time MajorVersion MinorVersion BuildNumber VendorInfo ServerState LocaleID Bandwidth OPCGroups PublicGroup Names ServerName ServerNode ClientName

Type
Date Date Date Integer Integer Integer String Long Long Long OPC Groups Variant String String String

Brief Description Time at which the server was started (in UTC). The current time (UTC), as supplied to the server by the system. The time (UTC), at which the server sent the last update of data to the client. The major version number of the server. The minor version number of the server. The build number of the server. The vendor information. Status of the server. Code for specifying the language for OPC server output texts Bandwidth of the server. A collection of OPCGroup objects The names of the public groups provided by this server. Name of the linked OPC server Computer name of the node in the network on which the OPC server is run. Option of informing the OPC server of the name of the client. Mainly intended for debugging and trace.

Notes: The OPC server for SIMATIC NET provides the following as vendor information: "SIMATIC NET OPC-Server Public groups are not supported by the OPC server for SIMATIC NET. The Bandwidth property is not supported by the OPC server for SIMATIC NET.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

281

The OPC Automation Interface for Data Access

11.4.2 Methods of the "OPCServer

GetOPCServers

(Optional Node as Variant) As Variant

Description: Provides the names (ProgIDs) of the registered OPC server on the local computer (without argument) or on the specified node. Notes: The ProgID for the OPC server for SIMATIC NET is as follows: OPC.SimaticNET
Connect (ProgID As String, Optional NodeName As String)

Description: Structure of a link to an OPC server. Notes: The ProgID for the OPC server for SIMATIC NET is as follows: OPC.SimaticNET
Disconnect ()

Description: Structure of the link to an OPC server. Notes: The OPC server for SIMATIC NET closes all communications connections after the Disconnect of the last OPC client.

282

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

CreateBrowser

() As OPCBrowser

Description: Creates an object of the OPCBrowser class to investigate the address area of the server. Notes: Refer to the description of the OPCBrowser object in Section 11.5.

GetErrorString

(ErrorCode As Long) As String

Description: Supplies the error message for a specific error code. Notes: The OPC server for SIMATIC NET supports German and English error texts. Errors detected by the Windows operating system are explained in the language in which the operating system was installed.

QueryAvailableLocaleIDs () As Variant

Description: Obtains the language codes available from the server as an array with long values. Notes: The OPC server for SIMATIC NET supports German and English error texts. Errors detected by the Windows operating system are explained in the language in which the operating system was installed.

QueryAvailableProperties ItemID As String, ByRef Count As Long, ByRef PropertyIDs() as Long, ByRef Descriptions() As String, ByRef DataTypes() As Integer

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

283

The OPC Automation Interface for Data Access

Description: Obtains a list of property codes and the corresponding description texts for the properties of the specified item. Notes: Properties are supported by the OPC server for SIMATIC NET.

GetItemProperties

(ItemID As String, Count As Long, ByRef PropertyIDs() as Long, ByRef PropertyValues() As Variant, ByRef Errors() As Long)

Description: Obtains a list with the values of the requested properties. Notes: Properties are supported by the OPC server for SIMATIC NET.

LookupItemIDs

(ItemID As String, Count As Long, PropertyIDs() as Long, ByRef NewItemIDs() As String, ByRef Errors () As Long)

Description: Obtains a list of the ItemIDs corresponding to the transferred PropertyIDs. ItemIDs can be inserted for more efficient data acquisition in OPC groups. Notes: The OPC server for SIMATIC NET does not supply PropertyIDs that could be represented as ItemIDs.

284

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.4.3 Events of "OPCServer"

ServerShutDown

(Reason As String)

Description: This event is triggered when the OPC server is closed down. The linked clients can react to the event, for example, by releasing items and groups.

Notes: The OPC server for SIMATIC NET triggers this event when the close request is set in the configuration program (Section 7.10).

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

285

The OPC Automation Interface for Data Access

11.5 The "OPCBrowser Object


Description The OPCBrowser object is a collection object with which the address area of the OPC server can be investigated. An object of the OPCBrowser class must be created by the CreateBrowser method of the OPCServer object. It is possible to create several OPCBrowser objects for one server.

11.5.1 Properties of "OPCBrowser

Property
Organization Filter

Type
Long String

Access Read-only Read/Write

Brief Description Organizational structure of the address area: hierarchy or flat The filter effective for the ShowBranches and ShowLeafs methods. The data type required for the ShowLeafs method. The default of this property is vbEmpty. The access rights required for the ShowLeafs method. Current position in the tree of the address area. The value is " when initialized in the root or when the organization structure is flat. Property necessary for the collection, provides the number of entries.

DataType

Integer

Read/Write

AccessRights CurrentPosition

Long String

Read/Write Read-only

Count

Long

Read-only

Notes:

The structure of the address area of the OPC server for SIMATIC NET is hierarchical. The rules for creating a filter are as follows: Asterisk (*) Plus (+) however at least Question marks (?) Open/close bracket ( [ ] ) Any character string, including empty strings Any string of characters, one character Any single character exactly one character from the specified set

To use one of the filter characters as a normal character, this must be preceded by a backslash (\).

286

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.5.2 Methods of "OPCBrowser"

Item

(Key As Variant) As String Description: Provides the name of the entry specified by the index "Key.

ShowBranches

()

Description: Enters the names of the branches of the current browse position into the collection.

ShowLeafs

(Optional Flat As Variant)

Description: Enters the names of the leaves of the current browse position into the collection. If the parameter "Flat is true, the collection with all leaves of the current and deeper branches are filled starting from the current browse position. The default for "Flat" is false.

MoveUp

()

Description: Moves the current position in the address area one level up.

MoveDown

(Branch As String)

Description: Moves the current position in the address area into the current branch (one level deeper).

MoveToRoot

()

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

287

The OPC Automation Interface for Data Access

Description: Moves the current position in the address area to the root.

MoveTo

(Branches() As String)

Description: Moves the current position in the address area to a specified, absolute position. The absolute position is specified as an array of branch names starting from the root.

GetItemID

(Leaf As String) As String

Description: The server converts the name to an ItemID that can be transferred to the "Add" method of "OPCItems". The creation of this ID is based on the current position of the browser, extended by the node with the name contained in the "Leaf" string.

GetAccessPaths

(ItemID As String) As Variant

Description: This provides the possibility of querying the access path of an ItemID. Notes: Not required for the OPC server for SIMATIC NET.

288

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.6 The "OPCGroups Collection Object


Description The OPCGroups object is a collection object for creating and managing OPC groups. The default properties of OPC groups specify default values for creating all OPC groups.

Public groups are not supported by the OPC server for SIMATIC NET.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

289

The OPC Automation Interface for Data Access

11.6.1 Properties of "OPCGroups

Property
Parent

Type
OPC server

Access ReadonlyReadonly Read/Write

Brief Description Provides a reference to the corresponding OPC server object. Specifies the initial value for the "ActiveState property of newly created OPC groups. Default: True Specifies the initial value for the "update rate property of newly created OPC groups. Default: 1000 milliseconds. Specifies the initial value for the "Deadband property of newly created OPC groups. Specifies the initial value for the "locale ID property of newly created OPC groups. Specifies the initial value for the "time bias property of newly created OPCGroups. Properties necessary for the collection, provides the number of entries.

DefaultGroupIsActive

Boolean

DefaultGroupUpdateRate

Long

Read/Write

DefaultGroupDeadband

Single

Read/Write

DefaultGroupLocaleID

Long

Read/Write

DefaultGroupTimeBias

Long

Read/Write

Count

Long

Read-only

Notes:

The DefaultGroupTimeBias property is not evaluated by the OPC server for SIMATIC NET. DefaultGroupLocaleID is irrelevant for the OPC server for SIMATIC NET. The DefaultGroupDeadband property has no significance for the OPC server for SIMATIC NET.-

290

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.6.2 Methods of "OPCGroups

Item

(Key As Variant) As OPCGroup

Description: Provides a reference to the indexed object of the collection.

Add

(Optional Name As Variant) As OPCGroup

Description: Creates a group in the server object. Notes: If the Name parameter is empty or not specified, the OPC server generates a name that starts with an underscore (for example "_123456"). User-defined names should therefore not begin with the underscore character.

GetOPCGroup

(Key As Variant) As OPCGroup

Description: Provides the reference to an OPC group indicated by the name or the server handle.

Remove

(Key As Variant)

Description: Deletes a group on the server.

RemoveAll

()

Description: Deletes all groups and items of the server.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

291

The OPC Automation Interface for Data Access

11.6.3 Events of "OPCGroups

GlobalDataChange

(TransactionID As Long, GroupHandle As Long, NumItems As Long, ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date)

Description: This event simplifies the processing of events throughout all groups of the collection by reporting changes in the value and state of all items in all groups.

292

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.7 The "OPCGroup Object


Description The OPC Group class manages the individual process variables, the OPC items. Using these group objects, a client can form semantically meaningful units of OPC items and execute operations with them.

11.7.1 Properties of "OPCGroup

Property
Parent

Type
OPC Server String Boolean

Access ReadonlyReadonly Read/Write Read-only

Brief Description Provides a reference to the corresponding OPC server object. The name of the group. Returns "True when this group is a public group, otherwise false. Active state of the group. An active group creates events for all active items of the group.

Name IsPublic

IsActive

Boolean

Read/Write

IsSubscribed

Boolean

Read/Write

Notification status of the group specifying whether or not the variables of a group will be monitored. A handle assigned by the client and that can be used in the client program to localize data (for example a row in a table) A unique handle assigned for the group by the server. The client must transfer this handle with many methods that influence the group (for example Remove). Specifies the language ID for strings supplied by the server (for example error texts) Provides the time offset used to change the time stamp of the data to the local time.

ClientHandle

Long

Read/Write

ServerHandle

Long

Read-only

LocaleID

Long

Read/Write

TimeBias

Long

Read/Write

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

293

The OPC Automation Interface for Data Access

Property
DeadBand

Type
Single

Access

Brief Description

Read/Write Specifies a bandwidth (as a percentage) within which value changes do not result in a message. Read/Write The fastest rate at which a client is informed of changes in values or states of items. Read-only Collections object "OPCItems for managing the items of a group

UpdateRate

Long

OPCItems

OPC Items

Notes:

The TimeBias property is not evaluated by the OPC server for SIMATIC NET. LocaleID is irrelevant for the OPC server for SIMATIC NET. The DeadBand property has no significance for the OPC server for SIMATIC NET. To allow value changes of the items of a group to be signaled using the appropriate event, the properties "IsActive" and "IsSubscribed" must be set to "True".

294

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.7.2 Methods of "OPCGroup

SyncRead

(Source As Integer, NumItems As Long, ServerHandles() As Long, ByRef Values() As Variant, ByRef Errors() As Long, Optional ByRef Qualities As Variant, Optional ByRef TimeStamps as Variant)

Description: Synchronous reading of the values, status information or time stamp of one or more items in a group. The values can be read from the cache of the server or directly from the hardware. Reading from the cache is, however, only possible when the group is activated. Notes: The call is monitored by the timeout monitoring on the server. The duration is specified by a configuration parameter in the protocolspecific configuration file (Section 8).

SyncWrite

(NumItems As Long, ServerHandles() As Long, Values() As Variant, ByRef Errors() As Long)

Description: Synchronous writing of values for one or more items of a group to the hardware. Notes: The call is monitored by the timeout monitoring on the server. The duration is specified by a configuration parameter in the protocolspecific configuration file (Section 8).

AsyncRead

( NumItems As Long, ServerHandles() As Long, ByRef Errors() As Long, TransactionID As Long, ByRef CancelID As Long)

Description: Sends an asynchronous read command. The result is returned with the "AsyncReadComplete event. Notes: Asynchronous read commands always read directly from the device! The call is monitored by the timeout monitoring on the server. The duration is specified by a configuration parameter in the protocolspecific configuration file (Section 8).

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

295

The OPC Automation Interface for Data Access

AsyncWrite

(NumItems As Long, ServerHandles() As Long, Values() As Variant, ByRef Errors() As Long, TransactionID As Long, ByRef CancelID As Long)

Description: Sends an asynchronous write command. The result is returned with the "AsyncWriteComplete event. Notes: The call is monitored by the timeout monitoring on the server. The duration is specified by a configuration parameter in the protocolspecific configuration file (Section 8).

AsyncRefresh

(Source As Integer, TransactionID As Long,ByRef CancelID As Long)

Description: Requests a current value for every active OPC item. The results are returned by the "DataChange event.

AsyncCancel

(TransactionID As Long)

Description: Cancels an outstanding asynchronous job.

296

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.7.3 Events of "OPCGroup

Description

The OPC automation interface supplies the changes to the values of active terms and the results of asynchronous operations with events. The requirement for this is the declaration of OPC groups WithEvents.

DataChange

(TransactionID As Long, NumItems As Long, ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date)

Description: The DataChange event occurs when it is detected that an active item has a change value or a change quality. Checking value changes is triggered by the UpdateRate timer. Events are generated only for active items within an active group of events.

AsyncReadComplete

(TransactionID As Long, NumItems As Long, ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date, Errors() As Long)

Description: The AsyncReadComplete event is triggered when a read job is completed.

AsyncWriteComplete

(TransactionID As Long, NumItems As Long, ClientHandles() As Long, Errors() As Long)

Description: The AsyncWriteComplete event is triggered when a write job is completed.

AsyncCancelComplete (TransactionID As Long)

Description: The AsyncCancelComplete event is triggered when a cancel job is completed.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

297

The OPC Automation Interface for Data Access

11.8 The "OPCItems Collection Object


Description The OPCItems object is a collection object for creating and managing OPC items. The default properties of OPCItems specify default values for all OPC items to be created.

11.8.1 Properties of "OPCItems

Property
Parent

Type
OPC Group

Access Read

Brief Description Supplies a reference to the corresponding OPCGroup object Specifies the initial value for the "RequestedDataTy pe property of newly added items. The default is vbEmpty for the canonical data type of the server. Specifies the initial value for the "AccessPath property of newly added items. The default is an empty string. Specifies the initial value for the "Active State property of newly added items. The default value is true.

DefaultRequestedDataType

Integer

Read/Write

DefaultAccessPath

String

Read/Write

DefaultIsActive

Boolean

Read/Write

Count

Long

Read-only

Properties necessary for the collection, provides the number of entries.

298

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.8.2 Methods of "OPCItems

Item

(ItemSpecifier As Variant) As OPCItem

Description: Provides a reference to the item of the collection described by the ItemSpecifier index. (The "GetOPCItem method, on the other hand, provides a reference to the server handle.)

GetOPCItem

(ServerHandle As Long) As OPCItem

Description: Provides a reference to the server handle created by Add.

AddItem

(ItemID As String, ClientHandle As Long)

Description: Inserts an item in the OPCItems collection of a group. Notes: AddItem returns errors using the variable "Err" to "On Error". The structure of the ItemIDs for the OPC server for SIMATIC NET is described in Chapter 5. It is possible to add the same OPC item to the same group more than once. In this case each of these items nevertheless has its own server handle. The server handles of the items are only unique within a group and not for all items of all groups.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

299

The OPC Automation Interface for Data Access

AddItems

(Count As Long, ItemIDs() As String, ClientHandles() As Long, ByRef ServerHandles() As Long, ByRef Errors() As Long, Optional RequestedDataTypes As Variant, Optional AccessPaths As Variant)

Description: Inserts several items in the OPCItems collection of a group. Notes: AddItems returns errors only using the "Errors" array, the error variable "Err" is not set. The structure of the ItemIDs for the OPC server for SIMATIC NET is described in Chapter 5. It is possible to add the same OPC item to the same group more than once. In this case each of these items nevertheless has its own server handle. The server handles of the items are only unique within a group and not for all items of all groups.

Remove

(Count As Long, ServerHandles() As Long, ByRef Errors() As Long)

Description: Deletes one or more items from a group.

Validate

(Count As Long, ItemIDs() As String, ByRef Errors() As Long, Optional RequestedDataTypes As Variant, Optional AccessPaths As Variant)

Description: Checks the validity of one or more OPC items; in other words whether it was added to a group without any error occurring, and supplies information such as the canonical data type. Notes: See AddItems

SetActive

(Count As Long, ServerHandles() As Long, ActiveState As Boolean, ByRef Errors() As Long)

Description: Sets the active state of one or more items in a group.

300

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

SetClientHandles

(Count As Long, ServerHandles() As Long, ClientHandles() As Long, ByRef Errors() As Long)

Description: Changes the client handle of one or more items in a group.

SetDataTypes

(Count As Long, ServerHandles() As Long, RequestedDataTypes() As Long, ByRef Errors() As Long)

Description: Sets the required data type of one or more items in a group.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

301

The OPC Automation Interface for Data Access

11.9 The "OPCItem Object


Description An object of the class OPC item represents a link to a process variable, for example to the input module of a programmable controller. A process variable is data of the process I/Os that can be written and/or read, for example the temperature of a tank. Each process variable is associated with a value (variant data type), a quality, and a time stamp.

302

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.9.1 Properties of "OPCItem

Property
Parent ClientHandle

Type
OPC Group Long

Access Read-only Read/Write

Brief Description Supplies a reference to the parent OPCGroup object. A handle that can be freely defined by the user to allow simpler assignment of the process variable in internal data structures of the client. A handle assigned uniquely to the item by the server. This handle is required in several operations to identify an item. The access path of the item as specified in the Add function. Provides the access rights of the variable. The unique name of the item as specified in the Add function. Specifies whether message events will be created for this item. The data type in which the value of the item will be supplied. The last valid value of the variable (default property of the OPCItem object) The quality of the value last read. The quality indicates the validity of the value of the variable. The time at which the last value was acquired. The original data type of the item. Identifies the unit of the value. If no units are available, the value is always "VT_EMPTY. Information about the unit of the value.

ServerHandle

Long

Read-only

AccessPath AccessRights ItemID

String Long String

Read-only Read-only Read-only

IsActive

Boolean

Read/Write

RequestedData Type Value

Integer

Read/Write

Variant

Read-only

Quality

Long

Read-only

TimeStamp CanonicalData Type EUType

Date Integer Integer

Read-only Read-only Read-only

EUInfo

Variant

Read-only

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

303

The OPC Automation Interface for Data Access

Notes: The OPC server for SIMATIC NET does not support units (engineering units)

304

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Automation Interface for Data Access

11.9.2 Methods of "OPCItem

Read

(Source As Integer, Optional ByRef Value As Variant, Optional ByRef Quality As Variant, Optional ByRef TimeStamp As Variant )

Description: Reads the value, the quality, and/or the time stamp of this variable.

Write

(Value As Variant)

Description: Sets the value of this variable synchronously.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

305

The OPC Custom Interface for Alarms & Events

306

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Alarms & Events

12

The OPC Custom Interface for Alarms & Events

This chapter lists the interfaces and methods of the OPC Custom interface for Alarms & Events. This is not a detailed interface description but contains supplementary information and notes relating specifically to SIMATIC NET.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

307

The OPC Custom Interface for Alarms & Events

12.1 Supplement to the Interface Description of the OPC Custom Interface for Alarms & Events
Introduction A detailed interface description of the OPC interfaces is beyond the scope of this manual. This is supplied as a file along with this product as an original English document from the OPC Foundation. You will find the documents in the "DOC" folder in the product folder of the OPC servers for SIMATIC NET.

Use in C/C++

The use of the OPC Custom interface for Alarms & Events is analogous to the use of the custom interface for Data Access (see Section 10.2). The ProgID must, however, be used for the OPC Alarm & Events server: OPC.SimaticNetAlarms

Refer, in particular, to the sample program for OPC Alarms & Events in the product folder "Samples\S7\Custom\AlrmEvnt\SimpleAE".

Structure of the Description

The following supplementary information about the interfaces lists the objects of OPC, their interfaces and the methods defined in these interfaces and points out particular characteristics of the OPC server for SIMATIC NET.

Overview of the Objects and Interfaces

"OPC EventServer" Object IOPCCommon IOPCEventServer IconnectionPointContainer

"OPC Event Subscription" Object IOPCEventSubscriptionMgt IconnectionPointContainer

"OPC Event Area Browser" Object* IOPCEventAreaBrowser

*: not supported by SIMATIC NET

308

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Alarms & Events

12.2 The "OPC Event Server" Object


Description A client generates an object of the class "OPC Event Server" and addresses this object to be able to use the Alarm&Event services. It provides a management interface via which a message object is created, various queries are executed and events are activated. The client can also set the language for output texts and logon to receive server-specific events.

ProgID SIMATIC NET

The Alarm & Event server for SIMATIC NET has the ProgID OPC.SimaticNETAlarms

Schematic

The following schematic illustrates the OPC server object with its interfaces.

IUnknown

IOPCEventServer IOPCCommon IConnectionPointContainer

OPC event server object

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

309

The OPC Custom Interface for Alarms & Events

12.2.1 The "IOPCEventServer" Interface

Overview

This is the central interface for use of the Alarm&Event functionality. It is used to generate subscription objects and the area browser as well as to investigate event categories and to manage conditions.

GetStatus

(OPCEVENTSERVERSTATUS ** ppEventServerStatus) Description: Provides current information about the status of the OPC server. The status is returned as a structure (refer to the OPC Alarms & Events specification). Notes: The client must release the memory required for the structure and the szVendorInfo.

CreateEventSubscription (BOOL bActive, DWORD dwBufferTime, DWORD dwMaxSize, OPCHANDLE hClientSubscription, REFIID riid, LPUNKNOWN * ppUnk, DWORD * pdwRevisedBufferTime, DWORD * pdwRevisedMaxSize)

Description: Creates a subscription for informing the client and returns the requested interface for access to the subscription object.

QueryAvailableFilters

(DWORD * pdwFilterMask)

Description: Provides information about the filter options supported by the OPC Event server. Notes: The OPC Event server for SIMATIC NET supports the following filters. OPC_FILTER_BY_EVENTS 0x01 OPC_FILTER_BY_CATEGORY 0x02 OPC_FILTER_BY_SEVERITY 0x04 OPC_FILTER_BY_SOURCE 0x16

310

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Alarms & Events

QueryEventCategories (DWORD dwEventType, DWORD* pdwCount, DWORD** ppdwEventCategories, LPWSTR** ppEventCategoryDescs )

Description: Provides the event categories offered by the OPC Event server. Notes: The OPC Event server for SIMATIC NET supplies event categories only when the value OPC_SIMPLE_EVENT is set for the parameter "dwEventType". The OPC Event server for SIMATIC NET supports the following event categories. S7_PROCESS_SCAN 0x01 S7_PROCESS_ALARM 0x02

QueryConditionNames (DWORD dwEventCategory, DWORD* pdwCount, LPWSTR** ppszConditionNames) Description: Provides the conditions offered by the OPC Event server for a particular event category. Notes: Conditions are not supported by the OPC Event server for SIMATIC NET.

QuerySubConditionNames (LPWSTR szConditionName, DWORD* pdwCount, LPWSTR** ppszSubConditionNames) Description: Provides the subconditions offered by the OPC Event server for specific event categories. Notes: Subconditions are not supported by the OPC Event server for SIMATIC NET.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

311

The OPC Custom Interface for Alarms & Events

QuerySourceConditions (LPWSTR szSource, DWORD* pdwCount, LPWSTR** ppszConditionNames) Description: Provides the conditions offered by the OPC Event server for a specific event source. Notes: Conditions are not supported by the OPC Event server for SIMATIC NET.

QueryEventAttributes (DWORD dwEventCategory, DWORD* pdwCount, DWORD** ppdwAttrIDs, LPWSTR** ppszAttrDescs, VARTYPE** ppvtAttrTypes) Description: Provides the attributes offered by the OPC server for a specific event category. Additional information (for example associated values) are transferred to the client using attributes. Notes: The attributes provided by the OPC Event server for SIMATIC NET are listed in Section 6.2.2.

TranslateToItemIDs (LPWSTR szSource, DWORD dwEventCategory LPWSTR szConditionName, LPWSTR szSubconditionName, DWORD dwCount, DWORD* pdwAssocAttrIDs, LPWSTR** ppszAttrItemIDs, LPWSTR** ppszNodeNames, CLSID** ppCLSIDs ) Description: Using this function, the OPCItems corresponding to an event attribute for use with an associated OPC Data Access server can be obtained. Notes: The attributes provided by the OPC Event server for SIMATIC NET cannot be represented as ItemIDs for use with the OPC Data Access server for SIMATIC NET. TranslateToItemIDs is not supported by the OPC Event server for SIMATIC NET.

312

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Alarms & Events

GetConditionState

(LPWSTR szSource, LPWSTR szConditionName, DWORD dwNumEventAttrs, DWORD* pdwAttributeIDs, OPCCONDITIONSTATE ** ppConditionState) Description: Provides information about the state of a condition of an event source. Notes: Conditions are not supported by the OPC Event server for SIMATIC NET. E_NOTIMPL is returned.

EnableConditionByArea (DWORD dwNumAreas, LPWSTR* pszAreas) Description: Activates all the conditions for all event sources within the specified area. Notes: Conditions are not supported by the OPC Event server for SIMATIC NET. E_NOTIMPL is returned.

EnableConditionBySource (DWORD dwNumSources, LPWSTR* pszSources) Description: Activates all conditions for all specified event sources. Notes: Conditions are not supported by the OPC Event server for SIMATIC NET. E_NOTIMPL is returned.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

313

The OPC Custom Interface for Alarms & Events

DisableConditionByArea (DWORD dwNumAreas, LPWSTR* pszAreas) Description: Deactivates all the conditions for all the events sources within the specified area. Notes: Conditions are not supported by the OPC Event server for SIMATIC NET. E_NOTIMPL is returned.

DisableConditionBySource (DWORD dwNumSources, LPWSTR* pszSources) Description: Deactivates all conditions for all specified event sources. Notes: Conditions are not supported by the OPC Event server for SIMATIC NET. E_NOTIMPL is returned.

AckCondition

(DWORD dwCount, LPWSTR szAcknowledgerID, LPWSTR szComment, LPWSTR* pszSource, LPWSTR* pszConditionName, FILETIME* pftActiveTime, DWORD* pdwCookie, HRESULT **ppErrors ) Description: Transfers an event confirmation to the client. Only conditional events can be confirmed. An event is identified by the event source, the event name, the activation time, and an additional information ("Cookie"). Notes: Conditions are not supported by the OPC Event server for SIMATIC NET.

314

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Alarms & Events

CreateAreaBrowser

(REFIID riid, LPUNKNOWN* ppUnk) Description: Creates an OPCEventAreaBrowser object for investigating the process area. Notes: Areas and the browsing of areas is not supported by the OPC Event server for SIMATIC NET. E_NOTIMPL is returned.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

315

The OPC Custom Interface for Alarms & Events

12.3 The "OPC Event Subscription" Object


Description An object of the class "OPC Event Subscription" provides event messages for the client that uses the connection point container of this event object. A client can use several objects of the class "OPC Event Subscription". It could, for example define different filters for different objects. An OPC event subscription is basically a subscription for defined events. The "OPC Event Subscription" object provides methods for selecting messages. Schematic The following schematic illustrates the OPC server object with its interfaces.

IUnknown

IOPCEventSubscriptionMgt IConnectionPointContainer

OPC event subscription object

316

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Alarms & Events

12.3.1 The "IOPCEventSubscriptionMgt" Interface

Overview

This is the central interface for managing the information via a specific "Event Subscription". On this interface, relevant events can be selected for the client among other things.

SetFilter

(DWORD dwEventType, DWORD dwNumCategories, DWORD* pdwEventCategories, DWORD dwLowSeverity, DWORD dwHighSeverity, DWORD dwNumAreas, LPWSTR* pszAreaList, DWORD dwNumSources, LPWSTR* pszSourceList) Description: Provides a filter for selecting certain events for this "Event Subscription". Notes: The parameters for filtering have the following significance for the OPC Event server for SIMATIC NET:

Event Type Event Categories

Only the event type OPC_SIMPLE_EVENT is supported. Filtering is pointless Possible event categories are as follows: S7_PROCESS_SCAN S7_PROCESS_ALARM The default severity of the message is 600 for S7_PROCESS_ALARM and 300 for S7_PROCESS_SCAN, this can however be changed using the configuration file. Areas are not supported As the source, connection information can be specified. (See Section 6.2.1 )

Severity

Areas Source

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

317

The OPC Custom Interface for Alarms & Events

GetFilter

(DWORD* pdwEventType, DWORD* pdwNumCategories, DWORD** ppdwEventCategories, DWORD* pdwLowSeverity, DWORD* pdwHighSeverity, DWORD* pdwNumAreas, LPWSTR** ppszAreaList, DWORD* pdwNumSources, LPWSTR** ppszSourceList ) Description: Returns the currently used filter for selecting certain events for this "Event Subscription". Notes: The parameters for filtering have the same significance for the OPC Event server for SIMATIC NET as explained in the description of the "SetFilter" method.

SelectReturnedAttributes (DWORD dwEventCategory, DWORD dwCount, DWORD* dwAttributeIDs) Description: Specifies the attribute for an event category to be supplied with the event message. Notes: The possible attributes for the OPC Event server for SIMATIC NET are described in Section 6.2.2.

GetReturnedAttributes ( DWORD dwEventCategory, DWORD * pdwCount, DWORD* pdwAttributeIDs) Description: Returns the list with the attributes for an event category to be supplied with an event message. Notes: The possible attributes for the OPC Event server for SIMATIC NET are described in Section 6.2.2.

Refresh

(DWORD dwConnection )

318

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Alarms & Events

Description: Sends all active and all inactive, unconfirmed condition messages corresponding to the current filter setting to the client. Notes: Since the OPC Event server for SIMATIC NET supports only simple events, no event messages are sent with the refresh.

CancelRefresh

(DWORD dwConnection ) Description: Cancels an active refresh. Notes: Since the OPC Event server for SIMATIC NET supports only simple events no event messages are sent during a refresh. A CancelRefresh therefore has not effect.

GetState

(BOOL * pbActive, DWORD * pdwBufferTime, DWORD * pdwMaxSize, OPCHANDLE * phClientSubscription) Description: Returns the current status of the event subscription.

SetState

(BOOL * pbActive, DWORD * pdwBufferTime, DWORD * pdwMaxSize, OPCHANDLE hClientSubscription DWORD * pdwRevisedBufferTime, DWORD * pdwRevisedMaxSize) Description: Allows the setting of various properties of an event subscription.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

319

The OPC Custom Interface for Alarms & Events

12.4 The Interfaces of the Client


Description When using connection points to transfer events to a client, the client must provide a COM object with the interfaces IUnknown and the callspecific interface (for example IOPCEventSink) to receive the calls. When it logs on at a connection point, the client transfers a pointer to the IUnknown interface to the server.

Schematic

The following schematic shows the object to be implemented by the client for receiving messages and its interfaces.

IUnknown

IOPCEventSink IOPCShutdown

Event sink client object

320

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

The OPC Custom Interface for Alarms & Events

12.4.1 The "IOPCEventSink" Interface

Overview

This is the central interface of the client for receiving messages. It contains a method called by the server to transfer events.

OnEvent

(OPCHANDLE hClientSubscription, BOOL bRefresh, BOOL bLastRefresh, DWORD dwCount, ONEVENTSTRUCT* pEvents) Description: Transfers one or more event messages to the client. Notes: The "*pEvents" structure contains one or more events. In the structure elements that follow, the SIMATIC NET OPC Event enters specific values:

SzSource

Connection information Conversion to an ItemID for use in OPC Data Access using TranslateToItemID provides no result. Time at which the event occurred on the partner device. The time at which the message is received on the OPC Event server is entered in the "EVENT_ATTR_S7_PCTIME" attribute. SCAN<message number> or ALARM<message number> OPC_SIMPLE_EVENT

ftTime

szMessage dwEventType

dwEventCategory S7_PROCESS_SCAN S7_PROCESS_ALARM pEventAttributes The attributes provided are described in Section 6.2.2.

All other structure elements are irrelevant.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

321

The OPC Custom Interface for Alarms & Events

12.4.2 The "IOPCShutdown" Interface

Overview

Via the call interface based on this connection point, the server can inform its clients before it is closed down or before it closes down. In critical situations, this allows the OPC server to inform its clients so that, for example, they can close down correctly. The interface contains one method:

ShutdownRequest

(LPWSTR szReason) Description: Via this interface, the server can inform its clients when it is closed. Notes: The "Reason" (parameter szReason) can be set using the configuration program for the OPC server.

322

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Where to Get Help

13

Where to Get Help

This section lists sources of information about SIMATIC NET: Who to contact with technical questions Who to contact about training for SIMATIC NET products

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

323

Where to Get Help

13.1 Help with Technical Questions

SIMATIC Customer Support Hotline


Available at all times worldwide:

Johnson City

Nuremberg

Singapore

SIMATIC Basic Hotline

Nuremberg SIMATIC BASIC Hotline

SIMATIC Premium Hotline (charged, only with SIMATIC card)

Local time: Mo to Fr 8:00 to 18:00 (CET) Local time: Mo to Fr 0:00 to 24:00 (CET) Phone: +49 (911) -895-7000 Phone: +49 (911) -895-7777 Fax: +49 (911) -895-7002 Fax: +49 (911) -895-7001 E-mail: simatic.support@nbgm.siemens.de

Johnson City SIMATIC BASIC Hotline Local time: Mo to Fr 8:00 to 17:00 Phone: +1 423 461-2522 Fax: +1 423 461-2231 E-mail: simatic.hotline@sea.siemens.com

Singapore SIMATIC BASIC Hotline Local time: Mo to Fr 8:30 to 17:30 Phone: +65 740-7000 Fax: +65 740-7376 E-Mail: simatic.hotline@sae.siemens.com.sg

324

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Where to Get Help

SIMATIC Customer Support Online Services


In its online services, SIMATIC Customer Support provides you with wide-ranging additional information about SIMATIC products: 1. You will find general, up-to-date information: on the Internet (http://www.ad.siemens.de/simatic) using fax polling 2. You can obtain the latest product information and downloads: on the Internet (http://www.ad.siemens.de/support/html-00). via the Bulletin Board System (BBS) of the SIMATIC Customer Support mailbox in Nuremberg (Tel.: +49 (911) - 895-7100). To dial the mailbox, use a modem with up to 28.8 Kbps, V.34 (parameters: 8, N, 1, ANSI) or ISDN (parameters: x.75, 64 Kbps)

SIMATIC Training Center


To help you to become familiar with the SIMATIC S7 automation system, we offer training courses Please contact your regional training center or the central training center in D-90327 Nuremberg, Tel. 0911-895-3154.

Authorization
Please note that this software product can only be operated when you are in possession of a valid authorization.. The product is supplied with a key diskette (authorization diskette).

Note For test or demonstration purposes, you can install the software product in the demonstration mode without a license to acquaint yourself with the functions.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

325

Where to Get Help

Standards and Approvals


The S7-300 meets the requirements and criteria of IEC 1131, Part 2. The S7-300 meets the requirements for CE marking. CSA, UL and FM approvals exist for the S7-300.

Recycling and Disposal


Due to the low levels of pollutants, the SIMATIC S7-300 can be recycled. For environmentally-friendly recycling and disposal of your old SIMATIC devices, contact: Siemens Aktiengesellschaft Anlagenbau und Technische Dienstleistung ATD ERC Essen Recyling/Remarketing Fronhauser Str. 69 45 127 Essen Phone: Telefax: 0201-816-1540 (Hotline) 0201-816-1506

326

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Where to Get Help

13.2 Who to Contact about Training for SIMATIC NET Products


Course Registration Siemens AG Trainings-Center fr Automatisierungstechnik AUT 959 Kursbro stliche Rheinbrckenstrae 50 76181 Karlsruhe Germany Telephone Telefax 0721 - 595 - 2917 outside Germany +49 - 721 - 595 - 2917 0721 - 595 - 6987 outside Germany +49 - 721 - 595 - 6987

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

327

Where to Get Help

328

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Glossary

14

Glossary

Application

Synonym for user programs

AS-Interface

Actuator Sensor Interface - cable for direct connection of simple binary sensors and actuators (transfer of small amounts of information)

COM

Component Object Model - specification from Microsoft for Windows objects, basis of OLE

DCOM

Distributed COM - extension of the COM standard allowing the distribution of COM objects in a network.

DLL

Dynamic Link Library - selection of functions available to more than one program. The DLL is only loaded in memory once (Windows/Windows NT property).

DP Protocol

Protocol for data transmission to distributed I/Os via a DP network -> PROFIBUS

FMS

Fieldbus Message Specification, -> PROFIBUS protocol for convenient communication on the basis of layer 7 of the ISO/OSI reference model

Industrial Ethernet

Bus system for use in industry on the basis of Ethernet (previously SINEC H1)

Network

A network consists of one or more connected subnets with any number of nodes. Several networks can exist parallel to each other.

OLE

Object Linking and Embedding - central architectural principle of the Windows versions Windows 95, Windows NT and the basis of Windows application software under Windows 3.x

OPC

OLE for Process Control - industrial standard allowing vendorindependent access to industrial communication networks, defined on the basis of OLE.

OPC Client

User program that uses an OPC server via the OPC interface to access process data.

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

329

Glossary

OPC Server

An OPC server is a product that provides the OPC client with wide ranging functions allowing communication via industrial networks.

PLC

Programmable Logic Controller - interface between sensors and production machines also used for communication and data transport between the user and the entire operational production sequence.

PROFIBUS

Process Field Bus - European fieldbus standard

SIMATIC

Name of products and systems for industrial automation from Siemens

SIMATIC NET

Siemens product range industrial communications networks and network components

SR

Send/Receive, SIMATIC NET protocol for simple, but powerful communication on layer 4 of the ISO/OSI reference model.

UTC

Coordinated Universal T ime - coordinated atomic universal time (UT); since 1967 worldwide time as atomic time as opposed to astronomical time.

VBA

Visual Basic for Applications - macro language of various office applications from Microsoft

330

Introduction to the OPC Server for SIMATIC NET 6GK1971-0BA00-0AA1

Appendix A SIMATIC COMPUTING

SIMATIC Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A.1 A.1.1 A.1.2 A.1.3 A.1.4 A.2 A.2.1 A.3 A.3.1 A.3.2 A.3.3 A.3.4 A.3.5 A.3.6 A.3.7 A.3.8 A.3.9 A.3.10 A.3.11 A.3.12 A.3.13 A.4 A.4.1 A.4.2 A.4.3 A.4.4 A.4.5 A.4.6 A.4.7 A.4.8 A.4.9 A.4.10 A.4.11 A.4.12 A.4.13 A.4.14 A.4.15 A.4.16 A.4.17 A.4.18 A.4.19 A.4.20 A.4.21 A.4.22 A.4.23 A.4.24 A.4.25 A.4.26 A.4.27 A.4.28 Getting Started with Computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a Sample I/O Panel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Connecting Third-Party Controls to a SIMATIC Data Control . . . . . . . . . . Using Computing with Microsoft Excel 97 . . . . . . . . . . . . . . . . . . . . . . . . . . . Product Overview and Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using an ActiveX Control to Access the Process Data . . . . . . . . . . . . . . . . Accessing the Process Data with the SIMATIC Data Control . . . . . . . . . . Connecting the SIMATIC Controls to the Control Engine . . . . . . . . . . . . . . Configuring the Connection Properties for the Data Control . . . . . . . . . . . Selecting the Control Engine for the Data Control . . . . . . . . . . . . . . . . . . . . Connecting to a Specific Control Engine over DCOM . . . . . . . . . . . . . . . . . Connecting the ActiveX Controls to the Control Engine . . . . . . . . . . . . . . . Filtering the Properties for the ActiveX Controls . . . . . . . . . . . . . . . . . . . . . Configuring Custom Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating a Connection Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sample Program for Creating a Connection Table and an Event Table . . Sample Program for Responding to Events . . . . . . . . . . . . . . . . . . . . . . . . . Sample Programs for Reading and Writing Data . . . . . . . . . . . . . . . . . . . . . Sample Program for Reading and Writing Boolean Data . . . . . . . . . . . . . . Properties, Methods, and Events of the Data Control . . . . . . . . . . . . . . . . . Properties and Methods of the SIMATIC Controls . . . . . . . . . . . . . . . . . . . . Activated Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Alignment Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Appearance Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . AutoConnect Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . AutoConnectTimeout Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BackColor Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . BorderStyle Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Caption1 and Caption2 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Caption1Alignment and Caption2Alignment Properties . . . . . . . . . . . . . . . Caption1BackColor, Caption2BackColor Properties . . . . . . . . . . . . . . . . . . Caption1Font and Caption2Font Properties . . . . . . . . . . . . . . . . . . . . . . . . . Caption1ForeColor, and Caption2ForeColor Properties . . . . . . . . . . . . . . . Caption1Size and Caption2Size Properties . . . . . . . . . . . . . . . . . . . . . . . . . Connect Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ConnectName Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ConnectObject Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ControlEngine Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ConvertedValue Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DataType Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DefaultDeadband Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . DefaultUpdateRate Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Direction Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Disconnect Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Enabled Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Factor Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FalseCaption Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . FalseColor Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Font Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

A-1 A-1 A-3 A-4 A-9 A-12 A-16 A-16 A-17 A-18 A-19 A-20 A-22 A-24 A-27 A-29 A-30 A-31 A-33 A-37 A-41 A-42 A-44 A-44 A-44 A-45 A-46 A-46 A-47 A-47 A-48 A-48 A-49 A-50 A-50 A-51 A-51 A-52 A-53 A-54 A-55 A-55 A-57 A-57 A-58 A-59 A-59 A-60 A-61 A-61 A-62

SIMATIC Computing 6GK19710BA000AA1

A.4.29 A.4.30 A.4.31 A.4.32 A.4.33 A.4.34 A.4.35 A.4.36 A.4.37 A.4.38 A.4.39 A.4.40 A.4.41 A.4.42 A.4.43 A.4.44 A.4.45 A.4.46 A.4.47 A.4.48 A.4.49 A.4.50 A.4.51 A.4.52 A.4.53 A.4.54 A.4.55 A.4.56 A.4.57 A.4.58 A.4.59 A.4.60 A.4.61 A.4.62 A.5 A.5.1 A.5.2 A.5.3 A.5.4 A.5.5 A.5.6 A.6 A.6.1 A.6.2 A.6.3

ForeColor Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LargeChange Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LayoutType Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LimitCheck Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Locked Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . LowerLimit Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Max Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Min Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MultipleEngines Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Offset Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PCName Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Precision Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PropertyChangedName Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PropertyChangedObject Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Radix Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RangeRawMax, RangeRawMin, RangeScaledMax, and RangeScaledMin Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ReadMultiVariables Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ReadVariable Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ScaleMode Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ShowButtons Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ShowErrorBoxes Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SmallChange Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TagServerName Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TagSource Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ticks Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TrueCaption Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . TrueColor Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . UpperLimit Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Value Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Write Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WriteMode Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WriteMultiVariables Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WriteVariable Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ZeroPad Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

A-62 A-63 A-63 A-64 A-65 A-65 A-66 A-67 A-67 A-68 A-68 A-69 A-69 A-70 A-71 A-72 A-74 A-74 A-75 A-76 A-77 A-78 A-79 A-79 A-80 A-80 A-81 A-81 A-83 A-84 A-84 A-85 A-85 A-86

Other SIMATIC Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-87 SIMATIC Button Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-87 Properties, Methods, and Events of the Button Control . . . . . . . . . . . . . . . A-91 SIMATIC Number Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-92 Properties, Methods, and Events of the Number Control . . . . . . . . . . . . . . A-99 SIMATIC Slider Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-103 Properties, Methods, and Events of the Slider Control . . . . . . . . . . . . . . . . A-106 Guidelines for Custom Controls and Third-Party Containers . . . . . . . . . . . Guidelines for Using Third-Party Containers with the Data Control . . . . . Guidelines for Creating a Custom ActiveX Control . . . . . . . . . . . . . . . . . . . Using a Custom Control with the Data Control . . . . . . . . . . . . . . . . . . . . . . . A-107 A-107 A-108 A-109

ii

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.1

Getting Started with Computing

Chapter Overview
The Computing software provides you with a simple way to access and to use data from a communication system such as a PROFIBUSDP, a FMS Network or a S7 programmable controller. This chapter provides some easy programming examples to help you become familiar with the power and flexibility that can be achieved by using the ActiveX controls provided by SIMATIC Computing.

Warning After you assign a variable to the Value property of a SIMATIC ActiveX control, the control is able to access process data. When you change the value that is displayed in the control, you are changing the value in the actual process. Do not connect these examples to a control engine that is connected to equipment. Altering process data can cause unpredictable process operation, and unpredictable process operation could result in death or serious injury to personnel, and/or damage to equipment. Exercise caution to ensure that you do not access any data that could cause process equipment to operate erratically. Always install a physical emergency stop circuit for your machineor process.

SIMATIC Computing 6GK19710BA000AA1

A-1

SIMATIC Computing

Simatic Computing fr WinAC und SlotPLC


The SIMATIC Computing software supplied with the OPC Server for SIMATIC NET corresponds to SIMATIC Computing for the products Win AC and Slot PLC Version V2.x. There are, however, the following differences: It is only possible to access variables via the SIMATIC NET communication systems. The names of the variables when using SIMATIC Computing with the OPC Server from SIMATIC NET differ from the variable names used in WinAC.

A-2

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.1.1

Overview
The examples in this chapter show some of the ways you can use the ActiveX controls provided by Computing. As shown in Figure A-1, this chapter provides samples of subroutines for the following applications: S Create a user interface: You can use the SIMATIC controls with a thirdparty container (such as Microsofts Visual Basic) to create an I/O interface Panel. See Section A.1.2. (You can use this panel to test the other sample programs in this chapter.) Use a standard ActiveX control: You can use a standard control (such as a Label control from Visual Basic) to access data in the control engine. See Section A.1.3. Load data from the control engine into standard software packages: You can load data into a Microsoft Office application (such as Microsofts Excel). See Section A.1.4.

I/O Panel

Interface Panel

QB0 0 OFF I 0.0

QB1 0 OFF I 0.1

QB2 0 OFF I 0.2

Standard ActiveX Control

Label control

Excel

Third-party application

Figure A-1

Using Computing to Access Data in the Control Engine

SIMATIC Computing 6GK19710BA000AA1

A-3

SIMATIC Computing

A.1.2

Creating a Sample I/O Panel


The Data control allows any OLE Container (such as Visual Basic 5.0) to access process data. You can use the SIMATIC controls provided by Computing with Visual Basic to create a simple I/O Panel that interacts with a control engine. To create this sample application, you need the following items: S S Microsoft Visual Basic 5 or higher SIMATIC controls from Computing

Inserting the SIMATIC Controls into the Toolbox for Visual Basic
Use the following procedure to create the sample I/O panel: 1. Open a standard Visual Basic project: Select the File >New Project menu command to display the New Project dialog box. Select the Standard EXE icon and click on the Open button. 2. Select the Project > Components menu command to display the Components dialolg box. 3. As shown in Figure A-2, select the following SIMATIC controls in the Components dialog box: Data control (Siemens SIMATIC Data Control) Button control (Siemens S7vbButton Control) Number control (Siemens S7Number Control) 4. Click on the Apply button. The SIMATIC controls that you selected appear in the toolbox for Visual Basic. Click on the OK button to close the Components dialog box.

Note Even though the Computing controls sometimes use S7 in their names, they can be used with other systems (S5, DPNetwork, FMSDevices) too.

A-4

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Components Controls Designers Insertable Objects

S Click on the Data control, Number


control, and the Button control.

Siemens S7DiagBF Control Siemens S7Number Control Siemens S7Panel Control Siemens S7vbButton Control Siemens S7vbSlider Control Siemens SIMATIC Data Control Third-Party Control... Third-Party Control... Third-Party Control...

S Click on the Apply button to add the


control to the VB toolbox.

S Click on the OK button to close the


Components dialog box.
Browse... Selected Items Only

Siemens SIMATIC Data Control Location: C:\SIEMENS\Common\OCX\S7WCDATX.OCX

OK

Cancel

Apply

Figure A-2

Adding SIMATIC Controls to the VB Toolbox

Creating the VB Form for the Sample I/O Panel


1. Insert one SIMATIC Data control, three SIMATIC Number controls and three SIMATIC Button controls onto the Visual Basic form. See Figure A-3. 2. Create standard VB label controls to indicate the address that you have assigned for each of the controls. See Figure A-3.

I/O Panel

Temp 0 0

Power 0

Flow

Label controls

Number controls

OFF

OFF

OFF

Button controls

EB0

EB1

EB2

Label controls

Data control

Figure A-3

Sample I/O Panel Created in Visual Basic

SIMATIC Computing 6GK19710BA000AA1

A-5

SIMATIC Computing

Assigning Variables in the Control Engine to the SIMATIC Controls


In order to connect a SIMATIC or third-party controls to the process data in the control engine, you must assign a variable to the Value property (or to other properties) for each control. You use the Connection tab of Properties dialog box for the Data control to assign properties to the process variables in the control engine. You cannot assign a process variable to the Value property of a control by using the property list of the control itself. Use the following procedure to assign variables to the SIMATIC controls: 1. Select the Data control and click the right mouse button to bring up the pop-up menu. From the pop-up menu, select the Properties menu command to display the Properties dialog box for the Data control. 2. Select the Connections tab. Click on the + symbol to expand the list of controls. 3. Select the control and click on its + symbol to expand its properties list. 4. As shown in See Figure A-4, select the Value property of the control.
Siemens SIMATIC Data Control Properties General Controls: S7vbBttn1 Enabled FalseCaption FalseColor Font ToolTipText TrueCaption TrueColor Value Add... Delete Filter... Engine Connections Events Name

Assigned Variable: S7:[DEMO]EB0 Browse...

Update rate (ms): Dead band:

100 0

After you select the property from the Automati hierarchy, enter the name of the variable to be assigned to that Apply property

OK

Cancel

Apply

Help

Figure A-4

Assigning a Variable in the Control Engine to a Property in a Control

5. Refer to Table A-1 and assign the variables to the SIMATIC controls. 6. Click on the Apply button to enter the assigned variables.

A-6

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Table A-1

Assigning Sample names to the SIMATIC Controls (for S7protocol) Name of variables S7:[DEMO]Demo Temperature S7:[DEMO]Demo Power S7:[DEMO]Demo Flow S7:[DEMO]EB0 S7:[DEMO]EB1 S7:[DEMO]EB2 Alias for MW1 Alias for DB10,W0 Alias for DB10,D0 Input byte 0 Input byte 1 Input byte 2 Description

Control S7Number1 S7Number2 S7Number3 S7vbBttn1 S7vbBttn2 S7vbBttn3

The variable names correspond to the itemIDs valid for the OPC

Selecting a Control Engine


Use the following procedure to configure the Data control for communicating with the control engine: 1. Select the Engine tab to configure the control engine. See Figure A-5. 2. Select the Direct Connect option and enter either @SimaticNet as the control engine. Click on the Apply button to enter the data, and then click on the OK button to close the dialog box.
Siemens SIMATIC Data Control Properties General Engine Connections Events Name

Select the option for a direct connection

Connect via Tag Source Tag Source Browse... Direct Connect PC Name Control Engine @SimaticNet

Enter @SimaticNet as the type of control engine

OK

Cancel

Apply

Help

Figure A-5

Connecting the Data Control to a Control Engine

SIMATIC Computing 6GK19710BA000AA1

A-7

SIMATIC Computing

Operating of the I/O Panel Program


Before you run the I/O Panel program, make certain that the communcation system is ready. 1. Select the File Save Project menu command to save the program before switching Visual Basic from Design mode to Run mode. 2. Click on the Start icon or select the Run Start menu command to switch Visual Basic from Design mode to Run mode to run the I/O panel program. 3. Click on the Button Control for EB0 to set the Input byte. The Button control changes color to show the state of EB0 4. Enter a value into the field Temp. 5. Monitor the changes of the values with the OPCScout.

A-8

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.1.3

Connecting Third-Party Controls to a SIMATIC Data Control


You can use the Data control to connect any ActiveX control (such as VB Label control) to data in the control engine. To create this sample application, you need the following items: S S Microsoft Visual Basic 5 or higher SIMATIC Data control from Computing

Creating a VB label that Displays a Value in the Control Engine


Use the following procedure to connect a Data control with a Label control: 1. Open a standard Visual Basic project: Use the File New Project menu command to display the New Project dialog box, then select the Standard EXE icon and click on the Open button. 2. Add the Siemens SIMATIC Data control to the VB toolbox. For information about adding controls to the VB toolbox, see Section A.1.1 and Figure A-6.

Components Controls Designers Insertable Objects

Siemens S7DiagBF Control Siemens S7Number Control Siemens S7Panel Control Siemens S7vbButton Control Siemens S7vbSlider Control Siemens SIMATIC Data Control Third-Party Control... Third-Party Control... Third-Party Control...

S Click on the SIMATIC Data control. S Click on the Apply button to add the
control to the VB toolbox.

S Click on the OK button to close the


Components dialog box.

Browse... Selected Items Only

Siemens SIMATIC Data Control Location: C:\SIEMENS\Common\OCX\S7WCDATX.OCX

OK

Cancel

Apply

Figure A-6

Adding the Data Control to the Visual Basic Toolbox

3. Insert a Data control onto the VB form. (For information about inserting controls onto the VB form, see Section A.1.1.) 4. Insert a VB label on your form. Change the Border Style property to 1Fixed Single. 5. Select the Data control and click the right mouse button to bring up the pop-up menu. From the pop-up menu, select Properties to display the Properties dialog box for the Data control. 6. From the Properties dialog box, select the Connections tab. Click on the + symbol to expand the list of controls.
SIMATIC Computing 6GK19710BA000AA1

A-9

SIMATIC Computing

7. Select the Label1 control and click on its + symbol to expand its properties list. 8. Select the Caption property and enter S7:[ DEMO]MB0 in the Assigned Variable field. A-7). Click on the Apply and OK buttons to enter the data and close the Properties dialog box.

Siemens SIMATIC Data Control Properties General Controls: Label1 Alignment Appearance Autosize BackColor BackStyle BorderStyle Caption DataField Add... Delete Filter... Engine Connections Events Name

Assigned Variable: S7:[DEMO]MB0 Browse...

Update rate (ms): Dead band: Automati Apply

100 0

Select the Caption property and enter S7:[DEMO]MB0 in the Assigned Variable field.

OK

Cancel

Apply

Help

Figure A-7

Assigning a Variable to the Caption Property of a VB Label Control

A-10

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Running the Sample Program for the Label Control


Save the program before switching Visual Basic from Design mode to Run mode. When the sample program runs, the caption of the label displays the value of MB0 in the control engine. Use the following procedure to configure the Data control for communicating with the control engine and for running the sample program. 1. Select the Engine tab to configure the control engine. See Figure A-8. 2. Select the Direct Connect option and enter either @SimaticNet as the control engine. Click on the Apply button to enter the data, and then click on the OK button to close the dialog box. 3. Switch Visual Basic from Design mode to Run mode to run the sample program.

Siemens SIMATIC Data Control Properties General Engine Connections Events Name

Select the option for a direct connection

Connect via Tag Source Tag Source Browse Direct Connect PC Name Control Engine @SimaticNet

Enter @SimaticNet as the type of control engine

OK

Cancel

Apply

Help

Figure A-8

Connecting to the Control Engine (Label Control Example)

SIMATIC Computing 6GK19710BA000AA1

A-11

SIMATIC Computing

A.1.4

Using Computing with Microsoft Excel 97


Using the Data control in an Excel spreadsheet allows you to access the values in the control engine. To create this sample application, you need the following items: S Microsoft Excel 97

Creating a Command Button in Excel 97


The first step in creating the sample Excel application is to create a command button. Use the following procedure to create a command button: 1. Start the Excel application. (If prompted about whether to enable or disable macros, select the Enable Macros option.) 2. In the following cells of the spreadsheet, enter the following labels: In cell A1, enter: MB0 In cell A2, enter: MB1 In cell A3, enter: MB2 3. Select the View Toolbars Control Toolbox menu command to display the Control toolbox. 4. Click on the Design Mode icon in the Control toolbox to put the spreadsheet into Design mode. 5. Insert a Command Button control onto the spreadsheet by clicking on the Command Button icon in the Control toolbox and then clicking the left mouse button in an empty area of the spreadsheet. 6. Move or size the Command Button control as required.

Using the Visual Basic Editor to Configure the Command Button


After you have created the command button, you use the Visual Basic Editor in Excel 97 to configure the command button for starting and stopping the program. Use the following procedure to configure the command button: 1. Select the command button (CommandButton1). 2. Select the Tools Macro Visual Basic Editor menu command to display the Visual Basic editor. 3. In the Properties window, select the Caption property of CommandButton 1 and enter the following caption: Start 4. Display the Code window by selecting the View>Code menu command. Select CommandButton1 from the drop-down list for the Object field. Enter the following code for the CommandButton1_Click() event: UserForm1.show 5. Close the Code window for CommandButton1.

A-12

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Creating a SIMATIC Data Control


1. Create a new user form by selecting the Insert>UserForm 2. In the Toolbox window, click the right mouse button to bring up a pop-up menu and select the Additional Controlsmenu command. (To display the Toolbox window, select the View>Toolbox menu command.) 3. Scroll through the list of controls and select the Siemens SIMATIC Data control (by selecting the check box). Click on the OK button to insert the Data control onto the toolbox. 4. Select the Data control icon in the Toolbox window and insert a Data control onto UserForm1. 5. Select the Data control and click the right mouse button to bring up the pop-up menu. From the pop-up menu, select the Properties menu command to display the properties for the Data control (S7Data1) in the Properties window. 6. In the Properties window for S7Data1, select the (Custom) property field and then click on the expansion button to display the Properties dialog box for the Data control.

Adding Events for the Data Control


1. In the Properties dialog box for the Data control, select Events tab. In the list under the Keys heading, select S7Data1. 2. Click on the Add button to add a new event key. See Figure A-9. In the Add dialog box, enter MB0 in the Add a new key field. After you click on the OK button, the event key is added to the S7Data1 control.

SIMATIC Computing 6GK19710BA000AA1

A-13

SIMATIC Computing

Siemens SIMATIC Data Control Properties General Keys: S7Soft1 S7Data1 Add Add a new key: MB0 Engine Connections Events

Select the Data control and click on the Add button to display the Add dialog box. Assigned Variable:
Name

Enter MB0 in the Add new key field and click on the OK button.

Add... OK Cancel

OK

Cancel

Apply

Help

Figure A-9

Adding an Event Key to the Data Control

3. In the Properties dialog box, enter the variable name S7:[DEMO]MB0 in the Assigned Variable field. See Figure A-10. 4. Click on the Apply button to accept the assigned variable. Notice that the event key MB0 appears in boldface under S7Data1. 5. Enter new event keys for MB1 (Variable S7:[DEMO] MB1) and MB2 (Variable S7:[DEMO]MB2) by selecting S7Data1 again and repeating steps 2. and 3.
Siemens SIMATIC Data Control Properties General Keys: S7Soft1 S7Data1 MB0 Update rate (ms): Dead band: 100 0 Engine Connections Events Name

Assigned Variable: S7:[DEMO]MB0 Browse...

Select the event key (MB0).


Add... Delete

Enter S7:[DEMO]MB0 in the Assigned Variable field and click on the Apply button.

OK

Cancel

Apply

Help

Figure A-10

Assigning a Variable to an Event Key

A-14

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Configuring the Control Engine for the Data Control


1. In the Properties dialog box for the Data control, select the Engine tab to configure the control engine. 2. Deactivate the option Auto Connect and specify @SimaticNet as the control engine. To enter the data, click teh Apply button; to close the dialog box, click OK.

Entering a Sample Program for the Data Control


1. Select the Data control in UserForm1. 2. Select the View Code command to open the code dialog for the data control.

3. Select S7Data2 from the drop-down list box of the Object box. 4. Enter the following program for the S7Data1_ValueChanged event, enter the following program: Select Case Property Case MB0 Worksheets(Sheet1).Range(B1).Value = Value Case MB1 Worksheets(Sheet1).Range(B2).Value = Value Case MB2 Worksheets(Sheet1).Range(B3).Value = Value End Select 5. Select UserForm from the dropdown list box of the object box. 6. Enter the following programm: Private Sub UserForm_Activate () S7Data1.Connect End Sub Private Sub UserForm_Deactivate S7Data1.Disconnect End Sub 7. Close the dialog for the data control and UserForm1.

Running the Sample Program


1. Select the File > Close and Return menu command to the spreadsheet. 2. Exit Design mode by clicking on the Exit Design Mode icon in the Toolbox window. 3. Connect the Excel spreadsheet to the control engine by clicking on the Start command button. 4. Use the OPCScout to change the memorybyte 0...2 and watch the changes in Excel.

SIMATIC Computing 6GK19710BA000AA1

A-15

SIMATIC Computing

Note To exit Excel or to activate the Excel menus, you must first close UserForm1.

A.2

Product Overview and Installation

A.2.1

Using an ActiveX Control to Access the Process Data


Computing provides access through the SIMATIC Data control to the process data being controlled by a control engine such as a Simatic Net Communicationsystem.You can use the standard SIMATIC controls provided with the Computing software (see Table A-2), or you can connect any other ActiveX control to the SIMATIC Data control.
Table A-2 Control Data Standard Controls Provided by Computing Representation Description Provides the connection to the control engine. Without the Data control, none of the other controls have access to the process data. Provides access to individual memory bits in the control engine. The Button control accesses only bits and has two values:

Button OFF

S Off = 0 (default color: red) S On = 1 (default color: green)


Changing the state of the Button control changes the state of the variable in your process that is associated with the control. If you configure the Button control to be readonly, then it functions like a lamp or LED. Number 0 Provides access to the variables on the control engine.You can access bytes, words, or double-words, and you can manipulate individual bits of this data. Entering a new value in the Number control changes the data in the control engine. Slider Provides access to variables in the control engine. You can access bytes, words, or double-words. Adjusting the value of the Slider control changes the data in the control engine.

A-16

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.3

Accessing the Process Data with the SIMATIC Data Control

Chapter Overview
The SIMATIC Data control provides the connection between your ActiveX controls and the control engine (for example, the protocol connection with S7). The Data control has specific properties that you can configure: S For container applications (such as MicroSoft Visual Basic): access the properties as for any other control in that container (for example, by using the right mouse button). Open the context menu for the Data control by clicking the right mouse button and selecting the Properties menu command.

SIMATIC Computing 6GK19710BA000AA1

A-17

SIMATIC Computing

A.3.1

Connecting the SIMATIC Controls to the Control Engine

Caution Failing to disable the timers in your program could cause timer-generated connections to remain connected, allowing these connections to continue to write data to the control engine. This could cause the control engine to operate erratically, which could potentially cause damage to equipment and injury to personnel. To ensure that all connections are disconnected when your program closes, always disable all timers before the End statement in the Form_Unload subroutine.

In order to access process data, the SIMATIC controls (Button, Number or Slider) must first establish a connection through the Data control. Figure A-11 shows the relationship between the Data control and the other SIMATIC controls. You use the Connections tab of the Data control to assign a variable (the memory location) to the Value property of each SIMATIC control. The Data control configures the control engine to check the assigned variables at a specified rate (in milliseconds). If there is a change in the value, the new value is written to the Data control. The Data control then writes the new value to the other controls.

Third-party control SIMATIC Button control SIMATIC Number control Computing SIMATIC Slider control SIMATIC Data control

OPC Client

OPC Server

Control Engine (i.e. DPprotocol) Distributed I/O Figure A-11 Using the SIMATIC Data Control for Connecting to a Control Engine

A-18

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.3.2

Configuring the Connection Properties for the Data Control


As shown in Figure A-12 the General tab allows you to configure the following parameters for the connection to the control engine: S Autoconnect (automatic connection): when this option is enabled, the Data control automatically connects to the process variables in the control engine. When this option is disabled, the Data control connects to the variables only when instructed by the program code (using a Connect method) that you associated with the control. Autoconnect Timeout: time-out (in milliseconds) for the automatic connection: specifies the amount of time that the Data control waits between connecting to the control engine and writing data. Some containers may not provide a mechanism for telling the Data control to write to the control engine. After the time-out that you specify, the Data control starts writing data. S S Default Update Rate (ms): specifies the rate that the control engine checks the process variables to see if change has occurred. Default Dead Band: specifies to the control engine the amount of change that must occur in a value before the control engine writes the new value to the Data control. For example: if the dead band is 10 and the value in the control engine is 22, then the control engine does not write a new value until the value becomes either 33 or 11. Show Error Boxes: specifies whether to display the default error boxes when there is a user-generated error. Computing provides error messages in English only. If you want to display messages in other languages, you must deselect this option and write program code to react on the error event.
Siemens SIMATIC Data Control Properties General Engine Connections Events Name

AutoConnect: AutoConnect Timeout (ms): Default Update Rate (ms): Default Dead Band: Show Error Boxes: 100 100 0

OK

Cancel

Apply

Help

Figure A-12

SIMATIC Data Control Properties (General Tab)

SIMATIC Computing 6GK19710BA000AA1

A-19

SIMATIC Computing

A.3.3

Selecting the Control Engine for the Data Control


Computing allows you to connect either to a single control engine or to several control engines. You can also connect to the control engine over a network, such as a local area network (LAN). Use the Engine tab of the Properties dialog box to select the control engine. See Figure A-13. In the type of operation with Simatic Net communication systems as described in this manual a control engine is a software module for binding a communication protocol. S If you select the Direct Connection option, enter the name of the control engine. If you are connecting to a control engine over a network, enter the computer name of the target computer in the PC Name field. Enter for operating with Simatic Net the following strings in the Control Engine field: @SimaticNet S If you want to use a symbol file, select the Connection via Tag Source option. In the Tag Source field, enter (or browse to) the tag source or file that identifies symbols for the variables and control engines to be accessed.
Siemens SIMATIC Data Control Properties General Engine Connections Events Name

Connection via Tag Source Tag Source Browse Direct Connection PC Name Control Engine @SimaticNet

OK

Cancel

Apply

Help

Figure A-13

SIMATIC Data Control Properties (Engine Tab)

A-20

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

As shown in Figure A-14, clicking on the Browse button allows you to search for a valid tag source (*.tsd). The tag source provides the symbolic identification that allows you to access different control engines from one Data control.
Siemens SIMATIC Data Control Properties General Engine Connections Events Name

Connection via Tag Source Tag Source Browse Direct Connection PC Name Control Engine @SimaticNet

Click on the Browse button to select a specific tag file for the SIMATIC controls
OK Cancel

Figure A-14

Selecting a Tag File for the Data Control

After you select the type of connection (single control engine or multiple control engines), click on the Apply button to enter your selections for the Data control properties.

SIMATIC Computing 6GK19710BA000AA1

A-21

SIMATIC Computing

A.3.4

Connecting to a Specific Control Engine over DCOM


As shown in Figure A-15, you can use the SIMATIC Data control to connect your program to a control engine residing on a different computer.

Note When you configure the SIMATIC Data control to connect to a single (specific) control engine, you cannot connect a tag file. This means that you cannot use symbol names for the variables in the control engine. To use symbol names, select the option for connecting to multiple control engines and browse to a tag file that contains symbols for only one control engine.

Third-party control SIMATIC Button control SIMATIC Number control SIMATIC Slider control SIMATIC Data control

DCOM

PC 1

PC 2

WinLC

Figure A-15

Connecting to a Specific Control Engine over DCOM

Use the following procedure to configure the SIMATIC Data control for communicating over DCOM with a control engine on a remote computer: 1. Open a container application (such as Visual Basic). 2. Insert a SIMATIC Data Control in a form.

A-22

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

3. Doubleclick on the Data control to display the Properties dialog box for the Data control. 4. Click on the Engine tab to display the configuration choices. See Figure A-16. 5. Select the Direct Connection option. 6. In the PC Name field, enter the network name of server computer (for example, PC_2). 7. In the Control Engine field, enter the name of the control engine: @SimaticNet (using Simatic Net). 8. Click on the OK button to configure the Data control for communicating with the remote control engine. All of the controls that you insert and connect through this Data control will access the variables in the remote control engine.

Note You must have configured the different computers for DCOM. For additional information about DCOM, refer to the online help for Windows NT.

Siemens SIMATIC Data Control Properties General Engine Connections Events Name

Connection via Tag Source Tag Source

Select Direct Connection and enter the name of the server computer and the control engine
Browse

Direct Connection PC Name Control Engine PC_2 @SimaticNet

OK

Cancel

Apply

Help

Figure A-16

Configuring DCOM for a Specific Control Engine

SIMATIC Computing 6GK19710BA000AA1

A-23

SIMATIC Computing

A.3.5

Connecting the ActiveX Controls to the Control Engine


As shown in Figure A-17, the Connections tab shows the ActiveX controls (whether they are SIMATIC controls or third-party) that can be connected to the control engine.

Siemens SIMATIC Data Control Properties General Controls: S7Soft1 S7Data1 S7vbBttn1 S7vbBttn2 S7WCNumber1 S7WCNumber2 Dead band: Automatic write Add... Delete Filter... Apply filter Update rate (ms Click on the box with the plus Browse... Engine Connections Events Name

Assigned Variable:

sign (or double-click on the name of the Data control) to expand the hierarchy of controls on the form. Expand the controls to access the individual properties.

OK

Cancel

Apply

Help

Figure A-17

SIMATIC Data Control Properties (Connections Tab)

Adding a Connection
If you want to configure a connection for an ActiveX control before you place the control into your ActiveX container, you can use the Add button to add an instance of the control to the Controls list. As shown in Figure A-18, click on the Add button to specify the instance that you want to connect to the Data control. After you have added the ActiveX control instance to the Controls list, you can select the instance from the list, choose the Add button again and add any additional properties. For instance, you could add a SIMATIC Number control instance to the connections list, and then add the Value property to the Number control in order to assign a variable to the Number control.

A-24

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Note If you have attached a tag file to the Data control or use the process variable from Simatic Net, you can enter the symbols instead of the absolute addresses. You can also click on the Browse button to navigate to the symbol.

Siemens SIMATIC Data Control Properties General Controls: S7Data1 S7vbBttn1 Enabled FalseCaption FalseColor Font ToolTipText TrueCaption TrueColor Value Add... Delete Filter... Engine Connections Events Name

Assigned Variable: S7:[DEMO]Power Browse...

Update rate (ms): Dead band: Automati Appl

100

After you select the property from the hierarchy, enter the name of the variable to be assigned to that property

OK

Cancel

Apply

Help

Figure A-18

SIMATIC Data Control Properties (Connections Tab)

Siemens SIMATIC Data Control Properties General Controls: S7Soft1 S7Data1 S7vbBttn1 Enabled Value S7vbBttn2 S7WCNumber1 Automatic writ Add... Delete Filter... Apply filter Update rate (ms): Dead band: 100 0 Browse... Engine Connections Events Name

Assigned Variable:

Click on the Browse button to check the process range.

OK

Cancel

Apply

Help

Figure A-19

SIMATIC Data Control Properties (Connections Tab)

SIMATIC Computing 6GK19710BA000AA1

A-25

SIMATIC Computing

Deleting a Connection
If you remove a control from the ActiveX container, the connection remains configured in the Data control. This means that the next time you place a control of the same name into the container, the connection that you configured for the previous control of that name is automatically applied to the new control. For instance, if you remove a control called Number1, and later insert a new Number control, the default name for the new control is Number1, and the new control inherits the existing Number1 connection. Use the Delete button if you want to prevent new controls from inheriting a previously configured connection: from the Controls list, select the instance whose connection you want to delete, and click on the Delete button.

Note If you remove a control, or change your mind about adding a control after you have already configured a connection for it using the Add button, you can only delete the connection to it if there is no control in the ActiveX container that uses the name specified in the connection. Delete the connection before you add any other control that uses the name that is specified in the connection. You cannot use the Delete button to remove a connection to a control that is present in the ActiveX container.

A-26

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.3.6

Filtering the Properties for the ActiveX Controls


The Data control provides a filter that allows you to display a subset of the properties for the controls. For example, you may want to display only the Enabled and Value properties and avoid scrolling through all of the other properties for each control. Use the following procedure for filtering the properties: 1. Access the Properties dialog box for the Data control. 2. As shown in Figure A-20, click on the Filter button.

Siemens SIMATIC Data Control Properties General Controls: S7Soft1 S7Data1 S7vbBttn1 S7vbBttn2 S7WCNumber1 S7WCNumber2 Dead band: 0 Update rate (ms): 100 Engine Connections Events Name

Assigned Variable:

Click on the Filter button to select the properties to be displayed

Automatic write mode: Add... Delete Filter... Apply filter to properties

OK

Cancel

Apply

Help

Figure A-20

SIMATIC Data Control Properties (Connections Tab)

3. As shown in Figure A-21, enter the properties to display and click on the Add button. Use the Edit button to correct entries and the Delete button to remove entries. 4. As shown in Figure A-22, select the Apply filter to properties check box to display only the properties listed in the filter. Use the Apply filter to properties check box to toggle the filter on and off.

SIMATIC Computing 6GK19710BA000AA1

A-27

SIMATIC Computing

Siemens SIMATIC Data Control Properties General Controls: S7Soft1 S7Data1 SIM SIM SIM SIM Add... OK Add... Edit Delete Cancel 0 Engine Connections Events Name

Property Filter Visible Properties: Enabled Value 100

Click on the Add button to enter a property to the filter

mode:
properties

OK

Cancel

Apply

Help

Figure A-21

SIMATIC Data Control Properties (Connections Tab)

Siemens SIMATIC Data Control Properties General Controls: S7Soft1 S7Data1 S7vbBttn1 Enabled Value S7vbButton2 S7WCNumber1 S7WCNumber1 Add... Delete Filter... Update rate (m Dead band: Automatic write mode: Apply filter to properties Browse... Engine Connections Events Name

Assigned Variable:

Click on the check box to toggle the property filter on and off

OK

Cancel

Apply

Help

Figure A-22

SIMATIC Data Control Properties (Connections Tab)

A-28

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.3.7

Configuring Custom Events


As shown in Figure A-23, the Events tab allows you to add custom events that are triggered by the Data control. You enter a key (string) and assign that key to a process variable. If that variable changes, then the Data control generates an event with a parameter that contains the string that you entered in the Key field. Your program can then react to this event. See Section Sample Program for Responding to Events for a sample program that responds to events.
Siemens SIMATIC Data Control Properties General Keys: S7Soft1 S7Data1 OverflowWarning Update rate (ms): Dead band: 100 0 Engine Connections Events Name

Assigned Variable: DP:[Demo]DemoPower Browse...

Add...

Delete

OK

Cancel

Apply

Help

Figure A-23

SIMATIC Data Control Properties (Events Tab)

Adding an Event
The Add button allows you to add user-specified events for controller value changes. You can write your own code to handle the event by handling the ValueChanged event of a Data control. Select a Data control from the expandable list under the Keys field and click on the Add button; then type any name you choose for the event (for example, OverflowWarning). Next, type a variable in the Assigned Variable field to identify the process value that causes the event to be fired. Figure A-23 shows an sample event that has been added. A change in the value of the variable DP:[Demo]DemoPower calls the event handler for the Data control. The input to the event handler is the text string OverflowWarning.

Deleting an Event
To delete a user-specified event, expand the list under Keys, select the desired event, and click on the Delete button.
SIMATIC Computing 6GK19710BA000AA1

A-29

SIMATIC Computing

A.3.8

Creating a Connection Table


The Data control uses a connection table for determining which property of the various controls are connected to specific process variables of the control engine. Each connection table contains an entry for each connection. Each entry contains the following information: S S S Property name: this field identifies the property that has an assigned variable. Data source: this field identifies the name of the process variable. Update rate: this field defines the update rate for the connection. If no value is entered in this field, the Data control uses the default update rate (which is the value stored in the DefaultUpdateRate property). Default Dead Band: this field defines the dead band for automatically writing to the control engine or the control. If no value is entered in this field, the Data control uses the default update rate (which is the value stored in the DefaultDeadBand property).

When you use the Properties dialog box to configure the Data control, the Data control automatically creates a connection table. You can also create a program to manually create connection tables. See Section A.3.9 for a sample program for manually creating a connection table.

A-30

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.3.9

Sample Program for Creating a Connection Table and an Event Table


You can write a program to create a table to define the connections (assigned variables) or events for the control engine.

Using a Connection Table


You can create a connection table to assign a variable in the control engine to a specific control. The connection table corresponds to the Connections tab on the Properties dialog box of the Data control. For each element in the connection table, you must define the property in the control for the connection, the source (process variable of the assigned variable in the control engine), the update rate, and the dead band value. In order to programmatically change connections with a connection table, you must first disconnect the data control (ending all connections) before you can reassign connections and reconnect the Data control.

Note Instead of creating a connection table, consider using the read and write methods for the Data control (ReadVariable, ReadMultipleVariables, WriteVariable, and WriteMultipleVariables). These methods allow you to access more data with just one line of code.

Table A-3 shows, how to assign the property caption of a label control with the name lblChange to the process variable S7:[DEMO]MW2 using program code.The value stored in MW2 displays as the caption in the label control.

Table A-3

Sample Program for Manually Creating a Connection Table

Visual Basic Code Dim ControlTable (4) As String Define a ControlTable ControlTable ControlTable ControlTable connection table for lblChange (0) = Caption Property<HR+> (1) = S7:[Demo]MW2 Source (memory location) (2) = 100 Update rate (3) = 0.0 Dead band

Attach the connection table to S7Data1 S7Data1.ConnectObject lblChange, ControlTable Connect to the control engine S7Data1.Connect Connects to the control engine

SIMATIC Computing 6GK19710BA000AA1

A-31

SIMATIC Computing

Using an Event Table


You can also create an event table to define events for the control engine. The event table corresponds to the Events tab on the Properties dialog box of the Data control. Table A-4 provides the sample Visual Basic code for creating an event table. Section A.3.10 provides a sample program that responds to events. This sample program uses an event table to define the events for control engine.

Table A-4

Sample Program for Manually Creating an Event Table

Visual Basic Code Dim ControlTable(4) As String define the event keys ControlTable(0) = m0_0 ControlTable(1) = S7:[DEMO]m0.0 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_1 ControlTable(1) = S7:[DEMO]m0.1 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_2 ControlTable(1) = S7:[DEMO]m0.2 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_3 ControlTable(1) = S7:[DEMO]m0.3 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_4 ControlTable(1) = S7:[DEMO]m0.4 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_5 ControlTable(1) = S7:[DEMO]m0.5 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_6 ControlTable(1) = S7:[DEMO]m0.6 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_7 ControlTable(1) = S7:[DEMO]m0.7 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) End

Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band

A-32

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.3.10

Sample Program for Responding to Events


You can create a program that responds to events in the control engine. In this sample program, eight lights correspond to the eight events which are defined in a connection table. See Figure A-24. The events are connected to the status of memory location MB0: a change in the value stored in MB0 generates a set of events (named for each bit in the byte). As shown in Figure A-24, the program also contains the following elements: S S S Data control (S7Data4) for connecting to the control engine Timer (Timer1) that increments the value stored in MB0 (which then causes the control engine to generate the events) Command button (cmdStartEvent) for starting or stopping the timer (thereby starting or stopping the generation of events)
WinAC VB5 Programming Example Light(0) to Light(7): These VB shapes change color to display the events stored in MB0

Start Events

cmdStartEvent: This command button starts (or stops) the events

S7Data4 Connects these elements to the control engine

Timer1: generates a ReadVariable and WriteVariable at fixed intervals

Figure A-24

Sample Program for Responding to Events in the Control Engine

Caution Failing to disable the timers in your program could cause timer-generated connections to remain connected, allowing these connections to continue to write data to the control engine. This could cause the control engine to operate erratically, which could potentially cause damage to equipment and injury to personnel. To ensure that all connections are disconnected when your program closes, always disable all timers before the End statement in the Form_Unload subroutine.

SIMATIC Computing 6GK19710BA000AA1

A-33

SIMATIC Computing

Creating an Event Table for the Sample Program


Your program can create an event table to define specific events in the control engine.Table A-5 lists the code for creating a connection table for defining event keys for a control engine.

Table A-5

Sample Program for Creating a Connection Table for Responding to Events

Visual Basic Code Dim ControlTable(4) As String define the event keys ControlTable(0) = m0_0 ControlTable(1) = S7:[DEMO]m0.0 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_1 ControlTable(1) = S7:[DEMO]m0.1 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_2 ControlTable(1) = S7:[DEMO]m0.2 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_3 ControlTable(1) = S7:[DEMO]m0.3 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_4 ControlTable(1) = S7:[DEMO]m0.4 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_5 ControlTable(1) = S7:[DEMO]m0.5 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_6 ControlTable(1) = S7:[DEMO]m0.6 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) ControlTable(0) = m0_7 ControlTable(1) = S7:[DEMO]m0.7 ControlTable(2) = 500 ControlTable(3) = 0 lResult = S7Data1.ConnectName(, ControlTable) End

Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band Event name process variable update rate dead band

A-34

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Responding to the Events Generated by the Sample Program


The program listing in table A-6 shows how to respond to different events from the control engine.

Table A-6

Sample Programm for Responding to Events in the Control Engine

Visual Basic Code Private Sub S7Data4_ValueChanged(ByVal Property As String, ByVal VarName As String, ByVal Value As Variant, ByVal Quality As Integer) Evaluates which event occurred Select Case Property Case M0_0 If Value = True Then Light(0).FillColor = vbGreen Else Light(0).FillColor = vbRed End If Case M0_1 If Value = True Then Light(1).FillColor = vbGreen Else Light(1).FillColor = vbRed End If Case M0_2 If Value = True Then Light(2).FillColor = vbGreen Else Light(2).FillColor = vbRed End If Case M0_3 If Value = True Then Light(3).FillColor = vbGreen Else Light(3).FillColor = vbRed End If Case M0_4 If Value = True Then Light(4).FillColor = vbGreen Else Light(4).FillColor = vbRed End If Case M0_5 If Value = True Then Light(5).FillColor = vbGreen Else Light(5).FillColor = vbRed End If Case M0_6 If Value = True Then Light(6).FillColor = vbGreen Else Light(6).FillColor = vbRed End If Event M0_0 turns Light(0) green

Event M0_1 turns Light(1) green

Event M0_2 turns Light(2) green

Event M0_3 turns Light(3) green

Event M0_4 turns Light(4) green

Event M0_5 turns Light(5) green

Event M0_6 turns Light(6) green

SIMATIC Computing 6GK19710BA000AA1

A-35

SIMATIC Computing

Table A-6

Sample Programm for Responding to Events in the Control Engine, continued


Event M0_7 turns Light(7) green

Case M0_7 If Value = True Then Light(7).FillColor = vbGreen Else Light(7).FillColor = vbRed End If End Select End Sub

Running the Sample Program (Generating the Events in the Control Engine)
The code listed in Table A-7 changes the value stored in MB0. These changes then causes the control engine to generate the events defined in the connection table (Table A-5). S S The command button (cmdStartEvents) starts or stops the timer (Timer1). The timer (Timer1) reads the value stored in MB0 of the control engine, increments the value, and writes the new value back to the control engine.

The changed value of MB0 causes the control engine to generate the events.

Warning Failing to disable the timers in your program could cause timer-generated connections to remain connected, allowing these connections to continue to write data to the control engine. This could cause the control engine to operate erratically, which could potentially cause damage to equipment and injury to personnel. To ensure that all connections are disconnected when your program closes, always disable all timers before the End statement in the Form_Unload subroutine.

A-36

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Table A-7

Other Subroutines for Running the Sample Program

Visual Basic Code Private Sub cmdStartEvents_Click() If cmdStartEvents.Caption = Start Events Then Timer1.Enabled = True cmdStartEvents.Caption = Stop Events Else Timer1.Enabled = False cmdStartEvents.Caption = Start Events End If End Sub Private Sub Timer1_Timer() Dim mb0 As Variant Dim my_state As Long S7Data4.ReadVariable S7:[Demo]MB0.0, mb0, my_state, 0 If mb0 < 254 Then mb0 = mb0 + 1 Else mb0 = 0 End If Label2.Caption = mb0 S7Data4.WriteVariable S7:[Demo]MB0.0, mb0, 0 End Sub

A.3.11

Sample Programs for Reading and Writing Data


You can write a program that initiates access to data (reading or writing) in the control engine.

Reading a Single Variable in the Control Engine


The program listing in Table A-8 uses the ReadVariable method of the Data control to read a single variable in the control engine.

Table A-8

Reading a Single Variable from the Control Engine

Visual Basic Code Private Sub ReadSingleRealVariable Dim rc As Long Dim name_s As String Dim value_v As Variant Dim state_l As Long Dim timeout_l As Long

SIMATIC Computing 6GK19710BA000AA1

A-37

SIMATIC Computing

Table A-8

Reading a Single Variable from the Control Engine, continued

Read one value name_s = S7:[Demo]MD0 timeout_l = 0 rc = S7Data3.ReadVariable(name_s, value_v, state_l, timeout_l) Display the value and return code in a List Box ListBox1.Clear ListBox1.AddItem RetCode = & Hex(rc) ListBox1.AddItem & name_s & = & value_v ListBox1.AddItem State = & Hex(state_l) End Sub

A-38

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Writing a Single Variable to the Control Engine


The program listing in Table A-9 uses the WriteVariable method of the Data control to write a single variable to the control engine.

Table A-9

Writing a Single Variable to the Control Engine

Visual Basic Code Private Sub WriteSingleRealVariable Dim rc As Long Dim name_s As String Dim value_v As Variant Dim timeout_l As Long Write one value name_s = S7:[Demo]MD0 value_v = (Rnd * 1000) timeout_l = 100 rc = S7Data3.WriteVariable(name_s, value_v, timeout_l) Display the value and return code in a List Box ListBox1.Clear ListBox1.AddItem Wrote & name_s & = & value_v ListBox1.AddItem Return Code = & Hex(rc) End Sub

Reading an Array in the Control Engine


The program listing in Table A-10 uses the ReadVariable method of the Data control to read an array of data in the control engine.

Table A-10 Sample Program for Reading an Array of Variables


Visual Basic Code Private Sub ReadArrayOfReals Dim rc As Long Dim name_s As String Dim value_v As Variant Dim state_1 As Long Dim timeout_l As Long Randomize Read an array oof values name_s = S7:[Demo]MD0,3 timeout_l = 0 rc = S7Data3.ReadVariable(name_s, value_v, state_1, timeout_l) Display the values ListBox1.Clear ListBox1.AddItem ListBox1.AddItem value_v(2) ListBox1.AddItem End Sub and return codes for the array in a List Box Return Code = & Hex(rc) name_s & = & value_v(0) & & value_v(1) & State = & Hex(state_1)

SIMATIC Computing 6GK19710BA000AA1

A-39

SIMATIC Computing

Writing an Array to the Control Engine


The program listing in Table A-10 uses the WriteVariable method of the Data control to write an array of data to the control engine.

Table A-11 Sample Program for Writing an Array of Variables


Visual Basic Code Private Sub WriteArrayOfReals Dim rc As Long Dim name_s As String Dim timeout_l As Long Dim value_b(2) As Byte for byte write Dim value_w(2) As Integer for word write Dim value_r(2) As Single for real write Read an array of values name_s = S7:[Demo]DB10,REAL0,3 value_r(0) = (Rnd * 1000) value_r(1) = (Rnd * 1000) value_r(2) = (Rnd * 1000) timeout_l = 100 rc = S7Data3.WriteVariable(name_s, value_r, timeout_l) Display the values ListBox1.Clear ListBox1.AddItem ListBox1.AddItem ListBox1.AddItem ListBox1.AddItem End Sub and return codes for the array in a List Box Return Code = & Hex(rc) Wrote MD0:REAL[0] = & value_r(0) Wrote MD0:REAL[1] = & value_r(1) Wrote MD0:REAL[2] = & value_r(2)

A-40

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.3.12

Sample Program for Reading and Writing Boolean Data


For reading and writing Boolean data, you must use the ReadMultiVariables method or WriteMultiVariables method. Table A-12 provides a sample program for reading and writing arrays of Boolean data.

Table A-12 Reading and Writing Multiple Variables


Visual Basic Code Private Sub Read_Booleans() Dim mybools(7) As String Dim vals_v As Variant Dim states_v As Variant Dim rc As Long mybools(0) mybools(1) mybools(2) mybools(3) mybools(4) mybools(5) mybools(6) mybools(7) = = = = = = = = S7:[Demo]M0.0 S7:[Demo]M0.1 S7:[Demo]M0.2 S7:[Demo]M0.3 S7:[Demo]M0.4 S7:[Demo]M0.5 S7:[Demo]M0.6 S7:[Demo]M0.7

rc = S7Data1.ReadMultiVariables(mybools, vals_v, states_v) End Sub Private Sub Write_Booleans() Dim mybools(7) As String Dim myvals(7) As Variant Dim states_v As Variant Dim rc As Long mybools(0) = S7:[Demo]M0.0 mybools(1) = S7:[Demo]M0.1 mybools(2) = S7:[Demo]M0.2 mybools(3) = S7:[Demo]M0.3 mybools(4) = S7:[Demo]M0.4 mybools(5) = S7:[Demo]M0.5 mybools(6) = S7:[Demo]M0.6 mybools(7) = S7:[Demo]M0.7 myvals(0) myvals(1) myvals(2) myvals(3) myvals(4) myvals(5) myvals(6) myvals(7) = = = = = = = = False False False False False False False False

rc = S7Data1.WriteMultiVariables(mybools, myvals, states_v) End Sub

SIMATIC Computing 6GK19710BA000AA1

A-41

SIMATIC Computing

A.3.13

Properties, Methods, and Events of the Data Control


You use the properties and methods listed in Table A-13 to manipulate the Data control.
Table A-13 Properties and Methods of the SIMATIC Data Control Property or Method Activated AutoConnect property AutoConnectTimeout property Connect method ConnectName method ConnectObject method ControlEngine property DefaultDeadband property DefaultUpdateRate property Disconnect method MultipleEngines property PCName property PropertyChangedName method PropertyChangedObject method ReadMultiVariables method ReadVariable method ShowErrorBoxes property TagSource property WriteMultiVariables method WriteVariable method Description Specifies whether or not all connections are activated Specifies whether or not the configured connections are established at runtime Specifies a timeout value Establishes all configured connections Establishes connections for the object that is specified by name Establishes connections for a specified object Specifies the control engine for the connection Specifies the dead band used by the Data control, if no dead band is specified in the connection table Specifies the update rate used by the SIMATIC DataControl, if no update rate is specified in the connection table Releases all established connections Specifies whether the connection is to one specific control or to several control engines Specifies the network identification for a remote computer (for connecting over a network) Notifies the Data control that the value of a property of a connected control, referenced by Name, has changed Notifies the Data control that the value of a property of a connected control, referenced by Object, has changed Reads the status of several variables in the control engine Reads the status of several variables in the control engine Specifies whether to display the default error boxes when there is a user-generated error Specifies the source (such as a tag file) of symbolic information Writes new values to several variables in the control engine Writes a new value to a specific variable in the control engine

The control responds to the events listed in Table A-14.

A-42

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Table A-14 Events of the SIMATIC Data Control Event ConnectionError ValueChanged Description Occurs when an error on a connection occurs Occurs when the value of a connected variable changes and no connected event was specified on the call to the Connect method

When an error occurs in the Data control, the control generates a ConnectionError event. Your program can capture this ConnectionError event and respond to specific situations. The ConnectionError event can detect standard OLE errors, such as E_FAIL or E_OUTOFMEM. Table A-15 lists some of the error codes.
Table A-15 SIMATIC Data Control Error Codes Error Code 0x80004005 0x8007000E 0x80070057 0xC0040007 0xC004000B General OLE failure Out of available memory Invalid variable syntax Invalid variable type Value passed to write is out of range Description

SIMATIC Computing 6GK19710BA000AA1

A-43

SIMATIC Computing

A.4

Properties and Methods of the SIMATIC Controls

A.4.1

Activated Property
Applies to: SIMATIC Data This property allows you to specify whether or not all connections are activated. Syntax: object.Activated [= value] The Activated property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Boolean expression that specifies whether object can respond to user-generated events.

The settings for value are: Setting True False Description (default) All connections are activated. All connections are deactivated.

Note The connections remain established, even if they are deactivated.

A.4.2

Alignment Property
Applies to: SIMATIC Number This property specifies the alignment of the number in the control. Syntax: object.Alignment [= value] The Alignment property has these parts:

A-44

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Part object value

Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the alignment.

The settings for value are: Setting 0 or Left 1 or Right 2 or Center Description (default) The number is aligned to the left side of the field. The number is aligned to the right side of the field. The number is centered in the field.

A.4.3

Appearance Property
Applies to: SIMATIC Number If this property is set to 3D (1), the Appearance property draws controls with three-dimensional effects if the BorderStyle property is set to Fixed Single (1). If the property is set to Flat (0), a flat border will surround the controls rectangle.

Note This property only has an effect if the BorderStyle property is set to Fixed Single (1).

Syntax: object.Appearance [= value] The Appearance property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the appearance of object.

The settings for value are: Setting 0 or Flat 1 or ThreeD Description Paints the controls and forms without visual effects. (default) Paints the controls with three-dimensional (3-D) effects.

SIMATIC Computing 6GK19710BA000AA1

A-45

SIMATIC Computing

A.4.4

AutoConnect Property
Applies to: SIMATIC Data This property allows you to specify whether or not the configured connections are established at runtime. Syntax: object.AutoConnect [= value] The AutoConnect property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Boolean expression that specifies whether object can respond to user-generated events.

The settings for value are: Setting True False Description (default) All configured connections will be established at runtime. The connections will be established with a call to the Connect method.

A.4.5

AutoConnectTimeout Property
Applies to: SIMATIC Data This property allows you to specify a timeout. After the time specified, the SIMATIC Data Control issues a call to its Connect method if the AutoConnect property is set to True. The value can also be specified at the General Property Tab. Syntax: object.AutoConnectTimeout [= value] The AutoConnectTimeout property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value of the type Long, which states the timeout in milliseconds.

A-46

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.6

BackColor Property
Applies to: SIMATIC Number This property returns or sets the background color of an object. Syntax: object.BackColor [= value] The BackColor property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the background color of an object.

The settings for value are: Setting Standard Colors Windows System Colors Description Colors specified by using the RGB Color palette Colors specified by system color constants (depending on the container); for example, colors listed in the Visual Basic (VB) object library in the Object Browser

A.4.7

BorderStyle Property
Applies to: SIMATIC Number If the property has the value Fixed Single (1), the control is surrounded by a rectangular border. If the property has the value None (0), no border will be displayed.

Note This property determines whether the Appearance property has any effect.

Syntax: object.BorderStyle [= value] The BorderStyle property has these parts:

SIMATIC Computing 6GK19710BA000AA1

A-47

SIMATIC Computing

Part object value

Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the border style.

The settings for value are: Setting 0 or None 1 or FixedSingle Description (default) No border or border-related elements A fixed, single-line border

A.4.8

Caption1 and Caption2 Properties


Applies to: SIMATIC Number These properties specify the displayed text of the first (Caption1) and second (Caption2) labels. Syntax: object.Caption1 [= value] object.Caption2 [= value] The Caption1 and Caption2 properties have these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A String value that specifies the text of the label.

A.4.9

Caption1Alignment and Caption2Alignment Properties


Applies to: SIMATIC Number These properties specify the alignment of the first (Caption1Alignment) or second (Caption2Alignment) labels. Syntax: object.Caption1Alignment [= value] object.Caption2Alignment [= value] The Caption1Alignment and Caption2Alignment properties have these parts:

A-48

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Part object value

Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the alignment of the label.

The settings for value are: Setting 0 or Left 1 or Right 2 or Center Description (Default for the first label) The label is aligned to the left side of the field. (Default for the second label) The label is aligned to the right side of the field. The label is centered in the field.

A.4.10

Caption1BackColor, Caption2BackColor Properties


Applies to: SIMATIC Number These properties return or set the background colors of the labels. The first label is determined by the Caption1BackColor property, and the second label is determined by the Caption2BackColor property. Syntax: object.Caption1BackColor [= value] object.Caption2BackColor [= value] The Caption1BackColor and Caption2BackColor properties have these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the background color of object.

The settings for value are: Setting Standard Colors Windows System Colors Description Colors specified by using the RGB Color palette Colors specified by system color constants (depending on the container); for example, colors listed in the Visual Basic (VB) object library in the Object Browser

SIMATIC Computing 6GK19710BA000AA1

A-49

SIMATIC Computing

A.4.11

Caption1Font and Caption2Font Properties


Applies to: SIMATIC Number This property returns a Font object for the font of the first (Caption1Font) or second (Caption2Font) label. Syntax: object.Caption1Font object.Caption2Font The Caption1Font and Caption2Font properties have these parts: Part object Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list.

A.4.12

Caption1ForeColor, and Caption2ForeColor Properties


Applies to: SIMATIC Number These properties return or set the foreground colors of the labels. The first label is determined by the Caption1ForeColor property, and the second label is determined by the Caption2ForeColor property. Syntax: object.Caption1ForeColor [= value] object.Caption2ForeColor [= value] The Caption1ForeColor and Caption2ForeColor properties have these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the background or foreground colors of object.

The settings for value are: Setting Standard Colors Windows System Colors Description Colors specified by using the RGB Color palette Colors specified by system color constants (depending on the container); for example, colors listed in the Visual Basic (VB) object library in the Object Browser

A-50

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.13

Caption1Size and Caption2Size Properties


Applies to: SIMATIC Number If the layout type is horizontal, than you can specify a width (in twips) of the first (Caption1Size) and second (Caption2Size) labels. If the layout type is vertical, than it specifies the height (in twips) of the labels. If you do not specify a size (if you accept the default value of -1), then the size will be calculated by the space required for the text. Syntax: object.Caption1Size [= value] object.Caption2Size [= value] The Caption1Size and Caption2Size properties have these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that allows the user is to determine a specific size for a label. The default value (-1) specifies that the size be determined by the length of the text for the label.

A.4.14

Connect Method
Applies to: SIMATIC Data This method establishes all configured connections. Syntax: result = object .Connect The Connect method has these parts: Part object result Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A long value that indicates whether an error has occurred. The result is zero if no error occurs.

SIMATIC Computing 6GK19710BA000AA1

A-51

SIMATIC Computing

A.4.15

ConnectName Method
Applies to: SIMATIC Data This method establishes connections for the object that is specified by the name of the object on the form (such as S7Number1).

Note A programmer who uses Visual Basic (or a similar programming language) would use the ConnectName method, while a programmer who uses Visual C (or a similar programming language) would use the ConnectObject method.

Syntax: result = object.ConnectName ConnectedObject, ConnectionTable The ConnectName method has these parts: Part object result ConnectedObject Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A long value that indicates whether an error has occurred. The result is zero if no error occurs. A String expression that evaluates to the name of an object that should be connected. If this parameter is set to an empty String, the control generates the ValueChanged event if a connected variable changes. (optional) Specifies a connection table. If this parameter is omitted, the control reads the ConnectionTable property of the ConnectedObject. The connection table is declared as an array. Each element in the array has the following parts:

ConnectionTable

S S S S

Name of the element (such as Value) Memory location (such as MW100) Update rate or time-out value (in ms) Deadband value

For more information about the connection table, see Section A.3.8.

Note If the ConnectedObject and ConnectionTable parameters are both omitted, an error is reported.

A-52

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.16

ConnectObject Method
Applies to: SIMATIC Data This method establishes connections for a specified object which was declared in the program.

Note A programmer who uses Visual Basic (or a similar programming language) would use the ConnectName method, while a programmer who uses Visual C (or a similar programming language) would use the ConnectObject method.

Syntax: result = object.ConnectObject ConnectedObject, ConnectionTable The ConnectObject method has these parts: Part object result ConnectedObject Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A long value that indicates whether an error has occurred. The result is zero if no error occurs. A String expression that evaluates to the name of an object that should be connected. If this parameter is set to an empty String, the control generates the ValueChanged event if a connected variable changes. (optional) Specifies a connection table. If this parameter is omitted, the control reads the ConnectionTable property of the ConnectedObject. The connection table is declared as an array. Each element in the array has the following parts:

ConnectionTable

S S S S

Name of the element (such as Value) Memory location (such as MW100) Update rate or time-out value Deadband value

Note If the ConnectedObject and ConnectionTable parameters are both omitted, an error is reported.

SIMATIC Computing 6GK19710BA000AA1

A-53

SIMATIC Computing

A.4.17

ControlEngine Property
Applies to: SIMATIC Data, SIMATIC Panel, S7DiagBF This property stores the pathname or identification of the control engine connected to the control. Syntax: object.ControlEngine [= value] The ControlEngine property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A String that specifies the pathname or identification of the control engine to be accessed by object.

A-54

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.18

ConvertedValue Property
Applies to: SIMATIC Number This read-only property holds the value from the control engine (after data typing and range transformation have been performed). Use the following descriptions to understand the differences between the Value, ConvertedValue and Text properties: S The Value property is a Variant. It must be connected, by way of the SIMATIC Data Control, to a value in the control engine. It can hold values of different data types. The ConvertedValue property is also a Variant and contains the value from the Value property, but it is already scaled and converted to the specified data type (DataType property). The Text property contains a String with the displayed String, which means, inclusively, radix conversion (Radix property), zero padding (ZeroPad property), and precision (Precision property) usage.

If the Enabled property is False, the bi-directional connection between Value and ConvertedValue is broken and changes to the Text or ConvertedValue property will not be written to the Value property. Syntax: object .ConvertedValue [= value] The ConvertedValue property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Variant that specifies the value of the control.

A.4.19

DataType Property
Applies to: SIMATIC Number This property defines the storage type used for converted values. If you are using a data type for displaying a value which is too large, the value will be truncated. The data type specified in the SIMATIC Number Control must match any data type specified in the Assigned Variable field of the SIMATIC Data Control.

SIMATIC Computing 6GK19710BA000AA1

A-55

SIMATIC Computing

Note This property determines whether the Precision property has any effect.

Syntax: object.DataType [= value] The DataType property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the data type. Table A-16 lists the data types and settings for value.

Table A-16 Settings for the Data Types Data Type Boolean Byte Word Integer Double Word Double Integer Real Timer Counter Setting 0 1 2 3 4 5 6 7 8 Size 1 bit 1 byte 2 bytes 2 bytes 4 bytes 4 bytes 4 bytes 2 bytes 2 bytes Single bit value Unsigned single-byte value Unsigned two-byte value Signed two-byte integer value Unsigned four-byte value (default) Signed four-byte integer value Signed four-byte real (floating-point) value Unsigned two-byte value Unsigned two-byte value Description

Note If the data size configured to be accessed in the control engine is larger than the data being displayed in the SIMATIC control and the value of the data from the control engine is larger than can be displayed by the data type, the value is displayed with ... preceding it. For example, you can assign a double-word variable, such as MD100, in the SIMATIC Data Control and select the data type Byte in the SIMATIC Number Control. If the value in the control engine exceeds 255 (the maximum value for a byte), ... precedes the value. Before the value can be changed from the SIMATIC Number Control, the ... preceding the value must be deleted.

A-56

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.20

DefaultDeadband Property
Applies to: SIMATIC Data This property allows you to specify the dead band used by the SIMATIC Data Control, if no dead band is specified in the connection table.

Note If you specify a dead band (such as 10) for a bit variable (such as M15.5), the control engine will not transmit a changed value for that bit.

Syntax: object.DefaultDeadBand [= value] The DefaultDeadband property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value of the type Single, which must not be negative.

A.4.21

DefaultUpdateRate Property
Applies to: SIMATIC Data This property allows you to specify the update rate used by the SIMATIC Data control, if no update rate is specified in the connection table.

Note For WinLC, the minimum default update rate is 0. For CPU 416-2 DP ISA, the minimum default update rate is 100 ms.

Syntax: object.DefaultUpdateRate [= value] The DefaultUpdateRate property has these parts:

SIMATIC Computing 6GK19710BA000AA1

A-57

SIMATIC Computing

Part object value

Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value of type Long.

The settings for value are: Part 0 >0 Description All changes of the connected variable are reported immediately. Changes of the connected variable are reported after this timeout.

A.4.22

Direction Property
Applies to: SIMATIC Slider The Direction property sets the orientation (horizontal or vertical) of the SIMATIC control. Syntax: object.Direction [= value] The Direction property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the orientation.

The settings for value are: Setting 0 1 Description Horizontal Vertical

A-58

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.23

Disconnect Method
Applies to: SIMATIC Data This method releases all established connections. Syntax: result = object.Disconnect The Disconnect method has these parts: Part object result Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A long value that indicates whether an error has occurred. The result is zero if no error occurs.

A.4.24

Enabled Property
Applies to: SIMATIC Button, SIMATIC Number, SIMATIC Slider When this property is True, the control reacts on changes of the Value property and fires events. If this property is False, then the control is disabled and does not react on changes in the Value property and does not fire any event (except the error event). Syntax: object.Enabled [= value] The Enabled property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Boolean expression that specifies whether object can respond to user-generated events.

The settings for value are: Setting True False Description (default) Allows the object to respond to events Prevents object from responding to events

SIMATIC Computing 6GK19710BA000AA1

A-59

SIMATIC Computing

A.4.25

Factor Property
Applies to: SIMATIC Number The Factor and Offset properties specify the scaling factor and the offset used when the scale-by-formula option has been enabled.

Note The ScaleMode property must be set to ByFormula (1) for the Factor and Offset properties to have any effect.

You can use a formula to scale the value. In the following formula, PLC Value is similar to the contents of the Value property if the control is connected to the control engine; Scale is the value of the Factor property; Offset is the value of the Offset property; and Displayed value is also the contents of the Text property. PLC Value * Factor + Offset = Displayed value Syntax: object.Factor [= value] The Factor property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A floating-point value that defines the factor for the scaling formula.

Note The default value of the factor is 1.0, and the default value of the offset is 0.0.

A-60

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.26

FalseCaption Property
Applies to: SIMATIC Button This property determines the text that is displayed in the control when the Value property is False (equal to 0, or Off). Syntax: object.FalseCaption [= value] The FalseCaption property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A String value that specifies the text of the label.

A.4.27

FalseColor Property
Applies to: SIMATIC Button This property determines the color of the control when the Value property is False (equal to 0, or Off). Syntax: object.FalseColor [= value] The FalseColor property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the background or foreground colors of an object.

The settings for value are: Setting Standard Colors Windows System Colors Description Colors specified by using the RGB Color palette Colors specified by system color constants (depending on the container); for example, colors listed in the Visual Basic (VB) object library in the Object Browser

SIMATIC Computing 6GK19710BA000AA1

A-61

SIMATIC Computing

A.4.28

Font Property
Applies to: SIMATIC Button, SIMATIC Number This property returns a Font object for the main font of the control. Syntax: object.Font The Font property has these parts: Part object Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list.

A.4.29

ForeColor Property
Applies to: SIMATIC Number The ForeColor property returns or sets the foreground color used to display text and graphics in an object. Syntax: object.ForeColor [= value] The ForeColor property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the foreground colors of object.

The settings for value are: Setting Standard Colors Windows System Colors Description Colors specified by using the RGB Color palette Colors specified by system color constants (depending on the container); for example, colors listed in the Visual Basic (VB) object library in the Object Browser

A-62

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.30

LargeChange Property
Applies to: SIMATIC Slider The LargeChange property determines how far the slider indicator moves when the control has focus and you press the Page Up or Page Down key. The Value property is increased by LargeChange if you press the Page Up key or click to to right/top of the indicator. It is decreased by LargeChange if you press the Page Down key or click to the left/bottom of the indicator. Syntax: object.LargeChange [= value] The LargeChange property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the amount of change.

A.4.31

LayoutType Property
Applies to: SIMATIC Number This property specifies how the labels are arranged around the display area of the control. When the layout type is Horizontal (0), caption 1 is on the left of the display area, and caption 2 on the right side of the display area. When the layout type Vertical (1), caption 1 is located above the display area, and caption 2 is below the display area. Syntax: object.LayoutType [= value]

The LayoutType property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the layout type.

The settings for value are: Setting Horizontal (0) Vertical (1) Description (default) Arranges the labels to the left and right of the display area of the control Arranges the labels above and below the display area of the control

SIMATIC Computing 6GK19710BA000AA1

A-63

SIMATIC Computing

A.4.32

LimitCheck Property
Applies to: SIMATIC Number This property determines whether to check that a value entered by the control is within specified limits and to define the range of values that determine the limits. A value changed by the control engine is not checked against the defined range. You can specify a range of valid values for any entry. (The lower limit equals the smallest number allowed, and the upper limit equals the largest number allowed). If an invalid value (a value which is outside of the range) is entered, the control does not write that value to the Value property. If the limit-check fails, the Error event and the LimitCheckFailed events will be fired. The Error event will be fired only if the ShowErrorBoxes property is enabled (selected).

Note This Limit Check property must be enabled for the UpperLimit and LowerLimit properties to have any effect.

Syntax: object.LimitCheck [= value] The LimitCheck property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the kind of limit check.

The settings for value are: Setting CheckNone (0) Lower (1) Upper (2) Both (3) Description (default) Does not check the entry against limits Checks the value against the lower limit only Checks the value against the upper limit only Checks the value against both the upper and lower limits

A-64

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.33

Locked Property
Applies to: SIMATIC Number If the control is locked it is in a read-only state. The user is unable to change any values, but the current value is nevertheless shown. By default the control is not in locked mode, so the user can enter numbers. Syntax: object.Locked [= value] The Locked property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Boolean expression that specifies whether object can be edited.

The settings for value are: Setting True Description You can scroll and highlight the text in the control, but you cannot edit it. The program can still modify the text by changing the Value property. Changes to the Value property are reflected: the control displays the values in the control engine, but you are unable to change them. (default) You can edit the text in the control.

False

A.4.34

LowerLimit Property
Applies to: SIMATIC Number These properties allow access to the lower limit value. If the value entered by the user is lower than the LowerLimit value or higher than the UpperLimit value, it will not be written to the control engine. You can specify a range of valid values for any entry. (The lower limit equals the smallest number allowed.) If an invalid value (a value which is outside of the range) is entered, the control does not write that value to the Value property. If the limit-check fails, the Error event and the LimitCheckFailed events will be generated. The Error event will be generated only if the ShowErrorBoxes property is enabled (selected).

SIMATIC Computing 6GK19710BA000AA1

A-65

SIMATIC Computing

Note The LimitCheck property must be set to Lower (1) or Both (3) before the LowerLimit property can have an effect. The LimitCheck property must be set to Upper (2) or Both (3) before the UpperLimit property can have an effect.

Syntax: object.LowerLimit [= value] The LowerLimit property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A floating-point value that defines the lower or upper limit used at limit checking.

A.4.35

Max Property
Applies to: SIMATIC Slider The Max property determines the position of the slider indicator of the SIMATIC control. When the Value property is greater than or equal to Max, the indicator is in its rightmost (or top) position. Syntax: object.Max [= value] The Max property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the maximum number displayed.

A-66

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.36

Min Property
Applies to: SIMATIC Slider The Min property determines the position of the slider indicator of the SIMATIC control. When the Value property is less than or equal to Min, the indicator is in its leftmost (or bottom) position. Syntax: object.Min [= value] The Min property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the minimum number displayed.

A.4.37

MultipleEngines Property
Applies to: SIMATIC Data This property specifies whether the control connects to a specific control engine or connects simultaneously to several control engines. Syntax: object.MultipleEngines [= value] The MultipleEngines property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Boolean expression that specifies whether object connects to one or to several control engines.

The settings for value are: Setting True False Description object connects to more than one control engine simultaneously. (default) object connects only to the control engine specified in the ControlEngine property.

SIMATIC Computing 6GK19710BA000AA1

A-67

SIMATIC Computing

A.4.38

Offset Property
Applies to: SIMATIC Number The Factor and Offset properties specify the scaling factor and the offset used when the scale-by-formula option has been enabled.

Note The ScaleMode property must be set to ByFormula (1) for the Factor and Offset properties to have any effect.

You can use a formula to scale the value. In the following formula, PLC Value is similar to the contents of the Value property if the control is connected to the control engine; Scale is the value of the Factor property; Offset is the value of the Offset property; and Displayed value is also the contents of the Text property. PLC Value * Factor + Offset = Displayed value Syntax: object.Offset [= value] The Offset property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A floating-point value that defines the factor or the offset for the scaling formula.

Note The default value of the factor is 1.0, and the default value of the offset is 0.0.

A.4.39

PCName Property
Applies to: SIMATIC Data This property selects the name of a remote computer (PC) in order to connect to a control engine over a network, such as a local area network (LAN). Syntax: object.PCName [= value] The PCName property has these parts:

A-68

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Part object value

Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A String that specifies the pathname or identification of the remote computer (PC) for the connection.

A.4.40

Precision Property
Applies to: SIMATIC Number This property is available if the DataType is set to Real (6) (data type with precision). In that case you can change the precision (number of digits behind the decimal point) of the number. The number will be rounded at the specified precision.

Note The DataType property must be set to Real (6) before this property can have an effect.

Syntax: object.Precision [= value] The Precision property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. An integer value that defines the precision of the number. The default precision is 3.

A.4.41

PropertyChangedName Method
Applies to: SIMATIC Data This method notifies the SIMATIC Data Control that the value of a property of a connected control, referenced by the name of the object in the form (such as S7Number1), has changed. The SIMATIC Data Control reads the value from the property and writes it to the data source.

SIMATIC Computing 6GK19710BA000AA1

A-69

SIMATIC Computing

Note A programmer who uses Visual Basic (or a similar programming language) would use the PropertyChangedName method, while a programmer who uses Visual C (or a similar programming language) would use the PropertyChangedObject method.

Syntax: result = object.PropertyChangedName ConnectedObject, Property The PropertyChangedName method has these parts: Part object result ConnectedObject Property Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A long value that indicates whether an error has occurred. The result is zero if no error occurs. A String expression that evaluates to the name of the connected control whose property has changed. A String value with the name of the property that has changed.

A.4.42

PropertyChangedObject Method
Applies to: SIMATIC Data This method notifies the SIMATIC Data Control that the value of a property of a connected control (an object which was declared in the program) has changed. The SIMATIC Data Control reads the value from the property and writes it to the data source.

A-70

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Note A programmer who uses Visual Basic (or a similar programming language) would use the PropertyChangedName method, while a programmer who uses Visual C (or a similar programming language) would use the PropertyChangedObject method.

Syntax: result = object.PropertyChangedObject ConnectedObject, Property The PropertyChangedObject method has these parts: Part object result ConnectedObject Property Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A long value that indicates whether an error has occurred. The result is zero if no error occurs. A String expression that evaluates to the name of the connected control whose property has changed. A String value with the name of the property that has changed.

A.4.43

Radix Property
Applies to: SIMATIC Number This property defines the radix (binary, octal, decimal, or hexadecimal) for the number to be displayed. Any value entered must also be in the radix defined by this property. Syntax: object.Radix [= value] The Radix property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the radix used for displaying the value.

The settings for value are:

SIMATIC Computing 6GK19710BA000AA1

A-71

SIMATIC Computing

Setting Binary (0) Octal (1) Decimal (2) Hexadecimal (3)

Description Binary mode (valid characters for input: 0 and 1) Octal mode (valid characters for input: 0 to 7) (default) Decimal mode (valid characters for input: 0 to 9, +, , and .) Hexadecimal mode (valid characters for input: 0 to 9, a to f, and A to F)

A.4.44

RangeRawMax, RangeRawMin, RangeScaledMax, and RangeScaledMin Properties


Applies to: SIMATIC Number These properties define the ranges for scaling a value by a range transformation: S S S S RangeRawMax specifies the upper value of the source range. RangeRawMin specifies the lower value of the source range. RangeScaledMax specifies the upper value of the destination range. RangeScaledMin specifies the lower value of the destination range.

Note The ScaleMode property must be set to ByRange (2) before these properties can have an effect.

When you use a range transformation to scale the value, you specify a source range (for the values in the control engine) and a destination range (for the values that are displayed by the control). The values of one range will be transformed to the other range. See Figure A-25. The source and destination ranges define a ratio for the transformation; they do not define upper or lower limits. A value can be larger or smaller than the range; the transformation will use the two ranges to extrapolate the other value.

A-72

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Transformation ratio RangeRawMax PLC value (in control engine) RangeRawMin Figure A-25 RangeScaledMin RangeScaledMax Value displayed by S7 control

Scaling Values by Range Transformation

Syntax: object.RangeRawMax [= object.RangeRawMin [= object.RangeScaledMax object.RangeScaledMin value] value] [= value] [= value]

The RangeRawMin, RangeRawMax, RangeScaleMin, RangeScaleMax properties have these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A floating-point value that defines the range boundaries for the range mode scaling.

Note The default value of the RangeRawMax is 255.0; the default value of the RangeRawMin is 0.0; the default value of the RangeScaledMax is 100.0; and the default value of the RangeScaledMin is 0.0.

SIMATIC Computing 6GK19710BA000AA1

A-73

SIMATIC Computing

A.4.45

ReadMultiVariables Method
Applies to: SIMATIC Data This method reads the status of the connected variables in the control engine. Syntax: result = object.ReadMultiVariables (VarNames, VarValues, States) The ReadMultiVariables method has these parts: Part object VarNames VarValues States result Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Variant that specifies the array of variables (memory locations) to be read from the control engine. A Variant that contains an array of the corresponding values of the specified variables in the control engine. A Variant that contains an array of the quality code (Long) for each of the variables. A Long value that indicates whether an error has occurred. The result is zero if no error occurs.

A.4.46

ReadVariable Method
Applies to: SIMATIC Data This method reads the status of one specific variable in the control engine. Syntax: result = object.ReadVariable (VariableName, Value, State, TimeOut ) The ReadVariable method has these parts: Part object VariableName Value State Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A String expression that specifies the variable (memory location) in the control engine to be read. A Variant value containing the content of the specified variable in the control engine. A Long value that provides the quality code for the variable.

A-74

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Part TimeOut

Description A Long value that determines the length of time (in ms) before generating a time-out error. (Not applicable for this release). For the current release, this value should always be 0. A Long value that indicates whether an error has occurred. The result is zero if no error occurs.

result

A.4.47

ScaleMode Property
Applies to: SIMATIC Number This property specifies the scaling mode to be used for scaling values. The values can also be specified at the Scale Property Tab. There are two choices for scaling mode: S By formula: PLC Value * Factor + Offset = Displayed value where: PLC Value is similar to the contents of the Value property if the control is connected to the control engine; Scale is the value of the Factor property; Offset is the value of the Offset property; and Displayed value is the contents of the Text property. S By range transformation: you specify a source range (of PLC values) and a destination range (of displayed values), and the values of the one range are transformed to the other range. See Figure A-25 and the Range properties.

SIMATIC Computing 6GK19710BA000AA1

A-75

SIMATIC Computing

Note The Scale Mode property determines whether the RangeRawMax, RangeRawMin, RangeScaledMax, RangeScaledMin, Factor, and Offset properties have any effect.

Syntax: object.ScaleMode [= value] The ScaleMode property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the kind of scaling.

The settings for value are: Setting ScaleNone (0) ByFormula (1) ByRange (2) Description (default) No scaling Use the formula containing the factor and offset to scale the value Use the range transformation method to scale the value

A.4.48

ShowButtons Property
Applies to: SIMATIC Number This property displays the Enter and Cancel buttons for the control. When this property is enabled (True), any new value entered with the control must be confirmed before it is written to the SIMATIC Data Control. Typing a new value in the display field of the control enables the buttons. Clicking on the Enter button writes the new value to the control engine; clicking on the Cancel button replaces the new value with the value from the control engine. The default setting for this option is False (disabled). Syntax: object.ShowButtons [= value] The ShowButtons property has these parts:

A-76

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Part object value

Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Boolean expression that specifies whether or not to display buttons.

The settings for value are: Setting True Description Two buttons will be shown on the right side of the display field. When you enter a new value in the display field, the buttons become active. To confirm the change and write this value to the Value property (and to the control engine), click on the Enter button; to cancel the value, click on the Cancel button. (default) The buttons are hidden.

False

A.4.49

ShowErrorBoxes Property
Applies to: SIMATIC Data, SIMATIC Number, SIMATIC Panel This property specifies whether to display the default error boxes when there is a user-generated error. Every time an error occurs, an Error event will be generated. If the ShowErrorBoxes property is enabled (selected), a default error message box will be displayed. All errors on connections are reported by the Connection Error event.

Note Computing provides error messages in English only. If you want to display messages in other languages, you must disable (deselect) the ShowErrorBoxes option and write program code to react on the error event.

Syntax: object.ShowErrorBoxes [= value] The ShowErrorBoxes property has these parts:

SIMATIC Computing 6GK19710BA000AA1

A-77

SIMATIC Computing

Part object value

Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Boolean expression that specifies whether the control displays error boxes.

The settings for value are: Setting True False Description (default) The control shows the default error boxes. The error boxes are hidden.

A.4.50

SmallChange Property
Applies to: SIMATIC Slider This property determines how far the slider indicator moves when the control has focus and you press the up/down or right/left arrow keys. The Value property is increased by SmallChange if you press the right (or up) arrow key. It is decreased by SmallChange if you press the left (or down) arrow key. Syntax: object.SmallChange [= value] The SmallChange property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the amount of change

A-78

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.51

TagServerName Property
Applies to: SIMATIC Number This property determines the name of the SIMATIC Data Control which shall be used for a connection to the control engine. The TagServerName property applies to the SIMATIC Number Control, but it is created automatically by the SIMATIC Data Control. It can also be created by your program code. Syntax: object.TagServerName [= value] The TagServerName property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A String value that specifies the name of an available SIMATIC Data Control.

A.4.52

TagSource Property
Applies to: SIMATIC Data This property identifies the source of symbolic information to be used when assigning variables and identifying control engines. The source can be a tag file. Syntax: object.TagSource [= value] The TagSource property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A String that identifies the pathname to the source (such as a tag file) of symbolic information to be used when configuring the control for variables and control engines.

SIMATIC Computing 6GK19710BA000AA1

A-79

SIMATIC Computing

A.4.53

Ticks Property
Applies to: SIMATIC Slider This property sets the number of ticks, or unit markers, of the control. For example, if Ticks = 10, the scale of the control will be divided into 10 sections. Syntax: object.Ticks [= value] The Ticks property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A constant that determines the number of unit markers to be displayed.

A.4.54

TrueCaption Property
Applies to: SIMATIC Button This property determines the text that is displayed in the control when the Value property is True (equal to 1, or On). Syntax: object.TrueCaption [= value] The TrueCaption property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A String value that specifies the text of the label.

A-80

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.55

TrueColor Property
Applies to: SIMATIC Button This property determines the color of the control when the Value property is True (equal to 1, or On). Syntax: object.TrueColor [= value] The TrueColor property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant that determines the background or foreground colors of object.

The settings for value are: Setting Standard Colors Windows System Colors Description Colors specified by using the RGB Color palette Colors specified by system color constants (depending on the container); for example, colors listed in the Visual Basic (VB) object library in the Object Browser

A.4.56

UpperLimit Property
Applies to: SIMATIC Number This property allows access to the upper limit value. If the value entered by the user is higher than the UpperLimit value, it will not be written to the control engine. You can specify a range of valid values for any entry. (The upper limit equals the largest number allowed.) If an invalid value (a value which is outside of the range) is entered, the control does not write that value to the Value property. If the limit-check fails, the Error event and the LimitCheckFailed events will be generated. The Error event will be generated only if the ShowErrorBoxes property is enabled (selected).

SIMATIC Computing 6GK19710BA000AA1

A-81

SIMATIC Computing

Note The LimitCheck property must be set to Lower (1) or Both (3) before the LowerLimit property can have an effect. The LimitCheck property must be set to Upper (2) or Both (3) before the UpperLimit property can have an effect.

Syntax: object.UpperLimit [= value] The UpperLimit property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A floating-point value that defines the lower or upper limit used at limit checking.

Note The default value for the LowerLimit is 0.0, and the default value for the UpperLimit is 100.0.

A-82

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.57

Value Property
Applies to: SIMATIC Button, SIMATIC Number, SIMATIC Slider This property should be linked, using the SIMATIC Data Control, to a value in the control engine. It is bindable. Use the following descriptions to understand the differences between the Value, ConvertedValue, and Text properties: S The Value property is a Variant. It must be connected, by way of the SIMATIC Data Control, to a value in the control engine. It can hold values of different data types. The ConvertedValue property is also a Variant and contains the value from the Value property, but it is already scaled and converted to the specified data type (DataType property). The Text property contains a String with the displayed String, which means, inclusively, radix conversion (Radix property), zero padding (ZeroPad property), and precision (Precision property) usage.

If the Enabled property is False, the bi-directional connection between Value and ConvertedValue is broken. The result is that changes to the Text or ConvertedValue property will not be written to the Value property.

Note If the value of the Value property changes, the Change event will be generated.

Syntax: object.Value [= value] The Value property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Variant that specifies the value of the control.

SIMATIC Computing 6GK19710BA000AA1

A-83

SIMATIC Computing

A.4.58

Write Method
Applies to: SIMATIC Number This method writes the value of the ConvertedValue property to the Value property. You must use this method only if the WriteMode is set to Manual (1). Syntax: object.Write The Write method has these parts: Part object Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list.

A.4.59

WriteMode Property
Applies to: SIMATIC Number This property determines how the control responds when the user enters a new value. If the write mode is set to Automatic (0), the value (if valid) is written automatically into the Value property (and to the control engine). If the write mode is Manual (1), the value is not written to the value property unless your program code calls the method Write at the control. Syntax: object.WriteMode [= value] The WriteMode property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A value or constant expression that specifies whether the control automatically passes entered values to the Value property.

The settings for value are: Setting Automatic (0) Manual (1) Description (default) Automatically passes the new (input) value to the Value property Does not write the new (input) value unless the control processes a Write method

A-84

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.4.60

WriteMultiVariables Method
Applies to: SIMATIC Data This method writes new values for several variables in the control engine. Syntax: result = object.WriteMultiVariables (VarNames, VarValues, States) The WriteMultiVariables method has these parts: Part object VarNames VarValues States result Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Variant that specifies the array of variables (memory locations) in the control engine. A Variant that contains an array of the corresponding values to be written to the specified variables. A Variant that contains an array of the quality code (Long) for each of the variables. A Long value that indicates whether an error has occurred. The result is zero if no error occurs.

A.4.61

WriteVariable Method
Applies to: SIMATIC Data This method writes a new value to a specific variable in the control engine. Syntax: result = object.WriteVariable (VariableName, Value, TimeOut ) The WriteVariable method has these parts: Part object VariableName Value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A String expression that specifies the variable (memory location) in the control engine. A Variant value containing the content to be written to the specified variable in the control engine.

SIMATIC Computing 6GK19710BA000AA1

A-85

SIMATIC Computing

Part TimeOut

Description A Long value that determines the length of time (in ms) before generating a time-out error. (Not applicable for this release). For the current release, this value should always be 0. A Long value that indicates whether an error has occurred. The result is zero if no error occurs.

result

A.4.62

ZeroPad Property
Applies to: SIMATIC Number This property determines whether the number displayed by the control is padded with zeros (to the left of the value) to the size of the data type. Syntax: object.ZeroPad [= value] The ZeroPad property has these parts: Part object value Description An object expression (identifier for the specific SIMATIC control) that evaluates to an object in the Applies To list. A Boolean expression that specifies whether or not the displayed number is filled with leading zeros.

The settings for value are: Part True False Description Fills the number with leading zeros to the size specified by the DataType property. (default) Does not fill the number with leading zeros.

A-86

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.5

Other SIMATIC Controls

Chapter Overview
SIMATIC Computing provides a collection of custom SIMATIC controls for accessing data in the control engine: S S S SIMATIC Button control reads and writes Boolean (single bit) values. SIMATIC Number control automatically converts the S7data types, allowing you to accurately read and write all of the S7 data types, SIMATIC Slider control provides a sliding indicator (slider) for entering or displaying dynamic data.

A.5.1

SIMATIC Button Control


The Button control allows you to associate a button display with data bit from your process and to change them. You associate the button with your process by assigning a variable (namely, the desired bit location) to it. You can then toggle the button display to change the state of the bit; the button color also changes automatically as the state of the bit changes within the process. Figure A-26 shows the Button control. The Button control has two states of animation: 0 (off) or 1 (on). Clicking on the Button control changes the data in the control engine.

OFF

Control

Figure A-26

SIMATIC Button Control

Connecting the Button control to the Process Data


To establish a connection between the Button control and your process data, you assign a (single-bit) variable to the Value property of the Button control. Die Variable kann mit Hilfe des Dialogfeldes Properties des Button Controls verbunden werden. Instead, use the Properties dialog box of the Data control and select the button from the expandable list of controls under the Connections tab. A-27). To set properties for anything other than the Value property, you can use the Properties dialog box of the Button control itself. Click the mouse button and select the Properties command for the control.

SIMATIC Computing 6GK19710BA000AA1

A-87

SIMATIC Computing

Warning After you assign a variable to the Value property of a SIMATIC or a third-party ActiveX control, the control is able to access process data. When you change the value that is displayed in the control, you are changing the value in the actual process. Altering process data can cause unpredictable process operation, and unpredictable process operation could result in death or serious injury to personnel, and/or damage to equipment. Exercise caution to ensure that you do not access any data that could cause process equipment to operate erratically. Always install a physical emergency stop circuit for your machine or process.

Remember that the button control can be assigned only to an individual bit in the control engine. The only valid data type for an Button control is BOOL.
Siemens SIMATIC Data Control Properties General Controls: S7Data1 S7vbBttn1 Enabled FalseCaption FalseColor Font ToolTipText TrueCaption TrueColor Value Add... Delete Filter... Engine Connections Events Name

Assigned Variable: S7:[DEMO]M0.0 Browse...

Update rate (ms): Dead band:

100 0

Automatic write mode: Apply filter to properties

OK

Cancel

Apply

Help

Figure A-27

Assigning Variables for the Button Control

A-88

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Defining the Label and Enabling the Control (Using the General Tab)
The General tab of the Properties dialog (see Figure A-28) allows you to define the two labels for the Button control: S S TrueCaption: Enter the text to be displayed in the control when the bit is true (equal to 1 or on). FalseCaption: Enter the text to be displayed in the control when the bit is false (equal to 0 or off).

The General tab also includes a check box for enabling the control. When you select this option, the control can actively access the control engine. Deselecting this option deactivates the control: it does not access the memory location of the control engine and does not react on any mouse clicks. It also does not generate events while disabled. The default setting for this option is enabled (selected).
Siemens Button Control Properties General Font Color Name

TrueCaption: FalseCaption:

ON OFF Enabled:

OK

Cancel

Apply

Help

Figure A-28

Button Control Properties (General Tab)

Defining the Typeface of the Label (Using the Font Tab)


The Font tab of the Properties dialog (see Figure A-29) allows you to define the typeface and size for the labels of the Button control: S S S Font: select the typeface for the label from a list of standard typefaces. Size: select the point size for the label or enter a specific point size for the label. Effects: select other typographical options (boldface, italic, underline, or strike-through) for the label.

The Sample Text field displays the selection of the Font property.

SIMATIC Computing 6GK19710BA000AA1

A-89

SIMATIC Computing

Defining the Color of the Control (Using the Color Tab)


The Color tab of the Properties dialog (see Figure A-30) allows you to define the colors for the two states of the Button control. You select the Off state (FalseColor) or the On state (TrueColor) and then select the color to be displayed for that state from the color palette. You can choose from a palette of standard colors, or you can create custom colors.
Siemens Button Control Properties General Font Color Font: MS Sans Serif Effects Bold Italic Underline Strikeout Size: 8.25

Properties: Font

Sample Text: MS Sans Serif

OK

Cancel

Apply

Help

Figure A-29

Button Control Properties (Font Tab)

Siemens Button Control Properties General Font Color Color Set: Standard Colors Color Palette: Gray Green Magenta Red Edit Custom Color...

Properties: FalseColor TrueColor

OK

Cancel

Apply

Help

Figure A-30

Button Control Properties (Color Tab)

A-90

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.5.2

Properties, Methods, and Events of the Button Control


You use the properties and methods listed in Table A-17 to manipulate the Button control. Das Data Control reagiert auf die in Tabelle A-18 aufgelisteten Ereignisse.
Table A-17 Properties and Methods of the Button Control Property or Method Enabled property FalseCaption property FalseColor property Font property TrueCaption property TrueColor property Value property Description Determines whether the control reacts to changes of the Value property and fires events Determines the text that is displayed in the control when the Value property is False (equal to 0, or Off) Determines the color of the control when the Value property is False (equal to 0, or Off) Returns a Font object for the main font of the control. Determines the text that is displayed in the control when the Value property is True (equal to 1, or On) Determines the color of the control when the Value property is True (equal to 1, or On) Contains the value that is linked to the control engine

Table A-18 Events of the Button Control Event Change event Click event Description Occurs when the value of the Value property changes Occurs when a mouse button is pressed and released while the mouse cursor is over the control

SIMATIC Computing 6GK19710BA000AA1

A-91

SIMATIC Computing

A.5.3

SIMATIC Number Control


The Number control allows you to display process data in a numeric format and to modify that data. You associate the number display with your process by assigning a variable (the process value) to it. You can type a new value into the display; the display also updates automatically when the variable associated with it changes within the process. Besteht eine Verknpfung des Number Controls mit einer Prozevariablen, zeigt das Control den Wert der Variablen an und die Prozevariable kann durch Eingabe eines Wertes gesetzt werden. The Number control provides access to the memory locations of the control engine. Entering a new value in the control changes the data in the control engine. Figure A-31 shows the Number control.

Display area Enter button Figure A-31 SIMATIC Number Control

Control Cancel button

Note In order to connect the Number control to actual process data, you must establish a connection through the Data control.

Connecting the Number Control to the Process Data


To establish a connection between the Number control and your process data, you assign a variable to the Value property of the Number control. The variable cannot be assigned within the Properties dialog box of the Number control. Instead, use the Properties dialog box of the Data control and select the Number control from the expandable list of controls under the Connections tab. A-32

A-92

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Warning After you assign a variable to the Value property of a SIMATIC or a third-party ActiveX control, the control is able to access process data. When you change the value that is displayed in the control, you are changing the value in the actual process. Altering process data can cause unpredictable process operation, and unpredictable process operation could result in death or serious injury to personnel, and/or damage to equipment. Exercise caution to ensure that you do not access any data that could cause process equipment to operate erratically. Always install a physical emergency stop circuit for your machine or process.

Siemens SIMATIC Data Control Properties General Controls: S7Data1 S7Number1 Value Alignment Appearance BackColor BorderStyle Caption1 Engine Connections Events Name

Assigned Variable: S7:[DEMO]MD100 Browse...

Update rate (ms): Dead band:

100 0

Automatic write mode: Add... Delete Filter... Apply filter to properties

OK

Cancel

Apply

Help

Figure A-32

Assigning Variables for the Number Control

To set properties for anything other than the Value property, you can use the properties dialog box for the Number control itself. Use the Edit menu or right click the mouse button and select the Properties command for the control.

SIMATIC Computing 6GK19710BA000AA1

A-93

SIMATIC Computing

Defining How the Data is Displayed (Using the General Tab)


The General tab of the Properties dialog box (see Figure A-33) allows you to define the presentation of the data accessed by the Number control.
Siemens Number Control Properties General Style Label Scaling Color Font Zero Pad Show Buttons Show Error Boxes

Data type: Radix: Precision:

4 Double Word 2 Decimal 0

Limit check: Upper limit: Lower limit:

0 None 100 0

Alignment:

OK

Cancel

Apply

Help

Figure A-33

Number Control Properties (General Tab)

The fields on the General tab allow you to define the following properties concerning how the data will be displayed: S Data type defines the size of the presentation for the data. Table A-19 describes the sizes of the data types used by the Number control. If you entered a specific data type for the assigned variable in the SIMATIC Data control, you must enter the same data type here. S S Radix configures the data to be accessed (display or entered) as a binary, octal, decimal or hexadecimal value. Precision defines the decimal place for the real (floatingpoint) number. (The default value is three digits) This field is enabled only for the Real data type.

A-94

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Table A-19 Size of Data Types for the Number control Data Type Boolean Byte Word Integer Double Word Double Integer Real Setting 0 1 2 3 4 5 6 Size 1 bit 1 byte 1 byte 2 bytes 4 bytes 4 bytes 4 bytes boolean value Unsigned singlebyte value Vorzeichenloser Zwei-Byte wert Vorzeichenbehafteter, ganzzahliger ZweiByte wert Unsigned fourbyte value (default) Signed fourbyte integer value Signed fourbyte real (floatingpoint) value Description

Using the alignment buttons, you can define how the value will be displayed in the Number control: aligned to the left side of the field, centered in the field, or aligned to the right side of the field. You can also enable the Number control to check for upper and lower limits on the value that you enter. You can select limit checking for a maximum value, a minimum value, both maximum and minimum value, or for no limit checking. When you enable the Limit Checking option, the Number control does not write an out-of-range value (larger than the upper limit or smaller than the lower limit) to the control engine. If the Number control has been configured to show the error messages, the out-of-range value generates an error message. Using the check boxes on the General tab, you can define other operations for the control: S Zero Pad: When you enable this option, the Number control fills out the data type by inserting zeroes (0) to the left of the value. The default setting for this option is disabled (not selected). Show Buttons: When you enable this option, the Number control displays the Enter and Cancel buttons. (See Figure A-33.) When this option is checked, you must confirm any new value in order to enter it. Typing a new value in the display field of the control enables the buttons. Clicking on the Enter button writes the new value to the control engine; clicking on the Cancel button replaces the new value with the value from the control engine. The default setting for this option is disabled (not selected). You can also use the Return (or Enter) key on the keyboard instead of the Enter button, and the Escape (Esc) key instead of the Cancel button. S Show Error Boxes: when you enable this option, the Number control displays the messages (error boxes) in response to pre-defined error conditions (for example, for out-of-range or invalid numbers). The default setting for this option is enabled (selected).

SIMATIC Computing 6GK19710BA000AA1

A-95

SIMATIC Computing

Defining the Appearance of the Number Control


The Style tab of the Properties dialog box (see Figure A-34) provides you with the following options for the appearance of the control: S Appearance: If you set this property to 3D, the control will have a three-dimensional appearance. (You must also set the border style to Fixed Single to enable the three-dimensional appearance.) The other option is Flat, which displays a two-dimensional, rectangular border around the control. Border Style: If you set this property to Fixed Single, the control is displayed with a rectangular border; if you set the property to None, no border will be displayed.

In addition to fields that determine the appearance of the control, the Style tab also includes a Write Mode field that controls whether changes to the value are written automatically to the control engine, or are written only when requested by the program code (using a Write command) that you associated with the Number control.
Siemens Number Control Properties General Style Label Scaling Color Font

Appearance: Border Style: Write Mode:

1 3D 1 Fixed Single 0 Automatic Enabled Locked (read-only)

OK

Cancel

Apply

Help

Figure A-34

Number Control Properties (Style Tab)

Using the check boxes on the Style tab, you can define other operations for the Number control: S Enabled: When you select this option, the control can actively access the control engine. Disabling this option deactivates the Number control: it does not access the memory location of the control engine and does not react on any mouse clicks. It also does not generate events while disabled. The default setting for this option is enabled (selected). Locked: When you enable this option, the control becomes a : read-only display. you can view the value in the memory location of the control engine, but you cannot change the values from this control. The default setting for this option is disabled (not selected).

A-96

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Creating a Label for the Number Control (Using the Label Tab)
The Label tab of the Properties dialog box (see Figure A-35) allows you to define a label (or caption) for the control. You can define two different captions for the control (Caption 1 and Caption 2). As shown in Figure A-36, the labels can be oriented either horizontally or vertically in relationship to the Number control: S S If you select Horizontal, Caption 1 is on the left and Caption 2 is on the right side of the control. If you select Vertical, Caption 1 on the top and the Caption 2 on the bottom.

Use the alignment buttons for each caption to determine whether the label is centered, aligned to the left, or aligned to the right. Use the Font tab and the Color tab to specify the font, the font color, and the background color of the label.
Siemens Number Control Properties General Style Label Scaling Color Font Vertical Size2: 1 Caption2: Control

Layout Type Horizontal Size1: 1 Caption1:

Alignment1:

Alignment2:

OK

Cancel

Apply

Help

Figure A-35

Number control Properties (Label Tab)

You can also specify a specific width (for horizontal labels) or height (for vertical labels). Figure A-36 shows the labeling options for the Number control. If you keep the default value for the size of the label (1), the Number control automatically adjusts the size of the label to the amount text entered or to the font size for the caption. Entering a specific size for the labels allows you to control the appearance of the Number control. For example, you may want to align the display area for a series of Number controls, but the labels vary in length for each control. Choosing a constant size for the labels would align the display areas. If you enter a specific size for the captions, you enter the size in twips. (A twip is a screen-independent unit that ensures that the placement and proportion of screen

SIMATIC Computing 6GK19710BA000AA1

A-97

SIMATIC Computing

elements are the same on all display systems. A twip is approximately 1/20 of a printer s point: 1440 twips=1 Inch. or 56.7 twips=1 mm when printed.)

Horizontal orientation

Caption1

Display area

Caption 2

Caption1 Vertical orientation Display area Caption 2 Figure A-36 Labeling Options for the Number Control

Using the Scaling Tab


The Scaling tab of the Properties dialog box (see Figure A-37) allows you to define a scale for displaying the value in the memory location. This scaling factor is used both in reading a value from and writing a value to the control engine. You can select one of three scaling options: S S S S S No scaling of the data (default) Scaling by formula Scaling by ranges

If you choose to scale by formula, you enter the following information: Scale represents a percentage of change (scaling factor) from the value in the control engine to the value in the Number control. Offset represents a fixed value to be added to the scaled result before being displayed.

The Number control uses the following formula to calculate the scaled value: (process value  Scale) + Offset = Display where: process value = the value strored in the control engine, value of the process variable Scale = the scalling factor Offset = the offset factor Display = the value displayed in the Number control When the Number control writes data to the control engine, the inverse of the formula is used to scale the value.

A-98

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Siemens Number Control Properties General Style Label Scaling Color Font

Scale mode: Scale by formula PLC value x Scale: + Offset: = Display

0 No Scaling Scale by range transformation PLC value Upper value: 1 0 Lower value: Display Upper value: Lower value: 100 0 255 0

OK

Cancel

Apply

Help

Figure A-37

Number Control Properties (Scaling Tab)

If you choose to scale by range transformation, you specifiy the upper and lower values for a source range (for the value in the control engine) and for a destination range (for the value displayed in the Number control or Display). The Number control then transforms the value from one range into the equivalent value for the other range. These ranges define only the relationship between the data in the control engine and the data in the Number Control: if the value is above or below the ranges entered for the information, the transformation uses the formula to extrapolate the scaled value.

A.5.4

Properties, Methods, and Events of the Number Control


You use the properties and methods listed in Table A-20 to manipulate the Number control. The control responds to the events listed in Table A-21. When an error occurs in the Number control, the control generates an Error event. Your program can capture this Error event and respond to specific situations. Table A-22 lists the error codes for the Number control.
Table A-20 Properties and Methods of the Number Control Property or Method Alignment property Appearance property BackColor property BorderStyle property Description Specifies the alignment of the number in the control Specifies whether the control is displayed 3D or flat Returns or sets the background color Selects the border style (fixed single, or none)

SIMATIC Computing 6GK19710BA000AA1

A-99

SIMATIC Computing

Table A-20 Properties and Methods of the Number Control, continued Property or Method Caption1 and Caption2 properties Caption1Alignment and Caption2Alignment properties Caption1BackColor and Caption2BackColor properties CaptionFont property Caption1ForeColor and Caption2ForeColor properties Caption1Size and Caption2Size properties Description Specifies the displayed text of the first or second label Specifies the alignment of the first or second label

Returns or sets the background color for the first or second label Returns a Font object for the labels Returns or sets the foreground color for the first or second label

Selects the size of the font for the text of the first or second label

ConvertedValue property Holds the value from the control engine (read-only) DataType property Enabled property Factor property Font property ForeColor property LayoutType property LimitCheck property Locked property LowerLimit property Offset property Precision property Radix property RangeRawMax, RangeRawMin, RangeScaledMax, and RangeScaledMin properties ScaleMode property ShowButtons property ShowErrorBoxes property Defines the storage type used for converted values Determines whether the control reacts to changes of the Value property and fires events Specifies the scaling factor used when the scale-by-formula option has been enabled (Used with ScaleMode property) Returns a Font object for the main font of the control Returns or sets the foreground color used to display text and graphics Specifies how the labels are arranged around the display area Determines whether to check that a value is within specified limits, and to define the range of values that determine the limits Sets the control to a read-only state Allows access to the lower limit value Specifies the offset used when the scalebyformula option has been enabled (Used with ScaleMode property) Selects the precision of the Real number Selects the radix for the number to be displayed (binary, octal, decimal, or hexadecimal) Defines the ranges for scaling a value by a range transformation by specifying the upper and lower limits for the source and the upper and lower limits for the destination

Specifies the scaling mode to be used for scaling the values Displays the Enter and Cancel buttons for confirming the entering of new values Specifies whether to display the default error boxes when there is a user-generated error

A-100

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Table A-20 Properties and Methods of the Number Control, continued Property or Method TagServerName property UpperLimit property Value property Write method WriteMode property ZeroPad Description Determines the name of the Data control which shall be used for a connection to the control engine Allows access to the upper limit value Contains the value that is linked to the control engine Writes the value of the ConvertedValue property to the Value property Selects whether to write new values automatically or manually Determines whether the displayed number is padded with zeroes (to the left of the value) to the size of the data type

Table A-21 Events of the Number Control Event Change Click DblClick Error KeyDown KeyPress KeyUp LimitCheckFailed MouseDown MouseMove MouseUp Description Occurs when the value of the Value property changes Occurs when a mouse button is pressed and released while the mouse cursor is over the control Occurs when a mouse button is double-clicked while the cursor is over the control Occurs when the control encounters an error Occurs when the user presses a key while the control has the focus Occurs when an ANSI key is pressed and released while the control has the focus Occurs when a key is released while the control has the focus Occurs when the limit check fails Occurs when a mouse button is pressed while the mouse cursor is over the control Occurs when the mouse cursor moves over the control Occurs when a mouse button is released while the mouse cursor is over the control

SIMATIC Computing 6GK19710BA000AA1

A-101

SIMATIC Computing

Table A-22 Error Codes for the Number Control Error Code C0040002 Description The scaling cannot proceed because of an error in the formula used. This error only appears if you are using the Number control with range scaling. In this case it is possible that you have specified a raw value range (RangeRawMin, RangeRawMax) of the length of zero (min equal to max). This would lead to a division by zero, which means the scaling is impossible. To correct the error, specify a raw value range where RangeRawMin is not equal to RangeRawMax. C0040003 The set value at the Value property is invalid. The value which came from the control engine or from a script that is accessing the Value property is not interpretable. To correct the error, check the values that you have written to the control. C0040004 The set value at the Text property is invalid. This is a common error, which occurs if the user enters an incorrect value in the control. Normally, it means that the entered text contains characters that are not allowed. The allowed characters are dependent on the Radix and DataType used. For a description of the allowed characters, see the description of the Radix property. To correct the error, reenter a value that is allowed. C0040005 The other OLE components could not be found. An error occurred in the installation of Computing or of Windows itself. The control is unable to access the other necessary parts that are needed for the sofware to work properly. To correct the error, check the installation. C0040006 The Microsoft standard controls could not be created. Something went wrong with the installation of Computing or Windows itself. The control is unable to access the other necessary parts that are needed for the sofware to work properly. To correct the error, check the installation. C0040010 The limit check cannot proceed, because the lower limit is greater than the upper limit. This error can only appear if you are using the Number control with limit checking (checking for upper and lower limit). In this case it is possible that youve specified a lower limit (LowerLimit) that is greater than the upper limit (UpperLimit). To correct the error, specify a valid range for limit checking. The lower limit has to be less than the upper limit.

A-102

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.5.5

SIMATIC Slider Control


The Slider control allows you to display process data in a visual format (as sliding indicator) and to modify that data. You associate the slider with your process by assigning a variable (the process value) to it. You can then adjust the slider indicator in order to modify the process value; the slider also changes its indicator position automatically as the variable associated with it changes within the process. The Slider control provides access to the memory locations of the control engine. Entering a new value in the control changes the data in the control engine. Figure A-38 shows the toolbox icon and the Slider control.

Control
0 100

Figure A-38

SIMATIC Slider Control

Note In order to connect the Slider control to actual process data, you must establish a connection through the SIMATIC Data control.

Connecting the Slider Control to the Process Data

Warning After you assign a variable to the Value property of a SIMATIC or a third-party ActiveX control, the control is able to access process data. When you change the value that is displayed in the control, you are changing the value in the actual process. Altering process data can cause unpredictable process operation, and unpredictable process operation could result in death or serious injury to personnel, and/or damage to equipment. Exercise caution to ensure that you do not access any data that could cause process equipment to operate erratically. Always install a physical emergency stop circuit for your machine or process.

To establish a connection between the Slider control and your process data, you assign a variable to the Value property of the control. The variable cannot be assigned within the Properties dialog box of the Slider control. Instead, use the Properties dialog box of the SIMATIC Data control and select the slider from the expandable list of controls under the Connections tab. (See FigureA-39).
SIMATIC Computing 6GK19710BA000AA1

A-103

SIMATIC Computing

Siemens SIMATIC Data Control Properties General Controls: S7Data1 S7vbSlid1 Direction LargeChange Max Min ShowMinMax Ticks Value Add... Delete Filter... Engine Connections Events Name

Assigned Variable: S7:[DEMO]MD10 Browse...

Update rate (ms): Dead band:

100 0

Automatic write mode: Apply filter to properties

OK

Cancel

Apply

Help

Figure A-39

Assigning Variables for the Slider Control

To set properties for anything other than the Value property, you can use the Properties dialog box of the Slider control. Use the Edit menu or right click the mouse button and select the Properties command for the control.

Defining How the Data is to be Displayed (Using the General Tab)


The General tab of the Properties dialog box (see Figure A-40) allows you to define the presentation of the data accessed by the Slider control. The Properties dialog box also allow you to dermine the amount that the value displayed by the Slider control increases or decreases when you press an arrow key (SmallChange) or press the Page Up and Page Down keys (LargeChange).

A-104

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Siemens Slider Control Properties General Direction Horizontal Vertical Show Min and Max Value Enabled Ticks:

Min:

Max:

SmallChange:

LargeChange:

OK

Cancel

Apply

Help

Figure A-40

Slider Control Properties (General Tab)

Figure A-41 shows the other elements that are defined by the Properties dialog box. You can enter the minimum (Min) and maximum (Max) values for the Slider control, and you can choose whether or not to display these values. You can also define the number of interim units (ticks) between the minimum and maximum values.

Ticks Minimum value


0 100

Maximum value

Figure A-41

Elements of the Slider Control

As shown in Figure A-42, the Slider control can be displayed in a vertical or horizontal orientation. You choose the orientation by selecting either a horizontal or vertical direction.

100

Horizontal
0 100

Vertical

Figure A-42

Orientation of the Slider Control

SIMATIC Computing 6GK19710BA000AA1

A-105

SIMATIC Computing

A.5.6

Properties, Methods, and Events of the Slider Control


You use the properties and methods listed in Table A-23 to manipulate the Slider control. Das Control reagiert auf die in Tabelle A-24 aufgelisten Ereignisse.
Table A-23 Properties and Methods of the Slider Control Property or Method Direction property Enabled property LargeChange property Max property Min property SmallChange property Ticks property Value property Description Sets the orientation (horizontal or vertical) Determines whether the control reacts to changes of the Value property and fires events Determines how far the slider indicator moves when the control has focus and you press the Page Up or Page Down key Determines the value of the rightmost (or top) position of the slider indicator Determines the value of the rightmost (or top) position of the slider indicator Determines how far the slider indicator moves when the control has focus and you press the up/down or right/left arrow keys Sets the number of ticks (unit markers) Contains the value that is linked to the control engine

Table A-24 Events of the Slider Control Event Change event Click event DblClick event KeyDown event KeyPress event KeyUp event MouseDown event MouseMove event MouseUp event Description Occurs when the value of the Value property changes Occurs when a mouse button is pressed and released while the mouse cursor is over the control Occurs when a mouse button is double-clicked while the cursor is over the control Occurs when the user presses a key while the control has the focus Occurs when an ANSI key is pressed and released while the control has the focus Occurs when a key is released while the control has the focus Occurs when a mouse button is pressed while the mouse cursor is over the control Occurs when the mouse cursor moves over the control Occurs when a mouse button is released while the mouse cursor is over the control

A-106

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.6

Guidelines for Custom Controls and Third-Party Containers

Chapter Overview
The SIMATIC Data control can be used not only with other SIMATIC ActiveX controls, but also controls of other providers or custom ActiveX controls. To work with a custom ActiveX control, the Data control requires that the control provide a minimum of code to respond to changes in the assigned variable. You can also use other containers, such as Visual Basic, with the SIMATIC Controls. In order to use the SIMATIC controls in another container, the container must support the requests of extended controls. If the container does not support these functions, you must supply program code to perform these functions.

A.6.1

Guidelines for Using Third-Party Containers with the Data Control


For the SIMATIC Data control to work within a third-party container, the container must support the property browsing functions of the Data control. To do this, the container must support the functions for extended controls (as defined by Microsoft for containers). An extended control is a partial control that wraps around another control to support container-specific properties, methods and events. (Refer to Microsofts online documentation for more information about containers and extended controls.) To provide the extended control functions, the container must support the following methods: S S S IOleClientSize::GetContainer IOleContainer::EnumObjects IOleControlSite::GetExtendedControl

The extended control of the container must also support a Name property. Visual Basic untersttzt extended Controls. Containers from other vendors (such as Borlands Delphi version 3.0) do not support extended controls. The Siemens customer support center can help determine if your container supports the extended control functions. If your container does not support the extended control functions, you must provide program code to perform these functions. Contact the Siemens customer support center for sample code that performs the extended control functions.

SIMATIC Computing 6GK19710BA000AA1

A-107

SIMATIC Computing

A.6.2

Guidelines for Creating a Custom ActiveX Control


In order to create a custom ActiveX control that can be used with SIMATIC Data Control, the custom control must provide a property to which data can be written For example, your custom control might have a value property: when the Value property changes, then the control reacts.

Reading Data from the Data Control


If the container supports extended controls, the Data control automatically finds the custom control and its properties. You use the Properties dialog box of the Data control to assign a variable in the control engine to the property of the custom control. Whenever the value of the variable in the control engine changes, the Data control updates the value of the property for the custom control. The custom control should include a subroutine for handling the data written from the Data control. Tabke A-25 provides a sample subroutine for a propertiy (Value). It reads the data written by the Data control.

Writing Data to the Data Control


For the custom control to generate (write) a change to the variable in the control engine, you must include a subroutine for handling a change in the property. Table A-25 provides a sample subroutine for writing the new value to the Data control.

Table A-25 Reading and Writing a Changed Value of a Property


Visual Basic Code

Public Property Get Value() As Long Value = Object1.Value End Property Public Property Let Value(ByVal New_Value As Long) Object1.Value() = New_Value PropertyChanged Value End Property Private Sub Value_Change() PropertyChanged Value End Sub

A-108

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

A.6.3

Using a Custom Control with the Data Control


You can create a custom ActiveX control that communicates through the Data control to access the control engine. To create this sample application, you need the following items: S S S Microsoft Visual Basic 5 or higher SIMATIC Data control from Computing Sample program

Creating a Custom ActiveX Control for Accessing the Control Engine


Use the following procedure to use a standard VB horizontal scrollbar (HScrollBar control) to create a custom ActiveX control: 1. Open a Visual Basic project for creating an ActiveX control: Use the File New Project menu command to display the New Project dialog box, then select the ActiveX Control icon (not the ActiveX EXE icon) and click on the Open button. 2. Add a User Control to the project: Select the ProjectAdd User Control menu command, then select the User Control icon from the Add User Control dialog box. Clicking on the Open button adds the User Control to the project. 3. Select the horizontal scrollbar control (HScrollBar) in the toolbox and insert it onto the UserControl1 form. 4. Select the scrollbar control. In the Properties window, select the Max property for this control (HScroll1) and enter the following value: 255 5. Display the Code window for UserControl1 by selecting the ViewCode menu command. In the Code window, enter the program listed in Table. 6. Close both the code window and the Object window. Visual Basic adds this ActiveX control (UserControl1) to the toolbox.

SIMATIC Computing 6GK19710BA000AA1

A-109

SIMATIC Computing

Table A-26 Sample Program for an ActiveX Control Used with Computing
Visual Basic Code Public Property Get Value() As Integer Value = HScroll1.Value End Property Public Property Let Value (ByVal New_Value As Integer) HScroll1.Value = New_Value PropertyChanged Value End Property Public Sub HScroll1_Change() Value = HScroll1.Value End Sub

Adding the Custom Control to a Program Using the SIMATIC Data Control
1. Open a new VB project: Use the FileAdd Project menu command to display the Add Project dialog box, then select the Standard EXE icon and click on the Open button. Visual Basic opens a new project with an empty form in the Object window. The Project directory area now lists two projects: Project1 contains UserControl1, and Project2 contains Form1. 2. Select the UserControl1 icon in the toolbox and insert it onto Form1 of Project2. 3. Add the Siemens SIMATIC Data control to the toolbox (components menu). 4. Select the Data control icon in the toolbox and insert it onto Form1 of Project2. 5. Select the Data control and click the right mouse button to bring up the pop-up menu. From the pop-up menu, select Properties to display the Properties dialog box for the Data control. 6. From the Properties dialog box, select the Connections tab. Click on the + symbol to expand the list of controls. 7. Select the UserControl1 control and click on its + symbol to expand its properties list. 8. Select the Value property and enter a process variable (browse button) in the Assigned Variable field. Click on the Apply and OK buttons to enter the data and close the Properties dialog box.

A-110

SIMATIC Computing 6GK19710BA000AA1

SIMATIC Computing

Running the Sample Program


Save the program before switching Visual Basic from Design mode to Run mode. When the sample program runs, the custom scrollbar control that you created reflects the changing value stored in the selected process variable. Use the following procedure to configure the Data control for communicating with the control engine and for running the sample program. 1. Whlen Sie das Register Engine zur Einrichtung der Control Engine. See Figure A-43. 2. Select the Direct Connect option and enter @SimaticNet. Click on the Apply button to enter the data, and then click on the OK button to close the dialog box. 3. Switch Visual Basic from Design mode to Run mode to run the sample program.

Siemens SIMATIC Data Control Properties General Engine Connections Events Name

Select the option for a direct connection

Connect via Tag Source Tag Source Browse Direct Connect PC Name Control Engine @SimaticNet

Enter@SimaticNet as the type of control engine

OK

Cancel

Apply

Help

Figure A-43

Connecting to the Control Engine (Scrollbar Control Example)

SIMATIC Computing 6GK19710BA000AA1

A-111