Computation Of Running Average - Campbell CR510 Operator's Manual

Datalogger
Hide thumbs Also See for CR510:
Table of Contents

Advertisement

SECTION 8. PROCESSING AND PROGRAM CONTROL EXAMPLES
The following examples are intended to illustrate the use of Processing and Program Control
Instructions, flags, dual Final Storage, and the capability to direct the results of Output Processing
Instructions to Input Storage.
The specific examples may not be as important as some of the techniques employed, for example:
Directing Output Processing to Input Storage is used in the Running Average and Rainfall Intensity
examples (8.1 and 8.2).
Flag tests are used in the Running Average, Interrupt Subroutine, Converting Wind Direction, and
Saving Data Prior to Event examples (8.1, 8.5, 8.7 and 8.8).
An algorithm for a down counter is used in the Saving Data Prior to Event example (8.8).
As in Section 7 these examples are not complete programs to be taken verbatim. They need to be
altered to fit specific needs.
8.1 COMPUTATION OF RUNNING
AVERAGE
It is sometimes necessary to compute a running
average (i.e., the average covers a fixed
number of samples and is continuously updated
as new samples are taken). Because the
output interval is shorter than the averaging
period, Instruction 71 cannot be used; the
algorithm for computing this average must be
programmed by the user. The following
example demonstrates a program for
computing a running average.
In this example, each time a new measurement
is made (in this case the CR510 internal
temperature) an average is computed for the 10
most recent samples. This is done by saving all
10 temperatures in contiguous input locations
and using the Spatial Average Instruction (51)
to compute the average. The temperatures are
stored in locations 2 through 11. Each time the
table is executed, the new measurement is
stored in location 11 and the average is stored
in location 1. The Block Move Instruction (54) is
then used to move the temperatures from
locations 3 through 11 down by 1 location; the
oldest measurement (in location 3) is lost when
the temperature from location 4 is written over
it.
PROGRAM
*
Table 1 Program
01:
10.0
Execution Interval (seconds)
01:
Internal Temperature (P17)
1: 11
Loc [ Temp_i ]
02:
Spatial Average (P51)
1: 10
Swath
2:
2
First Loc [ Temp_i_9 ]
3:
1
Avg Loc [ Av_10smpl ]
03:
Block Move (P54)
1:
9
No. of Values
2:
3
First Source Loc [ Temp_i_8 ]
3:
1
Source Step
4:
2
First Destination Loc [ Temp_i_9 ]
5:
1
Destination Step
04:
Do (P86)
1: 10
Set Output Flag High
05:
Sample (P70)
1:
1
Reps
2:
1
Loc [ Av_10smpl ]
INPUT LOCATIONS
1 Av_10smpl
7 Temp_i_4
2 Temp_i_#9
8 Temp_i_3
3 Temp_i_8
9 Temp_i_2
4 Temp_i_7
10 Temp_i_1
5 Temp_i_6
11 Temp_i
6 Temp_i_5
8-1

Advertisement

Table of Contents
loading

Table of Contents