• No results found

SIMATIC NET. DP Base Programming Interface for CP 5613/CP Preface, Contents. Basic Steps in Creating a DP Application 1

N/A
N/A
Protected

Academic year: 2021

Share "SIMATIC NET. DP Base Programming Interface for CP 5613/CP Preface, Contents. Basic Steps in Creating a DP Application 1"

Copied!
372
0
0

Loading.... (view fulltext now)

Full text

(1)

SIMATIC NET

DP Base Programming Interface

for CP 5613/CP 5614

Manual

Preface, Contents

Basic Steps in Creating a DP

Application

1

Overview of PROFIBUS DP

2

Overview of the DP Base

Interface

3

Description of the DP

Functions, Data, and Error

Codes

4

Description of the Sample

Programs

5

FAQ (Frequently Asked

Questions)

6

Glossary, Index

C79000-G8976-C139-09

(2)

This document contains notices which you should observe to ensure your own personal safety, as well as to protect the product and connected equipment. These notices are highlighted in the manual by a warning triangle and are marked as follows according to the level of danger:

!

Danger

indicates that death or severe personal injury will result if proper precautions are not taken.

!

Warning

indicates that death or severe personal injury can result if proper precautions are not taken.

!

Caution

with warning triangle indicates that minor personal injury can result if proper precautions are not taken.

Caution

without warning triangle indicates that damage to property can result if proper precautions are not taken.

Notice

indicates that an undesirable result or status can occur if the relevant notice is ignored.

Note

highlights important information on the product, using the product, or part of the documentation that is of particular importance and that will be of benefit to the user.

(3)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 3

SIMATIC®, SIMATIC NET® and SINEC® are registered trademarks of Siemens AG. Third parties using for their own purposes any other names in this document which refer to trademarks might infringe upon the rights of the trademark owners.

Safety Instructions Regarding your Product

Before you use the product described here, read the safety instructions below thoroughly.

Qualified Personnel

Only qualified personnel should be allowed to install and work on this equipment . Qualified persons are defined as persons who are authorized to commission, to ground, and to tag circuits, equipment, and systems in accordance with established safety practices and standards.

Correct Usage of Hardware Products

Please note the following regarding the correct usage of hardware products:

Caution

This device and its components may only be used for the applications described in the catalog or the technical description, and only in connection with devices or components from other manufacturers which have been approved or recommended by Siemens. This product can only function correctly and safely if it is transported, stored, set up, and installed correctly, and operated and maintained as recommended.

Before you use the supplied sample programs or programs you have written yourself, make certain that no injury to persons nor damage to equipment can result in your plant or process.

EU Directive: Do not start up until you have established that the machine on which you intend to run this component complies with the directive 2006/42/EEC.

(4)

Please note the following regarding the correct usage of software products:

Caution

This software may only be used for the applications described in the catalog or the technical description, and only in connection with devices or software products from other manufacturers which have been approved or recommended by Siemens.

Before you use the supplied sample programs or programs you have written yourself, make certain that no injury to persons nor damage to equipment can result in your plant or process.

Prior to Startup

Before putting the product into operation, note the following warning:

Caution

Prior to startup you must observe the instructions in the relevant documentation. For ordering data of the documentation, please refer to catalogs or contact your local Siemens representative.

(5)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 5

Preface

Purpose of the Manual

This manual supports you when creating DP user programs for the "DP Base Programming Interface", the programming interface of the CP 5613/CP 5614. It provides you with a comprehensive overview. The structure of DP user programs and the individual language elements are explained.

It is assumed that you are familiar with writing user programs in the "C" programming language in Windows.

How the SIMATIC CPs are named in this manual

Some SIMATIC CPs have one PROFIBUS connector and can be operated either as a DP master or DP slave; these are:

CP 5603, CP 5613 A2, CP 5623.

Unless stated otherwise, these are called "CP 5613" in this document.

Other SIMATIC CPs have two PROFIBUS connectors and can therefore be oper-ated both as a DP master or/and as a DP slave; these are: CP 5614 A2, CP 5624. Unless stated otherwise, these are called "CP 5614" in this document.

Scope of this Manual

This manual is valid as of the CD "SIMATIC NET PC Software, Edition 2008, Ser-vice Pack 2".

This manual is valid for the following communications processors: CP 5603, CP 5613 A2, CP 5614 A2, CP 5623, CP 5624

Recommendation

Read the following chapters to familiarize yourself with PROFIBUS DP, the DP Base programming interface, and the methods of creating a user program:

(6)

Chapter Content

Chapter 1 Explains step-by-step how to create your DP user program. Chapter 2 Provides you with an overview of PROFIBUS DP.

Chapter 3 Provides an overview of the DP Base programming interface and outlines its advantages.

Chapter 4 Describes the function calls of the DP Base programming interface and the mechanisms for accessing the dual-port RAM.

Chapter 5 Describes the supplied sample programs.

Chapter 6 Provides useful information on the general aspects of writing user programs.

Structure of the Documentation

You will find information on the use of this product in the following sources: • Supplied paper documentation

• Text, PDF, and HTML files of the SIMATIC NET CDs (some available as bound volumes)

