4 data output processing instructions, 9 measurement timing and processing – Campbell Scientific CR9000X Measurement and Control System User Manual
Page 152

Section 4. CRBasic – Native Language Programming
4.2.8.4 Data Output Processing Instructions
The output processing instructions included in a data table declaration
determine the values that are stored to the data table. The most commonly used
output processing instructions are Average, Maximum, Minimum, and Sample.
The table must be called by the program, using the CallTable instruction,
in order for the output processing to take place. When the Data Table is
called via the CallTable instruction, the data storage processing instructions
process the variables' current values. If the trigger conditions for the Table are
true, the processed values are stored to the data table and the output processing
is reset.
See Section 6.4 Output Processing for information on Data Processing
instructions.
Average is an output processing instruction that will output the average of a
variable over the output interval. The parameters are repetitions - the number of
elements in an array for which to calculate the averages, the Source variable or
array to average, the data format (see Table 4.5-1) to store the result in, and a
disable variable that allows excluding readings from the average if conditions
are not met. A reading will not be included in the average if the disable
variable is not equal to 0. In the following program snippet, averages for the
RefTemp variable, and the 6 elements of the TC() variable array are stored to
the Data Table as a single record every 100 milliseconds.
When using an Output processing instruction like Average, the table
should be called more frequently than Table output occurs so that more
than one value will be included in the average computation. For instance, in
Example 4.2.8-4, the Table output rate is once every 100 milliseconds. If the
Table is only called, using the CallTable instruction, once every 100
milliseconds, the computed average for each output would only use a single
sample. But, if the Table were called once every 10 milliseconds, the average
would be computed using 10 values.
EXAMPLE 4.2.8-4: CRBasic Code: Average Output Instruction
DataTable(Table1,True,2000)
DataInterval(0,100,msec,10)
CardOut(0,-1)
'Average(Reps, Source, DataType,
DisableVar)
Average(1,RefTemp,fp2,0)
Average(6,TC(1),fp2,0)
EndTable
4.2.9 Measurement Timing and Processing
All variables, Data Tables, Subroutines, Functions must be defined prior to the
BeginProg instruction within the CRBasic structure. The executable program
begins with BeginProg and ends with EndProg. The measurements, processing,
and calls to output tables bracketed by the Scan and NextScan instructions
determine the sequence and timing of the datalogging.
4-24