Hide thumbs Also See for S7-1200:
Table of Contents
Char
Char data occupies one byte in memory and stores a single character coded in ASCII
format. The editor syntax uses a single quote character before and after the ASCII character.
Visible characters and control characters can be used. A table of valid control characters is
shown in the description of the String data type.
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 String[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- 33
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.
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG
Current Character
Character 1
Count
3
Byte 1
Character 2
'C' (16#43)
'A' (16#41)
Byte 2
Byte 3
4.4 Data types
Character 3
...
'T' (16#54)
...
Byte 4
...
PLC concepts
Character 10
-
Byte 11
115
Table of Contents
loading

Table of Contents