• Internet (http://www.ad.siemens.de/net) • SIMATIC NET Product Catalog "IK PI"

Certification

The products and systems listed in this document are manufactured and marketed using a quality management system complying with DIN ISO 9001 and certified by DQS (certificate registration no. 2613). The DQS certificate is recognized in all IQNet countries (Reg. No.: 2613).

(7)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 7

Contents

1 Basic Steps in Creating a DP Application... 11

2 Overview of PROFIBUS DP... 15

2.1 Where Does PROFIBUS DP Fit In? ... 16

2.2 The Master-Slave-Concept of PROFIBUS DP ... 18

2.3 DP Communication Mechanisms... 22

2.3.1 Cyclic Polling by the Master... 23

2.3.2 Acyclic Services and Alarms... 25

2.4 CP 5613 Communications Processor... 26

2.5 CP 5614 Communications Processor... 27

2.5.1 The Transfer Software ... 28

2.5.2 The Configuration for the Transfer Software ... 29

2.6 Access to Process Data... 30

2.7 Startup and Operational Phase of a DP System ... 32

2.8 Modes of the DP Master ... 33

2.8.1 How a DP Master Starts Up... 35

2.8.2 How a DP Master Shuts Down ... 36

2.9 Separation of the Slave Data from the DP Master User Program... 37

2.10 Reliability of DP... 39

2.11 Control Frames to One or More Slaves ... 40

2.12 The Importance of Configuration ... 42

2.13 DP-V1 as an Extension of DP... 44

3 Overview of the DP Base Interface ... 47

3.1 Ways of Accessing the CP 5613/CP 5614 Communications Processor ... 48

3.2 Special Features of the CP 5613/CP 5614... 51

3.2.1 Hardware and Software Events ... 52

3.2.2 Fast Logic ... 58

3.2.3 Timeout Monitoring ... 60

3.2.4 Constant Bus Cycle Time Mode ... 61

3.2.5 Access to Operating Data in the Dual-port RAM ... 62

3.3 How Does a DP Master User Program Access Process Data? ... 64

3.3.1 Reading DP Slave Input Data... 65

3.3.2 Reading DP Slave Diagnostic Data ... 67

3.3.3 Writing DP Slave Output Data ... 70

3.3.4 Coordination in Multi-Thread Operation... 71

3.4 How Does a DP Master User Program Recognize Changed Input Data and New Diagnostic Data?... 73

(8)

3.4.2 Recognizing New DP Slave Diagnostic Data ... 75

3.5 Typical Sequences for the Master of the CP 5613/CP 5614... 78

3.5.1 Initialization Phase, Productive Operation, and Shutdown Phase in DP Master Operation ... 79

3.5.2 DP Master Mode Polling ... 81

3.5.3 DP Master Operation with Hardware and Software Events... 83

3.5.4 Acyclic Services Without Using Software Events ... 86

3.5.5 Acyclic Services Using Software Events ... 88

3.6 Properties of the DP Slave on the CP 5613/CP 5614 ... 90

3.6.1 Two Modes of the DP Slave on the CP 5613/CP 5614 ... 91

3.7 Basic Structure of a DP Slave User Program... 92

3.7.1 Typical Sequences in the "Simple Slave" Mode... 93

3.7.2 Typical Sequences in the "Dynamic Slave" Mode without Software Event... 98

3.7.3 Typical Sequences in the "Dynamic Slave" Mode with Software Event... 101

3.8 Multiple Protocols, DP User Programs, CPUs... 105

4 Description of the DP Functions, Data, and Error Codes... 107

4.1 List of Functions of the CP 5613 and CP 5614 ... 108

4.1.1 Overview of the Functions ... 110

4.1.2 DP_start_cp ... 113 4.1.3 DP_reset_cp ... 115 4.1.4 DP_open ... 116 4.1.5 DP_get_pointer ... 118 4.1.6 DP_release_pointer ... 120 4.1.7 DP_close... 121 4.1.8 DP_get_err_txt... 123 4.1.9 DP_set_mode ... 124 4.1.10 DP_slv_state... 127 4.1.11 DP_read_slv_par ... 130 4.1.12 DP_global_ctrl... 132 4.1.13 DP_ds_read ... 135 4.1.14 DP_ds_write... 138 4.1.15 DP_fetch_alarm ... 141 4.1.16 DP_alarm_ack ... 146 4.1.17 DP_get_actual_cfg... 149 4.1.18 DP_enable_event ... 152 4.1.19 DP_disable_event... 158 4.1.20 DP_get_result ... 159 4.1.21 DP_get_cref ... 162 4.1.22 DP_init_sema_object... 163 4.1.23 DP_delete_sema_object... 165 4.1.24 DP_fast_logic_on... 166 4.1.25 DP_fast_logic_off... 170

(9)

DP Base Programming Interface for CP 5613/CP 5614 C79000-G8976-C139-09 9 4.2.7 DPS_get_gc_command... 200 4.2.8 DPS_get_state... 203 4.2.9 DPS_set_diag ... 205 4.2.10 DPS_get_ind... 208

4.2.11 Structure Elements of DPS_C2_INITIATE_REQ ... 220

4.2.12 DPS_set_resp... 223

4.2.13 DPS_calc_io_data_len ... 231

4.3 Access to the Process Image of the CP 5613/CP 5614 ... 232

4.3.1 Reading the Input Data of a DP Slave... 233

4.3.2 Reading the Diagnostic Data of a DP Slave... 235

4.3.3 Writing the Output Data of a DP Slave ... 237

4.3.4 Checking the Slaves for Changed Data... 238

4.3.5 Querying the State of a DP Slave... 240

4.3.6 Querying Information about the DP Master ... 241

4.3.7 Querying the Current Bus Parameters of the Master ... 243

4.3.8 Querying Information about DP Slaves ... 245

4.3.9 Reading PROFIBUS Statistical Data ... 246

4.3.10 Querying the Fast Logic Status ... 248

4.3.11 Reading and Triggering User Watchdog in the Dual-Port RAM ... 250

4.3.12 Activating/Deactivating the Generation of Hardware Events... 252

4.3.13 Sending Data with the CP 5614 as DP Slave... 255

4.3.14 Receiving Data with the CP 5614 as DP Slave ... 256

4.3.15 Sending Diagnostic Data with the CP 5614 as DP Slave... 257

4.3.16 Using the Constant Bus Cycle Time Mode... 258

4.3.17 Typical Phases in the Constant Bus Cycle Time Mode... 264

4.3.18 Checking the Life Counter ... 268

4.4 Error Handling... 270

4.4.1 Entries in the error_decode, error_code_1 and error_code_2 structure elements in Error Class DP_ERROR EVENT ... 274

4.4.2 Error Codes... 277

4.5 Formats of the Slave Data ... 292

4.6 Formats of the Slave Diagnostic Data ... 293

4.6.1 Overview of the Entire Structure... 294

4.6.2 Format of the Diagnostic Data Header ... 295

4.6.3 Format of the Device-Related Diagnostic Data (Standard DP Slave) ... 299

4.6.4 Format of the Device-Related Diagnostic Data (Slaves with DP-V1 Extensions) ... 300

4.6.5 Format of ID-Related Diagnostics... 305

4.6.6 Format of Channel-Related Diagnostics... 306

4.6.7 Format of the Revision Number... 309

4.7 Format of the Slave Parameter Data ... 311

4.7.1 Structure of the General Slave Parameters... 312

4.7.2 Structure of the Parameter Assignment Data... 315

4.7.3 Structure of the Configuration Data ... 320

4.7.4 Meaning of GSD Files... 324

5 Description of the Sample Programs ... 337

5.1 Starting the Simple Sample Program ... 338

5.2 Starting the Complete Sample Program... 340

(10)

5.4 Starting the Transfer Sample Program for the CP 5614... 344

5.5 Configuring the Transfer for the CP 5614 Transfer Sample Program ... 347

6 FAQ (Frequently Asked Questions)... 349

6.1 FAQs about the Range of Functions of the Product... 350

6.2 FAQs about Structuring the DP User Program... 352

6.3 FAQ Check List for Programmers... 355

6.4 FAQs about Debugging and Starting Up Your Program... 358

6.5 FAQs Miscellaneous Programming Questions... 359

7 Glossary ... 362

(11)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 11

Basic Steps in Creating a DP Application

1

This chapter recommends a step-by-step procedure for creating a DP user program based on the DP programming interface of the CP 5613 and CP 5614 known as "DP Base". The steps begin with the basics of PROFIBUS DP and are completed when you test your application.

The DP Base programming interface allows direct access to the DP process image in the dual-port RAM of the CP 5613/CP 5614. The DP Base programming inter-face is therefore not compatible with the DP programming interinter-face of the CP 5511, the CP 5611 and the CP 5711.

Since the DP Base interface is a high-speed interface, it cannot be operated at the same time as the DP interface mentioned above on a CP 5613/CP 5614.

(12)

Procedure

The steps outlined below represent the fastest and simplest way of achieving your aims:

Step Description

1 Familiarize yourself with the basic principles of PROFIBUS DP. Read the following Chapter 2 "Overview of PROFIBUS DP".

2 Familiarize yourself with the basic characteristics of the DP Base programming interface of the CP 5613 and CP 5614. Read Chapter 3 "Overview of the DP Base interface".

3 Check through the contents of the subfolder "prog" in your installation folder so that you know what it contains and the purpose of the components for the subsequent steps.

The subfolder contains the following:

● The "readme.rtf" file with the latest additional information and most recent modifications.

● The C header file "dp_5613.h", dps_5614.h with the functions and data structures of the DP base interface and "5613_ret.h and 5614_ret.h" with the return codes.

● The import libraries "dp_base.lib" and "dps_base.lib" for linking to your DP user program.

● The sample programs and corresponding databases in the "examples" subfolder.

4 Now work through the source text of the sample program "ExamEasy" and read through the functions and data accesses in Chapter 4 ("Description of the DP Functions, Data, and Error Codes").

5 Adapt the "ExamEasy" sample program to suit your plant configuration, for example by using additional or other slaves. Compile and link the sample program and try it out. You may need to extend the

"ExamEasy" sample database.

6 Now work through the source text of the sample program "ExamComp", modify the program and try it out with an extended sample database. 7 If you want to use the slave functions of the CP 5614, you should also

work through the "transfer" sample, modify it to your requirements and try it out with an extended sample database.

8 Please read the FAQs in Chapter 6, particularly the check list for programmers and the information on structuring your DP user program.

(13)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 13

Continued

Step Description

9 Now create your own DP user program. You can use the "ExamComp" sample as a basis.

10 Test your application. Refer to the information and tips in the FAQ list in Chapter 6 and the diagnostic options described in the readme file of the SIMATIC NET CD.

(14)
(15)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 15

Overview of PROFIBUS DP

2

(16)

2.1

Where Does PROFIBUS DP Fit In?

PROFIBUS - The Worldwide Fieldbus Strategy

The trend towards reducing costs in automation engineering has meant that programmable controllers (PLCs), PCs, drives, transducers, and sensors are being networked more and more. This has resulted in greater distribution of these field devices using a fieldbus as the common communications medium for exchanging information.

The demand for an open, heterogeneous fieldbus system representing a safe and long-term investment for the user has been met by PROFIBUS. PROFIBUS is a bus system for communication between programmable controllers or PCs and field devices based on the European standard EN 50 170, Volume 2. This means that both users and manufacturers can be certain about long-term investments and guarantees "openness" for all applications conforming with the standard worldwide. Created in 1989 by a consortium of companies and institutions, PROFIBUS has become the world’s most popular fieldbus in discrete manufacturing and process control. It is mature, proven technology that is ideal for supporting modern automa-tion systems. With over 25 million installed devices, it is a significant driving force for the world’s production plants. By continuously enhancing the technology, PROFIBUS International has ensured that PROFIBUS remains the dominant field-bus solution. The ongoing commitment of the world’s automation major suppliers ensures that investments today are fully protected for the lifetime of any plant. PROFIBUS is unique in offering a fully integrated solution for discrete and process applications, a major benefit in the process industries where upstream, mainstream and downstream processes have to work together. Industries using PROFIBUS range from critical petrochemical operations and high volume robotic manufactur-ing plants, right across the spectrum to food and drink, water/waste treatment plants.

Siemens has supported PROFIBUS for many years as an optimized fieldbus solution and reliable investment for the user and supplies both products and complete systems. Apart from the programmable controllers (PLCs), devices such as network components, PC communications processors, and field devices for PROFIBUS are also included in the wide range of products.

(17)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 17

The Advantages of DP

PROFIBUS-DP is intended for fast data exchange in the fieldbus area.

Distributed peripheral devices collect the input signals locally and transfer them via the fieldbus to the central controller in the PG/PC. In the opposite direction, the central controller sends the output data to the distributed peripheral devices. The use of PROFIBUS DP means a considerable reduction in cabling compared to previous direct wiring of components.

(18)

2.2

The Master-Slave-Concept of PROFIBUS DP

Description

The master-slave concept of PROFIBUS DP describes the communications mechanisms between active and passive nodes on PROFIBUS.

Distributed I/Os

The distributed (peripheral) I/O allows you to use a variety of analog and digital input/output modules over PROFIBUS with a distributed configuration in close proximity to the process. This is normally abbreviated to DP.

Node Types

PROFIBUS DP defines two types of bus node: • DP master

DP masters are active nodes and control DP slaves.

A distinction is made between class 1 and class 2 DP masters. • DP slaves

DP slaves are normally passive nodes (distributed I/O devices). A distinction is made between DP-V0 and DP-V1 slaves.

(19)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 19

DP masters

DP Master Class 1

A DP master class 1 communicates cyclically with the DP slaves assigned to it. Cyclic communication means that during the data transfer phase the DP master constantly sends the latest output data to the DP slaves and receives the latest input data in the response frame. With a DP master class 1, communication involves central functions such as:

• Assignment of parameter values and configuration of the DP slaves during startup

• Cyclic data transfer to the DP slaves • Monitoring the DP slaves

• Preparing diagnostic information

Depending on the application, these tasks can, for example, also be handled by a SIMATIC S7 programmable controller. In the follow text , the DP master class 1

is simply known as the DP master.

DP Master Class 2

A DP master class 2 is a DP master that does not operate cyclically and is used for special functions such as online diagnostics in a PROFIBUS DP system. A DP master class 2 can also establish additional connection-oriented DPC2

communication relations with DP-V1 slaves. The DP-V1 slaves must support these DPC2 additional functions. Essentially, these include connection establishment, connection termination, reading data records, writing data records, and data transfer. This programming interface supports the DPC2 functions with the slave submodule of the CP 5614.

(20)

DP Slave

A DP slave is a peripheral device from which the DP master reads in input information and to which it sends output information cyclically. There are also DP slaves that provide only input or only output information.

DP slaves are generally inexpensive since passive participation on the bus is simple to implement.

DP-V0 Slave

A DP-V0 slave is a simple device that becomes active only when requested by the DP master. Essentially, it provides the following standard functions:

• Sends input data from the process to the DP master. • Transfers diagnostic data to the DP master.

• Passes on output data from the DP master to the process.

DP-V1 Slave

A DP-V1 slave has the functionality of a DP-V0 slave with the following additional functions:

• Processing data records

Data records contain special additional information specified using the slot and index. A data record can be sent via a DP master class 1 (DPC1 connection) or via a DP master class 2 (DPC2 connection). A DP master can send data records to a DP-V1 slave (write data record) or request a data record from it (read data record).

• Alarm handling

DP-V1 slaves with alarm capability can send alarms to the master. Alarms are special diagnostic data containing important events. The DP master must acknowledge alarms by sending alarm acknowledge frames to the DP slave.

Overview of the Communication

Section 2.13 shows how DP-V1 communication fits in to PROFIBUS DP.

Configuration

(21)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 21

Basic Structure of a DP System

The following diagram illustrates how to implement a process control with DP slaves using a PC and a CP 5613/CP 5614 communications processor.

DP slaves PC as DP master with CP 5613/CP 5614 PROFIBUS Process Process input/ output data

(22)

2.3

DP Communication Mechanisms

Description

Communication between a DP master (class 1) and DP slaves uses two basic mechanisms:

• Cyclic polling by the master

This mode is the basic communication mode and is supported by all slave types (DP-V0 and DP-V1 slaves).

● Acyclic services and alarms

This mode is an expansion of the basic communication. It is supported only by DP-V1 slaves.

(23)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 23

2.3.1 Cyclic Polling by the Master

Description

The basic communication between a DP master and the distributed I/O stations takes the form of polling. Polling means that the DP master sends cyclic calls to the DP slaves assigned to it. A separate call frame is sent to each DP slave.

In one polling cycle, all the operational DP slaves are addressed. The next polling cycle starts after the last slave has been addressed. This ensures that the data is up to date.

Polling is handled automatically and independently by the firmware of the CP 5613/CP 5614. DP master Input data (diagnostic data when necessary) Output data DP slaves

Figure 1 Schematic Representation of Polling

Output Data

The call frame contains the current output data that the DP slave will apply to its output ports. The data belonging to this area are specified by the DP user program. If a DP slave does not have output ports, an "empty frame" is sent to it instead.

Input Data

The reception of a call frame must be confirmed by the DP slave by returning a confirmation frame. The confirmation frame contains the current input data that are applied to the input ports of the DP slave. If a DP slave does not have input ports, an "empty frame" is returned instead.

(24)

Diagnostic Data

Diagnostic data is generated when the slave detects an error. This is signaled to the master which then fetches the diagnostic data using a special call frame.

(25)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 25

2.3.2 Acyclic Services and Alarms

Acyclic Services

Using acyclic services, the DP user program can send special data records to DP-V1 slaves or read them from the slaves. Within a DP-DP-V1 slave, the data records are addressed using a slot number and an index. The significance of the data records is specific to the particular slave. In contrast to the input/output data, data records are not transferred cyclically but only once per job.

Alarms

Alarms are a particular form of diagnostic data that must be acknowledged specifically by the DP master program in contrast to standard diagnostic frames. Only DP-V1 slaves can send alarms to the DP master. When the DP master user program confirms reception of an alarm, the DP master reacts by sending an alarm acknowledge frame to the DP-V1 slave.

(26)

2.4

CP 5613 Communications Processor

Description

The CP 5613 communications processor in conjunction with the DP user program that uses the functions of the DP base programming interface together form a PROFIBUS DP master class 1.

DP slave PROFIBUS DP CP 5613 Master user program DP slave

This DP base programming interface describes how to create your own DP master class 1 applications for the CP 5613/CP 5614.

(27)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 27

2.5

CP 5614 Communications Processor

Description

The CP 5614 consists of a master section that is identical to the CP 5613. It has an additional slave submodule (piggyback module) that allows attachment to a further PROFIBUS network. With the slave submodule, a CP 5614 can be operated as a DP slave on a PROFIBUS network. The slave is controlled by a remote DP master, for example a CP 5613 or SIMATIC S7 programmable controller.

DP slave PROFIBUS DP (II) PROFIBUS DP (I) R S 485 CP 5614 RS48 5 Slave Master Control system DP master Slave application Master application PC DP slave

This DP base programming interface describes how to create your own DP slave applications for the CP 5614.

(28)

2.5.1 The Transfer Software

To operate the CP 5614 with both master and slave functionality, you can use, for example the transfer software supplied (see Section 5.4). The transfer software transfers data between the master and slave section of the CP 5614.

The transfer software includes an access with which additional input, output or diagnostic jobs can be executed. Your DP user program can use this access to add extra functionality to the transfer program (in the sample program, a counter is activated on the CP 5614 slave submodule).

The example illustrates how a separate transfer function with a local application can access the process image of the CP 5614 (slave and master components of the CP 5614). PROFIBUS DP (II) PROFIBUS DP (I) RS485 CP 5614 RS485 Slave Master Transfer software PC Control system DP master DP slave DP slave Access

(29)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 29

2.5.2 The Configuration for the Transfer Software

To allow you to specify the separate transfer function, a configuration tool and a configured transfer file are also shipped as an example.

Using the configuration tool, you can specify how data is copied from master to slave and vice-versa.

(30)

2.6

Access to Process Data

Description

A distinction must be made between two general types of process data: • Input/output data and standard diagnostic data

(31)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 31

Access to Input/Output Data and Standard Diagnostic Data

Input/output data and standard diagnostic data is stored on the DP master

(CP 5613/CP 5614) in the dual-port RAM. This data represents the process image. There are three different data areas for each configured DP slave:

• Input data from the DP slave • Output data to the DP slave

• Standard diagnostic data from the DP slave

The DP user program accesses the input and output data in the dual-port RAM of the CP 5613/CP 5614 directly using C pointers; in other words without needing function calls. Standard diagnostic data can be read directly or using the function calls of the DP Base programming interface.

Slave data

DP master

Slave n Slave 2 Slave 1 DP application program PROFIBUS

Output data Diagn. data Input data

Access to Slave Data Records and Alarms

Slave data records are fetched or sent directly using the function calls of the DP

Base programming interface.

Alarms are special diagnostic data that is buffered and managed by the firmware

of the CP 5613/CP 5614. The DP user program must read out this alarm data with a function call of the DP Base programming interface and acknowledge it.

(32)

2.7

Startup and Operational Phase of a DP System

Functions of the DP Master during Startup and Operation The DP master handles the following tasks independently: • Initialization of the DP slaves

• Data transfer in the operational phase • Monitoring the DP slaves

Initialization of the DP Slaves

The DP master can only exchange process data with the DP slaves when it has previously assigned parameter values and configured the DP slaves using special frames. The parameter assignment/configuration is contained in the database and is performed as follows:

• During the startup phase of the DP master.

• Following any temporary failure of a DP slave during the productive phase The parameter assignment frame provides the DP slave with global operating parameters (for example Group_Ident, Watchdog on/off).

The configuration frame is sent after the DP slave has been assigned parameters. This frame contains the defined configuration of the DP slave. The configuration includes the number and type of input/output ports. The DP slave compares the received configuration frame with the values that it determined itself during the startup phase. If the values match, the DP slave confirms the configuration and changes to the operational phase.

Data Transfer in the Operational Phase

During the operational phase, the cyclic data transfer between the DP master and DP slaves takes place. The DP user program can also send acyclic data and fetch and acknowledge alarms during this phase.

(33)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 33

2.8

Modes of the DP Master

Overview

During communication with the DP slaves, the DP master can adopt the following four modes:

• OFFLINE • STOP

• CLEAR (or AUTOCLEAR) • OPERATE

Each of these modes is characterized by defined actions between the DP master and the DP slaves.

OFFLINE

No communication between the DP master and DP slaves. This is the startup mode of the DP master.

STOP

In this mode, there is also no communication between the DP master and the DP slaves. In contrast to the OFFLINE mode, a DP diagnostic station (DP master class 2) can read out diagnostic information from the DP master.

CLEAR

All the DP slaves entered and activated in the database are assigned parameters and configured in this mode. This is followed by the cyclic data exchange between the DP master and DP slaves. In this CLEAR mode, the value 0 or empty frames are sent to all slaves with a process output; in other words, process output is deactivated. The input data of the slaves are known and can be read out. If a slave fails, for example no longer answers, the DP master automatically attempts to reassign parameters and configure the slave and return it to the polling cycle.

(34)

AUTOCLEAR

The behavior of the DP master in the AUTOCLEAR mode is the same as in the CLEAR mode.

With certain errors, the DP master automatically changes to the AUTOCLEAR mode; for more detailed information, refer to Section 2.10, "Reliability of DP".

OPERATE

The cyclic, productive data transfer to the DP slaves takes place in the OPERATE mode. In this mode, the DP slaves are addressed one after the other by the DP master. The call frame transfers the actual output data and the corresponding response frame transfers the actual input data.

If a slave fails, for example no longer answers, the DP master automatically attempts to reassign parameters and configure the slave and return it to the polling cycle.

(35)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 35

2.8.1 How a DP Master Starts Up

Description

When the CP 5613/CP 5614 starts up, the DP master must run through the following modes in the specified order controlled by the DP user program: OFFLINE -> STOP -> CLEAR -> OPERATE.

Stage Mode Typical Actions of the DP User Program

1 OFFLINE The DP user program initiates the change to the STOP mode.

Reaction: The DP master changes to the STOP mode. 2 STOP The DP user program queries the STOP mode. Once the

STOP mode is reached, the program initiates the change to the CLEAR mode.

Reaction: The DP master changes to the CLEAR mode. 3 CLEAR The DP user program queries the CLEAR mode. If the

CLEAR mode is reached, the program can enter the output data in the process image. The program then initiates the change to the OPERATE mode. Reaction: The DP master changes to the OPERATE mode.

4 OPERATE The DP user program queries the OPERATE mode. Once the OPERATE mode is reached, productive data exchange with the slaves begins.

(36)

2.8.2 How a DP Master Shuts Down

Description

When the CP 5613/CP 5614 shuts down, the DP master must run through the modes in the following order controlled by the DP user program: OPERATE -> CLEAR -> STOP -> OFFLINE

Stage Mode Typical Actions of the DP User Program

1 OPERATE The DP user program initiates the change to the CLEAR mode.

Reaction: The DP master changes to the CLEAR mode. 2 CLEAR The DP user program queries the CLEAR mode. Once

the CLEAR mode is reached, the program initiates the change to the STOP mode.

Reaction: The DP master changes to the STOP mode. 3 STOP The DP user program queries the STOP mode. Once the

STOP mode is reached, the program initiates the change to the OFFLINE mode.

Reaction: The DP master changes to the OFFLINE mode.

(37)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 37

2.9

Separation of the Slave Data from the DP Master User

Program

The process image is separate from the DP master user program and the slaves To increase efficiency, the DP standard does not include flow control. The timing of the cyclic updating of the process image of the DP master is connected neither to the DP slaves nor to the DP master user program. Examples of different situations are shown below:

Example: Slave input data changes extremely quickly

If, for example, an analog slave modifies its output data more quickly than it can be fetched in the polling cycle of the DP master (sample sequence 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, ...), the DP master only receives a sequence of "snapshots" that it enters in the process image (sequence 1.1, 1.3, 1.5, 1.8, ...).

Example: The DP master user program reads very quickly

If the DP master user program reads the process image more quickly than it can be updated within the polling cycle of the DP master, values will be obtained more than once. Based on the example above, the DP master user program then, for example, reads a sequence 1.1, 1.1, 1.1, 1.1, 1.2, 1.2, 1.2, 1.2, 1.3, 1.3, 1.3, 1.3, 1.4, 1.4 ...

Example: DP master user program writes very quickly

If the DP master user program writes output data to the process image faster than this can be transferred to the slave within the polling cycle of the DP master, only a series of "snapshots" will be transferred the slave (sample sequence 1, 4, 6, ...)

Example: DP master user program reads very slowly

If the DP master user program only reads the process image occasionally, for example because it has other tasks to perform in the meantime, it is possible that some values will be skipped. A sequence such as 1.1, 1.2, 1.3, 1.4 in the process image then becomes, for example, 1.1, 1.3 etc. in the DP master user program.

(38)

Remedy

If the DP master user program requires a better link to the slave than described above, there are a number of options available:

• With the hardware events of the CP 5613/CP 5614, the DP master user program can be informed of changes on the slave. Under certain

circumstances, this results in a faster reaction of the DP master user program to a change in the input data.

• With user-specific implementations on the DP master and DP slave, flow controls can be achieved to link the DP master with the DP slaves and to avoid loss of data.

• If the polling cycle is too slow, it may be possible to increase the update rate of the process image by increasing the data transmission rate.

• The hardware event at the beginning of the cycle and end of the cycle of the CP 5613/CP 5614 can be used to synchronize the DP master user program with the polling cycle. These events are only supported in the constant bus cycle time mode. It is only possible to set parameters for the constant bus cycle time with STEP 7/NCM.

(39)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 39

2.10 Reliability

of

DP

Reliability Concept

The DP programming interface provides various mechanisms to limit the effects of the failure of a communication connection or the DP master.

• A watchdog function can be configured for the DP slave so that if a DP slave is not accessed for a longer period of time it can change automatically to a safe state.

• The AUTOCLEAR function can be activated to ensure that if DP slaves are not accessible, the DP master automatically changes from OPERATE to the (AUTO)CLEAR mode.

• A sign-of-life monitoring function can be activated on the CP 5613/CP 5614 to detect inactivity of a DP user program (failure) and to change the DP slaves to a safe operating mode.

The AUTOCLEAR function

The AUTOCLEAR option can be set during configuration.

How it works:

If an error occurs on one or more DP slaves during the productive phase, the DP master changes automatically from the OPERATE mode to the AUTOCLEAR mode (switches to a safe mode). In the AUTOCLEAR mode, the DP master behaves just as in the CLEAR mode. The DP master then sends data in the output direction with the value 0 or empty frames to the DP slaves. The DP master can no longer exit the AUTOCLEAR mode automatically; in other words, the change to the OPERATE mode must be triggered explicitly by the user.

(40)

2.11 Control Frames to One or More Slaves

Purpose of Control Frames

For particular applications, there are four control commands available with which a control frame can be sent. In standard applications, these are not required.

A control frame is a frame that the master sends to one slave, a group, several groups, or to all slaves. These frames are not acknowledged by the slaves. Control frames are used to transfer control commands (known as global controls) to the selected slaves to allow synchronization. A control command contains three components:

• Identifier indicating whether one or more DP slaves are being addressed • Identification of the slave group

• Control command

Creating Groups

During configuration, you can assign a group identifier to a slave; in other words, it is possible to include several slaves in one group.

Which slaves belong to a group is specified when you create the database. During this phase, each DP slave can be assigned a group number. The DP slave is informed of this group number during the parameter assignment phase. You can specify a maximum of eight groups.

(41)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 41

Control Commands

The following control commands can be sent to DP slaves when necessary during operation:

Control

Commands Description

FREEZE After receiving the FREEZE command, the DP slaves freeze the current states of all inputs. In the read cycles that follow, the DP master receives this frozen input data. The current input data is available to the DP master only after an UNFREEZE command or a further FREEZE command; with the additional FREEZE command this only applies to the current cycle.

UNFREEZE After receiving the UNFREEZE command, the freezing of the inputs is canceled. The DP slaves once again provide the DP master with the current input data.

SYNC When the DP slaves receive the SYNC command, they freeze the current states of all outputs. The output data sent by the DP master following this is initially not accepted by the DP slaves.

The current output data is accepted by the DP slaves only following an UNSYNC command or a further SYNC

command; with the additional SYNC command, this applies only to the current cycle.

UNSYNC After receiving the UNSYNC command, the freezing of the outputs is canceled. The current output data is accepted by the DP slaves again cyclically.

(42)

2.12 The Importance of Configuration

Using the DP Database

The DP database contains information about the bus parameters of PROFIBUS and about the slaves on the network. This information is evaluated when the CP 5613/CP 5614 starts up.

Configuring Slave Data Areas

During configuration, you specify the number and type (input, output, analog, digital) of the data areas of all the slaves. This configuration data is sent to the slave during startup and is then checked by the slave. If the configuration data does not match the actual properties of the slave, the slave enters this in the diagnostic data and it is not included in cyclic operation.

Activating the Watchdog

If the watchdog of a DP slave is activated in the configuration, the DP master must communicate with the DP slave within a selected time.

If there is no communication within this time, the DP slave switches its outputs to a safe state and no longer takes part in data transfer with the DP master section since the DP slave assumes that a serious problem has occurred, for example wire break or failure of the DP master.

The DP master must then assign parameter values to the DP slave and configure it again. Following this, the exchange of productive data can be resumed.

The values adopted by the outputs can be found in the descriptions of the DP slaves.

Configuring the AUTOCLEAR Property

If one of the activated slaves does not take part in the data transfer and if the AUTOCLEAR function is set, the DP master automatically changes to the CLEAR mode (with the coding AUTOCLEAR).

(43)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 43

Configuring Direct Data Exchange

The CP 5613/CP 5614 supports direct data exchange during cyclic polling. Only specially designed DP slaves (publishers/subscribers) are capable of direct data exchange. In direct data exchange, the publisher (transmitting slave) sends the response data with a special identifier and special timing so that not only the DP master but also the other DP slaves (subscribers) can listen in. You configure direct data exchange with STEP 7/NCM.

Configuring the "Min_Slave_Interval"

The "Min_Slave_Interval" is the minimum time between the DP master addressing a DP slave in two consecutive polling cycles. This is calculated automatically based on the GSD data of the slaves.

Meaning of GSD Files

Project engineering tools for the PROFIBUS DP master interpret the GSD files of the various DP slave types and generate the database of the DP master based on this information. To be able to use the slave module of the CP 5614, a suitable GSD file must be available. For more detailed information on this topic, refer to Section 4.7.4.

(44)

2.13 DP-V1 as an Extension of DP

Overview of the DP Protocol with DP-V1 Extensions

Apart from cyclic DP master operation (see Section 2.3.1), two further extensions are defined as DP-V1: DPC1 and DPC2. The paragraphs below contain an overview of these extensions:

DPC1 DP DPC2

DP slave with DP-V1 additional functions

User program User program

DP/DPC1 progr.

interface

DPC2

interface

progr.

PG/PC

DP master class 1

PG/PC

DP master class 2

Acyclic mode MSAC_C2 Cyclic mode MSCY_C1 Acyclic mode MSAC_C1

(45)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 45

DP-V1 Master Class 2 (DPC2)

An additional DP master that is not operating cyclically can establish connections to DP-V1 slaves using DPC2 initiate calls and send or read data records to or from the slaves, for example for reassigning parameter values or diagnostics.

(46)
(47)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 47

Overview of the DP Base Interface

3

The programming interface of the CP 5613/CP 5614 is known as the DP Base programming interface.

This chapter explains the basic characteristics of the DP Base programming interface including typical call and access sequences to prepare you for creating your own DP applications.

For a detailed description of the function calls and data access, please refer to Chapter 4.

(48)

3.1

Ways of Accessing the CP 5613/CP 5614

Communications Processor

Overview

There are basically two mechanisms with which you can access the CP 5613/CP 5614 communications processor:

• Function calls (DP Base programming interface)

• Access to the dual-port RAM of the CP 5613/CP 5614 (process image) using pointers

The DP user program uses the functions of the supplied DLLs. These are passed on to the CP 5613/CP 5614 communications processors by the drivers.

The DP user program can also access the process image on the communications processor with a C pointer .

CP 5613/CP 5614

DP user program

Process image

dp_base.dll

dps_base.dll

Drivers

C pointer

(49)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 49

Access Using Pointers

While your DP user program is running, data of the CP 5613 and CP 5614 that is required regularly is available directly in the dual-port RAM .

Most importantly, this data includes the process image (input, output, and diagnostic data of the DP slaves) along with a variety of status and configuration data and control registers.

The "DP_get_pointer" function call provides the base address (C pointer) for the DPR_CP5613_DP_T structure. With this C pointer, your DP user program can access the process image and the other data areas in the dual-port RAM efficiently.

The DPR_CP5613_DP_T structure describes the structure of the data above in the dual-port RAM of the CP 5613 and CP 5614.

(50)

Function Calls

Your user program can execute administrative tasks and make use of less

commonly required communication properties of the CP 5613 and CP 5614 during run time by calling functions of the DP Base programming interface.

The DP Base programming interface is a C programming interface and consists of two DLLs. The table below describes the two DLLs:

DLL Name Description Function Name

dp_base.dll Contains DP master functions of the CP 5613/CP 5614.

Function names start with "DP_".

dps_base.dll Contains DP slave functions of the CP 5614.

Function names start with "DPS_" (the S stands for slave submodule).

The DP Base programming interface also includes the following header files and import libraries:

• Header Files

– dp_5613.h (definitions for DP master) – dps_5614.h (definitions for DP slave) – 5613_ret.h (error codes for DP master) – 5614_ret.h (error codes for DP DP slave) • Import Libraries

– dp_base.lib (master functions) – dps_base.lib (slave functions)

(51)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 51

3.2

Special Features of the CP 5613/CP 5614

Overview

The CP 5613/CP 5614 has a series of special additional functions and properties that allow the implementation of highly efficient and reliable DP user programs. Since the CP 5613/CP 5614 generally has special hardware control logic for these functions, execution is extremely fast.

The special characteristics of the CP 5613/CP 5614 are as follows: • Hardware and software events

• Fast Logic

• Timeout monitoring

• Constant bus cycle time mode

(52)

3.2.1 Hardware and Software Events

Hardware Events

The CP 5613/CP 5614 can monitor important process data and operating states independently controlled by the DP user program.

If the monitored event occurs, a control register is set in the dual-port RAM. This control register can be checked quickly and efficiently by DP user program using a pointer to access it.

Using the Hardware Events

By checking the control registers in the dual-port RAM, the DP user program can recognize whether or not the CP 5613/CP 5614 has detected a particular event. Since the event is monitored by a hardware control logic, certain events (for example changes to the process image) can be detected quickly and efficiently.

Software Events

With certain events of the CP 5613/CP 5614, a Windows DP user program can be informed interrupt-controlled using a Windows semaphore .

Using the Software Events

Software events allow synchronization between the DP user program and the CP 5613/CP 5614 using Windows semaphores.

If a selected event occurs on the CP 5613/CP 5614, the corresponding Windows semaphore is activated and the DP user program is resumed (where this was waiting at a synchronization object).

Using software events can, in some situations, also reduce CPU load because, for example, the DP user program does not need to check the process image

constantly but is informed of changes in the process image interrupt-controlled by the CP 5613/CP 5614.

(53)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 53

Using a Combination of Hardware and Software Events

With certain events, a combination of hardware and software events is possible providing the advantages of both mechanisms:

High performance and low CPU load.

How the Mechanism Works

If a hardware event is detected by the CP 5613/CP 5614, the corresponding control register is set and an interrupt to the driver of the CP 5613/CP 5614 is triggered. The driver then informs the Windows DP user program using a Windows semaphore.

Example

The input data of a DP slave change. The change is signaled by the hardware event "Change in input data" by setting the corresponding control register in the dual-port RAM. In addition to this, the software event also activates the Windows DP user program that is waiting at a synchronization object using a Windows semaphore. By evaluating the control register, this recognizes the DP slave on which the change took place and then reads its input data.

Events that Trigger Hardware Events

The overview below shows the possible criteria for triggering hardware events: • The input data of a DP slave have changed.

The hardware event "Change in slave input data" can be activated for each DP slave separately.

• A DP slave sends new diagnostic data (regardless of whether it has changed or not).

The hardware event "New slave diagnostic data" can be activated for each DP slave separately.

• A Fast Logic trigger condition was detected.

• A new DP cycle begins in the constant bus cycle time mode.

(54)

Events that Trigger Software Events

The overview below shows the possible criteria for triggering software events: • The acknowledgment of an asynchronous function call of the DP Base

programming interface has been received.

• The "Change in slave input data" hardware event was triggered. • The "New slave diagnostic data" hardware event was triggered. • A Fast Logic trigger condition was detected.

• A new DP cycle begins in the constant bus cycle time mode.

• The cyclic part of the DP cycle ends in the constant bus cycle time mode.

Note 1

To be able to trigger a software event, a suitable Windows semaphore must be initialized once using the DP_init_sema_object function.

Note 2

With software events, the corresponding hardware events must also be activated. Exception: The "Acknowledgment of an asynchronous function call of the DP programming interface has been received" event.

Implementing Filter Mechanisms with Events

The DP user program can activate hardware or software events selectively. This allows you to implement a simple filter mechanism .

Example

You only want the changes in the input data of a particular DP slave to be reported as an event.

The DP user program therefore only enables the "Change in slave input data" event for this DP slave and not for the other DP slaves. As a result, there is a filter for data changes only on this DP slave.

(55)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 55

Further Information on Hardware Events

The table below names the hardware events and indicates the section in which the event is described in detail.

Hardware Events Reference to Function Calls, Direct Access, General Information

"Change in slave input

data" Sections 4.3.4 and 4.3.12 describe how to check whether input data of DP-slaves has changed by directly accessing control registers. These sections also describe how the event must be enabled again following a change in the input data.

"New slave diagnostic data" Section 4.3.12 describes how to check whether diagnostic data have been received by direct access to control registers. This section also describes how to enable the event again after receiving new diagnostic data.

"Fast Logic trigger condition

was triggered" Section 4.1.24 describes the DP_fast_logic_on function call with which a trigger condition is activated.

Section 4.1.25 describes the DP_fast_logic_off function call with which a trigger condition is deactivated.

Section 4.3.10 describes how to query the Fast Logic status and how to acknowledge a Fast Logic trigger event by direct access to control registers. ● "A new DP cycle begins

in the constant bus cycle time mode" and

● "The cyclic part of the DP cycle ends in the constant bus cycle time mode".

Section 4.3.16 describes the principle and handling of the constant bus cycle time mode.

(56)

Further Information on Software Events

The following table names the software events and indicates the sections where these events are described in detail:

Software Events Reference to Function Calls, Direct Access, General Information

Software events in

general Section 4.1.22 describes the DP_init_sema_object function call with which various Windows semaphores can be initialized.

Section 4.1.23 describes the DP_delete_sema_object function call with which a Windows semaphore can be removed again.

Software event "Acknowledgment of an

asynchronous function call has been received".

Section 4.1.20 describes the DP_get_result function call that returns the acknowledgments of various asynchronous function calls.

Other software

events These software events are linked to corresponding hardware events. For more detailed information, see the references in the above table of hardware events. Note

For events relating to input data and diagnostic data, the release (in the "req_mask" element) of the semaphore is implemented with the

DPR_DATA_INT_CLEAR_AND_UNMASK constant so that the corresponding semaphore (interrupt-controlled) can be activated).

