Anda di halaman 1dari 44

Library description 01/2016

Weihenstephan Standards
for S7-1200 / S7-1500
Communication Protocol

https://support.industry.siemens.com/cs/ww/en/view/109475571
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.

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,
Siemens AG 2016 All rights reserved

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 the Siemens AG.

Security Siemens provides products and solutions with industrial security functions that
informa- support the secure operation of plants, solutions, machines, equipment and/or
tion networks. They are important components in a holistic industrial security
concept. With this in mind, Siemens’ products and solutions undergo continuous
development. Siemens recommends strongly that you regularly check for
product updates.
For the secure operation of Siemens products and solutions, it is necessary to
take suitable preventive action (e.g. cell protection concept) and integrate each
component into a holistic, state-of-the-art industrial security concept. Third-party
products that may be in use should also be considered. For more information
about industrial security, visit http://www.siemens.com/industrialsecurity.
To stay informed about product updates as they occur, sign up for a product-
specific newsletter. For more information, visit
http://support.industry.siemens.com.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 2
Table of contents

Table of contents
Warranty and liability ............................................................................................... 2
1 Library Overview ............................................................................................ 4
1.1 Different user scenarios ..................................................................... 5
1.2 Hardware and software requirements................................................. 8
1.3 Library resources ............................................................................... 9
2 Blocks of the Library .................................................................................... 10
2.1 List of the blocks .............................................................................. 10
2.2 Explanation of the blocks ................................................................. 11
2.2.1 LWeihStd_Server (FB 30400) .......................................................... 11
2.2.2 LWeihStd_ServerBasic (FB 30401).................................................. 15
2.2.3 LWeihStd_Client (FB 30402) ........................................................... 17
2.2.4 LWeihStd_ComWriteDiagBuffer (FB 30403) .................................... 30
2.2.5 LWeihStd_ComSearchTag (FC 30400) ............................................ 31
2.2.6 PLC data types ................................................................................ 32
2.2.7 PLC tags ......................................................................................... 36
3 Working with the Library .............................................................................. 39
3.1 Integrating the library into STEP 7.................................................... 39
3.2 Integrating the library blocks into STEP 7......................................... 39
4 Notes and Support ....................................................................................... 41
Siemens AG 2016 All rights reserved

4.1 Creating WS_Data and WS_Config DBs .......................................... 41


4.1.1 WS_Data (DB304xx) example ......................................................... 42
4.1.2 WS_Config (DB304xx) example....................................................... 43
4.2 Weihenstephan Standards Test Tool ............................................... 43
5 Related literature .......................................................................................... 44
6 Contact.......................................................................................................... 44
7 History .......................................................................................................... 44

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 3
1 Library Overview

1 Library Overview
What you get
This document describes the 'Communication Protocol' part of the LWeihStd block
library. The block library provides you with the tested code with clearly defined
interfaces. They can be used as a basis for your task to be implemented.
A key concern of the document is to describe
all blocks of the block library
the functionality implemented through these blocks.

Furthermore, this documentation shows possible fields of application and helps you
integrate the library into your STEP 7 project using step-by-step instructions.

Scope of application
STEP 7 Professional V13 SP1
S7-1200 CPU as of firmware 4.1.1
S7-1500 CPU as of firmware 1.8.0
Siemens AG 2016 All rights reserved

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 4
1 Library Overview

1.1 Different user scenarios


Possible application for the LWeihStd library
The Weihenstephan Standards for production data acquisition (PDA) define the
contents and physical aspects of an interface standard for the communication
between machine controllers and higher-level data acquisition systems or MES
(Manufacturing Execution Systems). They also define the data that must be
provided for the acquisition. All relevant technical and economic information can be
determined on the basis of this standardized database.
The standardized communication enables different machine types to be connected
to the PDA system.
With regard to the definitions made for order, batch, NVE/SSCC and key data for
the batch tracking, the PDA today is much more than pure data acquisition.

Figure 1-1: System Architecture (WS Protocol Version 08)


Siemens AG 2016 All rights reserved

The connection between server and client can be realized with standard Ethernet
interface. This allows a data evaluation which results in an efficiency analysis, a
batch tracing of data and of course a quality assurance. For an explicit definition of
the data, the content is described in a description file with a unique tag number, tag
name and data type.

