Program instructions
7.5 Convert
S7-200 SMART
240
System Manual, V2.3, 07/2017, A5E03822230-AF
7.5.2
ASCII character array conversion
Converting from or to ASCII character byte arrays
The ASCII character array instructions use the BYTE data type for character input or output.
An array of ASCII characters is referenced a sequence of byte addresses.
This is not the STRING data type, as no length byte is used. Use the ASCII string
instructions to work with the variables of the STRING data type.
ASCII to Hex and Hex to ASCII
LAD / FBD
STL
Description
ATH IN, OUT, LEN
HTA IN, OUT, LEN
ATH converts a number LEN of ASCII characters, starting at IN, to hexadec-
imal digits starting at OUT. The maximum number of ASCII characters that
can be converted is 255 characters.
HTA converts the hexadecimal digits, starting with the input byte IN, to ASCII
characters starting at OUT. The number of hexadecimal digits to be convert-
ed is assigned by length LEN. The maximum number of ASCII characters or
hexadecimal digits that can be converted is 255.
Valid ASCII input characters are the alphanumeric characters 0 to 9 with a
hexadecimal code value of 30 to 39, and uppercase characters A to F with a
hex code value of 41 to 46.
Non-fatal error conditions with ENO = 0
SM bits affected
•
0006H Indirect address
•
0091H Operand out of range
•
SM1.7 ATH: Illegal ASCII value
•
SM1.7 ATH: Illegal ASCII value
Input / output
Data type
Operand
IN, OUT
BYTE
IB, QB, VB, MB, SMB, SB, LB, *VD, *LD, *AC
LEN
BYTE
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant