EasyManua.ls Logo

Siemens SIMATIC S7-1200

Siemens SIMATIC S7-1200
1614 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
PLC concepts
5.4 Data types
S7-1200 Programmable controller
130 System Manual, V4.2, 09/2016, A5E02486680-AK
5.4.5
Character and String data types
Table 5- 35 Character and String data types
Data type
Size
Range
Constant Entry Examples
Char
8 bits
16#00 to 16#FF
'A', 't', '@', 'ä', '∑'
WChar 16 bits 16#0000 to 16#FFFF 'A', 't', '@', 'ä', '∑', Asian characters, Cyrillic
characters, and others
String
n+ 2 bytes
n = (0 to 254 bytes)
"ABC"
WString n+ 2 words n = (0 to 65534 words) "ä123@XYZ.COM"
Char and WChar
A Char occupies one byte in memory and stores a single character coded in ASCII format,
including the extended ASCII character codes. A WChar occupies one word in memory and
can contain any double-byte character representation.
The editor syntax uses a single quote character before and after the character. You can use
visible characters and control characters.
String and WString
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 bytes in the
string. Each byte in a String data type can be any value from 16#00 - 16#FF.
The WString data type provides for longer strings of one-word (double-byte) values. The first
word contains the maximum total character count; the next word contains the total character
count, and the following string can contain up to 65534 words. Each word in a WString data
type can be any value from 16#0000 - 16#FFFF.
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" or "WString" 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 (String) or words (WString) by entering
square brackets after the keyword "String" or "WString" after you select one of those data
types from the data type drop-down 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 for a string and 65534 for a WString. "MyWString
WString[1000]" would specify a 1000-word WString.

Table of Contents

Other manuals for Siemens SIMATIC S7-1200

Related product manuals