More information on the Weihenstephan Standards for the food and beverage
packaging industry can be found at the according homepage
(http://www.weihenstephaner-standards.de/index.php?id=2&L=1).

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 5
1 Library Overview

The following section shows a scenario for a possible application of the LWeihStd
library:

Scenario
Machine PLCs are using the Weihenstephan Server application to provide their
production data. The Weihenstephan server application is available for SIMATIC
S7-300/400, S7-1200/S7-1500 and SIMOTION devices.
The Master PLC concentrates data from different machine PLCs or other
compatible devices that offer a Weihenstephan Server communication. It
exchanges the data between the Weihenstephan Client application and the
Weihenstephan Server (partner). The Weihenstephan Client application is
available for S7-300/400 devices and S7-1500 devices.
The Master PLC itself contains a Weihenstephan Server application to provide the
concentrated data of the line to the MES system that acts as a Weihenstephan
Client.
The supported commands and data points (tags) are described in an XML file
(PDACONF.xml). The data blocks containing the tags and administrative
information (tag number, access rights, data type) are created automatically based
on this XML file.

Figure 1-2: Client – Server connectivity


Siemens AG 2016 All rights reserved

Weihenstephan Client
Command:
• NOOP
• READ_SVALUE
Answer according • WRITE_SVALUE
to Weihenstephan • READ_LIST
Standard • WRITE_LIST
• READ_STRING
• WRITE_STRING
+ Tag number
Weihenstephan Server

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 6
1 Library Overview

Different server variations


There are two versions of the Weihenstephan server application available in this
library. The “Server” version and an additional “ServerBasic” version with reduced
memory needs. Only the minimum required commands (NOOP, READ_SVALUE,
WRITE_SVALUE) are available in this reduced version.

Table 1-1 Supported Weihenstephan commands


No. Command Description Server Server Client
basic
1. NOOP No Operation x x x
2. READ_SVALUE Read Single Value x x x
3. WRITE_SVALUE Write Single Value x x x
4. READ_LIST Read List (without STRING16) x x
5. WRITE_LIST Write List (without STRING16) x x
6. READ_MVALUE Read Multiple Values
7. WRITE_MVALUE Write Multiple Values
8. READ_STRING Read String x x
9. WRITE_STRING Write String x x
10. READ_CONFIG Read Configuration File
Siemens AG 2016 All rights reserved

11. READ_MIXED_LIST Read mixed List (STRING16 inclusive)


12. WRITE_MIXED_LIST Write mixed List (STRING16 inclusive)

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 7
1 Library Overview

1.2 Hardware and software requirements


Requirements for this library
To be able to use the functionality of the library described in this document, the
following hardware and software requirements must be met:

Hardware
Table 1-2 Hardware components
No. Component Article number Alternative
1. CPU 1513-1 PN 6ES7513-1AL00-0AB0 Other S7-1500 CPU with FW V1.8.0
2. Or CPU 1215C 6ES7215-1AG40-0XB0 Other S7-1200 CPU with FW V4.1.1

Software
Table 1-3 Software components
No. Component Article number Quantity
3. Step7 Professional V13 SP1 6ES7822-1..03-.. 1
4. Or Step7 Basic V13 SP1 6ES7822-0..03-.. 1
Siemens AG 2016 All rights reserved

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 8
1 Library Overview

1.3 Library resources


What will you find in this section?
The following section gives you an overview of the memory size of the blocks of the
LWeihStd library needed for communication (WS protocol) in the main and load
memory.

Overall size
The overall size of the blocks used for a Weihenstephan Server application of the
LWeihStd library in the main memory is 23 Kbytes and 226 Kbytes in the load
memory.
The overall size of the blocks used for a Weihenstephan ServerBasic application of
the LWeihStd library in the main memory is 11 Kbytes and 124 Kbytes in the load
memory.
The overall size of the blocks used for a Weihenstephan Client application of the
LWeihStd library in the main memory is 25 Kbytes and 252 Kbytes in the load
memory.

Size of the individual blocks1


Table 1-4: Size of blocks
Siemens AG 2016 All rights reserved

Block Symbol Size in main memory Size in load memory


[Kbytes] [Kbytes]
FB30400 LWeihStd_Server 18.3 186.2
FB30401 LWeihStd_ServerBasic 7.0 87.6
FB30402 LWeihStd_Client 20.3 210.8
FB30403 LWeihStd_ComWriteDiagBuffer 1.1 11.2
FC30400 LWeihStd_ComSearchTag 1.2 16.4
DB30400 instLWeihStd_Server 2.2 11.5
DB30401 instLWeihStd_ServerBasic 1.5 8.6
DB30402 instLWeihStd_Client 2.2 13.4
DB304xx WS_Data_<MachineID> Depending on PDACONF.xml
DB304xx WS_Config_<MachineID> Depending on PDACONF.xml

The <MachineID> attached at the symbol name of the WS_Data_ and WS_Config_
data block depends on the unique name you choose while generating the source
files from the PDACONF.xml description file.
The total memory of WS_Data and WS_Config depends on the configuration and
data (PDACONF.xml) you choose.
How to generate the source files from the PDACONF.xml and to implement them in
your application can be found in chapter 4.

1
Instance data blocks (prefix instLWeihStd_) are not delivered with the library. They will be
generated automatically with the call of a function block.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 9
2 Blocks of the Library

2 Blocks of the Library


What will you find in this section?
This chapter lists and explains all blocks of the LWeihStd library used for
communication (WS protocol). Before that, however, you are informed of the blocks
that are essentially involved in the implementation of the functionality.

2.1 List of the blocks


The following table lists all blocks of the LWeihStd library used for communication
(WS protocol).

Table 2-1: Blocks of the library


Block Symbol Classification
FB30400 LWeihStd_Server In-house development
FB30401 LWeihStd_ServerBasic In-house development
FB30402 LWeihStd_Client In-house development
FB30403 LWeihStd_ComWriteDiagBuffer In-house development
FC30400 LWeihStd_ComSearchTag In-house development
Siemens AG 2016 All rights reserved

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 10
2 Blocks of the Library

2.2 Explanation of the blocks


The following table explains all blocks and their functionality of the LWeihStd library
used for communication (WS protocol).

2.2.1 LWeihStd_Server (FB 30400)

Figure

LWeihStd_Server

Bool enable connected Bool

Variant tagInfo valid Bool

Variant listInfo busy Bool

DB_ANY data error Bool

LWeihStd_typeServer
configuration status Word
Configuration
LWeihStd_typeServer
diagnostics
Diagnostics
Siemens AG 2016 All rights reserved

Principle of operation
The FB LWeihStd_Server expects the required TCP parameterization (e.g. local
port number of the TCP server, unique connection ID) and the parameterization of
the Weihenstephan data as input. Furthermore it is necessary to define the tag
information and the list information to establish a successful connection according
to Weihenstephan Standards. The tagInfo consists of a unique tag number, the
data offset, data type and read/write access of each variable. The listInfo consists
of all lists and the contained tags in the lists.
The establishment of a connection, the status and the error information is provided
as outputs.
The output diagnostics provides further error information, e.g. values of runtime
measurement or a diagnostic buffer which contains detailed entries of occurred
errors.

Note The upper limit of the internal send buffer of the FB can be adapted by changing
the constant LWEIHSTD_SERVER_SEND_BUFFER_LEN. The value has a
minimal length of 8 and must be divisible by 4.

Note The upper limit of the internal receive buffer of the FB can be adapted by
changing the constant LWEIHSTD_SERVER_RECEIVE_BUFFER_LEN. The
value has a minimal length of 8 and must be divisible by 4.

Note The upper limit of diagnostic buffer array can be adapted by changing the
constant LWEIHSTD_SERVER_DIAG_BUFFER_UPPER_LIM.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 11
2 Blocks of the Library

Function characteristics
Figure 2-1: Timing diagram of FB LWeihStd_Server

1. After enabling the function block the TCP port is opened so that the client can
connect. As long as the client is not connected the output connected is not set
and the outputs busy and valid are set if no error occurs.
2. If the client is connected to the server the output connected is set.
Siemens AG 2016 All rights reserved

3. An error occurred that is cleared by the function block on its own, e.g. the
connection to the client is lost, while the FB was sending data. If this type of
error occurs, the outputs connected and valid are reset and the outputs error
and busy are set. After solving the error reason, e.g. by reconnecting, the FB
continues with normal workflow. The output error is reset and the output valid
is set.
4. An error occurred, that can only be cleared by the user. For example the data
DB or the configuration DB is incompatible. Then the outputs busy, valid and
connected are reset. The output error is set.
The output error can only be reset by resetting the input enable.

Input parameters
Table 2-2 LWeihStd_Server input parameters
Parameter Data type Description
enable Bool TRUE: Enable functionality of FB
(default: FALSE)
tagInfo Variant Array with Weihenstephan tag information
listInfo Variant Array with Weihenstephan list information
data DB_ANY Weihenstephan data DB number
configuration LWeihStd_typeServerConfiguration FB configuration

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 12
2 Blocks of the Library

Output parameters
Table 2-3 LWeihStd_Server output parameters
Parameter Data type Description
connected Bool TRUE: Connection established
(default: FALSE)
valid Bool TRUE: Valid set of outputs available at the FB
(default: FALSE)
busy Bool TRUE: FB is working and new output values
can be expected
(default: FALSE)
error Bool Rising edge informs that an error occurred
during the execution of FB
(default: FALSE)
status Word Current status of FB
(default: STATUS_NO_CALL)
diagnostics LWeihStd_typeServerDiagnostics Diagnostic values of FB

Status and error displays


Possible values at the output status are listed below.
Siemens AG 2016 All rights reserved

Table 2-4: LWeihStd_Server operating status


Status Meaning Remedy / notes
16#7000 STATUS_NO_CALL No call of FB
16#7001 STATUS_FIRST_CALL First call of FB after enabling
16#7002 STATUS_NOT_CONNECTED Port open but no client connected
16#7003 STATUS_CONNECTING Port open und waiting for connection
16#7004 STATUS_TCP_CONNECTED Client is connected
16#7006 STATUS_DISCONNECTING Disconnecting from partner

Table 2-5: LWeihStd_Server Weihenstephan protocol warnings


Status Meaning Remedy / notes
16#7200 WARN_TCON Warning in TCON FB occurred
16#7201 WARN_TRCV Warning in TRCV FB occurred
16#7202 WARN_TSEND Warning in TSEND FB occurred
16#7308 WARN_WS_WRITE Warning WS 0x8888: Write was not successful
16#7309 WARN_WS_MEM_OVERFLOW Warning WS 0x9999: Memory overflow
16#730A WARN_WS_UNKNOWN_CMD Warning WS 0xAAAA: Unknown command
16#730B WARN_WS_ACCESS Warning WS 0xBBBB: Access not allowed
16#730D WARN_WS_ARGUMENT Warning WS 0xDDDD: Implausible argument
16#730E WARN_WS_LIST Warning WS 0xEEEE: Implausible list

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 13
2 Blocks of the Library

Table 2-6: LWeihStd_Server configuration errors


Status Meaning Remedy / notes
16#8200 ERR_ARRAY_TAG_INFO No array connected to input tagInfo
16#8201 ERR_ARRAY_LIST_INFO No array connected to input listInfo
16#8202 ERR_DATA_TYPE_TAG_INFO Wrong data type in tagInfo array
16#8203 ERR_DATA_TYPE_LIST_INFO Wrong data type in listInfo array
16#8204 ERR_DATA_DB No DB is connected to input data
16#8205 ERR_WS_SEND_BUFFER_LEN Error WS Send Buffer wrong length
16#8206 ERR_WS_RECV_BUFFER_LEN Error WS Receive Buffer wrong length

Table 2-7: LWeihStd_Server common errors


Status Meaning Remedy / notes
16#8600 ERR_ADDRESS_SEARCH Error in 'address search' occurred
16#8601 ERR_ADDR_LIST Error when trying to access list data in DB
16#8602 ERR_STATE Error in internal receive state machine
16#8603 ERR_SEND_STATE Error in internal send state machine
16#8604 ERR_CONN_STATE Error in internal connection state machine
16#8610 ERR_TCON Error in TCON communication block
Siemens AG 2016 All rights reserved

16#8611 ERR_TRCV Error in TRCV communication block


16#8612 ERR_TSEND Error in TSEND communication block
16#8613 ERR_TDISCON Error in TDISCON communication block
16#8614 ERR_PEEK Error at peek operation in data DB
16#8615 ERR_POKE Error at poke operation in data DB

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 14
2 Blocks of the Library

2.2.2 LWeihStd_ServerBasic (FB 30401)

Figure

LWeihStd_ServerBasic

Bool enable connected Bool

Variant tagInfo valid Bool

DB_ANY data busy Bool

LWeihStd_type
configuration error Bool
ServerConfiguration

status Word

subfunction
Word
Status

Principle of operation
The FB LWeihStd_Server expects the required TCP parameterization (e.g. local
port number of the TCP server, unique connection ID) and the parameterization of
Siemens AG 2016 All rights reserved

the Weihenstephan data as input. Furthermore it is necessary to define the tag


information and the list information to establish a successful connection according
to Weihenstephan Standards. The tagInfo consists of a unique tag number, the
data offset, data type and read/write access of each variable. The listInfo consists
of all lists and the contained tags in the lists.
The establishment of a connection, the status and the error information is provided
as outputs.
The output subfunctionStatus provides further error information, e.g. status of
subsequent called system functions.

Note The upper limit of the internal send buffer of the FB can be adapted by changing
the constant LWEIHSTD_SERVER_SEND_BUFFER_LEN. The value has a
minimal length of 8 and must be divisible by 4.

Note The upper limit of the internal receive buffer of the FB can be adapted by
changing the constant LWEIHSTD_SERVER_RECEIVE_BUFFER_LEN. The
value has a minimal length of 8 and must be divisible by 4.

Note The upper limit of diagnostic buffer array can be adapted by changing the
constant LWEIHSTD_SERVER_DIAG_BUFFER_UPPER_LIM.

Function characteristics
Identically with LWeihStd_Server (FB30400), see chapter 2.2.1

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 15
2 Blocks of the Library

Input parameters
Table 2-8 LWeihStd_ServerBasic input parameters
Parameter Data type Description
enable Bool TRUE: Enable functionality of FB
(default: FALSE)
tagInfo Variant Array with Weihenstephan tag information
data DB_ANY Weihenstephan data DB number
configuration LWeihStd_typeServerConfiguration FB configuration

Output parameters
Table 2-9 LWeihStd_ServerBasic output parameters
Parameter Data type Description
connected Bool TRUE: Connection established
(default: FALSE)
valid Bool TRUE: Valid set of outputs available at the
FB
(default: FALSE)
busy Bool TRUE: FB is working and new output values
Siemens AG 2016 All rights reserved

can be expected
(default: FALSE)
error Bool Rising edge informs that an error occurred
during the execution of FB
(default: FALSE)
status Word Current status of FB
(default: STATUS_NO_CALL)
subfunctionStatus Word Status of subsequent called function

Status and error displays


Identically with LWeihStd_Server (FB30400), see chapter 2.2.1

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 16
2 Blocks of the Library

2.2.3 LWeihStd_Client (FB 30402)

Figure

LWeihStd_Client

Bool enable connected Bool

Bool executeRequest valid Bool

USInt requestMode busy Bool

Time requestCycle error Bool

Variant tagInfo status Word

Variant listInfo requestDone Bool

DB_ANY data requestBusy Bool

LWeihStd_typeClient LWeihStd_typeClient
configuration diagnostics
Configuration Diagnostics
commands
Variant Variant
Siemens AG 2016 All rights reserved

Principle of operation
The FB LWeihStd_Client expects the required TCP parameterization (e.g. local
port number of the TCP client, unique connection ID, IP address and remote port of
Weihenstephan server) and the parameterization of the Weihenstephan data as
input. Furthermore it is necessary to define the tag information and the list
information to establish a successful connection according to Weihenstephan
Standards. . The tagInfo consists of a unique tag number, the data offset, data type
and read/write access of each variable. The listInfo consists of all lists and the
contained tags in the lists. The InOut parameter commands must be connected to
an array of the data type LWeihStd_typeClientCommand. The commands array
contains information about the sent commands. Every command in the commands
array can be set inactive.
Commands are sent cyclically (requestCycle) or by trigger input (executeRequest).
According to the chosen mode, all commands are sent in one block or only one
command is sent to the server and the client waits for acknowledgement.
The establishment of a connection, the status or error information is provided as
outputs.
The output diagnostics provides further error information, e.g. values of runtime
measurement or a diagnostic buffer which contains detailed entries of occurred
errors.

Note The upper limit of the internal send buffer of the FB can be adapted by changing
the constant LWEIHSTD_CLIENT_SEND_BUFFER_LEN. The value has a
minimal length of 8 and must be divisible by 4.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 17
2 Blocks of the Library

Note The upper limit of the internal receive buffer of the FB can be adapted by
changing the constant LWEIHSTD_CLIENT_RECEIVE_BUFFER_LEN. The
value has a minimal length of 8 and must be divisible by 4.

Note The upper limit of diagnostic buffer array can be adapted by changing the
constant LWEIHSTD_CLIENT_DIAG_BUFFER_UPPER_LIM.

Function characteristics
Figure 2-2: Timing diagram of FB LWeihStd_Client
Siemens AG 2016 All rights reserved

1. After enabling the function block a connection is established via TCP to the
server IP address and port. As long as the client is not connected the outputs
valid and connected are not set and the output busy is set if no error occurs. If
the client is connected via TCP, the output valid is set.
2. After the client is connected to the server via TCP, a NOOP command is sent
to the server to check its ability to communicate via Weihenstephan protocol. If
the response on the NOOP command is correct and arriving in the specified
time (configuration.cmdTimeout), the output connected is set.
3. An error occurred that is cleared by the FB on its own, e.g. the connection to
the client is lost, while the FB was sending data. If this type of error occurs, the
outputs connected and valid are reset and the outputs error and busy are set.
After solving the error reason, e.g. by reconnecting, the FB continues with
normal workflow. The output error is reset and the output valid is set.
4. An error occurred that can only be cleared by the user. For example the data
DB and the configuration DB is incompatible. Then the outputs busy, valid and
connected are reset. The output error is set.
The output error can only be reset by resetting the input enable.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 18
2 Blocks of the Library

WS connection test mechanism (“sign of life”)


To check the availability of the Weihenstephan connection a test mechanism is
implemented. If no request is processed for a specified time
(configuration.WSConnTestCycleTime), a NOOP command is automatically sent
from the WS Client application to the WS Server. While the NOOP command is
sent and the client application waits for a response, no other trigger is allowed. If
the value zero is chosen for configuration.WSConnTestCycleTime, the cyclic test
mechanism is deactivated.

Figure 2-3: Timing diagram for WSConnTest mechanism with triggered requesting
Siemens AG 2016 All rights reserved

1. The timer for sending a test request is started when the Weihenstephan
connection is established. A communication request (sending commands from
the commands array) stops the timer.
2. When receiving the response from the WS Server the test timer is restarted.
3. A NOOP command is sent when the timer is elapsed. The ping time can be
configured via configuration.WSConnTestCycleTime. The timer is restarted
when the response of the WS Server is received.
4. No request was sent since the last test, so a new NOOP command is sent.
5. If the WS Server does not respond on a configured number of retries
(configuration.maxNoOfFailedWSConnTests) an automatically cleared error is
set. The WS Client application reacts on automatically cleared errors by
closing the connection and reconnecting to the WS Server.
6. The WS connection is reestablished by sending a NOOP command to the
server and receiving a correct response. This clears automatically the error
and a new request can be triggered.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 19
2 Blocks of the Library

Request modes
The Weihenstephan client supports different modes of data exchange. The
decision which mode is best relates to the possibilities of the connected WS server.
The LWeihStd Server is able to communicate with the LWeihStd Client in each of
these modes.
Table 2-10: Supported request modes
Value Constant Triggered Cyclic Sequential Block Single
LWEIHSTD_REQUEST_
0 x x
MODE_SEQ_TRIG
LWEIHSTD_REQUEST_
1 x x
MODE_SEQ_CYCLIC
LWEIHSTD_REQUEST_
2 x x
MODE_BLOCK_TRIG
LWEIHSTD_REQUEST_
3 x x
MODE_BLOCK_CYCLIC
LWEIHSTD_REQUEST_
4 x x
MODE_SINGLE_TRIG
Siemens AG 2016 All rights reserved

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 20
2 Blocks of the Library

The first difference in the request modes is in triggering:

Triggered requesting
If triggered requesting is selected (suffix _TRIG), the request is sent if no other
request is busy at the same time and the executeRequest input is set.
All active commands
Input of WS Client FB
executeRequest

PLC Runtime

Figure 2-4: Timing diagram triggered requesting


Siemens AG 2016 All rights reserved

1. If the connection is successfully established, a request can be triggered via the


executeRequest input. Every trigger before a WS connection is successfully
established doesn’t have any effect on the FB. If a request is successfully
triggered, the requestBusy output is set.
2. After finishing all checks of the response from the WS Server, the output
requestDone is set as long as the executeRequest input is set.
3. A new request can be sent with a rising edge at the executeRequest input if no
request is busy at the same time. If a request is busy, a rising edge of the
executeRequest is ignored by the FB. If executeRequest is reset while
requestBusy is set, the requestDone output, signalizing that the request is
finished, is only set for one FB call.
4. If a request and the according response lasts longer than the requestCycle, a
new request is triggered immediately after the request before is finished
(requestDone set for one cycle).
5. An error occurs during a request, e.g. a tag is not known in the WS Server and
it sends the according response (WS error code implausible tag) back to the
client. The client signals the automatically cleared error by setting the error
output. If this type of error occurs, the client tries to solve the problem on its
own by deactivating the command with the implausible tag in the commands
array and reconnects to the WS Server.
6. After solving the error, a new request can be triggered by a rising edge at the
executeRequest input.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 21
2 Blocks of the Library

Cyclic requesting
If cyclic requesting is chosen (suffix _CYCLIC), the request is sent the first time
when the client FB is enabled and a connection is established. At the same time
the first request is sent, a timer is started with the requestCycle time. After the timer
is elapsed, the next request is triggered automatically. The timer is restarted
immediately before the commands are sent to the server. If the requestCycle is
less than the roundtrip time of the commands (from client to server and back to the
client), a new request is sent immediately after receiving the response to the
request sent before.

All active commands

Multiple of
0 1 2 3
requestCycle
requestCycle

Figure 2-5: Timing diagram cyclic requesting


Siemens AG 2016 All rights reserved

1. If the connection is successfully established, a request is sent immediately to


the WS Server. While a request is active and the response of the server is not
checked, the requestBusy output is set. The requestCycle timer is restarted
immediately when it is elapsed and requestBusy is set.
2. After finishing all checks of the response from the WS Server, the output
requestDone is set for one cycle. A rising edge of the executeRequest input
doesn’t influence the requesting in cyclic mode.
3. The requestCycle timer is elapsed. This event triggers automatically a new
request by the WS Client application.
4. If a request and the according response last longer than the requestCycle, a
new request is triggered immediately after finishing the request before
(requestDone set for one cycle).
5. An error occurs during a request, e.g. a tag is not known in the WS Server and
it sends the according response (WS error code implausible tag) back to the
client. The client signals the automatically cleared error by setting the error
output. If this type of error occurred, the client tries to solve the problem on its
own by deactivating the command with the implausible tag in the commands
array and reconnects to the WS Server.
6. After solving the error, a new request is sent immediately.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 22
2 Blocks of the Library

The second difference is the type of sending the commands to the server:

Sequential sending of commands


Figure 2-6: Schema sequential sending

WS Client WS Server

A request is triggered
Wait for telegram receive
Build telegram(s) with first
command of commands
array and send it to server Command received

Wait for response Execute command and


send response
Check response
Siemens AG 2016 All rights reserved

Build telegram(s) with next


command of commands
array and send it to server Command received

Wait for response Execute command and


send response

Check response

… …

Execute command and


send response
Check response for last
command in commands
array

Request finished
Set requestDone

If sequential sending is selected, the first command is sent immediately after


triggering. The second command of the commands array is sent if the request sent
before is finished by receiving a response from the server. An advantage of this
method is that a WS Server has to process only one command at the same time.
All modes using sequential sending have a _SEQ_ in the name of the constant.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 23
2 Blocks of the Library

Sending commands in a block


Figure 2-7: Schema sending commands in a block

WS Client WS Server

A request is triggered;
deactivate receive Wait for receive of
message(s)
Add first command of
commands array to
message(s)

Add second command of


commands array to
message(s)

If max send buffer length Message with commands


is reached, send telegram received
Siemens AG 2016 All rights reserved

Add next command of Execute command and


commands array to new send or prepare response
telegram message

Add last command of
commands array to Execute command and
message(s) and send it send response message(s)

Enable receiving

Check responses

Request finished
Set requestDone

If sending commands in a block is selected the receiving of response messages in


the WS Client application is disabled as long as the sending of the complete
commands array is busy. After sending of all commands the receiving is enabled
and the response messages of the WS Server are checked. The advantage of this
method is that the network traffic is reduced. All modes using sending in a block
have a _BLOCK_ in the name of the constant.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 24
2 Blocks of the Library

Single sending
Figure 2-8: Schema single sending

WS Client WS Server

A request is triggered
Wait for telegram receive
Build telegram(s) with first
command of commands
array and send it to server Command received

Wait for response Execute command and


send response
Check response

Request finished
Set requestDone
Siemens AG 2016 All rights reserved

Wait for trigger

Build telegram(s) with next


command of commands
array and send it to server Command received

Wait for response Execute command and


send response

Check response

Request finished
Set requestDone
… …

If single sending is selected, only one command is sent per trigger. If the last active
command in commands array is reached, the first active command in commands
array is sent. The advantage of this method is that a WS Server has to process
only one command at the same time and between each command a defined action
in client can take place before a new command is sent. All modes using single
sending have a _SINGLE_ in the name of the constant.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 25
2 Blocks of the Library

Input parameters
Table 2-11 LWeihStd_Client input parameters
Parameter Data type Description
enable Bool TRUE: Enable functionality of FB
(default: FALSE)
executeRequest Bool Rising edge triggers FB to execute a
request
requestMode USInt Mode for sending and receiving request
(see Request modes)
(default: LWEIHSTD_REQUEST_MODE_
SEQ_TRIG)
requestCycle Time Interval of sending requests for all
commands; T#0ms means triggered by
executeRequest
tagInfo Variant Array with Weihenstephan tag information
listInfo Variant Array with Weihenstephan list information
data DB_ANY Weihenstephan data DB number
configuration LWeihStd_typeClient FB configuration
Configuration

Output parameters
Siemens AG 2016 All rights reserved

Table 2-12 LWeihStd_Client output parameters


Parameter Data type Description
connected Bool TRUE: Connection established
valid Bool TRUE: Valid set of outputs available at the
FB
busy Bool TRUE: FB is working and new output
values can be expected
error Bool Rising edge informs that an error occurred
during the execution of FB
status Word Current status of FB
(default: STATUS_NO_CALL)
requestDone Bool Request of commands is done
requestBusy Bool Request of commands is busy
diagnostics LWeihStd_typeClient Diagnostic values of FB
Diagnostics

InOut parameters
Table 2-13 LWeihStd_Client InOut parameters
Parameter Data type Description
commands Variant Array with commands

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 26
2 Blocks of the Library

Principle of error handling


The Weihenstephan Client application in general knows two different error types:
Automatically cleared errors
These errors can be handled by the application itself without any interaction of
the user. Examples for these errors are a loss of connection or an overload in
the WS Server. The WS Client tries to disconnect from the server and then
connects again. If an automatically cleared error appears, the outputs error and
busy are set and the output valid is reset. The output status has a value that is
negative in Integer format.

User cleared error


These errors can only be cleared with a interaction of the user. The user at
least has to acknowledge the error. Examples for these errors are that the sent
command is unknown in the WS Server or a DB number written to the inputs is
not correct. If a user cleared error appears, the output error is set and the
outputs busy and valid are reset. The output status has a value that is negative
in Integer format.

Automatic cleared error appeared:


1. WS Client disconnects from WS
Siemens AG 2016 All rights reserved

Server.
2. WS Client tries to reconnect to WS
Server. This empties the TCP stack
of the WS Client.
3. Send a NOOP command to WS
Server and wait for correct answer
for a specified time
(configuration.cmdTimeout).

User cleared error appeared:


4. All functionality of the WS Client FB
is disabled immediately.
5. The WS Client FB waits for a new
rising edge at the input enable.
This acknowledges the error.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 27
2 Blocks of the Library

Status and error displays


Possible values at the output status are listed below.

Table 2-14: LWeihStd_Client operating status


Status Meaning Remedy / notes
16#7000 STATUS_NO_CALL No call of FB
16#7001 STATUS_FIRST_CALL First call of FB after enabling
16#7002 STATUS_NOT_CONNECTED Port open but no client connected
16#7003 STATUS_CONNECTING Port open und waiting for connection
16#7004 STATUS_TCP_CONNECTED Client is connected to a TCP partner
16#7005 STATUS_DISCONNECTING Disconnecting from partner
16#7006 STATUS_WS_CONNECTED Client is connected to a WS partner

Table 2-15: LWeihStd_Client Weihenstephan protocol warnings


Status Meaning Remedy / notes
16#7200 WARN_TCON Warning in TCON FB appeared
16#7201 WARN_TRCV Warning in TSEND FB appeared
16#7202 WARN_TSEND Warning in TRCV FB appeared
Siemens AG 2016 All rights reserved

16#7203 WARN_WS_CONN_TEST NOOP command response not correct (WS


connection test)
16#7204 WARN_RECV_NOT_EXPECTED Data received while no receive was expected
16#7205 WARN_WRONG_RESULT Wrong result code received
16#7206 WARN_WRONG_ARGUMENT Wrong argument received
16#7207 WARN_WRONG_COUNT Wrong count of elements in list, characters or
bytes received
16#7208 WARN_CMD_TIMEOUT Command timeout detected
16#7209 WARN_TOO_MUCH_DATA More data received than expected for command
16#720A WARN_TDISCON Warning in TDISCON appeared
16#7308 WARN_WS_WRITE Warning WS 0x8888: Write was not successful
16#7309 WARN_WS_MEM_OVERFLOW Warning WS 0x9999: Memory overflow
16#730A WARN_WS_UNKNOWN_CMD Warning WS 0xAAAA: Unknown command
16#730B WARN_WS_ACCESS Warning WS 0xBBBB: Access not allowed
16#730C WARN_WS_OVERLOAD Warning WS 0xCCCC: Server overload
16#730D WARN_WS_ARGUMENT Warning WS 0xDDDD: Implausible argument
16#730E WARN_WS_LIST Warning WS 0xEEEE: Implausible list

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 28
2 Blocks of the Library

Table 2-16: LWeihStd_Client configuration errors


Status Meaning Remedy / notes
16#8200 ERR_ARRAY_TAG_INFO No array connected to input tagInfo
16#8201 ERR_ARRAY_LIST_INFO No array connected to input listInfo
16#8202 ERR_DATA_TYPE_TAG_INFO Wrong datatype in tagInfo array
16#8203 ERR_DATA_TYPE_LIST_INFO Wrong datatype in listInfo array
16#8204 ERR_DATA_DB No DB is connected to input data
16#8205 ERR_WS_SEND_BUFFER_LEN Error WS Send Buffer wrong length
16#8206 ERR_WS_RECV_BUFFER_LEN Error WS Receive Buffer wrong length
16#8207 ERR_ARRAY_CMDS No array connected to InOut commands
16#8208 ERR_DATA_TYPE_CMDS Wrong datatype in commands array
16#8209 ERR_REQUEST_MODE Request mode is invalid

Table 2-17: LWeihStd_Client external errors caused by WS Server


Status Meaning Remedy / notes
16#8400 ERR_WS_CONN_TEST Number of failed WS connection tests (sending
NOOP command) exceeded the configured
maximum
Siemens AG 2016 All rights reserved

Table 2-18: LWeihStd_Client internal errors


Status Meaning Remedy / notes
16#8600 ERR_ADDRESS_SEARCH Error in 'address search' occurred
16#8601 ERR_ADDR_LIST Error when trying to access list data in DB
16#8602 ERR_STATE Error in internal state machine
16#8603 ERR_SEND_STATE Error in internal send state machine
16#8604 ERR_CONN_STATE Error in internal connection state machine
16#8605 ERR_SUBSTATE Error in internal sub state
16#8606 ERR_ADDR_CMD Error when trying to access command data in
DB
16#8610 ERR_TCON Error in TCON communication block
16#8611 ERR_TRCV Error in TRCV communication block
16#8612 ERR_TSEND Error in TSEND communication block
16#8613 ERR_TDISCON Error in TDISCON communication block
16#8614 ERR_PEEK Error at peek operation in data DB
16#8615 ERR_POKE Error at poke operation in data DB

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 29
2 Blocks of the Library

