Omron SYSMAC CP Series Instruction & Reference Manual page 324

Cpu unit
Hide thumbs Also See for SYSMAC CP Series:
Table of Contents

Advertisement

2 Instructions
Function
For the first N–1 cycles when the execution
condition is ON, AVG(195) writes the values of
S in order to words starting with R+2. The Pre-
vious Value Pointer (bits 00 to 07 of R+1) is
incremented each time a value is written. Until
the Nth value is written, the contents of S will
be output unchanged to R and the Average
Value Flag (bit 15 of R+1) will remain OFF.
When the Nth value is written to R+N+1, the
average of all the values that have been stored
will be computed, the average will be output to
R as an unsigned binary value, and the Aver-
age Value Flag (bit 15 of R+1) will be turned
ON. For all further cycles, the value in R will be
updated for the most current N values of S.
The maximum value of N is 64. If a value
greater than 64 is specified, operation will use
a value of 64.
The Previous Value Pointer will be reset to 0
after N–1 values have been written.
The average value output to R will be rounded
to the nearest integer.
Precautions
The processing information (R+1) is cleared to 0000 each time the execution condition changes from
OFF to ON.
But the processing information (R+1) will not be cleared to 0000 the first time the program is executed
at the start of operation. If AVG(195) is to be executed in the first program scan, clear the First Work
Area Word from the program.
Sample program
When CIO 0.00 is ON in the following example, the contents of D100 will be stored one time each scan
for the number of scans specified in D200. The contents will be stored in order in the ten words from
D302 to D311. The average of the contents of these ten words will be placed in D300 and then bit 15 of
D301 will be turned ON.
0.00
AVG
S
D100
N
D200
R
D300
2-288
S: Source word
R+N+1
S:D100
R:D300
15
R+1:D301
R+2:D302
R+3:D303
R+11:D311
N: Number of cycles
R
R+1
Pointer
Average Valid Flag
R+2
S
Cycle 1
S
Cycle 2
R+3
S
Cycle N
N:D200
0
0
0
8
7
0
Pointer
Average Valid Flag
S, scan 1
S, scan 2
S, scan n
CP1E CPU Unit Instructions Reference Manual(W483)
Average
N values
(10 times)
A
Average

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents