Campbell Scientific CR6 CR6 Measurement and Control System - Page 193
Data Output: Calculating Running Average
![]() |
View all Campbell Scientific CR6 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 193 highlights
Section 7. Installation BeginProg Scan(1,Sec,0,0) A() = 1 'set all elements of 1D array or first dimension to 1 B(1,1)() = 100 'set B(1,1) and B(1,2) to 100 B(-2,1)() = 200 'set B(2,1) and B(3,1) to 200 B(-2,2)() = 300 'set B(2,2) and B(3,2) to 300 C(1,-1,1)() = A() 'copy A(1), A(2), and A(3) into C(1,1,1), C(1,2,1), and C(1,3,1), 'respectively C(2,-1,1)() = A() * 1.8 + 32 'scale and then copy A(1), A(2), and A(3) into C(2,1,1), 'C(2,2,1), and C(2,3,1), respectively 'scale the first column of Da by corresponding multiplier and offset 'copy the result into the first column of Db 'then set second column of Db to NAN Db(-1,1)() = Da(-1,1)() * DMultiplier() + DOffset() Db(-1,2)() = NAN NextScan EndProg 7.9.6 Data Output: Calculating Running Average The AvgRun() instruction calculates a running average of a measurement or calculated value. A running average (Dest) is the average of the last N values where N is the number of values, as expressed in the running-average equation: where XN is the most recent value of the source variable and XN-1 is the previous value (X1 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. The figure Running-Average Frequency Response (p. 195) is a graph of signal attenuation plotted against signal frequency normalized to 1/(running average 193
![](/manual_guide/products/campbell-scientific-cr6-cr6-measurement-control-a476969/193.png)