×
Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 42002283, Entry date: 03/24/2010
(3)
Rate

How do you compensate for the string mismatch caused by the RCV_PTP and SEND_PTP blocks?

  • Entry
  • Associated product(s)

Description
When dealing with string tags, the PTP (point-to-point) communication blocks ignore the specific properties of maximum string length and actual string length (Fig.01).
When writing data to a string tag, the RCV_PTP block will overwrite the string header data (Fig.02).
When reading data from a string tag, the SEND_PTP block will read the string header information as part of the virtual string data and send them as well (Fig.03).

Structure of a string tag
A string tag in STEP 7 Basic consists of three parts:

  • Maximum length of the string
  • Actual length of the string
  • Virtual string data


Fig. 01

From the point of view of PTP communication, a string tag consists of the virtual string data only.

Characteristics of the RCV_PTP block
The RCV_PTP block writes the received virtual string data to the prepared string tag in the S7-1200 PLC, without the necessary length data in the first two bytes. As a result, the processing of this data cannot be continued, due to the nonexistent string tag header.


Fig. 02

Characteristics of the SEND_PTP block
The SEND_PTP block reads the requested string data including the string header data, which are sent as the first two bytes of the requested data string.

 
Fig. 03

Preconditions

  • The data block (DB), in which the string tag is created, needs to be "non-symbolic".
  • Absolute addressing of the buffer is required.
Creating a string tag in a non-symbolic data block
Browse the "Project tree" and double-click the item "Add new block" of your PLC. In the "Add new block" dialog window, click the "Data Block (DB)" button and uncheck the checkbox "symbolic access only". To match the absolute addresses used in this example, set the number of this data block manually to "2". Click the "OK" button.


Fig. 04

Browse the "Project tree", and double-click the data-block "Data_block_2 (DB2)". In the "Static" column of the table, enter a tag with a  "String[8]" data type.


Fig.05

Compensation of string mismatch using the RCV_PTP block
For compensation, the string length information has to be handled separately.
In this example, a string tag with a length of eight bytes is used.
 

No. Compensation of string mismatch using the RCV_PTP block
1. Write the virtual string data into the string tag
To keep the string header data, the received virtual string data needs to be written in the string tag starting at the third byte. Absolute addressing of the buffer makes thsi possible.
In this example, the string tag has a length of eight bytes. It begins at offset 10.0 (DB2.DBBX10.0), so the virtual string data begins at offset 12.0 (DB2.DBBX12.0).

The address expression consists of the following items:

  • Pointer "P#".
  • Absolute address of the 1st bit of the 3rd byte, (for example DB2.DBX12.0).
  • Number of bytes you want to write into the string tag, separated by a blank. This should be the maximum length of  the string tag (for example BYTE 8).


Fig. 06

2.

 Copy the maximum and actual string length into the string header


Fig. 07

Note
Before you copy the "actual length" value, you need to convert its data type from UINT to BYTE.

Table 01

Compensation of string mismatch using the SEND_PTP block
For compensation, the string length information has to be handled separately.
In this example, a string tag with a length of eight bytes is used.
 

No. Compensation of string mismatch using the SEND_PTP block
1. Replace the actual string length in the SEND_PTP block


Fig. 08

Note
Before you replace the "#length" value, you need to convert its data type from BYTE to UINT.

2.

 Read the virtual string data from the string tag
To prevent the string header data from being sent, the SEND_PTP block needs to start reading at the 3rd byte of the string tag. Absolute addressing of the buffer makes this possible.
In this example, the string tag has a length of eight bytes. It begins at offset 10.0 (DB2.DBBX10.0), so the virtual string data begins at offset 12.0 (DB2.DBBX12.0).

The address expression is similar to the expression used in table 01, Figure 06.


Fig. 09

Table 02

Requirements

  • S7-1200 PLC
  • Ethernet cable
  • PC / PG with Ethernet interface
  • STEP 7 Basic V10.5

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit
https://www.siemens.com/cybersecurity#Ouraspiration.
Rate entry
no rating
Requests and feedback
What do you want to do?
Note: The feedback always relates to the current entry / product. Your message will be forwarded to our technical editors working in the Online Support. In a few days, you will receive a response if your feedback requires one. If we have no further questions, you will not hear from us.