Omron CJ - REFERENCE MANUAL 10-2009 Reference Manual page 714

Table of Contents

Advertisement

3. 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
Previous 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
Average 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
CIO 302 to CIO 311. The average of the contents of these ten words will be placed in CIO 300 and then
bit 15 of CIO 301 will be turned ON.
0.00
S
N
R
676
S: D100
D100
D200
300
S: Source word
R
R+1
Average Valid Flag
R+2
S
R+3
S
S
R+N+1
N: D200
R: CIO 300
R+1: CIO 301
Pointer
Average Valid Flag
S, scan 1
R+2: CIO 302
S, scan 2
R+3: CIO 303
S, scan n
R+11: CIO 311
CS/CJ/NSJ Series Instructions Reference Manual (W474)
N: Number of cycles
Pointer
Average
Cycle 1
Cycle 2
N values
Cycle N
(10 times)
Average

Advertisement

Table of Contents
loading

Table of Contents