683
3. Instructions
CS/CJ/NSJ Series Instructions Reference Manual (W474)
Data Control Instructions
3
AVG
AVG
Applicable Program Areas
Operands
N: Number of Cycles
The number of cycles must be between 0001 and 0040 hexadecimal (0 to 64 cycles).
R: Result First Word and R+1: First Work Area Word
Note R to R+N+1 must be in the same area.
z Operand Specifications
Flags
Instruction Mnemonic Variations
Function
code
Function
AVERAGE AVG --- 195
Calculates the average value of an input word for
the specified number of cycles.
Symbol
AVG
Area
Function block
definitions
Block program areas Step program areas Subroutines Interrupt tasks
SFC action or
transition programs
Usage OK OK OK OK OK OK
Operand Description Data type Size
S Source word UINT 1
N Number of cycles UINT 1
R Result first word UINT Variable
Area
Word addresses
Indirect DM/EM
addresses
Con-
stants
Registers Flags
Pulse
bits
TR
bits
CIO WR HR AR T C DM EM
@DM
@EM
*DM
*EM
DR IR
Indirect
using IR
TK CF
S, N
OK OK OK OK OK OK OK OK OK OK
OK OK
--- OK --- --- --- ---
R --- ---
Name Label Operation
Error Flag ER • ON if the contents of N is 0.
• OFF in all other cases.
S: Source word
N: Number of cycles
R: Result first word
AVG(195)
S
N
R
R+1
R+2:
15 014
R+N+1:
Used by system.
Previous value #1
Previous value #N
R: Average
R+1: Processing information
Average Valid Flag
OFF: Not valid (AVG(195) has not yet been executed the specified number of cycles.)
ON: Valid.