Omron CPM1 - PROGRAMING MANUAL 02-2001 Programming Manual page 495

Hide thumbs Also See for CPM1 - PROGRAMING MANUAL 02-2001:
Table of Contents

Advertisement

Special Math Instructions
Precautions
Flags
Example
00001
The following diagram shows the function of words D to D+N+1.
D
Average value (after N or more executions)
D+1
Used by the system.
D+2
Content of S from the 1
D+3
Content of S from the 2
D+N+1
Content of S from the N
The average value is calculated in binary. Be sure that the content of S is in
binary.
N must be BCD from #0001 to #0064. If the content of N
operate with N=64.
The average value will be rounded off to the nearest integer value. (0.5 is
rounded up to 1.)
Set the contents of D+1 to #0000 to execute AVG(––) from the first scan.
Indirectly addressed DM word is non-existent. (Content of *DM word is
ER:
not BCD, or the DM area boundary has been exceeded.)
One or more operands have been set incorrectly.
D and D+N+1 are not in the same data area.
In the following example, the content of IR 200 is set to #0000 and then increm-
ented by 1 each cycle. For the first two cycles, AVG(––) moves the content of
IR 200 to DM 1002 and DM 1003. On the third and later cycles AVG(––) calcu-
lates the average value of the contents of DM 1002 to DM 1004 and writes that
average value to DM 1000.
@MOV(21)
#0000
200
AVG(––)
200
#0003
DM 1000
CLC(41)
ADB(50)
200
#0001
200
st
1
cycle
IR 200
0000
st
1
cycle
DM 1000
0000
DM 1001
DM 1002
0000
DM 1003
---
DM 1004
---
st
execution of AVG(––)
nd
execution of AVG(––)
th
execution of AVG(––)
Address Instruction
00000
LD
00001
@MOV(21)
00002
AVG(––)
00003
CLC(41)
00004
ADB(50)
nd
rd
th
2
cycle
3
cycle
4
cycle
0001
0002
0003
nd
rd
th
2
cycle
3
cycle
4
cycle
0001
0001
0002
0000
0000
0003
0001
0001
0001
---
0002
0002
Section
7-23
#0065, AVG(––) will
Operands
00001
#
0000
200
200
#
0003
DM
1000
200
#
0001
200
Average
Used by the system.
Previous
values of
IR 200
477

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the CPM1 - PROGRAMING MANUAL 02-2001 and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents