101BExtended instructions
8.2 String and character
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
251
Parameter and type
Data type
Description
Chars
IN_OUT
Variant
The Chars parameter is a pointer to zero based array [0..n] of
characters copied from the input string. The array can be
declared in a DB or as local variables in the block interface.
Example: "DB1".MyArray points to MyArray [0..10] of Char
element values in DB1.
Cnt
OUT
UInt
Count of characters copied
Table 8- 41 ENO status
ENO
Description
1
No error
0
Chars_TO_Strg: Attempt to copy more character bytes to the output string than allowed by the maximum
length byte in the string declaration
0
Chars_TO_Strg: The nul character (16#00) value was found in the input character byte array.
0
Strg_TO_Chars: Attempt to copy more character bytes to the output array than are allowed by the element
number limit
8.2.3.3
ASCII to Hex and Hex to ASCII conversions
Use the ATH (ASCII to hexadecimal) and HTA (hexadecimal to ASCII) instructions for
conversions between ASCII character bytes (characters 0 to 9 and uppercase A to F only)
and the corresponding 4-bit hexadecimal nibbles.
Table 8- 42 ATH instruction
LAD / FBD
SCL
Description
ret_val := ATH(
in:=_variant_in_,
n:=_int_in_,
out=>_variant_out_);
Converts ASCII characters into packed hexadecimal digits.
Table 8- 43 Data types for the ATH instruction
Parameter type
Data Type
Description
IN
IN
Variant
Pointer to ASCII character byte array
N
IN
UInt
Number of ASCII character bytes to convert
RET_VAL
OUT
Word
Execution condition code
OUT
OUT
Variant
Pointer to the converted hexadecimal byte array
Conversion begins at the location specified by parameter IN and continues for N bytes. The
result is placed at the location specified by OUT. Only valid ASCII characters 0 to 9 and
uppercase A to F can be converted. Any other character will be converted to zero.
8-bit ASCII coded characters are converted to 4-bit hexadecimal nibbles. Two ASCII
characters can be stored in a single byte.