KEYENCE Visual KV Series User Manual
Page 168

2.4 Instruction Details
3-144
2
Chapter 2 Instructions
■ When a BCD (2-digit) digital switch is connected to inputs 0000 through
0007 and a toggle switch is connected to inputs 0008 through 0015
a)
Use the value of the digital switch (2 digits) as the setting value of a counter
(C001).
b) The current value of the counter (C001) is output to 0500 to 0515 using BCD
output.
Coding
Description
•
In example
a)
, the LDA instruction reads the ON/OFF status of input relays 0000
through 0015 to the internal register.
•
"ANDA $00FF" instruction is used to leave only the digital switch input (2 digits).
•
BCD data is then converted into BIN (binary) data. (BIN is used in the KV series.)
•
The contents of the internal register is input as the setting value of C001.
•
In example
b)
, the current value of counter C001 is read and output to output
relays 0500 through 0515.
Note 1: An LDA instruction can read the current value of a counter or a timer, but
cannot read the setting value.
Note 2: An STA instruction can change the setting value of a counter or a timer, but
cannot change the current value.
(C001)
<59>
2
0
+ 2
1
+ 2
3
+ 2
4
+ 2
5
= 1 + 2 + 8 + 16 + 32 = 59
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
D10
D11
D12
D13
D14
D15
D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
D10
D11
D12
D13
D14
D15
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
C001
1
1
0
1
1
1
0
0
0
0
0
0
0
0
0
0
1
0
0
1
1
0
1
0
0
0
0
0
0
0
0
0
$00FF
1
0
0
1
1
0
1
0
0
1
1
1
0
0
0
0
ON
OFF
OFF
ON
ON
OFF
ON
OFF
OFF
ON
ON
ON
OFF
OFF
OFF
OFF
000
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
07000
(Decimal
number)
Digital switch
Reset input
Proximity
SW input
SW input
Internal register
Counter
setting
value
ON/OFF
status is
trans-
ferred to
internal
register.
Only low-
order 2
digits is
used.
BCD
data is
converted
into binary
data.
Data is
transferred
as setting
value of
counter.
0008
0010
0000
LDA
$00FF
ANDA
TBIN
C001
STA
#09999
C001
0009
0011
C001
LDA
TBCD
0500
STA
b)
a)
Line No.
Instruction
Operand
0000
LDB
0008
0001
C
001 #09999 0009
0002
LD
0010
0003
LDA
0000
0004
CON
0005
ANDA
$00FF
0006
CON
0007
TBIN
0008
CON
0009
STA
C001
0010
LD
0011
0011
LDA
C001
0012
CON
0013
TBCD
0014
CON
0015
STA
0500
LDA / @LDA / STA @STA
KVNKA Chap 02_4cP.p65
08.3.11, 0:02 PM
144