309
Special Math Instructions Section 5-22
When bit 15 of C is OFF, data within the range is treated as unsigned binary
and when it is ON the data is treated as signed binary.
!Caution If bit 14 of C is ON, values above #8000 are treated as negative numbers, so
the results will differ depending on the specified data type. Be sure that the
correct data type is specified.
Flags ER: Indirectly addressed DM word is non-existent. (Content of *DM word
is not BCD, or the DM area boundary has been exceeded.)
R
1
and R
1
+N–1 are not in the same data area.
EQ: ON when the minimum value is #0000.
5-22-3 AVERAGE VALUE – AVG(––)
Limitations This instruction is available in the CQM1 only.
S must be hexadecimal.
N must be BCD from #0001 to #0064.
D and D+N+1 must be in the same data area.
DM 6144 to DM 6655 cannot be used for S, N, or D to D+N+1.
Description AVG(––) is used to calculate the average value of S over N cycles.
When the execution condition is OFF, AVG(––) is not executed.
Each time that AVG(––) is executed, the content of S is stored in words D+2 to
D+N+1. On the first execution, AVG(––) writes the content of S to D+2; on the
second execution it writes the content of S to D+3, etc. On the N
th
execution,
AVG(––) writes the content of S is stored in D+N+1, AVG(––) calculates the
average value of the values stored in D+2 to D+N+1, and writes the average
to D.
15 14 13 12 11 00
Data type
1 (ON): Signed binary
0
Number of words
in range (N)
Not used – set to zero.
Output address to D+1?
1 (ON): Yes.
0 (OFF): No.
C:
S: Source word
IR, SR, AR, DM, HR, TC, LR
N: Number of cycles
IR, SR, AR, DM, HR, TC, LR, #
Ladder Symbols
Operand Data Areas
D: First destination word
IR, SR, AR, DM, HR, LR
AVG(––)
S
N
D