Cover. WinAC IP Driver V2. User documentation. V1.8 September Applikationen & Tools. Answers for industry

Cover WinAC IP Driver V2 User documentation V1.8  September 2010 Applikationen & Tools Answers for industry. Industry Automation and Drives Techn...
22 downloads 0 Views 253KB Size
Cover

WinAC IP Driver V2 User documentation V1.8  September 2010

Applikationen & Tools Answers for industry.

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/48354110

If you have any questions concerning this document please e-mail us to the following address:

Copyright  Siemens AG 2010 All rights reserved

[email protected]

2

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

s

Copyright  Siemens AG 2010 All rights reserved

SIMATIC WinAC IP Driver V2

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

Basic information

1

Overview

2

Installation

3

The user interface

4

Example projects

5

Parameterization of connections

6

Tipps for solving problems

7

Error codes

8

History

9

3

Warranty and Liability

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.

Copyright  Siemens AG 2010 All rights reserved

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.

4

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

Table of Contents

Table of Contents Warranty and Liability ................................................................................................. 4 Foreword....................................................................................................................... 6 1

Basic information .............................................................................................. 7 1.1 1.2

2

Overview ............................................................................................................. 8 2.1

3

Copyright  Siemens AG 2010 All rights reserved

Scope of Functions............................................................................... 8

Installation.......................................................................................................... 9 3.1 3.2 3.2.1 3.2.2

4

Objective .............................................................................................. 7 Reference System................................................................................ 7

Quickstart ............................................................................................. 9 Settings in the Operating System......................................................... 9 Adjustment for Cable Break Recognition ............................................. 9 Keepalive............................................................................................ 10

The User Interface ........................................................................................... 11 4.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.4 4.5 4.5.1 4.5.2 4.6 4.7

Initialisation FB 621 - TINIT_WINAC.................................................. 12 Establish connection with FB651 - TCON_WINAC............................ 13 The TCON_WINAC parameter „ID“ ................................................... 13 TCP/IP native - TCON_WINAC parameter „Port number“................. 14 ISO on TCP – port number 102 ......................................................... 14 Disconnect with FB661 - TDISCON_WINAC ..................................... 15 Send data with FB631 - TSEND_WINAC .......................................... 15 Receive data with FB641 - TRCV_WINAC ........................................ 15 The TRCV_WINAC parameter LEN................................................... 16 Data consistency / accuracy when receiving ..................................... 17 Send data with FB671 - TUSEND_WINAC........................................ 17 Receive data with FB681 - TURCV_WINAC ..................................... 18

5

Example project ............................................................................................... 19

6

Parameterization of connections ................................................................... 21 6.1 6.2 6.2.1 6.2.2 6.2.3 6.2.4

Parameterization with Open Communication Wizard ........................ 21 Examples for parameterization .......................................................... 22 WinAC with two TCP/IP Client for two separate servers ................... 22 WinAC with two TCP/IP clients for one server PC............................. 23 WinAC as TCP/IP server with two clients .......................................... 25 WinAC with UDP communication....................................................... 26

7

Tipps for solving problems ............................................................................ 27

8

Error codes....................................................................................................... 29 8.1 8.1.1 8.1.2 8.2

9

Error codes of WinAC ODK 4.1.......................................................... 29 Error Codes for SFB65001 CREA_COM ........................................... 29 Error Codes for SFB65002 EXEC_COM ........................................... 30 Additional error information ................................................................ 30

History............................................................................................................... 35

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

5

0 Foreword

Foreword Objective of the application

Copyright  Siemens AG 2010 All rights reserved

This document describes the WinAC IP Driver V2 software for the user.

6

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

1 Basic information

1

Basic information

1.1