(57)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 57

Overview of the Sequence of Events that can be Signaled Using Windows Semaphores

The following diagram shows the basic structure of a Windows DP master user program that is informed of various software events of the DP master.

Activate other hardware events:

• Const. bus cycle: start, end of DP cycle • DP_fast_logic_on

When the program starts up, initialize the required semaphores with DP_init_sema_object and activate the hardware events “Change in slave input data“ and “New diagnostic data“ 1) for the first time.

Send asynchronous function call: • DP_ds_read/write • DP_alarm_ack Wait at semaphore 2) • DP_enable_event • DP_get_actual_cfg

When program complete, release semaphore with DP_release_sema_object.

Check control register:

• If input/diagnostic event: activate event again 1) and then read out data.

• Other events: Evaluate event.

Fetch result with DP_get_result and evaluate it

1) When the hardware event is activated, the triggering of an interrupt (by writing the constant DPR_DATA_INT_CLEAR_AND_UNMASK in the "req_mask" control register) must be enabled so that the CP 5613/CP 5614 can signal the event as a software event.

2) The DP user program can wait at Win32 API functions (for example

WaitForMultipleObjects, WaitForSingleObject, MsgWaitForMultipleObjects) at the semaphores.

(58)

3.2.2 Fast

Logic

Description

Fast Logic is an automatic function on the CP 5613/CP 5614: DP slave input data is monitored automatically by the CP 5613/CP 5614. If a trigger condition set by the DP master user program occurs, the CP 5613/CP 5614 automatically sets the relevant DP slave output data. Up to four trigger conditions can be activated at the same time.

