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...
Extended instructions
9.2 String and character
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
359
9.2.3.3
ATH and HTA (Convert to/from ASCII string and hexadecimal number) instructions
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 9- 40 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 9- 41 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, lower
case a to f, 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 converted into a single byte containing two 4-bit hexadecimal nibbles.
The IN and OUT parameters specify byte arrays and not hexadecimal String data. ASCII
characters are converted and placed in the hexadecimal output in the same order as they
are read. If there are an odd number of ASCII characters, then zeros are put in the right-
most nibble of the last converted hexadecimal digit.
Table 9- 42 Examples: ASCII-to-hexadecimal (ATH) conversion
IN character bytes
N
OUT value
ENO
'0a23'
4
W#16#0A23
TRUE
'123AFx1a23'
10
16#123AF01023
FALSE
'a23'
3
W#16#A230
TRUE

Table of Contents

Other manuals for Siemens SIMATIC S7-1200

Related product manuals