Objective WinAC RTX 2005 does not support native TCP/IP communication or ISO on TCP. The new WinAC IP Driver V2 provides native TCP/IP communication as well as ISO on TCP communication of WinAC to other communication partners. The used interface is FBs 63-66 (TSEND, TRCV, TCON, TDISCON) which we are familiar from S7 applications (CPU 317-2 PN/DP, CPU 400). Difference ist only FB Number and Name ((TSEND_WINAC, TRCV_WINAC, TCON_WINAC, TDISCON_WINAC). The connection types 11h - TCP/IP native, 12h – ISO on TCP and 13h – UDP are supported.

1.2

Reference System

Copyright  Siemens AG 2010 All rights reserved

The described application in this user documentation is based on the following reference system: 

Microbox PC427B (1 GHz, 512 MB RAM, 1 GB Flash) with XP embedded SP2



WinAC RTX 2008 (V4.5)



Simatic Manager V5.4, SP5

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

7

2 Overview

2

Overview

2.1

Scope of Functions WinAC IP V2 provides TCP/IP communication functionality as the active part (client) as well as the passive part (server). Both variants may also be utilised together. Figure 2-1 Communication possibilities with WinAC IP V2

WinAC

Client ID 1

Server 1 Server 2

Copyright  Siemens AG 2010 All rights reserved

Client 1

Client ID 2 ID 3

Client

ID 4

Server

ID 5

Server

Client 2

Uebersicht01.vsd

One unique ID must be allocated to each connection. 32 connections are supported in the current version of the WinAC-IP-driver which contain IDs 1..32. Irrespective whether the connection has been arranged as client or server (active / passive connection), sending as well as receiving are possible via the connection (ID) once the connection is established. The connection type UDP is optimized for speed. In contrast to the TCP/IP based types for UDP all commands are executed synchronously. E.g. when calling TUSEND the data is given to the Windows socket directly.

8

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

3 Installation

3

Installation

3.1

Quickstart

Copyright  Siemens AG 2010 All rights reserved

Carry out the following steps to start up WinAC IP V2. 

copy the DLL WinLC_IP_TCOM.DLL into the system32 directory (setup.bat)



make possible adjustment for cable break recognition and keepalive (see 3.2)



copy components from the demo project into the user project: - FBs 621-681 including their instance DBs DB621-681 - UDT 65 and DB2 (derived from UDT 65) - SFBs 65001 and 65002



configure connections in DB2 (derived from UDT 65) (When using Open Communication Wizard, see chapter 6.1 on page 21 the DB2 has to be updated according the generated UDT)



call FB621 TINIT_WINAC with the right local IP address



call FB651 TCON_WINAC with configuration



once connection is established send / receive data with FB631 / FB641 (TCP/IP based) or FB67 / FB68 (UDP)

 NOTE

3.2

WinAC-IP-V2 DLL requires DLL msvcrt.dll. It is included in the standard image of the Simatic Microbox PC427B. When using a different PC configuration it may need installing.

Settings in the Operating System Some settings of the operating system (Windows XP) regarding the Ethernet communication have importance for the WinAC IP driver.

3.2.1

Adjustment for Cable Break Recognition When using a wired ethernet connection (e.g. RJ45), Windows recognises when the connection has been interrupted (cable break or pulled the plug).

Note

This cable break recognition works only for the local RJ45 plug. If the cable is broken behind a switch, it will not be recognized by this functionality.

This information, however, is not automatically forwarded to the Windows socket and thus to the WinAC IP driver. Adjustment in Registry This functionality is controlled via an entry in the registry: Under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters you find parameter DisableDHCPMediaSense.

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

9

3 Installation

When this parameter exists and when it is set to 1, the information on a seperate TCP/IP connection is not forwarded to the Windows socket and thus not to the WinAC IP driver either. The exact functionality of this registry entry is described in the Microsoft Knowledge Base ID D239924. Meaning of the parameter under Simatic NET This value is deliberately set to 1 by Simatic NET: When DHCP is used for the allocation of IP addresses, plugging in / unplugging of the cable could result in obtaining a new IP address. As a consequence, however, the configuration of a Simatic project would no longer be correct. For this reason this function has been deactivated by Simatic NET via this flag (this has the following side effect: TCP/IP applications are no longer notified of a cable break.) If static IP addresses are used in an application or if fixed IP addresses are allocated to specific MAC addresses in the DHCP server there should be no problem when setting this registry entry to 0.

3.2.2

Keepalive

Copyright  Siemens AG 2010 All rights reserved

The operating system can automatically check an Ethernet connection with keepalive telegrams. In that way a failure will be recognized along the communication path (also behind switches). For this functionality there are two important entries in the registry: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\ Parameters  DWORD – “KeepAliveTime” - wait before sending keep alive packets (default: 2 hours - 7,200,000 milliseconds) in [milliseconds]  DWORD – “KeepAliveInterval” - time between retransmissions of keepalives, once the KeepAliveTime has expired (default: 1 second - 1000 milliseconds) in [milliseconds] If you set the first parameter to 10000 (decimal) the system will check the connection after 10 seconds without communication.

10

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

4 The User Interface

4

The User Interface When WinAC IP V2 was developed, importance was attached to almost exact recreation of the known FBs 63-68 (TSEND, TRCV, TCON, TDISCON, TUSEND, TURCV). Parameterisation of the connections is carried out with structures of type UDT 65 TCON_PAR and UDT 66 TADDR_PAR defined.

Attention

When using the WinAC IP driver you may not use the FB63 – FB68 from the Standard Library! You must use the same-named FBs from the provided demonstration project!

In addition to these FBs there is a further FB 621 TINIT_WINAC.

Copyright  Siemens AG 2010 All rights reserved

For the documentation of the FBs 63-68 as well as UDT 65, 66 of WinAC IP V2 please refer to the Simatic manager. Over and above the interfaces of the FBs important information can be found in the instance DBs. There is the constraint that at the moment: WinAC IP V2 supports connection types 11h - TCP/IP native, 12h – ISO on TCP and 13h – UDP. An additional recommended documentation is the manual “System and Standard Functions for S7-300/400”, chapter “Open Communication via Industrial Ethernet”. Link: http://support.automation.siemens.com/WW/view/en/1214574. In distinction to the T-function blocks from the standard library the instance data blocks of the function blocks from the WinAC IP driver contain some additional information.

Attention

Note

The FBs of WinAC IP V2 require their own instance DBs. These FBs are not multi-instance capable!

The numbers of the FBs/DBs 621-681 may be changed freely by the user. Please ensure that the correct numbers of the instance DBs are transferred to FB TINIT_WINAC.

The T-function blocks have a REQ or EN_R input. If this input is not set to “true” the output values are reseted. You have to latch possible returned error codes, like done in the example project.

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

11

4 The User Interface

4.1 Attention

Initialisation FB 621 - TINIT_WINAC In the current version of the driver the number of TINIT_WINAC has to be changed from 62 to 621 to prevent a collision with the UDT FBs.

This FB initialises the ODK-DLL. It must be called once (e.g. in OB100). The remaining FBs of the WinAC-IP driver can only be used after calling TINIT_WINAC. Because the connection is realized independent from the IE General, TINIT is used to define the local IP address (Ethernet port) for the communication. Interface Table 4-1 Parameter of FB TINIT

Copyright  Siemens AG 2010 All rights reserved

Parameter

In/Out

Type

Description

IP_ADDR

In

DWord

Local IP address of the Ethernet port to be used by the driver *1)

DB_TSEND

In

Block_DB

instance DB of TSEND

DB_TRCV

In

Block_DB

instance DB of TRCV

DB_TCON

In

Block_DB

instance DB of TCON

DB_TDISCON

In

Block_DB

instance DB of TDISCON

DB_TUSEND

In

Block_DB

instance DB of TUSEND

DB_TURCV

In

Block_DB

instance DB of TURCV

ERROR

Out

Bool

Error occured

STATUS

Out

Word

State of the call (analyse if bit ERROR is set)

*1)