Uses

With the Fast Logic property of the CP 5613/CP 5614, you can set parameters for the DP-master so that it automatically monitors data of DP slaves and triggers specific reactions on other DP slaves.

This has the following advantages:

• The DP master user program does not need to read out and monitor input data constantly. The control logic is handled by the CP 5613/CP 5614. This can reduce the CP load.

(59)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 59

Further Information on Fast Logic

The following table names the Fast Logic functions and indicates the sections where these are described in detail:

Fast Logic Functions Reference to Function Calls, Direct Access, General Information

Activate Fast Logic Section 4.1.24 describes the DP_fast_logic_on function call with which a trigger condition is activated. Deactivate Fast Logic Section 4.1.25 describes the

DP_fast_logic_off function call with which a trigger condition is deactivated. Query status in dual-port RAM Section 4.3.10 describes how the Fast

Logic status can be queried and a Fast Logic trigger event acknowledged using direct access to control registers in the dual-port RAM.

Activate software event for Fast Logic Refer to "Further Information on Software Events" on Page 56.

(60)

3.2.3 Timeout

Monitoring

Description

Timeout monitoring is a programmable, automatic watchdog function of the

CP 5613/CP 5614. The CP 5613/CP 5614 monitors the DP master user program to check whether it retriggers the watchdog in the dual-port RAM within a selectable time.

Uses

The timeout monitoring (watchdog) of the CP 5613/CP 5614 detects a permanent or sporadic failure of the DP master user program on the PC and automatically changes the DP master from OPERATE to CLEAR (safe plant state).

Further Information on the Watchdog

The following table names the watchdog functions and indicates the sections where these are described in detail:

Watchdog Functions Reference to Function Calls, Direct Access, General Information

Watchdog on/off Section 4.1.26 describes the

DP_watchdog function with which the monitoring function can be activated and deactivated.

Trigger watchdog and query status Section 4.3.11 describes how to trigger the watchdog and read the status using direct access to the dual-port RAM.

(61)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 61

3.2.4 Constant Bus Cycle Time Mode

Description

The constant bus cycle time mode is a mode that can be selected for special applications in which the transfer of user data between the DP master and the DP slaves takes place at constant (equidistant) intervals. The DP master user program can also synchronize itself with the constant bus cycle time bus cycle using

hardware or software events.

Uses

The constant bus cycle time mode allows the implementation of applications that require bus cycles of a constant length and a very close link between the DP master user program cycle and the bus cycle; for example clocked controls in motion control.

Further Information on the Constant Bus Cycle Time Mode

The following table names the functions of the constant bus cycle time mode and indicates the sections where these are described in detail:

