## Moving Average (MA) Filter
SubVI_moving_average_filter.vi
It is a recursive (or online, or real-time) moving average filter
implemented as a sub-VI. The filter output is calculated with out_k = (1 - a)*out_km1 +
a*in_k where a = 1/N where N = t_ma/dt + 1 Above: ·
in_k is filter input at
time index k (“now”). ·
out_k is filter output at
time index k (“now”). ·
out_km1 is filter output at
time index k-1 (“km1 = k minus 1”, i.e. previous time index). ·
dt is the time step
(sampling time). ·
t_ma [s] is the filter time
window. The smallest value of t_ma is 0 implying the filter does not filter. ·
N is the filter length
(number of samples to be averaged). ·
a is a filter parameter. This MA filter is identical to a time constant filter if
the filter time window (t_ma) is identical to the filter time constant, and
the time steps of both filters are equal.
Inputs: ·
in_k ·
t_ma ·
dt [s] Outputs: ·
out_k ·
N ·
a
1.
Save the subVI file to any
folder (do not open it directly in LabVIEW). 2.
Add the subVI to the block
diagram of your VI via
To increase the filtering (smoothing), increase t_ma. Updated 4
March 2022 by Finn Aakre Haugen |