+ All Categories
Home > Documents > WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document...

WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document...

Date post: 10-Jun-2018
Category:
Upload: phungdiep
View: 224 times
Download: 1 times
Share this document with a friend
48
Applikationen & Tools Answers for industry. Cover WinAC Driver for SIMATIC PCIe DIO4 Operator manual V 1.11 June 2012
Transcript
Page 1: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

Applikationen & Tools

Answers for industry.

Cover

WinAC Driver for SIMATIC PCIe DIO4 Operator manual

V 1.11 June 2012

Page 2: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

2 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Industry Automation and Drives Technologies Service & Support Portal This article is taken from the Service Portal of Siemens AG, Industry Automation and Drives Technologies. The following link takes you directly to the download page of this document. http://support.automation.siemens.com/WW/view/en/63204530 If you have any questions concerning this document please e-mail us to the following address: [email protected] [email protected]

Page 3: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

WinAC DIO4 driver V 1.11, Entry ID: 63204530 3

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

s

SIMATIC WinAC DIO4 driver Operator manual

Automation Task 1

Overview 2

Driver Supported Functionality

3

WinAC Function Blocks 4

Installation 5

Use Cases of Application 6

Error Codes 7

Related Literature 8

History 9

Page 4: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

Warranty and Liability

4 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Warranty and Liability Note The Application Examples are not binding and do not claim to be complete

regarding the circuits shown, equipping and any eventuality. The Application Examples do not represent customer-specific solutions. They are only intended to provide support for typical applications. You are responsible for ensuring that the described products are used correctly. These application examples do not relieve you of the responsibility to use safe practices in application, installation, operation and maintenance. When using these Application Examples, you recognize that we cannot be made liable for any damage/claims beyond the liability clause described. We reserve the right to make changes to these Application Examples at any time without prior notice. If there are any deviations between the recommendations provided in these application examples and other Siemens publications – e.g. Catalogs – the contents of the other documents have priority.

We do not accept any liability for the information contained in this document.

