Siemens SIMATIC S7 System Manual page 91

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

String
The CPU supports the String data type for storing a sequence of single-byte characters. The
String data type contains a total character count (number of characters in the string) and the
current character count. The String type provides up to 256 bytes for storing the maximum
total character count (1 byte), the current character count (1 byte), and up to 254 characters,
with each character stored in 1 byte.
You can use literal strings (constants) for instruction parameters of type IN using single
quotes. For example, 'ABC' is a three-character string that could be used as input for
parameter IN of the S_CONV instruction. You can also create string variables by selecting
data type "String" in the block interface editors for OB, FC, FB, and DB. You cannot create a
string in the PLC tags editor.
You can specify the maximum string size in bytes by entering square brackets after the
keyword "String" (once the data type "String" is selected from a data type drop-list). For
example, "MyString[10]" would specify a 10-byte maximum size for MyString. If you do not
include the square brackets with a maximum size, then 254 is assumed.
The following example defines a String with maximum character count of 10 and current
character count of 3. This means the String currently contains 3 one-byte characters, but
could be expanded to contain up to 10 one-byte characters.
Table 4- 23
Example of a String data type
Total Character
Count
10
Byte 0
ASCII control characters can be used in Char and String data. The following table shows
examples of control character syntax.
Table 4- 24
Valid ASCII control characters
Control characters
$L or $l
$N or $n
$P or $p
$R or $r
$T or $t
$$
$'
Arrays
You can create an array that contains multiple elements of the same data type. Arrays can
be created in the block interface editors for OB, FC, FB, and DB. You cannot create an array
in the PLC tags editor.
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
Current Character
Character 1
Count
3
'C' (16#43)
Byte 1
ASCII Hex value
0A
0A and 0D
The new line shows two characters in the
0C
0D
09
24
27
Character 2
'A' (16#41)
Byte 2
Byte 3
Control function
Line feed
Line break
string.
Form feed
Carriage return (CR)
Tab
Dollar sign
Single quote
97BPLC concepts
4.4 Data types
Character 3
...
'T' (16#54)
...
Byte 4
...
Examples
'$LText', '$0AText'
'$NText', '$0A$0DText'
'$PText', '$0CText'
'$RText','$0DText'
'$TText', '$09Text'
'100$$', '100$24'
'$'Text$'','$27Text$27'
Character 10
-
Byte 11
91

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-1200

Table of Contents