Ascii To Hex And Hex To Ascii Conversions - Siemens SIMATIC S7 System Manual

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

Parameter and type
Chars
IN_OUT
Cnt
OUT
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
ret_val := ATH(
Table 8- 43
Data types for the ATH instruction
Parameter type
IN
IN
N
IN
RET_VAL
OUT
OUT
OUT
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.
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
Data type
Variant
UInt
in:=_variant_in_,
n:=_int_in_,
out=>_variant_out_);
Data Type
Variant
UInt
Word
Variant
Description
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.
Count of characters copied
Description
Converts ASCII characters into packed hexadecimal digits.
Description
Pointer to ASCII character byte array
Number of ASCII character bytes to convert
Execution condition code
Pointer to the converted hexadecimal byte array
101BExtended instructions
8.2 String and character
251

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-1200

Table of Contents