2.2.4 LWeihStd_ComWriteDiagBuffer (FB 30403)

Figure

LWeihStd_ComWriteDiagBuffer

LWeihStd_typeCom
entry entryIndex Int
DiagnosticEntry

Bool reset status Word

diagnosticBuffer
Variant Variant

Principle of operation
This function block is called by the LWeihStd_Server FB and manages the
diagnostic buffer. In case of error LWeihStd_ComWriteDiagBuffer is called and
input entry will be written in the diagnostic buffer array. If input reset is TRUE, the
diagnostic buffer array will be initialized.
Siemens AG 2016 All rights reserved

Note The LWeihStd_ComWriteDiagBuffer FB is not relevant for the


LWeihStd_ServerBasic.

Input parameters
Table 2-19: LWeihStd_ComWriteDiagBuffer input parameters
Parameter Data type Description
entry LWeihStd_typeComDiagnosticEntry Entry to be written into diagnostic buffer
reset Bool Reset/Initialize diagnostic buffer

Output parameters
Table 2-20: LWeihStd_ComWriteDiagBuffer output parameters
Parameter Data type Description
entryIndex Int Index of written entry in diagnostic buffer
(default: -1)
status Word FB Status

InOut parameters
Table 2-21: LWeihStd_ComWriteDiagBuffer InOut parameters
Parameter Data type Description
diagnosticBuffer Variant Diagnostic buffer array

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 30
2 Blocks of the Library

