Strings; Determining Offset Addresses For Data Block Structures - Siemens SINUMERIK 828D Function Manual

Hide thumbs Also See for SINUMERIK 828D:
Table of Contents

Advertisement

Code
+AR1 AR2;
L
DIW [AR1, P#0.0];
END_FUNCTION_BLOCK
13.15.4

Strings

The STRING data type is required by certain services of the basic program. For this reason, some additional
facts about the string structure and general handling procedures for parameter assignments are given below.
Structure of strings
A data of type STRING is generally stored (defined) in a data block. There are two methods of defining a string:
1. Only the data type STRING is assigned to a variable. The STEP7 compiler automatically generates a length
of 254 characters.
2. Data type STRING is assigned to a variable together with a string length in square parenthesis (e.g. [32]).
With this method, the STEP7 compiler generates a string length corresponding to the input.
Two bytes more than prescribed by the definition are always stored for variables of the STRING data type. The
STEP 7 compiler stores the maximum possible number of characters in the 1st byte. The 2nd byte contains the
number of characters actually used. Normally, the useful length of the assigned strings is stored by the STEP 7
compiler. The characters (1 byte per character) are then stored from the 3rd byte onwards.
String parameters are generally assigned to blocks of the basic program by means of a POINTER or ANY. Such
assignments must generally by made using symbolic programming methods. The data block, which contains the
parameterizing string, must be stored in the symbol list. The assignment to the basic program block is then made
by means of the symbolic data block name followed by a full stop and the symbolic name of the string variable.
13.15.5

Determining offset addresses for data block structures

Function
Another task, which occurs frequently, is symbolic determination of an offset address within a structured DB, e.g.
an ARRAY or STRUCTURE is stored somewhere within the DB. After loading the address register symbolically
with the start address, you might like to access the individual elements of the ARRAY or STRUCTURE via an
address register. One way of loading the address register symbolically is to use an FC whose input parameter is
a pointer. The address of the ARRAY or STRUCTURE is then assigned symbolically to the input parameter of
this FC in the program. The program code in the FC now determines the offset address from the input parameter,
and passes the offset address in the address register (AR1) to the calling function. Symbolic addressing is thus
possible even with indirect access.
Basic Functions
Function Manual, 09/2011, 6FC5397-0BP40-2BA0
P3: Basic PLC Program for SINUMERIK 840D sl
Comment
//AR2 instance offset to be added
//You can now indirectly access the ARRAY
//of variable 1 via AR1.
//E.g. access to the first element
13.15 Programming tips with STEP 7
1083

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sinumerik 840d sl

Table of Contents