Any claims against us – based on whatever legal reason – resulting from the use of the examples, information, programs, engineering and performance data etc., described in this Application Example shall be excluded. Such an exclusion shall not apply in the case of mandatory liability, e.g. under the German Product Liability Act (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life, body or health, guarantee for the quality of a product, fraudulent concealment of a deficiency or breach of a condition which goes to the root of the contract (“wesentliche Vertragspflichten”). The damages for a breach of a substantial contractual obligation are, however, limited to the foreseeable damage, typical for the type of contract, except in the event of intent or gross negligence or injury to life, body or health. The above provisions do not imply a change of the burden of proof to your detriment. Any form of duplication or distribution of these Application Examples or excerpts hereof is prohibited without the expressed consent of Siemens Industry Sector.

Page 5: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

Table of Contents

WinAC DIO4 driver V 1.11, Entry ID: 63204530 5

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Table of Contents Warranty and Liability..............................................................................................4 1 Automation Task ............................................................................................7

1.1 Overview...........................................................................................7 1.1 Needed knowledge............................................................................7 1.2 Required Hardware and Software Components .................................7

2 Overview.........................................................................................................9 2.1 Functional range................................................................................9 2.2 Version of the driver.........................................................................10

3 Driver supported functionality.....................................................................12 3.1 General overview.............................................................................12 3.2 Digital inputs / outputs .....................................................................12 3.3 Counter ...........................................................................................12 3.4 Interrupt processing.........................................................................13 3.5 Error handling..................................................................................14

4 WinAC function blocks (FB).........................................................................15 4.1 DIO4_INIT - initialization..................................................................16 4.2 DIO4_CONFIG – configure..............................................................18

Excel tool for register configuration ..................................................19 4.3 DIO4_READ_DI – read digital inputs ...............................................20 4.4 DIO4_READ_CNT – read counter values.........................................21 4.5 DIO4_WRITE_DO – Write digital outputs.........................................22 4.6 DIO4_WRITE_CNT – Write counter.................................................23 4.7 Interrupt OBs (OB52, OB53) ............................................................24

5 Installation ....................................................................................................25 5.1 Quick-start.......................................................................................25 5.2 Setup the SIMATIC PCIe DIO4 as RTX Device................................25 5.3 Check PCIO installation with “Dio4Scan.rtss” ...................................32 5.4 Installation WinAC driver on runtime system ....................................33 5.5 Installation WinAC driver on engineering system..............................33

6 Use Cases of the Application.......................................................................34 6.1 Overview.........................................................................................34 6.2 Provided example projects...............................................................34 6.3 Use Cases.......................................................................................36 6.3.1 Direct write of digital output..............................................................36 6.3.2 Direct read of digital input (incl. Interrupt).........................................36 6.3.3 Filtering of inputs .............................................................................37 6.3.4 Pulse width measurement................................................................38 6.3.5 Frequency measurement .................................................................39 6.3.6 Output with PWM function ...............................................................40 6.3.7 Counter (incl. Interrupt)....................................................................41 6.3.8 Timer (incl. Interrupt) .......................................................................42

7 Error Codes ..................................................................................................44 7.1 Error codes of WinAC ODK..............................................................44 7.2 Special error codes of the WinAC DIO4 driver..................................46

8 Related Literature.........................................................................................47 8.1 Bibliography.....................................................................................47 8.2 Internet Link Specifications ..............................................................47

Page 6: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

Table of Contents

6 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

9 History ..........................................................................................................48

Page 7: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

1 Automation Task

WinAC DIO4 driver V 1.11, Entry ID: 63204530 7

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

1 Automation Task 1.1 Overview

Introduction The Nanobox IPC227D is available in various configuration settings. One of them is an option with on-board IOs (4xDI, 4xDO). For this option the extension board SIMATIC PCIe DIO4 is used. To use the features of the DIO4 board from within a WinAC application a WinAC driver is needed. This document describes the WinAC DIO4 driver. The driver supports all functions of the DIO4 board (Interrupts, PWM, etc.). To make the usage of the DIO4 simple, examples of configuration for typical use cases are provided in this document.

1.1 Needed knowledge

To understand this document the following knowledge needed: SIMATIC WinAC RTX 2010 SIMATIC Manager STEP7 V5.5

or TIA Portal V11 SIMATIC PCIe DIO4 extension board

1.2 Required Hardware and Software Components

The application was generated with the following components:

Hardware components Simatic Nanobox IPC 227D (1 GHz, 1 GB RAM, 4 GB CF-Card)

with Windows XP embedded SP3 SIMATIC PCIe DIO4 extension board

Firmware Revision Version: 04h

Standard software components SIMATIC WinAC RTX 2010 SIMATIC Manager STEP 7 V5.5

or TIA Portal V11 SP2

Page 8: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

1 Automation Task

8 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Sample files and projects The following list includes all files and projects that are used in this example. Table 1-1 Included files

Component Note

Documentation \ WinAcDio4_Doc_de.pdf Documentation \ WinAcDio4_Doc_en.pdf

This documentation in German and English

Driver \ WinAcDio4Drv.rtdll The WinAC driver Driver \ RegisterWinAcDio4Driver.bat Setup batch for the driver S7Example \Dio4.zip Step7 example project including all WinAC

function blocks of the driver TiaExample\Dio4.zip TIA Portal example project including all

WinAC function blocks of the driver Tools \ Dio4Scan.rtss Checks installed DIO4 board Tools \ Dio4PrintRegisters.rtss Prints all actual register values Tools \ RegisterConfig.xls MS Excel tool for configuring the DIO4

registers

Page 9: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

2 Overview

WinAC DIO4 driver V 1.11, Entry ID: 63204530 9

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

2 Overview 2.1 Functional range

The WinAC DIO4 driver supports the following functions of the SIMATIC PCIe DIO4 extension board: Read digital inputs (incl. Interrupts, input filter) Write digital outputs (incl. Interrupts) Process counters (incl. Interrupts)

The counter functionality provides the opportunity to realize a PWM output.

CAUTION The WinAC DIO4 driver supports only one SIMATIC PCIe DIO4 extension board!

It is not allowed to install more than one DIO4 board in a computer running the WinAC.

If more than one DIO4 board is found, an error code is returned by the driver. The used concept for signaling hardware interrupts into the WinAC program allows only one DIO4 board.

MSI – Message Signaled Interrupts The SIMATIC PCIe DIO4 board supports MSI (Message Signaled Interrupts). The WinAC driver is realized as IntervalZero RTX real-time driver. It supports MSI.

Concept of the WinAC interface To give the WinAC programmer the full power of the DIO4 board all registers of the DIO4 are accessible by the WinAC driver.

Process data (cyclic) vs. configuration data For operation of the DIO4 various register values have to be read and written. There is a differentiation in: Settings, written once or rarely Values, written cyclic Values, read cyclic

The following table contains an overview about the registers and the classification into the categories mentioned above:

Page 10: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

2 Overview

10 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Table 2-1 Classification of parameters

Group Function (single) Initializatio

n

Cyclic read Cyclic write

Input Input Filter X Input Inversion X Edge Detection X Interrupt Config X Eingangsregister X Output Quelle Ausgang X Modus X Interrupt Config X Ausgangsregister X Counter Config X Config Interrupts X Counter Wert X Counter Status X Capture Wert X Reload Wert X Compare Wert X

According to this classification there are function blocks available. Cyclic read / write is done by the function blocks DIO4_READ_DI, DIO4_READ_CNT, DIO4_WRITE_DO, DIO4_WRITE_CNT. The configuration can be executed by DIO4_CONFIG.

NOTE It is possible to change the configuration during run-time. The user must consider possible side-effects (e.g. changing counter configuration when counter is active).

2.2 Version of the driver

Determine driver under Windows OS The registered real-time driver RTDLL is located in the system directory, e.g.: C:\windows\Rtss\Rtdll You can identify the version of the driver RTDLL in the file properties (Windows explorer right click properties)

Page 11: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

2 Overview

WinAC DIO4 driver V 1.11, Entry ID: 63204530 11

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Figure 2-1 Properties of the driver RTDLL

Check driver version in Step7 project In the instance DB of DIO4_INIT the version of the RTDLL is stored: tOdkIf.wFbVersion Version der Step7-Treiber-SW tOdkIf.dwDllVersion Version der Treiber- RTDLL

Page 12: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

3 Driver supported functionality

12 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

3 Driver supported functionality The functionality of the DIO4 is described in the document “SIMATIC PCIe DIO4 Operator Manual”. In this chapter special features of the WinAC driver are explained.

3.1 General overview

Figure 3-1 Build-up of the WinAC DIO4 driver

DIO4

DIO4 real-time driver

WinAC RTX

FB CONFIGFB READFB WRITE

OB 52OB 53

A real-time driver was developed for the DIO4 board. The WinAC driver includes a number of function blocks (FB) for reading / writing register values of the DIO4. If an interrupt is generated by the DIO4 board the real-time driver calls special operation blocks (OB) in the WinAC program.

3.2 Digital inputs / outputs

The SIMATIC PCIe DIO4 provides four digital inputs and four digital outputs. If configured the digital inputs and outputs can be read / written directly. The corresponding function blocks are part of the WinAC driver.

NOTE It is recommended to use an adequate input filter configuration when using the digital inputs (see chapter 6.3.3 page 37).

3.3 Counter

The DIO4 provides powerful functionality for the eight counter channels. The configuration of the counters is described in the DIO4 operating manual. You have to configure the counters by using the function blocks of the WinAC driver. You access the register values.

Page 13: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

3 Driver supported functionality

WinAC DIO4 driver V 1.11, Entry ID: 63204530 13

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

3.4 Interrupt processing

The DIO4 generates various interrupts. The interrupts are forwarded to the WinAC (OB52, OB53). Of course the user can configure what events should trigger an interrupt. In the WinAC program two interrupts are used: OB52 and OB53. The number of local data in an operation block is limited. That’s why two OBs are used:

OB 52 – Error / Input / Ouptut (EIO) Interrupts by inputs Interrupts by outputs Error interrupts (collective fault)

OB 53 – Counter Interrupts by counters

The interrupt logic is described in the SIMATIC PCIe DIO4 operator manual. It is structured hierarchical. For example the interrupts for falling / rising edges are organized like this: Figure 3-2 Hierarchical structure of the input interrupts

The values are determined like this:

INPIFF = („Input falling edge“ AND INPxC.ENFEI) INPIFR = („Input rising edge“ AND INPxC.ENREI) INPIF = INPIFF OR INPIFR GSR.IIF = „Any bit of INPIF“

Note If the interrupts are configured but the interrupt enabling bit is not set, the interrupt logic is processed. The status bits are set, but no interrupt is triggered. The bits stay ‘1’ because they are not resetted by the interrupt service routinge (ISR).

Page 14: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

3 Driver supported functionality

14 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

3.5 Error handling

The DIO4 provides collective fault information. It is not possible to determine the reason of the fault (power fail, over temperature, short circuit, etc.). If a failure situation is detected by the driver, it is signaled in the return value of the read/write function blocks. If the error interrupt is activated, an error interrupt is generated in case of error.

Page 15: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

4 WinAC function blocks (FB)

WinAC DIO4 driver V 1.11, Entry ID: 63204530 15

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

4 WinAC function blocks (FB) The WinAC FileServer provides a number of function blocks for access all functionality. The numbers of the function block can be changed by the user. FB901 - DIO4_INIT FB902 - DIO4_CONFIG FB903 - DIO4_READ_DI FB904 - DIO4_READ_CNT FB905 - DIO4_WRITE_DO FB906 - DIO4_WRITE_CNT The example project contains data blocks for configuration data and read/write data. DB1002 - DIO4_CONFIG_DATA DB1003 - DIO4_READ_DATA DB1004 - DIO4_WRITE_DATA

Note The driver function blocks are implemented in SCL (source included). For the usage of the WinAC DIO4 driver is SCL not needed!

Page 16: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

4 WinAC function blocks (FB)

16 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

4.1 DIO4_INIT - initialization

This block initializes the WinAC DIO4 driver. It has to be called one-time before any other call of WinAC DIO4 driver function blocks. This function loads the driver RTDLL, scans the PC for the DIO4 board. The result of the scanning is provided in the instance data block of DIO4_INIT. The driver checks the version of RTDLL and Step7 function block. If there is a version problem, the DIO4_INIT returns an error Table 4-1 Parameter of FBs DIO4_INIT

Parameter In/Out

Typ Description

ODK_REF Out WORD Reference to driver *1) ERROR Out Bool Error STATUS Out WORD Status information

Note *1) The value ODK_REF hast to provided to all other function blocks of the WinAC DIO4 driver.

Additional information in instance DB of DIO4_INIT Additional to the output parameters some information is stored in the instance data block of the function block: Table 4-2 Information in instance data block of DIO4_INIT

Name In/ Out

Type Description

tOdkIf.wFbVersion Out Word Version of Step7 function blocks tOdkIf.dwDllVersion In Dword Version of driver RTDLL tOdkIf.HWIFVersion In Byte Hardware interface version of DIO4 tOdkIf.HWRevision In Byte Hardware revision tOdkIf.InputsTotal In Byte Number of inputs tOdkIf.OutputsTotal In Byte Number of outputs tOdkIf.CountersTotal In Byte Number of counters tOdkIf.MaxCounterValLow tOdkIf.MaxCounterValHigh

In In

Dword Dword

Maximum value of counter (64 bit value) Splitted in low and high DWORD

Note The data in the instance data block is valid after the first call of INIT function block!

Page 17: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

4 WinAC function blocks (FB)

WinAC DIO4 driver V 1.11, Entry ID: 63204530 17

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Coding of RTDLL version The RTDLL version is coded hexadecimal. The last sign of the DWORD is used for mark Debug and Release version: D – Debug-Version A – Release-Version Figure 4-1 Examples for DLL versions in the instance DB

iDB_DIO4_INIT.tOdkIf.dwDllVersion HEX DW#16#0001000D

\ /|

\/ +- Debug

+---- V 1.0.0.0

iDB_DIO4_INIT.tOdkIf.dwDllVersion HEX DW#16#0001100A

\ /|

\/ +- Release

+---- V 1.1.0.0

Information about DIO4 hardware The instance data block contains some information about the found DIO4 hardware. Figure 4-2 Information on found DIO4 in instance data block of DIO4_INIT

Page 18: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

4 WinAC function blocks (FB)

18 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

4.2 DIO4_CONFIG – configure

A call of DIO4_CONFIG parameterizes the DIO4 board. The configuration data is stored in a range of a data block. This data is provided to the DIO4_CONFIG function block. For specific use cases (e.g. configuration of counters) before calling DIO4_CONFIG the function block FB_WRITE_CNT has to be called. The function block DIO4_CONFIG can be called more than one time to change the configuration parameter during run-time.

Note The configuration can be changed during run-time. The operator has to be aware about possible side effects (e.g. when changing counter configuration).

Table 4-3 Parameter of DIO4_CONFIG

Parameter In/Out

Typ Description

ODK_REF In WORD Reference to the driver (see DIO4_INIT) CONFIG In ANY Any pointer to parameterization data ERROR Out BOOL Error STATUS Out WORD Status information

Structure of configuration data for DIO4 board The function block DIO4_CONFIG needs the information for all four IO channels and for the eight counters. The data is provided in a data area. The structure of this data is fixed. It is organized like the configuration registers of the DIO4 board. The example project provides the DB1002 DIO4_CONFIG_DATA with the matching structure. Table 4-4 Structure of configuration data

Name Type Description

GCR DWORD General Control Register INPC ARRAY[0..3] Input configuration INP0..INP3 Low DWORD High DWORD OUTPC ARRAY[0..3] Output configuration OUTP0…OUTP3 Low DWORD High DWORD CCR ARRAY[0..7] OF DWORD Counter Control Register C0CR … C7CR CTR ARRAY[0..7] Counter trigger register CxTRx REG ARRAY[0..4] OF DWORD CxTR0 … CxTR4

Page 19: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

4 WinAC function blocks (FB)

WinAC DIO4 driver V 1.11, Entry ID: 63204530 19

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

The specific meaning of all configuration data is described in the “SIMATIC PCIe DIO4 operator manual”. To support the full functionality of the DIO4 the configuration values are copied to the DIO4 registers. The user may re-use example configurations provided in this documentation but also may create its own configurations.

Excel tool for register configuration To make the register configuration more easily, the driver package includes a MS Excel tool for determining the register values: RegisterConfig.xls. Figure 4-3 Register Configuration Tool (MS Excel)

Page 20: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

4 WinAC function blocks (FB)

20 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

4.3 DIO4_READ_DI – read digital inputs

This function block reads the digital inputs of the DIO4 board. Table 4-5 Parameter of DIO4_READ_DI

Parameter In/Out

Typ Description

ODK_REF Out WORD Reference to the driver (see DIO4_INIT) ERROR In BOOL Error flag STATUS In WORD Status information INP In DWORD Digital inputs (only four bits are used)

Additional to the state of the digital inputs the FB provides additional register values in the instance data block: Table 4-6 Additional information in instance data block of FB DIO4_READ_DI

Parameter I/O Typ Description

tOdkIf.dwINPIF In DWORD Register INPIF (Interrupt register Inputs) tOdkIf.dwINPIFG In DWORD Register INPIFR (Interrupt register Inputs, rising

edge) tOdkIf.dwINPIFF In DWORD Register INPIFF (Interrupt register Inputs, falling

edge) tOdkIf.dwGSR In DWORD Register GSR (General Status register)

These interrupt registers are processed in the interrupt service routine (ISR) when the interrupts are activated. The registers are resetted in the ISR. The register values in the instance DB of READ_DI may help in solving issues.

Page 21: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

4 WinAC function blocks (FB)

WinAC DIO4 driver V 1.11, Entry ID: 63204530 21

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

4.4 DIO4_READ_CNT – read counter values

This function block reads the values of the eight counters of the DIO4 board. Table 4-7 Parameter of DIO4_READ_CNT

Parameter In/Out

Typ Description

ODK_REF Out WORD Reference to the driver (see DIO4_INIT) DATA In ANY Pointer to range for counter values ERROR In BOOL Error flag STATUS In WORD Status information

Data structures for counter values The current counter values are provided in a fixed structure. In the example project the DB 1003 DI4_READ_DATA is used. The array contains the values for the eight counters: counter value, status flags and capture value. Table 4-8 Structure of counter value data

Name Type Description

CSR ARRAY [0..7] OF STRUCT

Counter Status register (32 bit)

CVR ARRAY [0..7] Counter Value Register Low DWORD High DWORD CCAPR ARRAY [0..7] Counter Capture Register Low DWORD High DWORD

Note Counter Status Bits: The interrupt flags in the status are set independent if the interrupts are enabled or not (e.g. Counter Compare Equal Interrupt Flag CxSR.SEIF). Interrupt flags are reset in the interrupt processing only. E.g. a not-activated interrupt flag is reset if any other interrupt is raised and processed.

Page 22: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

4 WinAC function blocks (FB)

22 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

4.5 DIO4_WRITE_DO – Write digital outputs

This function block writes the four digital outputs of the DIO4 board. Table 4-9 Parameter of DIO4_WRITE_DI

Parameter In/Out

Typ Description

ODK_REF Out WORD Reference to the driver (see DIO4_INIT) OUTP In DWORD Digital outputs (only four bits are used) ERROR In BOOL Error flag STATUS In WORD Status information

Additional to the state of the digital inputs the FB provides additional register values in the instance data block: Table 4-10 Additional information in instance data block of FB DIO4_READ_DI

Parameter I/O Typ Description

tOdkIf.dwOUTPIF In DWORD Register OUTPIF (Interrupt register Outputs) tOdkIf.dwOUTPIFG In DWORD Register OUTPIFR (Interrupt register Outputs,

rising edge) tOdkIf.dwOUTPIFF In DWORD Register OUTPIFF (Interrupt register Outputs,

falling edge)

These interrupt registers are processed in the interrupt service routine (ISR) when the interrupts are activated. The registers are resetted in the ISR. The register values in the instance DB of READ_DO may help in solving issues.

Page 23: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

4 WinAC function blocks (FB)

WinAC DIO4 driver V 1.11, Entry ID: 63204530 23

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

4.6 DIO4_WRITE_CNT – Write counter

This function block writes information to the eight counters of the DIO4 board. Table 4-11 Parameter of DIO4_WRITE_CNT

Parameter In/Out

Typ Description

ODK_REF Out WORD Reference to the driver (see DIO4_INIT) DATA In ANY ANY pointer to data to be written ERROR In BOOL Error flag STATUS In WORD Status information

Data structures for counter set point values The values for the counters are provided in a fixed structure. In the example project the DB 1004 DIO4_WRITE_DATA is used. The array contains the values for the eight counters: reload value and compare value. Table 4-12 Structure of counter value data

Name Type Description

COMR ARRAY [0..7] Compare Register Low DWORD High DWORD RELR ARRAY [0..7] Reload Register Low DWORD High DWORD

Page 24: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

4 WinAC function blocks (FB)

24 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

4.7 Interrupt OBs (OB52, OB53)

An (interrupt) operation block of the WinAC contains a limited number of bytes (local data). In sum 64 bit of the local data can be used by application (8 + 8 + 16 + 32 = 64 Bit). The meaning of this 64 bit (dataType2, dataType1, data1, data2) is used for the different interrupts in a defined way (see tables below). Because of the limited amount of local data two interrupt OBs are used. Table 4-13 Local data of interrupt OB 52 (error / input / output)

Name Type Addr. Description

dataType2 Byte 4.0 GSR general status register (1 Byte) dataType1 Byte 5.0 DI interrupt flag register (1 Byte) data1 Word 6.0 DI Interrupt flags (rising edge) (1 Byte)

DI Interrupt flags (falling edge) (1 Byte) data2 DWord 8.0 DO interrupt flag register (1 Byte)

DO Interrupt flags (rising edge) (1 Byte) DO Interrupt flags (falling edge) (1 Byte) Reserved (1 Byte)

Table 4-14 Local data of interrupt OB 52 (error / input / output)

Name Type Addr. Description

dataType2 Byte 4.0 Counter Status Register 0 (low byte) dataType1 Byte 5.0 Counter Status Register 1 (low byte) data1 Word 6.0 Counter Status Register 2 (low byte)

Counter Status Register 3 (low byte) data2 DWord 8.0 Counter Status Register 4 (low byte)

Counter Status Register 5 (low byte) Counter Status Register 6 (low byte) Counter Status Register 7 (low byte)

To access the DIO4 interrupt data in symbolic way in the provided Step7 example project a possible solution is prepared.

Page 25: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

5 Installation

WinAC DIO4 driver V 1.11, Entry ID: 63204530 25

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

5 Installation 5.1 Quick-start

Convert SIMATIC PCIe DIO4 extension board from Windows device to RTX device

Execute driver setup with setup.bat Utilize and modify Step7 demo project

5.2 Setup the SIMATIC PCIe DIO4 as RTX Device

The WinAC DIO4 driver is realized as real-time driver for the real-time extension for Windows IntervalZero RTX. That’s why the DIO4 has to be setup as RTX device.

Cancel the Windows Plug and Play Manager (Windows XP) Under Windows XP the Windows Plug and Play Manager recognized the new hardware and wants to install a Windows driver. This dialogue has to be canceled. Figure 5-1 Windows Plug and Play Manager (Windows XP)

Under Windows7 this dialog is not shown.

Find DIO4 in the device manager (Windows XP) The device manager can be started over the system properties.

Page 26: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

5 Installation

26 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Figure 5-2 Start the device manager from system properties (Windows XP)

Find DIO4 in the device manager (Windows 7) The device manager can be found under “System”. Figure 5-3 Start the device manager from system properties (Windows XP)

Unknown device “DPIO Module” It should exist only one device with a question mark: „DPIO Module“. This is the SIMATIC PCIe DIO4 Board.

Page 27: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

5 Installation

WinAC DIO4 driver V 1.11, Entry ID: 63204530 27

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Figure 5-4 Unknown device „DPIO Module“

Settings in RTX Properties Via control panel of the Windows operating system you can reach the RTX properties. Figure 5-5 RTX Properties in the control panel (Windows XP)

Page 28: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

5 Installation

28 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Figure 5-6 RTX Properties in the control panel (Windows 7)

Page 29: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

5 Installation

WinAC DIO4 driver V 1.11, Entry ID: 63204530 29

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Select the tab “Hardware”, button “Settings”. Figure 5-7 RTX Properties / Hardware

Next you choose the device with the right mouse bottom and click on Add RTX INF support. Figure 5-8 Adding RTX INF support to the DIO4 board

NOTICE You have to press the „Apply“ button! The „OK“ button is not enough!

Page 30: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

5 Installation

30 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Uninstall the device in the Windows device manager Next you go again to the Windows device manager in order to uninstall the SIMATIC PCIe DIO4 board („DPIO Module“ with question mark). Figure 5-9 (Windows) device Uninstallation

The device disappears firstly from the device manager.

NOTE Perhaps a checkbox must be set, to deinstall the old driver from device.

Installation of device as RTX device Afterwards you choose at the menu Action Scan for new Hardware (This works only, if you have clicked into the main window of the device manager before). Now the DIO4 will be registered as RTX device automatically.

Page 31: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

5 Installation

WinAC DIO4 driver V 1.11, Entry ID: 63204530 31

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Figure 5-10 SIMATIC PCIe DIO4 as RTX device

Check MSI At least you have to check if support of MSI of the DIO4 was detected. You can check this in the RTX properties. Figure 5-11 RTX Properties with DIO4 as RTX-Device

Page 32: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

5 Installation

32 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Now select right mouse button properties:: Figure 5-12 Interrupt settings of DIO4 in the RTX properties

5.3 Check PCIO installation with “Dio4Scan.rtss”

The WinAC DIO4 driver includes a tool to check the installed DIO4 board. The tool Dio4Scan.rtss is located in the \tools\ directory. It is a RTX application. On a computer with installed IntervalZero RTX you can start this application with double click. This is the case on all computers with WinAC RTX. Figure 5-13 Output of “Dio4Scan.rtss”

Start <DIO4Scan> DioDrvOpen returned <0x0> DIO device information Version: 0x1000 0000 HWIFVersion: 0x10 HWRevision: 0x4 NumberOfInputs: 0x4 NumberOfCounters: 0x8 DioDrvClose returned <0x0> End <Dio4Scan>

NOTICE The tool Dio4Scan.rtss needs exclusive access to the DIO4 card. That’s why it is not allowed to execute the tool at same time the WinAC DIO4 driver is running.

Page 33: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

5 Installation

WinAC DIO4 driver V 1.11, Entry ID: 63204530 33

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

5.4 Installation WinAC driver on runtime system

The installation of the WinAC driver PCIO is only about the registration of the driver realtime DLL (WinLcDio4Drv.rtdll) with the batch file setup.bat (rtssrun /dll WinLcPcIoDrv.rtdll). You can check the installation with the command rtsskill. At the registered DLLs you must see the WinLcDio4Drv.rtdll.

5.5 Installation WinAC driver on engineering system

There is no installation needed of the WinAC DIO4 driver on the engineering station. On the engineering system only this documentation and the Step7 example program is needed. You can copy the needed function blocks and user defined types from this Step7 example to you own application.

Page 34: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

6 Use Cases of the Application

34 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

6 Use Cases of the Application 6.1 Overview

To use the WinAC DIO4 driver in an effective way an example project is provided as part of this driver package. Additional some typical use cases are explained in this document. These configurations are explained for one channel. Of course they can be used with different channels, too or may be mixed in any way: Direct read of digital input (incl. Interrupt) Direct write of digital output Frequency measurement Pulse width measurement Output with PWM function Counter (incl. Interrupt)

6.2 Provided example projects

The driver package also includes a example project for Step7 and TIA Portal V11. The example application is realized in FBD (Function Block Diagram). Target of the example is the demonstration of all functions of the DIO4 driver. The different functionalities are controlled by some variable tables.

OB100 Complete Restart In start up phase the driver is loaded (DIO4_INIT). Additional some internal flags are reset.

OB1 CYCL_EXC The OB1 contains all the function blocks of the DIO4 driver. They can be activated by separate flags (see variable tables).

OB52, OB53 Interrupt processing In OB52 and OB53 the information about the interrupt source is copied to variables. Thus the information can be accessed in a symbolic way. For various interrupt sources counters are increased.

FB901 – FB906 –DIO4 Driver These are fhe function blocks of the WinAC DO4 driver.

Page 35: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

6 Use Cases of the Application

WinAC DIO4 driver V 1.11, Entry ID: 63204530 35

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

DB901 – DB906 –DIO4 Driver These are the instance data blocks of the FBs of the WinAC DIO4 driver.

DB1002 DIO4_CONFIG_DATA - Configuration This data block contains the configuration fort he DIO4 board.

DB1003 DIO4_READ_DATA – Reading data of DIO4 This data block is used to hold the read data from DIO4 (digital inputs and counter values).

DB1004 DIO4_WRITE_DATA – Write data for DIO4 This data block is used to hold the data to be written to the DIO4 board (digital outputs and counter configuration).

DB1005 DIO4_IRQ_DATA – Interrupt Data This data block holds the various interrupt information and counters for selected interrupts sources.

VAT_... – Variable tables The variable tables are prepared to test specific functionality of the DIO4 board.

Page 36: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

6 Use Cases of the Application

36 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

6.3 Use Cases

6.3.1 Direct write of digital output

The output signals can be configured for different sources. If the outputs should be set/reset by direct writing (OUTP register) it has to be configured in that way. Table 6-1 Call parameters for function block DIO4_CONFIG

Register Value Description

GCR – Global Control Register 0x0001 Global enable INPxC – Input Config. 0x0000 OUTPxC – Output Config. LOW HIGH

0x0000 0x0000

Source Select: „OUTPx“

6.3.2 Direct read of digital input (incl. Interrupt)

The current input values can be read by register INP. If the input changes should raise interrupts this has to be configured. Table 6-2 Call parameters for function block DIO4_CONFIG

Register Value Description

GCR – Global Control Register 0x0007 Global enable Global Interrupt enable Input Interrupt enable

INPxC – Input Config. 0x000C Enable rising edge interrupt Enable falling edge interrupt

NOTE It is recommended to use an input filter (see chapter 6.3.3 page 37).

Page 37: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

6 Use Cases of the Application

WinAC DIO4 driver V 1.11, Entry ID: 63204530 37

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

6.3.3 Filtering of inputs

It is recommended to filter the input signals. Without filtering the DIO4 may detect multiple rising edges because of the very high sample rate of the DIO4. The concrete parameterization of the input filter depends on the specific automation task. A typical value for the input filter could be: Sample rate: 1 kHz (1 ms) Threshold: 3 samples

For the above mentioned configuration is adjusted by the following register values: Table 6-3 Call parameters for function block DIO4_CONFIG

Register Value Description

GCR – Global Control Register 0x0007 Global enable Global Interrupt enable Input Interrupt enable

INPxC – Input Config. 0x3D0C Enable rising edge interrupt Enable falling edge interrupt Threshold: 3 samples Sample rate: 1,00 ms

Page 38: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

6 Use Cases of the Application

38 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

6.3.4 Pulse width measurement

A counter of the DIO4 is used to determine the length of a pulse on an input. Time basis is the internal counter frequency of the DIO4 of 62.5 MHz. The rising edge of the input signal clears the falling edge is used to capture the current counter value. After that the capture register contains the counter value. With this value the pulse with can be computed with the formula:

nsCxCAPRMHz

CxCAPRTPW 1615.62

1

NOTE The value of the capture register is a 36 bit value. When calculating in SIMATIC it is easier when limiting the usage to the lower 32 bits.

If the full range of 36 bit is used, up to 1099 seconds can be measured with full count frequency. When using the “prescaler” parameter, longer periods can be measured, too. Table 6-4 Call parameters for function block DIO4_CONFIG

Register Value Description

GCR – Global Control Register 0x0001 Global enable INPxC – Input Config. 0x0000 OUTPxC – Output Config. LOW HIGH

0x0000 0x0000

CxCR – Counter Control 0x0001 Enable Counter CxTR0 – Counter Trigger UP 0x0100 source constant ‚1’ (62,5 MHz) CxTR1 – Counter Trigger DOWN 0x0000 - (not used) CxTR2 – Counter Trigger CLEAR 0x2808 Rising edge

Source select: „Input 0“ CxTR3 – Counter Trigger RELOAD 0x0000 - (not used) CxTR4 – Counter Trigger CAPTURE 0x280A Falling edge

Source select: „Input 0“

Page 39: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

6 Use Cases of the Application

WinAC DIO4 driver V 1.11, Entry ID: 63204530 39

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

6.3.5 Frequency measurement

A counter of the DIO4 is used to measure the distance between two rising edges of an input (frequency at input). Time basis is the internal counter frequency of the DIO4 of 62.5 MHz. The rising edge of the input signal stores the current counter value in the capture register and clears counter. The capture register contains the counter value. With this value the frequency can be computed with the formula:

nsCxCAPRCxCAPR

MHzf161

11

5.62

NOTE The value of the capture register is a 36 bit value. When calculating in SIMATIC it is easier when limiting the usage to the lower 32 bits. This reduces the value range.

Table 6-5 Call parameters for function block DIO4_CONFIG

Register Value Description

GCR – Global Control Register 0x0001 Global enable INPxC – Input Config. 0x0000 OUTPxC – Output Config. LOW HIGH

0x0000 0x0000

CxCR – Counter Control 0x0001 Enable Counter CxTR0 – Counter Trigger UP 0x0100 source constant ‚1’ (62,5 MHz) CxTR1 – Counter Trigger DOWN 0x0000 - (not used) CxTR2 – Counter Trigger CLEAR 0x2808 Rising edge

Source select: „Input 0“ CxTR3 – Counter Trigger RELOAD 0x0000 - (not used) CxTR4 – Counter Trigger CAPTURE 0x2808 Rising edge

Source select: „Input 0“

Page 40: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

6 Use Cases of the Application

40 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

6.3.6 Output with PWM function