2.2.5 LWeihStd_ComSearchTag (FC 30400)

Figure

LWeihStd_ComSearchTag

UInt tagNumber tagInfo LWeihStd_typeComTagInfo

subfunction
Variant tagInfoArray Word
Status

Principle of operation
This function provides information about the requested tag number. The
tagNumber is searched in the tagInfoArray. The type of output tagInfo is a PLC
datatype which contains the address (data offset in data DB), the access rights
(read, write or read/write) and the datatype of the tag.

Input parameters
Table 2-22: LWeihStd_ComSearchTag input parameters
Siemens AG 2016 All rights reserved

Parameter Data type Description


tagNumber UInt Tag number
tagInfoArray Variant Array with additional Weihenstephan tag
information

Output parameters
Table 2-23: LWeihStd_ComSearchTag output parameters
Parameter Data type Description
tagInfo LWeihStd_typeComTagInfo Complete information of tag
subfunctionStatus Word Status of sub functions

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 31
2 Blocks of the Library

2.2.6 PLC data types

Common PLC data types:


These PLC data types are necessary for Weihenstephan Server and Client
applications.

LWeihStd_typeComDiagnosticEntry
An entry in the diagnostic buffer will be made when a message occurs.

Table 2-24: LWeihStd_typeComDiagnosticEntry


Parameter Data type Description
status Word Status of FB
timestamp DTL Timestamp when entry was created
subfunctionStatus Word Status of subsequent called function
state Int Internal state
sendState Int Internal send state
connectionState Int Internal connection state
tagNumber UInt Tag number
(default: 65535)
Siemens AG 2016 All rights reserved

additionalValue1 UInt Additional value 1


additionalValue2 Word Additional value 2

Note The LWeihStd_typeComDiagnosticEntry data type is not relevant for the


LWeihStd_ServerBasic.

LWeihStd_typeComTagInfo
The tagInfo contains a unique tag number, the data offset (address in data DB),
data type and access authorization of each variable.

Table 2-25: Parameter of LWeihStd_typeComTagInfo


Parameter Data type Description
tagNumber UInt Number of according tag
dataOffset UInt Offset of data
dataType USInt 0: Undefined
1: Unsigned32
2: Signed32
3: Real
4: Hex32
5: String16
253, 254, 255: List
rwAccess USInt 0: No access
1: Read
2: Write
3: Read/Write

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 32
2 Blocks of the Library

WS Server PLC data types:


These PLC data types are additional necessary for Weihenstephan Server
applications.

LWeihStd_typeServerDiagnostics
This type contains diagnostics information for Server FB.

Table 2-26: LWeihStd_typeServerDiagnostics


Parameter Data type Description
statistics Struct Statistical values of FB
sendCounter UDInt Send counter
receiveCounter UDInt New data received counter
actRuntime Time Actual runtime of FB in ms
maxRuntime Time Maximum runtime of FB in ms
bufferIndex Int Index of actual buffer entry
(default: -1)
buffer Array[0..LWEIHSTD_SERVER_DIAG_ Diagnostic information buffer
BUFFER_UPPER_LIM] of
LWeihStd_typeComDiagnosticEntry
Siemens AG 2016 All rights reserved

Note The LWeihStd_typeServerDiagnostics data type is not relevant for the


LWeihStd_ServerBasic.

LWeihStd_typeServerConfiguration
The type configuration data contains information to establish a TCP
communication.

Table 2-27: LWeihStd_typeServerConfiguration


