6 reading analog input, Kv -300 – KEYENCE Visual KV Series User Manual
Page 349

8.4 Programming
KV-300 Series Only
KV
-300
KV-10/80
Chapter 8 KV-AN6 Analog I/O Module
1-325
1
8
8.4.6
Reading Analog Input
The following example describes how to read analog input.
Example
This program reads data from analog input ch. 0 of the KV-AN6 module no. 1, and
writes positive data into DM0000 and negative data into DM0001. (The data value
up to the second decimal position is written.)
Input range of ±10 V is used.
Input of +10 V is stored as 1000 into DM0000, and input of -10V is stored as 1000
into DM0001 (data value x 100).
Ladder diagram
➮ For assignment of data memory addresses, refer to page 1-324.
Example
■ Conversion tip
Conversion from hexadecimal data to decimal data
Example: Convert 7D00H (in hexadecimal) to a decimal value
7 x 16 3 + D x 16 2 + 0 x 16 1 + 0 x 16 0 = 28672 + 3328 + 0 + 0 = 32000
(in decimal)
2002
2009
DM9000
LDA
$8000
CMP
2009
COM
#00001
ADD
#00016
DIV
DM0001
STA
#00005
MUL
DM0000
STA
>
<
#00016
DIV
#00005
MUL
DM9000
Analog input:
KV-AN6
module no. 1,
input ch. 0
Result of
$8000
When analog input is positive
DM9000/#16 x 5 mV —> DM0000
When analog input is negative
(Reversed bit of DM9000 + #1)/#16 x 5 mV —> DM0001
Analog input
→
Analog input +10 V (±10 V range)
D15 D14 D13 D12 D11 D10 D09 D08 D07 D06 D05 D04 D03 D02 D01 D00
0
1
1
1
1
1
0
1
0
0
0
0
0
0
0
0
7
D
0
0
DM9000 data
32000
32000/16 x 5 = 10000 —> Written into DM0000.
10.000 V (Up to the third decimal position)
Convert to decimal:
Analog input -10 V (±10 V range)
32000/16 x 5 = 10000 —> Written into DM0001.
10.000 V (Up to the third decimal position)
→→
→
KVHKA Chap 08.p65
08.3.11, 11:19 AM
325