Siemens string data types and string function

Published on Jul20, 2021 | Category: data type
Share this article:

string data type store character . range of character for string data types is 0 to 255. in brackets you can declare range of character.siemens Complex data types . string is one dimensional array with a maximum 254 character.

Format of the Data Type STRING

string data type declaration

make a data block (DB) declare string data types with length and save the data block.

img/string/stringdatatypeac.webp

string function block

Following iec string blocks available in siemens, for inserting theses blocks go to projectr > libraries > IEC than select your string block

some of the example of string function blocks

siemens LEN function block FC 21 : LEN

A STRING variable contains two lengths, the maximum length which is given in square brackets when the variables are being defined, and the current length which is the number of currently valid characters. The current length must be smaller than or equal to the maximum length. The number of bytes occupied by a string is 2 greater than the maximum length. The function FC21 outputs the current length of a string as a return value. A blank string (' ') has the length zero. The maximum length is 254. The function does not report any errors.

img/string/fc21stringlen.webp

siemens equal string function block FC10 EQ_STRNG

FC10 blocks is string comparison block it compares two input string if both input sting is equal than it return 1 at the output (RET_VAL) otherwise 0.

img/string/fc10stringequ.webp

siemens find function block FC11 FIND

The function FC11 provides the position of the second string (IN2) within the first string (IN1). The search starts on the left; the first occurrence of the string is reported. If the second string is not found in the first, zero is returned. The function does not report any errors.

img/string/findstringfc11.webp

siemens greater than equal to FC13 GE_STRNG

FC13 is a string comparison blocks, if string value of S1 is greater than or equal to the string value of S2 than output RET_VAL is 1 otherwise 0.

img/string/fc13gtstringblocks.webp