Application of div instruction – KEYENCE Visual KV Series User Manual
Page 182

2.4 Instruction Details
3-158
2
Chapter 2 Instructions
Application of DIV instruction
■ Total count average
Outputs the average of 3 counter values in 4-digit BCD.
(C001 + C002 + C003) ÷ 3
➞ BCD output value
The BCD value is output to 500 to 515.
Coding
C001
LDA
DM0001
STA
0000
C002
LDA
DM0002
STA
0000
C003
LDA
DM0003
STA
0000
DM0001
LDA
DM0002
ADD
DM0003
ADD
2002
#09999
C003
0003
#09999
C001
#09999
0001
0002
C002
(DM0001+DM0002+DM0003)
TM00
STA
#00000
LDA
2002
#00003
DIV
TBCD
0500
STA
2002
÷ 3
➞ Output to 0500 to 0515 in 4-digit BCD.
Writes the C001 current value into DM0001.
Writes the C002 current value into DM0002.
Writes the C003 current value into DM0003.
Line No.
Instruction
Operand
0000
LDB
0000
0001
C
001 #099999 0001
0002
CON
0003
LDA
C001
0004
CON
0005
STA
DM0001
0006
LDB
0000
0007
C
002 #099999 0002
0008
CON
0009
LDA
C002
0010
CON
0011
STA
DM0002
0012
LDB
0000
0013
C
003 #099999 0003
0014
CON
0015
LDA
C003
0016
CON
0017
STA
DM0003
0018
LD
2002
0019
LDA
DM0001
0020
CON
0021
ADD
DM0002
0022
CON
0023
ADD
DM0003
0024
LD
2002
0025
DIV
#0003
0026
CON
0027
TBCD
0028
CON
0029
STA
500
DIV / @DIV
KVNKA Chap 02_4cP.p65
08.3.11, 0:02 PM
158