A counter of DIO4 is used to define the period of the PWM signal. The counter counts downward from a defined start value (reload value). For counter overflow the counter is started again with the reload value. The ratio between ON and OFF is realized by the compare function of the counter: If the counter value becomes smaller than the compare value, the output is set. By defining the compare value the ON/OFF ratio is defined. Example: The output should be set “1” for 1 sec. And set “0” for 4 sec. period is 5 sec. Solution: A counter decreases with the internal frequency of 62,5 MHz. The overflow (passing 0) is used as signal for reloading the counter.

hex12A0.5F1C6312.499.99

145,62sec5

45,62

eReloadValueReloadValu

MHzeReloadValu

PrescalerMHzTimeeReloadValu

The compare value is set to 1 sec.:

hex3B9.ACA1062.500.001

115,62sec1

15,62

ueCompareValueCompareVal

MHzueCompareVal

PrescalerMHzTimeueCompareVal

The compare value may be computed relatively:

hex3B9.ACA1062.500.001

1%100%20

1sec000.500.62sec5

1%100

[%]""5,62

1

ueCompareValueCompareVal

ueCompareVal

OnTimePrescaler

MHzTimeueCompareVal

NOTE The calling order of the function blocks is important here! First parameterize the counter values and second write the configuration registers.

Page 41: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

6 Use Cases of the Application

WinAC DIO4 driver V 1.11, Entry ID: 63204530 41

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

The calling order is important: First set the counter values (function block DIO4_WRITE_CNT) Second the configuration registers have to be written (incl. “Counter enable”)

(function block DIO4_CONFIG) Table 6-6 Call parameters for function block DIO4_WRITE_CNT

Register Wert Bemerkung

Reload Value 0x12A05F1C = 5 sec. (bei prescaler = 0) Compare Value 0x03B9ACA1 = 1 sec. (bei prescaler = 0)

Table 6-7 Call parameters for function block DIO4_CONFIG

Register Wert Bemerkung

GCR – Global Control Register 0x0001 Global enable INPxC – Input Config. 0x0000 OUTPxC – Output Config. LOW HIGH

0x0000 0x0B00

Source: Counter 0 Compare Smaller

CxCR – Counter Control 0x0001 Enable Counter CxTR0 – Counter Trigger UP 0x0000 - (not used) CxTR1 – Counter Trigger DOWN 0x0100 Source: constant ‚1’ (62,5 MHz) CxTR2 – Counter Trigger CLEAR 0x0000 - (not used) CxTR3 – Counter Trigger RELOAD 0x0800 Source: Counter 0 overflow

Prescaler = 0 CxTR4 – Counter Trigger CAPTURE 0x0000 - (not used)

6.3.7 Counter (incl. Interrupt)

Example: Every 10 rising edges on a digital input should raise an interrupt. Solution: The rising edge of an input is used as counter trigger. If the counter value becomes greater than 10 (compare value) an interrupt is triggered and the counter value is reset to 0.

NOTE The calling order of the function blocks is important here! First parameterize the counter values and second write the configuration registers.

The calling order is important: First set the counter values (function block DIO4_WRITE_CNT)

Page 42: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

6 Use Cases of the Application

42 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

Second the configuration registers have to be written (incl. “Counter enable”) (function block DIO4_CONFIG)

Table 6-8 Call parameters for function block DIO4_WRITE_CNT

Register Wert Bemerkung

Reload Value 0x00000000 Compare Value 0x00000009 = 9 decimal

Table 6-9 Call parameters for function block DIO4_CONFIG

Register Wert Bemerkung

GCR – Global Control Register 0x0013 Global enable Global Interrupt enable Counter interrupt enable

INPxC – Input Config. 0x0000 OUTPxC – Output Config. LOW HIGH

0x0000 0x0000

CxCR – Counter Control 0x0043 Enable Counter Enable Counter Interrupt Enable Greater Interrupt

CxTR0 – Counter Trigger UP 0x2808 Rising Edge Source: Input 0

CxTR1 – Counter Trigger DOWN 0x0000 - (not used) CxTR2 – Counter Trigger CLEAR 0x0A08 Rising Edge

Source: Counter 0 Compare Greater

CxTR3 – Counter Trigger RELOAD 0x0000 - (not used) CxTR4 – Counter Trigger CAPTURE 0x0000 - (not used)

NOTE It is recommended to use an input filter (see chapter 6.3.3 page 37).

6.3.8 Timer (incl. Interrupt)

Example: Every 5 seconds an interrupt should be triggered in the WinAC. Solution: A counter decreases with the internal frequency of 62.5 MHz. The passing 0 (overflow) is used as interrupt source and as trigger for reloading the counter initial value.. ReloadValue = Time * (freq / prescaler)

Page 43: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

6 Use Cases of the Application

WinAC DIO4 driver V 1.11, Entry ID: 63204530 43

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

= 5 sec * ( 62.5 MHz / 1 ) = 312.500.000 = 12A0.5F20 hex

NOTE The calling order of the function blocks is important here! First parameterize the counter values and second write the configuration registers.

The calling order is important: First set the counter values (function block DIO4_WRITE_CNT) Second the configuration registers have to be written (incl. “Counter enable”)

(function block DIO4_CONFIG) Table 6-10 Call parameters for function block DIO4_WRITE_CNT

Register Wert Bemerkung

Reload Value 0x12A05F20 = 5 sec. (bei prescaler = 0) Compare Value 0x00000000

Table 6-11 Call parameters for function block DIO4_CONFIG

Register Wert Bemerkung

GCR – Global Control Register 0x0013 Global enable Global Interrupt enable Counter interrupt enable

INPxC – Input Config. 0x0000 OUTPxC – Output Config. LOW HIGH

0x0000 0x0000

CxCR – Counter Control 0x0007 Enable Counter Enable Counter Interrupt Enable Overflow Interrupt

CxTR0 – Counter Trigger UP 0x0000 - (not used) CxTR1 – Counter Trigger DOWN 0x0100 source constant ‚1’ (62,5 MHz) CxTR2 – Counter Trigger CLEAR 0x0000 - (not used) CxTR3 – Counter Trigger RELOAD 0x0800 Source: Counter 0 overflow

Prescaler = 0 CxTR4 – Counter Trigger CAPTURE 0x0000 - (not used)

Page 44: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

7 Error Codes

44 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

7 Error Codes The WinAC FileServer can provide different classes of error messages: - Code in the FB-output STATUS according to WinAC-ODK (see chapter 8.1 in

this document) - Special error codes of the FileServer (see chapter 8.2 on page 46 in this

document)

7.1 Error codes of WinAC ODK

The driver had been developed with the WinAC ODK (Open Development Kit). The ODK can generate error codes, which are returned from the STATUS of the FBs. Table 7-1 WinAC ODK error messages

ODK Code (HEX)

Description

0 Success 8001 An exception occurred. 8002 Input: the ANY pointer is invalid. 8003 Input: the ANY pointer range is invalid. 8004 Output: the ANY pointer is invalid. 8005 Output: the ANY pointer range is invalid. 8006 More bytes were written into the output buffer by the extension object than

were allocated. 8007 ODK system has not been initialized: no previous call to SFB65001

(CREA_COM). 8008 The supplied handle value does not correspond to a valid extension object. 8009 More bytes were written into the input buffer by the extension object than

were allocated. 807F An internal error occurred. 80C3 Maximum number (32) of parallel jobs/instances exceeded. 8102 The call to CLSIDFromProgID failed. 8103 The call to CoInitializeEx failed. 8104 The call to CoCreateInstance failed. 8105 The library failed to load. 8106 A Windows response timeout occurred. 8107 Controller is in an invalid state for scheduling an OB. 8108 Schedule information for OB is invalid. 8109 Instance ID for SFB65001 call is invalid. 810A Controller could not load proxy DLL. 810B The WinAC controller could not create or initialize shared memory

area. 810C Attempt to access unavailable option ocurred. 8201 The Execute command index could not be found 8250 No more available positions in the job list

Page 45: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

7 Error Codes

WinAC DIO4 driver V 1.11, Entry ID: 63204530 45

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

ODK Code (HEX)

Description

8252 The count is invalid 8253 A data type of an item in the list is invalid 8254 The count specified is invalid 8255 A memory area of an item in the list is invalid 8256 A DB number of an item in the list is invalid 8257 A bit number of an item in the list is invalid 8258 A pBuff of an item in the list is invalid 8259 A data quantity is invalid 825A The area offset parameter is invalid for this type 825B The frequency value is invalid 825C The callback pointer is invalid 825D The job ID pointer is invalid 825E The job ID is invalid 825F Job could not be completed because address is incorrect 8260 Job could not be completed because of protection level 8261 Job could not be completed because of hardware issues 8301 Invalid Thread Execution Priority 8401 Invalid Asynchronous Event 8402 Asynchronous Processor Queue is empty 8403 Asynchronous Processor Queue is full

Page 46: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

7 Error Codes

46 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

7.2 Special error codes of the WinAC DIO4 driver

Among the general error bit of the driver FBs there is a special error code in the value of STATUS to describe the reason of the problem. Table 7-2 Error codes of WinAC DIO4 driver

0x0000 - no error error codes from DIO driver 0x8501 - Invalid parameter was given to function 0x8502 - The function is not supported 0x8505 - Function/device not ready 0x8506 - Device reported an error 0x8509 - Overflow occured 0x850b - Item already started/present 0x8511 - detected to many DIO4 boards on PCI bus 0x8512 - base address not defined 0x8513 - RtTranslateBusAddress failed 0x8514 - Failure on RtMapMemory 0x8515 - no MSI support signaled 0x8516 - attach interrupt failed 0x8517 - create of event failed 0x8520 - error detected (register GSR.EIF) e.g. missgin supply voltage of output or overload / short circuit

application errors 0x8550 - no successful init called before errors with WinAC Handling (ODK part) 0x9001 - error using ODK_Read.. function 0x9002 - error using ODK_Write.. function 0x9011 - error reading STRING - invalid pointer to string 0x9012 - error reading STRING - error reading string len 0x9013 - error reading STRING - string is too large for the STEP 7 string 0x9014 - error reading STRING - string is too large for the output data buffer 0x9015 - error reading STRING - error writing current string len 0x9016 - error reading STRING - error writing max. string len 0x9017 - error reading STRING - error writing string to WinAC

Page 47: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

8 Related Literature

WinAC DIO4 driver V 1.11, Entry ID: 63204530 47

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

8 Related Literature 8.1 Bibliography

This list is not complete and only represents a selection of relevant literature. Table 8-1

Subject Title

/1/ STEP7 Automation with STEP7 in STL and SCL Hans Berger Publisher: Vch Pub ISBN-10 3895783412 ISBN-13 9783895783418

/2/ WinAC Windows Automation Center RTX – WinAC RTX 2010 Operating Instructions

/3/

8.2 Internet Link Specifications

This list is not complete and only represents a selection of relevant information. Table 8-2

Subject Title

\1\ Reference to the entry

http://support.automation.siemens.com/WW/view/en/EntryID

\2\ Siemens I IA/DT Customer Support

http://support.automation.siemens.com

\3\ WinAC Operating Instructions

http://support.automation.siemens.com/WW/view/en/43715176

\4\

Page 48: WinAC Driver for SIMATIC PCIe DIO4 - Siemens · If you have any questions concerning this document please e-mail us to the following address: ... Related Literature r e s e r v e

9 History

48 WinAC DIO4 driver

V 1.11, Entry ID: 63204530

Cop

yrig

ht

Sie

men

s A

G 2

012

All

right

s re

serv

ed

9 History Table 9-1 Version History

Version Date Modifications

V0.95 09.08.2011 First version for pre-relase V1.00 15.09.2011 Use case input filtering added

Additional register values in instance data blocks of READ_DI and WRITE_DO Detailed description of the interrupt processing Description of Configuration Data Description of Counter Data (read/write) Update output Dio4Scan Excel Tool for Register Configuration added List of all included files Update formulas for PWM configuration Screenshots Windows 7 added

V1.10 15.06.2012 example project for TIA Portal added update documentation

V1.11 11.12.2012 Smaller corrections


Recommended