Constant Bus Cycle Time Functions Reference to Function Calls, Direct Access, General Information

Using the constant bus cycle time

mode. Section 4.3.16 describes the principle and handling of the constant bus cycle time mode.

Additional Functions for the CP 5623/CP 5624

Section 4.1.28 describes how the cycle start interrupt can be delayed with the DP_delay_irq function.

Section 4.1.29 describes how the re-maining cycle time can be queried with the DP_cycle_time function.

(62)

3.2.5 Access to Operating Data in the Dual-port RAM

Description

Operating data is important information in the dual-port RAM of the

CP 5613/CP 5614 relating to the DP master and its DP slaves. The operating data can be divided up as follows:

• general operating data (for example bus parameters)

• configuration information of the DP slaves (for example amount of input and output data)

• current mode of the DP master • operability of the DP slaves

Uses

All the operating data required when the DP master user program executes are

updated automatically by the CP 5613/CP 5614 and can be queried extremely

efficiently using direct access to the dual-port RAM.

Example: The "Operability of the DP slaves" information indicates whether or not each DP slave is involved in cyclic data transfer. Based on this, a DP master user program can easily recognize whether the input/output data of the DP slave in the process image are valid.

(63)

DP Base Programming Interface for CP 5613/CP 5614

C79000-G8976-C139-09 63

Overview of the Operating Data

The following table names the operating data types and indicates the section in which they are described in detail:

Type of Data Reference to Direct Access, General Information

Current status of the DP slaves: • READY

• NOT READY

Section 4.3.5 describes how to query the operating state of DP slaves

Information on the DP master: ● Current mode of the DP master:

OFFLINE, STOP, CLEAR, AUTOCLEAR, OPERATE ● Identification number of the

certification

● Hardware and firmware version

Section 4.3.6 describes how to query important information on the DP master.

Configured bus parameters Section 4.3.7 describes how to query the current bus parameters of the DP master.

Further information on the DP slave: ● Slave type

● Number of configured input and output bytes

● Configured/not configured

Section 4.3.8 describes how to query further important information on DP slaves.

PROFIBUS statistics counter (error

(64)

3.3

How Does a DP Master User Program Access Process

Data?

Overview

The following sections explain how a DP master user program accesses this process data:

• Read DP slave input data • Read DP slave diagnostic data • Write DP slave output data

These sections also explain points to note when using the multitask mode (several tasks access the CP 5613/CP 5614 at the same time).

References

Related documents