Parameter Data type Description
serverPort UInt Local port (see system function TCON)
(default: 5000)
connectionID CONN_OUC Unique connection identifier
(W#16#0001...W#16#0FFF)
(default: 16#0FFE)
interfaceID HW_ANY Hardware identifier of the local
interface, PLC tags--Default tag table--
System constant default value:
PROFINET_interface_1 = 64
(default: 64)
reconnectDelay Time Time to wait before reconnecting after
temporary error
(default: T#200ms)

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 33
2 Blocks of the Library

WS Client PLC data types:


These PLC data types are additional necessary for Weihenstephan Client
applications.

LWeihStd_typeClientDiagnostics
This type contains diagnostic information of the client FB.

Table 2-28: LWeihStd_typeClientDiagnostics


Parameter Data type Description
statistics Struct Statistical values of FB
sendCounter UDInt Send counter
receiveCounter UDInt New data received counter
actRuntime Time Actual runtime of FB in ms
maxRuntime Time Maximum runtime of FB in ms
bufferIndex Int Index of actual buffer entry
(default: -1)
buffer Array[0..LWEIHSTD_CLIENT_ Diagnostic information buffer
DIAG_BUFFER_UPPER_LIM]
of LWeihStd_typeCom
DiagnosticEntry
Siemens AG 2016 All rights reserved

LWeihStd_typeClientCommand
The type contains information about the used command with according tag
number. With the Boolean parameter isInactive commands can be set inactive.

Table 2-29: LWeihStd_typeClientCommand


Parameter Data type Description
command USInt WS command number according to
global constants
(default:
LWEIHSTD_COM_CMD_UNDEFINED)
tagNumber UInt WS tag or list number
isInactive Bool TRUE: Command is inactive; FALSE:
Command is active

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 34
2 Blocks of the Library

LWeihStd_typeClientConfiguration
The type configuration data contains the information about the connection and
other configuration parameters like timeout detection for the client FB.

Table 2-30: LWeihStd_typeClientConfiguration


Parameter Data type Description
serverIPAddress IP_V4 IP address of Weihenstehan Server
serverPort UInt TCP/IP port of Weihenstephan Server
(Remote port - see system function
TCON)
(default: 5000)
clientPort UInt TCP/IP port of Weihenstephan Client
(Local port - see system function
TCON)
(default: 5000)
connectionID CONN_OUC Unique connection identifier
(W#16#0001...W#16#0FFF)
(default: 16#0FFE)
interfaceID HW_ANY Hardware identifier of the local
interface, PLC tags--Default tag table--
System constant default value:
PROFINET_interface_1 = 64
Siemens AG 2016 All rights reserved

(default: 64)
cmdTimeout Time Timeout for receiving response for
previously sent command
(default: T#10s)
reconnectDelay Time Time to wait before reconnecting after
temporary error
(default: T#5s)
WSConnTestCycleTime Time Cycle time for sending NOOP
command if no other command is sent
(WS connection test), T#0ms means
cyclic test is disabled
(default: T#10s)
maxNoOfFailed USInt Maximum number of failed WS
WSConnTests connection tests before error is set that
can only be solved by user
(default: 3)

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 35
2 Blocks of the Library

2.2.7 PLC tags

The PLC tag tables LWeihStd_Com, LWeihStd_Server and LWeihStd_Client


contain user constants of permitted data types, buffer lengths and allowed memory
access (read/write) of all lists and tags according to Weihenstephan Standards.

Common user constants in LWeihStd_Com


These constants are necessary for Weihenstephan Server and Client applications.

Table 2-31: Constants for data types


Name Data type Value Comment
LWEIHSTD_COM_DATA_TYPE_ USInt 1 Weihenstephan data type Unsigned32
UNSIGNED32
LWEIHSTD_COM_DATA_TYPE_ USInt 2 Weihenstephan data type Signed32
SIGNED32
LWEIHSTD_COM_DATA_TYPE_REAL USInt 3 Weihenstephan data type Real
LWEIHSTD_COM_DATA_TYPE_ USInt 4 Weihenstephan data type Hex32
HEX32
LWEIHSTD_COM_DATA_TYPE_ USInt 5 Weihenstephan data type String16
STRING16
Siemens AG 2016 All rights reserved

LWEIHSTD_COM_DATA_TYPE_ USInt 253 Internal data type mixed list with tag
MIXED_LIST numbers
LWEIHSTD_COM_DATA_TYPE_ USInt 254 Internal data type list with offset of first
CONT_LIST tag and number of tags (Continuous
list)
LWEIHSTD_COM_DATA_TYPE_ USInt 255 Internal data type list with offsets of all
NON_CONT_LIST tags (Non continuous list)

Table 2-32: Constants for access modes


Name Data type Value Comment
LWEIHSTD_COM_ACCESS_NO USInt 0 No access to tag or list is allowed
LWEIHSTD_COM_ACCESS_READ USInt 1 Only read access to tag or list is
allowed
LWEIHSTD_COM_ACCESS_WRITE USInt 2 Only write access to tag or list is
allowed
LWEIHSTD_COM_ACCESS_RW USInt 3 Read and write access to tag or list
allowed

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 36
2 Blocks of the Library

Table 2-33: Constants for commands


Name Data type Value Comment
LWEIHSTD_COM_CMD_NOOP USInt 1 Value for command NOOP
LWEIHSTD_COM_CMD_READ_ USInt 2 Value for command READ_SVALUE
SVALUE
LWEIHSTD_COM_CMD_WRITE_ USInt 3 Value for command WRITE_SVALUE
SVALUE
LWEIHSTD_COM_CMD_READ_LIST USInt 4 Value for command READ_LIST
LWEIHSTD_COM_CMD_WRITE_LIST USInt 5 Value for command WRITE_LIST
LWEIHSTD_COM_CMD_READ_ USInt 8 Value for command READ_STRING
STRING
LWEIHSTD_COM_CMD_WRITE_ USInt 9 Value for command WRITE_STRING
STRING
LWEIHSTD_COM_CMD_UNDEFINED USInt 0 Undefined command

Server specific user constants in LWeihStd_Server


These constants are necessary for Weihenstephan Server applications.

Table 2-34: Constants for buffer


Siemens AG 2016 All rights reserved

Name Data type Value Comment


LWEIHSTD_SERVER_DIAG_ Int 19 Upper limit of diagnostic buffer array for
BUFFER_UPPER_LIM Weihenstephan blocks
LWEIHSTD_SERVER_SEND_ Int 1024 Length of send buffer for
BUFFER_LEN Weihenstephan functionality
LWEIHSTD_SERVER_RECEIVE_ Int 240 Length of receive buffer for
BUFFER_LEN Weihenstephan functionality

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 37
2 Blocks of the Library

Client specific user constants in LWeihStd_Client


These constants are necessary for Weihenstephan Client applications.

Table 2-35: Constants for buffer


Name Data type Value Comment
LWEIHSTD_CLIENT_DIAG_ Int 19 Upper limit of diagnostic buffer array for
BUFFER_UPPER_LIM Weihenstephan blocks
LWEIHSTD_CLIENT_SEND_ Int 240 Length of send buffer for
BUFFER_LEN Weihenstephan functionality
LWEIHSTD_CLIENT_RECEIVE_ Int 1024 Length of receive buffer for
BUFFER_LEN Weihenstephan functionality

Table 2-36: Constants for requestMode


Name Data type Value Comment
LWEIHSTD_REQUEST_MODE_ USInt 0 Send command list once per trigger
SEQ_TRIG (FB waits for ack from WS Server
before sending next command)
LWEIHSTD_REQUEST_MODE_ USInt 1 Send command list cylic (FB waits for
Siemens AG 2016 All rights reserved

SEQ_CYCLIC ack from WS Server before sending


next command)
LWEIHSTD_REQUEST_MODE_ USInt 2 Send command list blocked per trigger
BLOCK_TRIG (Send as much commands at once as
possible)
LWEIHSTD_REQUEST_MODE_ USInt 3 Send command list blocked cyclic
BLOCK_CYCLIC (Send as much commands at once as
possible)
LWEIHSTD_REQUEST_MODE_ USInt 4 Single triggering (one trigger per
SINGLE_TRIG command)

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 38
3 Working with the Library

3 Working with the Library


What will you find in this section?
This chapter consists of instructions for integrating the 'Communication Protocol'
part of the LWeihStd library into your STEP 7 project and instructions for using the
library blocks.

3.1 Integrating the library into STEP 7


The table below lists the steps for integrating the LWeihStd
library into your STEP 7 project. Subsequently, you can use the blocks of the
LWeihStd library.

Note The following section assumes that a STEP 7 project exists.

Table 3-1: Integrating the library into STEP 7


No. Action
1. Extract the library LWeihStd_V1_x_x.zip to a local folder.
Siemens AG 2016 All rights reserved

2. In TIA Portal select “Options” -> “Global libraries” -> “Open library…”
3. Browse to the file LWeihStd.al13.
It can be found in the subfolder LWeihStd of the extracted zip file.
4. Open the global library in read-only mode.
5. The LWeihStd library is now available in the task card “Global libraries”

3.2 Integrating the library blocks into STEP 7


The table below lists the steps for integrating the blocks of the LWeihStd
library into your STEP 7 program.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 39
3 Working with the Library

Figure 3-1: Integrating the library blocks into STEP 7


Siemens AG 2016 All rights reserved

Table 3-2: Integrating the library blocks into STEP 7


No. Action Note
1. Copy the LWeihStd_Server, LWeihStd_ServerBasic or LWeihStd_Client Copy program blocks
FB in subfolder “02_CommunicationProtocol -> S7-1200/S7-1500 ->
01_Server -> LWeihStd_Blocks or -> 02_Client -> LWeihStd_Blocks”
with Drag & Drop into the “Program blocks” in the PLC.

Copy the necessary common FBs in subfolder


“02_CommunicationProtocol -> S7-1200/S7-1500 -> 00_Common ->
LWeihStd_Blocks” with Drag & Drop into the “Program blocks” in the
PLC.
Alternatively copy the whole folder LWeihStd_Blocks in subfolder
“00_Common“ with Drag & Drop into the “Program blocks” in the PLC.

Note: For a basic server application the LWeihStd_ComWriteDiagBuffer


is not necessary.
2. Copy the folder LWeihStd_Tags in subfolder Copy PLC tags
“02_CommunicationProtocol -> S7-1200/S7-1500 -> 00_Common” and
“01_Server” or “02_Client” with Drag & Drop into the “PLC tags” in the
PLC.
3. Copy the folder LWeihStd_Types in subfolder Copy PLC data types
“02_CommunicationProtocol -> S7-1200/S7-1500 -> 00_Common” and
“01_Server” or “02_Client” with Drag & Drop into the “PLC data types” in
the PLC.
Note: For a basic server application the data types
LWeihStd_typeComDiagnosticEntry and
LWeihStd_typeServerDiagnostics are not necessary.
4. Now the blocks can be configured and called in the user program.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 40
4 Notes and Support

4 Notes and Support


What will you find in this section?
This chapter provides further support in handling the described LWeihStd library.

Note The standard Weihenstephan port number 50000 cannot be used for an S7 with
PN interface because this number is in the range of the dynamically assigned
port numbers (49152 to 65535).
For a successful TCP connection we recommend to use user ports (1024-
49151), e.g. the port number 5000.
See: http://www.iana.org/assignments/service-names-port-numbers/service-
names-port-numbers.xhtml.

4.1 Creating WS_Data and WS_Config DBs


First step is to generate the source file WS_Source_<MachineID>.scl, which
contains all information about the tags and lists. This generation is done by an
external program called WS_TIA_GenTool. This tool can be used to automatically
convert the XML description file (PDACONF.xml) of a machine to the appropriate
source files for your TIA project.
Siemens AG 2016 All rights reserved

Table 4-1 Using WS_TIA_GenTool to generate the necessary source files


No. Action
1. Double-click the WS_TIA_GenTool.exe to start the generation tool. Confirm the disclaimer of
liability and click OK.

2. Browse to the appropriate description file (PDACONF.xml) via clicking the Browse button.
3. Choose a destination path to save the generated source file (WS_Source).
4. In the section MachineID type in a unique name for the accompanying application.
5. When you are finished, click Generate to create the source files for your TIA project.
6. The following source files have been added to your destination path:
WS_Source_<MachineID>.scl

Note Such machine description files (PDACONF.xml) can be generated with the
WS_Edit program.
See http://www.weihenstephaner-standards.de/index.php?id=29&L=1).

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 41
4 Notes and Support

4.1.1 WS_Data (DB304xx) example

The Global DB WS_Data_<MachineID> is generated from an external source file


named WS_Source_<MachineID>.scl. Before using the LWeihStd library it is
necessary to create this source file from a chosen PDACONF.xml and to import it
to the project.

The WS_Data DB contains the Weihenstephan tags (WS tags) corresponding to


the specification in the PDACONF.XML file. Every tag has a unique tag number
and an initial value as seen in the following figure of a sample data block.

Figure 4-1: Example of a Data DB


Siemens AG 2016 All rights reserved

An example of a defined tag in the machine description file (PDACONF.xml) could


be as follows:

The tag “WS_Error” is defined as a HEX32 variable, which is read only tag with the
unique tag number “000000”.

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 42
4 Notes and Support

4.1.2 WS_Config (DB304xx) example

The Global DB WS_Config_<MachineID> is generated from an external source file


named WS_Source_<MachineID>.scl. Before using the LWeihStd library it is
necessary to create this source file from a chosen PDACONF.xml and to import it
to the project.

The WS_Config DB contains administration information such as access rights, data


types and offsets of all tags in the WS_Data DB. Furthermore you can find there
the list information according to Weihenstephan Standards.

Figure 4-2: Example of a Config DB


Siemens AG 2016 All rights reserved

Note The data in the tagInfo array must be sorted according to the tag number in
ascending order. The sorting is automatically done by the WS_TIA_GenTool.

Each element of the tagInfo array contains the tag number, the data offset, the
data type and the access rights of one data point

Note To avoid any incompatibility, invalid data or connection errors it is important not
to modify, add or delete any entries in the WS_Config DB.

4.2 Weihenstephan Standards Test Tool


The Weihenstephan Standards Test Tool provides functionality to simulate a WS
Server as well as a WS Client in accordance with the Weihenstephan Standards
and can be used to test the machine implementation based on LWeihStd library,
see http://www.weihenstephaner-standards.de/index.php?id=27&L=1

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 43
5 Related literature

5 Related literature
Table 5-1
Topic Title / Link
\1\ Siemens Industry http://support.automation.siemens.com
Online Support
\2\ Download page of http://support.automation.siemens.com/ww/view/en/109475571
this entry
\3\ Weihenstephan http://www.weihenstephaner-standards.de/index.php?id=2&L=1
Standards

6 Contact
Siemens AG
Digital Factory Division
Factory Automation
Production Machines
Siemens AG 2016 All rights reserved

DF FA PMA APC
Frauenauracher Str. 80
91056 Erlangen,Germany

mailto: tech.team.motioncontrol@siemens.com

7 History
Table 7-1
Version Date Modifications
V1.0 01/2016 First version

LWeihStd for SIMATIC - Communication Protocol


Entry-ID: 109475571, V1.0, 01/2016 44

Anda mungkin juga menyukai