EasyManua.ls Logo

Omron NJ501-1500

Omron NJ501-1500
990 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
2 Instruction Descriptions
2-388
NJ-series Instructions Reference Manual (W502)
The MovingAverage instruction stores the value of input value In in input value storage array Buf[] each
time it is executed. It stores the average of the stored values in calculation result Out. Specify the maxi-
mum number of elements to include in the average with BufSize.
The processing procedure when BufSize is UINT#3 is described below as an example. The instruction
and statement are written as follows:
The input value storage position CurIndex is set to 0 and the instruction is executed.
Buf[0] to Buf[BufSize
1] of input value storage array Buf[] are cleared to zeros and the first input value
In is stored in Buf[0].
The value of calculation completed flag Q changes to FALSE. This indicates that the number of values
that are stored in Buf[] has not reached BufSize yet.
While the value of Q is FALSE, the average value is calculated for the CurIndex + 1 numbers that start
from Buf[0]. The calculation result is stored in Out.
Finally, the value of CurIndex is incremented.
Function
First Time a Number Is Input
jkl:=MovingAverage(abc, def, ghi[1], UINT#3, mno);
LD ST
jkl
def
ghi[1]
mno
abc
def
ghi[1]
UINT#3
mno
MovingAverage
EN ENO
In
CurIndex
Buf
BufSize
Q
Out=jkl
Q=mno
First Execution of Instruction
The value of
In is stored in Buf[0].
Incremented
Average of Buf[0] to Buf[0]
(i.e., the value of Buf[0])
CurIndex=def
CurIndex=def
In=abc
Cleared to zeros.
FALSE because the number of numbers
stored has not reached BufSize.
Buf[0]=ghi[1]
Buf[1]=ghi[2]
Buf[2]=ghi[3]
1234
0
0
1234
FALSE
0
1
1234

Table of Contents

Related product manuals