AVE (average)
The AVE instruction calculates a running average over a number of defined samples and stores the value at each cycle.
Operation details:
- The defined number of samples (N) cannot exceed 127.
- When setting or changing the value for N, set RUN to FALSE, then set it back to TRUE.
- If the RUN command is FALSE (reset mode), the output value is equal to the input value.
- When the maximum number of stored values is reached, the first stored value is erased by the last one.
- Using floating-point data types could result in inaccurate calculations due to the rounding limitations inherent in floating-point mathematics.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the Micro810, L20E, L50E, and L70E controllers.
AVE

Parameter | Parameter Type | Data Type | Description |
---|---|---|---|
RUN | Input | BOOL |
|
XIN | Input | REAL | Any real variable. |
N | Input | DINT | Application defined number of samples. |
XOUT | Output | REAL | Running average of XIN value. |
ENO | Output | BOOL | Enables output. Applies to ladder diagram programs. |
AVE examples
AVE function block diagram example

AVE ladder diagram example

AVE structured text example

(* ST Equivalence: AVE1 an instance of an AVE block *) AVE1((auto_mode & store_cmd), sensor_value, 100); ave_value := AVE1.XOUT;
Provide Feedback