2-387
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Conversion Instructions
2
MovingAverage
MovingAverage
The MovingAverage instruction calculates a moving average.
* If you omit the input parameter, the default value is not applied.A building error will occur.
Instruction Name FB/FUN Graphic expression ST expression
MovingAverage Moving Average FUN Out:=MovingAverage(In,
CurIndex, Buf, BufSize, Q);
Variables
Name Meaning I/O Description Valid range Unit Default
In Input value
Input
Number to include in aver-
age
Depends on data type.
---
*
BufSize Maximum
number
stored
Maximum number of ele-
ments to include in average
1
CurIndex Input value
storage
position
In-out
Position in Buf[] in which to
store In
Depends on data type.
--- ---
Buf[]
(array)
Input value
storage
array
Array to store In values
Q Calculation
completed
flag
TRUE: BufSize elements or
more have been stored in
Buf[]
FALSE: BufSize elements
are not yet stored in Buf[]
Out Calculation
result
Output Calculation result Depends on data type. --- ---
Boolean
Bit strings Integers
Real
numbers
Times, durations,
dates, and text strings
BOOL
BYTE
WORD
DWORD
LWORD
USINT
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
LREAL
TIME
DATE
TOD
DT
STRING
In OK OK OK OK OK OK OK OK OK OK
BufSize OK
CurIndex OK
Buf[] (array) Must be an array with elements that have the same data type as In.
QOK
Out OKOKOKOKOKOKOKOKOKOK
(@)MovingAverage
EN ENO
In Out
CurIndex
Buf
BufSize
Q