Specifications
SIMATIC Instructions
9-135
S7-200 Programmable Controller System Manual
C79000-G7076-C233-01
ASCII to HEX, HEX to ASCII
The ASCII to HEX instruction converts the ASCII string
of length (LEN), starting at IN, to hexadecimal digits
starting at OUT. The maximum length of the ASCII string
is 255 characters.
The HEX to ASCII instruction converts the hexadecimal
digits, starting with the input byte (IN), to an ASCII string
starting at OUT. The number of hexadecimal digits to be
converted is specified by length (LEN). The maximum
number of the hexadecimal digits that can be converted
is 255.
Legal ASCII characters are the hexadecimal values 30 to
39, and 41 to 46.
ASCII to Hex: Error conditions that set ENO = 0:
SM1.7 (illegal ASCII), SM4.3 (run-time),
0006 (indirect address), 0091 (operand out of range)
Hex to ASCII: Error conditions that set ENO = 0:
SM4.3 (run-time), 0006 (indirect address),
0091 (operand out of range)
These instructions affect the following Special Memory
bits: SM1.7 (illegal ASCII)
Inputs/Outputs Operands Data Types
IN, OUT VB, IB, QB, MB, SMB, LB, *VD, *AC, SB, *LD BYTE
LEN VB, IB, QB, MB, SMB, LB, AC, Constant, *VD, *AC, SB, *LD BYTE
ASCII to HEX Example
LAD STL
3
ATH
LEN
OUT VB40
I3.2
EN
VB30 IN
Application
ATH
VB30 33 45 41
VB40 3E AX
Note: The X indicates that the “nibble” (half of a byte)
is unchanged.
LD I3.2
ATH VB30, VB40, 3
FBD
ENO
3
ATH
LEN
OUT VB40
EN
VB30 IN
ENOI3.2
Figure 9-47 Example of ASCII to HEX Instruction
L
A
D
S
T
L
ATH IN, OUT, LEN
HTA IN, OUT, LEN
ATH
EN
IN
LEN
OUT
HTA
EN
IN
LEN
OUT
F
B
D
ENO
ENO
222 224
333
221