AVERAGE

Stores a value at each cycle and calculates the average value of all stored values. Stores only the latest N values.
The maximum number of samples N is 128. When N exceeds 128, the number of samples is truncated to 128.
If the "RUN" command is FALSE (reset mode), the output value is equal to the input value.
Upon reaching the maximum N of stored values, the first stored value is overwritten with the latest value.
TIP: When setting or changing the value for N, set RUN to FALSE, then set it back to TRUE.
lrsb_av1
Arguments
RUN
BOOL
TRUE=run / FALSE=reset
XIN
REAL
Any real variable
N
DINT
Application defined number of samples
XOUT
REAL
Running average of XIN value
Example
(* FBD program using the AVERAGE block: *)
lrsb_av2
(* ST Equivalence: AVERAGE1 instance of AVERAGE block *)
AVERAGE1((auto_mode & store_cmd), sensor_value, 100); ave_value := AVERAGE1.XOUT;
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal