Campbell Scientific CR1000 Measurement and Control System User Manual
Page 264

Section 7. Installation
264
where X
N
is the most recent value of the source variable and X
N-1
is the previous
value (X
1
is the oldest value included in the average, i.e., N-1 values back from
the most recent). NANs are ignored in the processing of AvgRun() unless all
values in the population are NAN.
AvgRun() uses high-precision math, so a 32-bit extension of the mantissa is saved
and used internally resulting in 56 bits of precision.
Note This instruction should not normally be inserted within a For/Next
construct with the
Source
and
Destination
parameters indexed and
Reps
set to
1
.
Doing so will perform a single running average, using the values of the different
elements of the array, instead of performing an independent running average on
each element of the array. The results will be a running average of a spatial
average of the various source array elements.
A running average is a digital low-pass filter; its output is attenuated as a function
of frequency, and its output is delayed in time. The amounts of attenuation and
phase shift (time delay) depend on the frequency of the input signal and the time
length (which is related to the number of points) of the running average.
Figure Running-Average Frequency Response
(p. 265)
is a graph of signal
attenuation plotted against signal frequency normalized to 1/(running average
duration). The signal is attenuated by a synchronizing filter with an order of 1
(simple averaging): Sin(πX) / (πX), where X is the ratio of the input signal
frequency to the running-average frequency (running-average frequency = 1 /
time length of the running average).
Example:
Scan period = 1 ms,
N value = 4 (number of points to average),
Running‐average duration = 4 ms
Running‐average frequency = 1 / (running‐average duration = 250 Hz)
Input‐signal frequency = 100 Hz
Input frequency to running average (normalized frequency) = 100 / 250
= 0.4
Sin(0.4π) / (0.4π) = 0.757 (or read from figure Running‐Average
Frequency Response
(p. 265),
where the X axis is 0.4)
For a 100‐Hz input signal with an Amplitude of 10‐V peak to peak, a
running average outputs a 100‐Hz signal with an amplitude of 7.57‐V
peak to peak.
There is also a phase shift, or delay, in the AvgRun() output. The formula for
calculating the delay, in number of samples, is:
Delay in samples = (N‐1)/2