If the IP driver is used on a PC with more than one Ethernet port, the driver has to know wich ethernet port is to used. The local IP address to use is defined with the parameter IP_ADDR. The IP address is given as DWORD: 149.246.247.49  DW#16#95F6F731

Note

12

If the PC only has one ethernet port, the parameter IP_ADDR can have the value 0 (Null).

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

4 The User Interface

Return value Beside the single return value STATUS of the interface of FB TINIT_WINAC, there are more information stored in the instance DB of the FB. E.g you can see the DLL version of the driver ( "IDB_TINIT".C_IF.DLL_VERSION ). The last digit of this value marks the version Debug (D) or Release (A). Table 4-2 Examples for driver DLL versions "IDB_TINIT".C_IF.DLL_VERSION

4.2

DLL-Version

DW#16#0001991D

V 1.9.9.1 Debug

DW#16#0002010A

V 2.0.1.0 Release

Establish connection with FB651 - TCON_WINAC

Copyright  Siemens AG 2010 All rights reserved

This FB is well documented in the Simatic Manager help (standard library  communication blocks) and in the manual “System and Standard Functions for S7300/400”, chapter “Open Communication via Industrial Ethernet”. Additional the instance DB of TCON_WINAC includes further information in case of an error ( "IDB TCON".C_IF.STATUS_IP_ZINFO ). The values are explained in chapter 8.2 „Additional error information “.

Note

4.2.1

The function block TCON_WINAC has to be called for every connection with bit REQ = TRUE until the connection is established (DONE without error). First after this the call of the other function blocks TSEND_WINAC / TRCV_WINAC / TDISCON_WINAC makes sense.

The TCON_WINAC parameter „ID“ The TCON_WINAC from the standard library allows values for ID from 1H up to 999H. The TCON_WINAC of WinAC IP driver only allows the values 1D – 32D. The reason is the specific implementation.

Attention

Differing to the documentation of TCON_WINAC of the standard library fort he WinAC IP driver only values 1D up to 32D are valid for the parameter “ID”.

This parameter of the FB TCON_WINAC must match the ID of the connection parameterization (UDT65).

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

13

4 The User Interface

4.2.2

TCP/IP native - TCON_WINAC parameter „Port number“ When using TCP/IP native, a portnumber must be defined as part of UDT65 TCON_PAR for 

local_tsap_id – local portnumber



rem_tsap_id – remote portnumber

The concrete parametrisation depends on the projected connection: is it a client (active) or server (passive) connection. For servers you must define the port number! Normally the port number of client is not defined by user. The operating system assigns a free port number to the client side automatically. Sometimes it can be useful to define a port number fort he client side too. E.g. it simplifies the client identification on the server side.

The TCP/IP specification defines: a specific combinatino of port and IP address must stay in state „TIME_WAIT“ for 2xMSL (about 4 min).

Copyright  Siemens AG 2010 All rights reserved

Note

That means when using a fixed port on client side it can take about 4 minutes till the connection can re-established after a connection lost.

4.2.3

ISO on TCP – port number 102 If the WinAC works as ISO on TCP server (passive connection) there could be disturbance of the communication to the engineering system (PG).

Note

If choosing connection type “ISO on TCP” the TCP/IP port number is fixed. The server opens the port 102 and waits for client connect. Unfortunately the engineering software (Simatic Manager) uses this port 102 too (e.g. variable control/observe). That’s why already runs a server on port 102 on the AG (established by the IE General in the Component Configurator). If the WinAC should work as ISO on TCP server, this server process collides with the server process of the IE General using the same port 102. That’s why the WinAC should always work as ISO-on-TCP client (active connection. If the WinAC must be the ISO-on-TCP server (passive connection), there are some solutions for this issue:

14



Using two different Ethernet ports for the ISO on TCP communication of the WinAC and the connection of the engineering system (PG)



Set WinAC to STOP before the engineering system (PG) established a connection to the IE General. After activating e.g. “variable observe/control” the WinAC can be set to RUN.

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

4 The User Interface

4.3

Disconnect with FB661 - TDISCON_WINAC This FB is well documented in the Simatic Manager help (standard library  communication blocks) and in the manual “System and Standard Functions for S7300/400”, chapter “Open Communication via Industrial Ethernet”. Additional the instance DB of TCON includes further information in case of an error ( "IDB TCON".C_IF.STATUS_IP_ZINFO ). The values are explained in chapter 8.2 „Additional error information “.

Note

4.4

Copyright  Siemens AG 2010 All rights reserved

Attention

The function block begins working with the rising edge of REQ. The REQ bit has to stay at 1 until DONE and/or ERROR are set.

Send data with FB631 - TSEND_WINAC TSEND_WINAC may not be used for UDP connections!

This FB is well documented in the Simatic Manager help (standard library  communication blocks) and in the manual “System and Standard Functions for S7300/400”, chapter “Open Communication via Industrial Ethernet”. Additional the instance DB of TCON_WINAC includes further information in case of an error ( "IDB TCON".C_IF.STATUS_IP_ZINFO ). The values are explained in chapter 8.2 „Additional error information “.

Note

4.5 Attention

The function block begins working with the rising edge of REQ. The REQ bit has to stay at 1 until DONE and/or ERROR are set.

Receive data with FB641 - TRCV_WINAC TRCV_WINAC may not be used for UDP connections!

This FB is well documented in the Simatic Manager help (standard library  communication blocks) and in the manual “System and Standard Functions for S7300/400”, chapter “Open Communication via Industrial Ethernet”. Additional the instance DB of TCON_WINAC includes further information in case of an error ( "IDB TCON".C_IF.STATUS_IP_ZINFO ). The values are explained in chapter 8.2 „Additional error information “. Additional the function block TRCV_WINAC can be used to determine the actual connection state. When using the T-function blocks, you have to update the connection state manually by calling TRCV_WINAC or TSEND_WINAC. In the shipped example project the function block TRCV_WINAC is used to update the internal status bit “CONNECTED”.

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

15

4 The User Interface

4.5.1

The TRCV_WINAC parameter LEN

Connection type ‘ISO on TCP’

Note

For ISO on TCP this parameter should be 0! The ISO on TCP protocol guarantees the receiving of complete telegrams. So every NDR - “new data received” signals a new complete telegram.

When using ISO on TCP and LEN not equal 0 and the received telegram is longer than LEN, an error is returned. Connection type ‘TCP/IP native’ With this parameter you can control if the driver delivers received data immediately or if the data is buffered until the desired length of bytes is received.

Copyright  Siemens AG 2010 All rights reserved

Is the parameter LEN set to 0, the Step7 program is informed about every received (part)package. E.g. if a telegram of 400 bytes is devided into 4 partial packets by the socket, every packet is separately signaled to the S7 program. Figure 4-1 TRCV with LEN = 0

Is the parameter LEN set to a specific value, the S7 program is informed after complete receiving of the telegram. Figure 4-2 TRCV with specific value for LEN

If the received telegram is longer than LEN you will get as many data with TRCV as the value of LEN is specified. No error code is returned.

16

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

4 The User Interface

4.5.2

Data consistency / accuracy when receiving The specification for the Step7 function blocks defines the maximum telegram length (e.g. 8192 Byte for TCP/IP native). This buffer size is used for receiving data by the socket. Received data is stored internal because the TCP/IP driver works asynchronous to the WinAC. If TRCV does not pick up the data from the driver fast enough, an internal buffer of received data is build up. This buffer must processed, e.g. even if the communication partner does not send any new data, TRCV will signal new data received until the internal buffer is processed.

Note

Copyright  Siemens AG 2010 All rights reserved

4.6

Pay attention to call TRCV fast enough to avoid the build up of an internal data buffer with unmeant behavior like signal delay.

Send data with FB671 - TUSEND_WINAC The connection type UDP is optimized for speed. In contrast to the TCP/IP based types for UDP all commands are executed synchronously. E.g. when calling TUSEND_WINAC the data is given to the Windows socket directly. On a test system (Microbox PC427B, 1 GHz) a execution time of TUSEND_WINAC of 70..120µs was determined.

Attention

TUSEND_WINAC may only be used for UDP connections!

This FB is well documented in the Simatic Manager help (standard library  communication blocks) and in the manual “System and Standard Functions for S7300/400”, chapter “Open Communication via Industrial Ethernet”. Additional the instance DB of TCON_WINAC includes further information in case of an error ( "IDB TCON".C_IF.STATUS_IP_ZINFO ). The values are explained in chapter 8.2 „Additional error information “.

Note

The function block begins working with the rising edge of REQ. The REQ bit has to stay at 1 until DONE and/or ERROR are set.

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

17

4 The User Interface

4.7 Attention

Receive data with FB681 - TURCV_WINAC TRCV_WINAC may only be used for UDP connections!

This FB is well documented in the Simatic Manager help (standard library  communication blocks) and in the manual “System and Standard Functions for S7300/400”, chapter “Open Communication via Industrial Ethernet”. Additional the instance DB of TCON_WINAC includes further information in case of an error ( "IDB TCON".C_IF.STATUS_IP_ZINFO ). The values are explained in chapter 8.2 „Additional error information “. If data was received (NDR) the output ADDR contains the sender address. After the next call of TURCV_WINAC this data will be overwritten. Thus you have to process the sender address information just after the NDR flag was set.

Copyright  Siemens AG 2010 All rights reserved

Additional the function block TURCV_WINAC can be used to determine the actual connection state. When using the T-function blocks, you have to update the connection state manually by calling TRCV_WINAC or TSEND_WINAC. In the shipped example project the function block TRCV_WINAC is used to update the internal status bit “CONNECTED”. An important feature of UDP is: telegrams are not segmented. I.e. a sent telegram is always received in one piece. That’s why the parameter LEN should be always big enough or even set to 0. If the received telegram is longer than LEN, an error code is returned.

Note

Pay attention to call TURCV_WINAC fast enough to avoid the build up of an internal data buffer with unmeant behavior like signal delay.

When using complex network structures (e.g. some routers) it is not guaranteed that the order of the received telegrams is the same as the order of the sent telegrams.

18

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

5 Example project

5

Example project An example project is provided to show how to use the T-blocks.

For own projects you have to use the T-blocks from the example project and not from the standard library!

Attention

For the two connection types 

TCP/IP based (TCP/IP native and ISO-on-TCP)



UDP

there are two function blocks which realize the communication by using the Tblocks.

Copyright  Siemens AG 2010 All rights reserved

If more connections are needed, you have to call this FBs with different instance data blocks. For every connection you have to create a separate instance DB. You find the call of this FBs in the OB1. For the example all connections were parameterized by the Open Communicaiton Wizard (UDT651-656, UDT663). These UDTs are instantiated in the DB1 / DB2. If you generate / change these UDTs it is not enough to update the DB1 / DB2. You have to initialize these DBs again. By using a “Reset”-Bit (set in OB100) the instance DBs are initialized internally. Of course this project is designed as example. The used flags and data blocks may be used in a concrete customer project. Then they have to be changed. Table 5-1 Objects of the example project Object

DLL-Version

OB1 CYCL_EXC

Process the cycle flag Calling connection FBs At the end: reset the “Reset” flag

OB100 COMPLETE RESTART

Calling TINIT_WINAC Copy connection parameters from the central parameter DBs DB1/DB2 to the separate instance DBs

FB1 CON_TCP

Realized a TCP/IP based connection (TCP/IP native or ISOon-TCP) incl. establishing connection, sending and receiving

FB2 CON_UDP

Realized an UDP based connection incl. establishing connection, sending and receiving

FB62 – FB68

T-blocks for open communication Not from standard library!

DB1 CON_DEF

Contains parameter for connections. Consists of some UDTs of type UDT65 TCON_PAR generated by the Open Communication Wizard.

DB2 ADDR_DEF

Contains parameter for remote partners of UDP. Consists of some UDTs of type UDT66 TADDR_PAR generated by the Open Communication Wizard.

DB62 – DB68

Instance DBs of the T-blocks

DB101 – DB106

Instance DBs for FB1 / FB2. For every connection a single one.

UDT651 – UDT656

Connection parameters generated by the Open

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

19

5 Example project

Object

DLL-Version Communication Wizard Parameters of remote partners for UDP, generated by Open Communication Wizard

Copyright  Siemens AG 2010 All rights reserved

UDT663

20

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

6 Parameterization of connections

6

Parameterization of connections

6.1

Parameterization with Open Communication Wizard On the support pages of the Siemens AG there is a tool for the comfortable parameterization of connections with T-function blocks: the Open Communication Wizard. http://support.automation.siemens.com/WW/view/en/25209116 This tool is recommended for parameterization of the WinAC IP V2 driver. Dialog-based you have to parameterize the connection. According to this an UDT (type UDT65 - TCON_PAR) for the connection parameters is generated. When using communication type UDP an additional UDT (type UDT66 – TADDR_PAR) for the remote communication partner is generated. This UDT have to be instantiated in your project. A manually editing of the communication parameters should be not necessary. You have to consider some things when using the Open Communication Wizard.

Copyright  Siemens AG 2010 All rights reserved

Parameter “Used interface” In step “connection partner” the parameter “used interface” has to be selected. This parameter is not considered by the WinAC IP driver. Thus you can choose e.g. the entry “CP 443-1 Advanced” or “Integrated (315/317, Firmware V2.5 and newer)”. With other interfaces you may got false connection parameterization (e.g. false connection type). Parameter “TSAP-ID” for ISO-on-TCP The ISO-on-TCP specification defines for open TCP/IP function blocks the beginning of the TSAP-ID with E0h. The second byte is used for the rack number. Thus the Open Communication wizard inserts the two characters E0h 02h in the beginning of the TSAP-ID automatically when using e.g. rack number 2. The TSAP-IDs must match exactly in the projecting of both communication partners. You have to add E0h 02h in the projection of the communication partner or you have to change the TSAP-ID after finishing the Open Communication Wizard in the UDT manually. Result is an UDT The result of the Open Communication Wizard is one or more UDTs (user defined type). Therefore you have to DB or a variable inside a DB of this generated user defined type. If you had updated an existing UDT you have to “check block consistency” for the entire project to update the new information of the UDT in all the relevant data blocks. It is recommended to let the Open Communication Wizard store the resulting UDT in the block folder of the WinAC project. Comments in the UDT The Open Communication Wizard generates UDTs of type 65 or 66 (see standard library / communication blocks). In opposite to the UDTs of the Standard Library the elements of the generated UDTs does not have comments.

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

21

6 Parameterization of connections

.net 2.0 framework The Open Communication Wizards needs the Microsoft .NET Framework Version 2.0 installed on the PC. If not installed yet, you can download the Redistributable Package from the Microsoft web page.

6.2

Examples for parameterization A detailed documentation about the configuration of the open communication with the T-blocks can be found in the manual “System Software for S7-300/400 System and Standard Functions” in chapter 23 „Open Communication via Industrial Ethernet“. Link: http://support.automation.siemens.com/WW/view/en/1214574

6.2.1

WinAC with two TCP/IP Client for two separate servers In this example the WinAC PC only uses one Ethernet port. That’s why there is no need to define the local IP address for the connections.

Copyright  Siemens AG 2010 All rights reserved

Because of connection with two different servers there is no need for a specific port number on the client side. The operating system assigns the port numbers automatically to the client connections. Figure 6-1 WinAC with two clients for two separate servers

The following table shows the adequate parameterisation. Table 6-1 Parameterisation WinAC with two clients for two separate servers Adr.

Name

Typ

Wert

Komm. // Connection ID 1

2.0

id

WORD

W#16#1

Reference to this connection

4.0

connection_type

BYTE

B#16#11

TCP/IP native

5.0

active_est

BOOL

TRUE

TRUE - active connection

local_tsap_id

BYTE

B#16#0

local port no.

BYTE

B#16#0

BYTE

B#16#95

... 12.0 13.0 ... 34.0

22

rem_staddr

IP Adr. remote point

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

6 Parameterization of connections

Adr.

Name

Typ

Wert

35.0

BYTE

B#16#F6

36.0

BYTE

B#16#F7

37.0

BYTE

B#16#31

BYTE

B#16#13

BYTE

B#16#88

Komm.

... 40.0

rem_tsap_id

41.0

remote port

... // Connection ID 2 WORD

W#16#2

connection_type

BYTE

B#16#11

TCP/IP native

active_est

BOOL

TRUE

TRUE - active connection

local_tsap_id

BYTE

B#16#0

local port no.

BYTE

B#16#0

BYTE

B#16#95

66.0

id

68.0 69.0

Reference to this connection

... 76.0 77.0 ... Copyright  Siemens AG 2010 All rights reserved

98.0

rem_staddr

99.0

BYTE

B#16#F6

100.0

BYTE

B#16#F7

101.0

BYTE

B#16#32

BYTE

B#16#13

BYTE

B#16#88

IP Adr. remote point

... 104.0 105.0

6.2.2

rem_tsap_id

remote port

WinAC with two TCP/IP clients for one server PC In this example the WinAC PC only uses one Ethernet port. That’s why there is no need to define the local IP address for the connections. If the server wants to identify every single connection, it is useful to define a specific port number on the client side. So the identification is possible via the client port number without any specific identification telegram. Figure 6-2 WinAC with two clients for one server PC

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

23

6 Parameterization of connections

The following table shows the adequate parameterisation. Table 6-2 Parameterisation WinAC with two clients for one server PC Adr.

Name

Typ

Wert

Komm. // Connection ID 1

2.0

id

WORD

W#16#1

Reference to this connection

4.0

connection_type

BYTE

B#16#11

TCP/IP native

5.0

active_est

BOOL

TRUE

TRUE - active connection

local_tsap_id

BYTE

B#16#17

local port no.

BYTE

B#16#70

BYTE

B#16#95

35.0

BYTE

B#16#F6

36.0

BYTE

B#16#F7

37.0

BYTE

B#16#31

BYTE

B#16#13

BYTE

B#16#88

... 12.0 13.0 ... 34.0

rem_staddr

IP Adr. remote point

... Copyright  Siemens AG 2010 All rights reserved

40.0

rem_tsap_id

41.0

remote port

... // Connection ID 2 66.0

id

WORD

W#16#2

Reference to this connection

68.0

connection_type

BYTE

B#16#11

TCP/IP native

69.0

active_est

BOOL

TRUE

TRUE - active connection

local_tsap_id

BYTE

B#16#17

local port no.

BYTE

B#16#71

... 76.0 77.0 ... BYTE

B#16#95

99.0

BYTE

B#16#F6

100.0

BYTE

B#16#F7

101.0

BYTE

B#16#31

BYTE

B#16#13

BYTE

B#16#88

98.0

rem_staddr

IP Adr. remote point

... 104.0 105.0

24

rem_tsap_id

remote port

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

6 Parameterization of connections

6.2.3

WinAC as TCP/IP server with two clients In this example the WinAC PC only uses one Ethernet port. That’s why there is no need to define the local IP address for the connections. For the server on WinAC side you must define the local port number. The clients connect to the IP and port of the server PC. If both clients run on different PCs there is no need to define the remote ports. The IP address of the clients is enough information to identify the connection.

Copyright  Siemens AG 2010 All rights reserved

Figure 6-3 WinAC as server with two clients

The following table shows the adequate parameterisation. Table 6-3 Parameterisation WinAC as server with two clients Adr.

Name

Typ

Wert

Komm. // Connection ID 1

2.0

id

WORD

W#16#1

Reference to this connection

4.0

connection_type

BYTE

B#16#11

TCP/IP native

5.0

active_est

BOOL

FALSE

FALSE - passive connection

local_tsap_id

BYTE

B#16#17

local port no.

BYTE

B#16#70

BYTE

B#16#95

35.0

BYTE

B#16#F6

36.0

BYTE

B#16#F7

37.0

BYTE

B#16#31

BYTE

B#16#0

BYTE

B#16#0

... 12.0 13.0 ... 34.0

rem_staddr

IP Adr. remote point

... 40.0

rem_tsap_id

41.0

remote port

... // Connection ID 2 66.0

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

id

WORD

W#16#2

Reference to this connection

25

6 Parameterization of connections

Adr.

Name

Typ

Wert

Komm.

68.0

connection_type

BYTE

B#16#11

TCP/IP native

69.0

active_est

BOOL

FALSE

FALSE - passive connection

local_tsap_id

BYTE

B#16#17

local port no.

BYTE

B#16#70

... 76.0 77.0 ... BYTE

B#16#95

99.0

BYTE

B#16#F6

100.0

BYTE

B#16#F7

101.0

BYTE

B#16#32

BYTE

B#16#0

BYTE

B#16#0

98.0

rem_staddr

IP Adr. remote point

... 104.0

rem_tsap_id

105.0

6.2.4

remote port

WinAC with UDP communication

Copyright  Siemens AG 2010 All rights reserved

Also for UDP communication the communication channel has to be established by calling TCON. But for UDP in the UDT65 only two parameters are relevant: 

ID



Local port (local_tsap_id)

All other parameters are not relevant. The communication partner is defined by calling TUSEND_WINAC or identified by calling TURCV. It is provided by a structure of type UDT66 TADD_PAR. In comparison to the TCP/IP based communication types for UDP you have to use the special FBs TUSEND_WINAC and TURCV_WINAC respectively.

26

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

7 Tipps for solving problems

7

Tipps for solving problems If the connection is not established you can check various reasons.

Does ping work? Check if you can ping you communication partner. Is a firewall active? Is on the local PC or the remote partner or along the communication way a firewall active? Does block this firewall the communication with the chosen port? Windows XP SP2 does have a active firewall blocking all communication by default. Is the connection established with the desired parameters? If the connection with the communication partner is not established, the reason could be the usage of false parameters. With the netstat command it is easy to check the used connection parameters.

Copyright  Siemens AG 2010 All rights reserved

Example: WinAC should open an UDP channel on the local IP 192.168.1.27 on port 2000. netstat -p UDP -a -n –b ... UDP

192.168.1.27:2000 *:*

[s7wlcrtx.exe] ... The output of netstat shows: The WinAC (s7wlcrtx.exe) has opened a UDP channel on IP 192.168.1.27 on port 2000. Using ‘localhost’ as local IP? When using localhost (127.0.0.1) as local IP, the communication partner will not accept this address. Does help the additional info of the instance DB of TCON_WINAC? Pleas check the value of "IDB TCON".C_IF.STATUS_IP_ZINFO. The values are explained in chapter 8.2 „Additional error information “. Swap client and server Try to swap client and server. If the WinAC should be server, try to use WinAC as client and the partner as Server. Perhaps you will get error information now, which will help to solve the problem. Example (1) TSAP not well configured WinAC is server  TCON stays in state 0x7002 WinAC is client  internal error code 0x507 Example (2) remote IP address not well configured WinAC is server  TCON stays in state 0x7002 WinAC is client  error code 0x80A7 (0x408)

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

27

7 Tipps for solving problems

Unknown telegrams on Port 102 traced with Wireshark when using ISO on TCP When tracing the communication e.g. with Wireshark you can get additional telegrams on port 102. The reason is: e.g. the Simatic Manager uses this port for “Variables online” too. Projecting communication partner with NetPro If the communication partner is e.g. a CP 343-1 you can projection this connection side with NetPro. You may not choose the WinAC as connection partner but the entry “unspecified”. You have to pay attention to the exactly matching TSAP-ID in the projecting with NetPro and the projection with the Open Communcation Wizard, especially the leading charcters E0h 02h – see also chapter 6.1 on page 21. Bit “CONNECTED” remains active after stop of communication partner

Copyright  Siemens AG 2010 All rights reserved

In the provided example program there is a status bit “CONNECTED”. This bit is updated after calling the four function blocks TCON_WINAC, TDISCON_WINAC, TSEND_WINAC or TRCV_WINAC. If the communication partner changes to STOP, this bit is only updated after calling TSEND_WINAC or TRCV_WINAC. A automatically update of this bit is not possible.

28

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

8 Error codes

8

Error codes The TCP/IP driver can return three different classes of error codes:

8.1



Error codes of the function blocks at the FB output STATUS corresponding to the documentation for the FBs in the standard library in the Simatic Manager: Standard Library  Communication Blocks



Error codes at the FB output STATUS corresponding the WinAC-ODK (see chapter 8.1 in this document)



Additional error information in the instance DB of the FBs C_IF.STATUS_IP_ZINFO (see chapter 8.2 in this document)

Error codes of WinAC ODK 4.1 The WinAC IP driver was developed with the WinAC ODK (Open Development Kit). This ODK can return some spezial error codes, which are returned in the output STATUS of the FBs. This special error codes are not part of the Simatic Manager documentation of the standard library function blocks.

Copyright  Siemens AG 2010 All rights reserved

8.1.1

Error Codes for SFB65001 CREA_COM This error codes can be returned only by FB TINIT. Table 8-1 WinAC ODK error codes for CREA_COM Error Code

Symbol

Description

0

NO_ERRORS

Success

0x807F

ERROR_INTERNAL

An internal error occurred.

0x8001

E_EXCEPTION

An exception occurred.

0x8102

E_CLSID_FAILED

0x8103

E_COINITIALIZE_FAILED

0x8104

E_CREATE_INSTANCE_FAILED

0x8105 0x8106

E_LOAD_LIBRARY_FAILED E_NT_RESPONSE_TIMEOUT

0x8107

E_INVALID_OB_STATE

0x8108

E_INVALID_OB_SCHEDULE

0x8109

E_INVALID_INSTANCEID

0x810A

E_START_ODKPROXY_FAILED

0x810B

E_CREATE_SHAREMEM_FAILED

0x810C

E_OPTION_NOT_AVAILABLE

The call to CLSIDFromProgID failed. The call to CoInitializeEx failed. The call to CoCreateInstance failed. The library failed to load. A Windows response timeout occurred. Controller is in an invalid state for scheduling an OB. Schedule information for OB is invalid. Instance ID for SFB65001 call is invalid. Controller could not load proxy DLL. The WinAC controller could not create or initialize shared memory area. Attempt to access unavailable option ocurred.

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

29

8 Error codes

8.1.2

Error Codes for SFB65002 EXEC_COM This error codes may returned by all function blocks of WinAC IP driver. Table 8-2 WinAC ODK error codes for EXEC_COM Error Code

Copyright  Siemens AG 2010 All rights reserved

0

8.2

Symbol NO_ERRORS

Description Success

0x807F

ERROR_INTERNAL

An internal error occurred.

0x8001

E_EXCEPTION

An exception occurred.

0x8002

E_NO_VALID_INPUT

Input: the ANY pointer is invalid.

0x8003

E_INPUT_RANGE_INVALID

Input: the ANY pointer range is invalid.

0x8004

E_NO_VALID_OUTPUT

Output: the ANY pointer is invalid.

0x8005

E_OUTPUT_RANGE_INVALID

Output: the ANY pointer range is invalid.

0x8006

E_OUTPUT_OVERFLOW

More bytes were written into the output buffer by the extension object than were allocated.

0x8007

E_NOT_INITIALIZED

ODK system has not been initialized: no previous call to SFB65001 (CREA_COM).

0x8008

E_HANDLE_OUT_OF_RANGE

The supplied handle value does not correspond to a valid extension object.

0x8009

E_INPUT_OVERFLOW

More bytes were written into the input buffer by the extension object than were allocated.

Additional error information Beside of the error codes described in the Simatic Manager documentation for FB 631-661 there are some further information in case of an error. This information can help to find the reason of the problem. This data is stored in the instance DB in the variable C_IF.STATUS_IP_ZINFO. Table 8-3 Codes of additional error information

0x0000 - no error current state of connection 0x0001 - a server socket is waiting for client connect 0x0002 - a worker socket is waiting for CR 0x0003 - a client socket is waiting for worker accept 0x0004 - connection established 0x0005 - error when creating server for client 0x0006 - error when creating client socket 0x00FF - undefined state of socket

30

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

8 Error codes

errors with WinAC Handling 0x0101 - error using ODK_Read.. function 0x0102 - error using ODK_Write.. function parameter errors 0x0200 - can't read local IP address 0x0201 - UDT61 false block len 0x0202 - false ID value 0x0203 - ID value 0 0x0204 - IDs don't match 0x0205 - UDT65 connection type not supported 0x0206 - UDT65 local device ID not supported 0x0207 - UDT65 active est. for UDP only false allowed 0x0208 - UDT65 local tsap id len not supported for TCP/IP 0x0209 - UDT65 local tsap id len not supported for ISO on TCP

Copyright  Siemens AG 2010 All rights reserved

0x020A - UDT65 local tsap id len not supported for UDP 0x020B - UDT65 remote subnet ID len not supported 0x020C - UDT65 remote staddr len not supported for TCP 0x020D - UDT65 remote staddr len not supported for UDP 0x020E - UDT65 remote tsap_id len not supported for TCP/IP 0x020F - UDT65 remote tsap_id len not supported for ISO on TCP 0x0210 - UDT65 remote tsap_id len not supported for UDP 0x0211 - internal error processing parameters init errors 0x0300 - error creating internal event objects 0x0301 - error retriving version of DLL 0x0302 - try to add existing comm.partner 0x0303 - number of comm-partners exceeds 0x0304 - number of local servers exceeds 0x0305 - try to add comm.partner with existing ID 0x0306 - port of local server may not be 0 0x0307 - port of remote server may not be 0 0x0308 - internal error processing initialisation (1) 0x0309 - internal error processing initialisation (2) 0x030A - internal error processing initialisation (3)

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

31

8 Error codes

socket errors 0x0400 - error WSAStartup() 0x0401 - false socket version number 0x0402 - unknown socket type (stream, dgram, ...) 0x0403 - error creating socket with socket() 0x0404 - error setting socket options 0x0405 - error get socket options 0x0406 - error bind() 0x0407 - error bind() - local address not valid in this context (check local IP/port) 0x0408 - error connect() 0x0409 - timeout error select() 0x040A - error select() 0x040B - error recv() 0x040C - error CreateThread() for receive thread 0x040D - error ResumeThread() for receive thread Copyright  Siemens AG 2010 All rights reserved

0x040E - error CreateThread() for listen thread (server) 0x040F - error ResumeThread() for listen thread (server) 0x0410 - error closesocket() 0x0411 - error switching listen mode with listen() 0x0412 - error getsockname() 0x0413 - connection lost 0x0414 - error recvfrom() receiving errors 0x0500 - got no information for this ID 0x0501 - more receive data available than space in given buffer 0x0502 - socket receives more data than space in internal receive buffer 0x0503 - length greater than given ANY pointer 0x0504 - ANY pointer buffer size is 0 0x0505 - try receiving data from not connected client 0x0506 - unable to receive because error state of worker/client socket 0x0507 - connection closed 0x0508 - undefined receive buffer 0x0509 - TURCV called with no UDP connection 0x050A - TRCV called with UDP connection sending errors 0x0600 - send event for undefined comm.partner 0x0601 - error ResetEvent() for send event 0x0602 - error SetEvent() for send event 0x0603 - internal send buffer not empty (e.g. last data not send by socket)

32

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

8 Error codes

0x0604 - try sending more data than space in internal send buffer 0x0605 - given buffer to small for complete send data 0x0606 - nothing to send in send buffer 0x0607 - undefined index value for internal comm.partner list 0x0608 - called SendData() without send data 0x0609 - error send() 0x060A - send() could not sent complete data 0x060B - WinAC interface - len does not make sense 0x060C - invalid pointer to send data buffer 0x060D - this is no error - used for mark a send command as 'initiated' 0x060E - got now socket object for send event 0x060F - UDP socket not ready for sending 0x0610 - error sendto() 0x0611 - TUSEND called with no UDP connection 0x0612 - TSEND called with UDP connection

Copyright  Siemens AG 2010 All rights reserved

0x0613 - try sending data to not connected client ISO on TCP errors 0x0700 - invalid TPDU code used 0x0701 - false local TSAP-ID length 0x0702 - false remote TSAP-ID length 0x0703 - local TSAP-ID not defined 0x0704 - remote TSAP-ID not defined 0x0705 - got other than 'connect confirm' 0x0706 - received calling TSAP-ID length to big 0x0707 - received called TSAP-ID length to big 0x0708 - ISO on TCP connection not established 0x0709 - message too long 0x070A - other than DT tpdu received 0x070B - this operation is not supportet by 'TCP/IP native' 0x070C - no complete header received 0x070D - no complete data received 0x070E - got remote TPDU size greater than locale 0x070F - got remote (calling) TSAP length other than parametrised 0x0710 - got remote (calling) TSAP other than parametrised 0x0711 - got local TSAP length other than parametrised 0x0712 - got local TSAP other than parametrised 0x0713 - got connection request with unknown parameters 0x0714 - did not found socket object in 'unspecific worker' list 0x0715 - socket object not referenced! 0x0716 - send called with no ISO-on-TCP connection

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

33

8 Error codes

handling errors 0x0800 - try removing server object which does not exist error codes used by Step7 function blocks 0x9999 - given connection ID not in range 1..32 other

Copyright  Siemens AG 2010 All rights reserved

0x3FFF - could not define state

34

WinAC IP Driver V2 V1.8, Entrys-ID: 48354110

9 History

9

History

Copyright  Siemens AG 2010 All rights reserved

Table 9-1 Version

Date

Comments

V1.0

05-18-06

first version

V1.1

06-26-06

- explanantion of parameter “LEN“ of TRCV - explanation of parameter “Port“ of TCON - added parameterisation examples - explanation data consistency for TRCV - added WinAC ODK error codes - registry entry for cable creak - described local IP for TINIT - included hints by F. Kock

V1.2

05-09-07

- insert general notes - insert chapter ”Reference System” - change contact person on front page - adapt reference regarding export codes

V1.3

02-07-08

- added ISO on TCP functionality - complete new error codes - Hint to Open Communication Wizard - change when data receiving is too slow (big internal buffer caches data) - added tips for error diagnostics - Registry for KeepAlive

02-26-08

- added remarks from integration test (added tips for solving problems)

V1.4

04-03-08

- added UDP functionality - TINIT with Block_DB instead of Int

V1.5

04-22-08

- add results from integration test - move chapters “Open Comm. Wizard” and “Tipps” - corrected internal error codes - description of example project

V1.6

04-22-09

- Customize on WinAC RTX 2008 - Change FB Numbers and Names

V1.7

03-30-10

- Description of REQ bits

V1.8

09-30-10

- Tested with WinAC RTX 2009

WinAC IP Driver V2 V1.8, Entry-ID: 48354110

35

Suggest Documents