Kv -300 – KEYENCE Visual KV Series User Manual
Page 390

9.5 Programming Examples
KV-10/80 Series Only
KV
-300
KV-10/80
Chapter 9 KV-AD4/DA4 Analog I/O Unit
1-366
9
Outputting Analog Input from a Pressure Sensor to an Air Valve
This sample program outputs analog inputs (1 to 5 V) from a pressure sensor to an
air valve (4 to 20 mA).
Conditions
•
Analog input data is input from analog input V0 on the KV-AD4.
(The digital data of data memory DM0992 is used for this operation.)
•
The data that was input from analog input V0 is converted, and output to analog
output I0 on the KV-DA4. (The digital data is written to data memory DM0996.)
•
When the input data in DM0992 is a low value, the output current is decreased.
When input data in DM0992 is a high value, the output current is increased.
•
Input data 1 V (#2200) in DM0992 is converted to output data 20 mA (#4000) in
DM0996.
•
Input data 5 V (#3000) in DM0992 is converted to output data 4 mA (#0000) in
DM0996.
Ladder diagram
1. The data of DM0992 is calculated, and the calculation result ((DM0992 - 2200) x
5 mV) is written to DM0000.
2. (4095 - DM0000) is calculated, and the calculation result is written to DM0001.
3. Before the digital data is written to data memory for D/A conversion, check that
the data is #4095 or less.
Note: An unsteady value will be output if a value outside the range 0 to 4095 is
written to data memory for D/A conversion.
4. The output data will be updated at the rising edge of special utility relay 2800. (As
internal relay 1000 switches ON/OFF at each scan, the output data will be
updated every two scans.)
Note 1: "2007" (first scan OFF at power ON) must be set as the input condition. In
the case of analog input, an unsteady value will be input for the first scan when the
power is turned ON.
Note 2: In the case of current output, DM0996 need not be initialized (#2000 written
to DM0996) when the power is turned ON.
2007 DM0992
LDA
#02200
SUB
2002 #04000
LDA
1000
DM0000
SUB
DM0000
STA
DM0001
STA
#00005
MUL
1000
1000
2800
2002
2011
DM0001
LDA
#04095
CMP
DM0001
LDA
DM0996
STA
1
2
3
4
( )
( )
KVHKA Chap 09.p65
08.3.11, 11:20 AM
366