Specifications

Section 9. CR1000 Programming
9-15
9.7.1.3 Output Processing Instructions
Data storage processing (“output processing”) instructions determine what
data are stored in the data table. When a data table is called in the CRBASIC
program, data storage processing instructions process variables holding current
inputs or calculations. If trigger conditions are true, e.g. the required interval
has expired, processed values are stored (“output”) in the data table. In
EXAMPLE, three averages are stored.
Consi
der the Average() instruction as an example of output processing
instructions. Average() stores the average of a variable over the data storage
output interval. Its parameters are:
Reps -- number of elements in the variable array for which to calculate
averages. In EXAMPLE 9.7-1, reps is set to 1 to average PTemp, and set
to 2 to a
verage 2 thermocouple temperatures, both of which reside in the
variable array “Temp_C”.
Source -- variable array to average. In EXAMPLE 9.7-1, variable arrays
PTem
p_C (an array of 1) and Temp_C() (an array of 2) are used.
DataType -- Data type for the stored average.
EXAMPLE 9.7-1 uses data type FP2, which is Campbell Scientific’s 2 -
b
yte floating point data type.
Read more! See Section 9.6.1.3 for more information on available data
types.
DisableVar -- 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 false or equal to zero; EXAMPLE 9.7-2, as is typical, has
false en
tered for the disable variable, so all readings are included in the
averages. In EXAMPLE 9.7-2, the average of variable “Oscillator” does
not
include samples occurring when Flag 1 is high, producing an average
of 2, whereas, when Flag 1 is low (all samples used), an average of 1.5 is
calculated.
EXAMPLE 9.7-2. CRBASIC Code: Use of the Disable Variable.
'Declare Variables and Units
Public Oscillator As Long
Public Flag(1) As Boolean
Public DisableVar As Boolean
'Define Data Tables
DataTable(OscAvgData,True,-1)
DataInterval (0,1,Min,10)
Average(1,Oscillator,FP2,DisableVar)
EndTable
'Main Program
BeginProg
Scan(1,Sec,1,0)
'Reset and Increment Counter
If Oscillator = 2 Then Oscillator = 0
Oscillator = Oscillator + 1