5 ascii code/binary conversion function, Kv -300 – KEYENCE Visual KV Series User Manual
Page 324
7.7 Non-procedure Mode Programming
KV-300 Series Only
KV
-300
KV-10/80
Chapter 7 KV-L2 Serial Interface Module
1-300
7
7.7.5
ASCII code/Binary Conversion Function
Besides ASC and RASC instructions, the KV-300 CPU has a function to convert a
character string in ASCII code to a binary value, and vice versa. This function helps
simplify programs that convert text data to binary values or binary values to text
data.
ASCII to Binary conversion
All text data fetched at reception can be converted to binary data at one time. To
convert ASCII code to a binary value, use data memory addresses DM9600 and
DM9601 and special utility relay 2314 as follows.
■ Special utility relay 2314
Special utility relay 2314 converts an ASCII string for the scan when it turns ON and
transfers the converted data to data memory for the next scan.
For reception of a converted value, simplify the program by describing a loading
program prior to a conversion program through N.O. contact of 2314. (
➮ Refer to
page 1-301.)
■ Data memory address DM9600
The DM address into which the ASCII string is to be written is specified in DM9600.
For example, when specifying the data loaded upon reception of text data, the first
DM address +1 selected during assignment of data memory addresses (
➮ Refer to
page 1-296) is written here.
■ Data memory address DM9601
The first DM address in which a conveted binary data is written is specified in
DM9601. The converted binary uses three DM addresses, including the first DM
address described above.
Avoid using DM addresses already used by the program.
Set DM addresses to which ASCII code is to be written as follows.
■ ASCII code length
The number of text data bytes loaded during reception of text data is set here. For
example, when a 4-byte ASCII code [30H 31H 32H 40H] is received, [4] is set.
■ ASCII string
Text data is input byte by byte in ASCII for each data memory address. Within data
memory addresses, "00" is loaded to the high-order 8 bits and ASCII code is loaded
to the low-order 8 bits (
➮ Refer to page 1-298).
The binary-converted value is loaded to data memory as follows.
2314
Turn ON to execute conversion (for one scan time).
DM9600
Write the first address of the data memory into which ASCII strings are
to be stored.
DM9601
Write the first address of the data memory addresses into which converted
binary values are to be written.
DM****+0
ASCII code length (text data bytes)
DM****+1
First value of ASCII string (data 1 of text data)
:
:
DM****+99
Last value of ASCII string (data 99 of text data)
DM****+0
Binary high-order 16 bits
DM****+1
Binary low-order 16 bits
DM****+2
Decimal point (0: None, 1 to 99: DM position)
KVHKA Chap 07_5to10.p65
08.3.11, 11:18 AM
300