Crbasic example 9. use of the disable variable – Campbell Scientific CR200/CR200X-series Dataloggers User Manual
Page 94

Section 9. Programming
Consider 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. Reps is set to 1 to average Batt_Volt, and set to 2 to average 2
thermistor temperatures, both of which reside in the variable array
"T109_C".
•
Source-variable array to average. Variable arrays Batt_Volt (an array of 1)
and T109_C() (an array of 2) are used.
•
DisableVar-controls whether or not a measurement or value is included in
an output processing function. A measurement or value will not be included
if the disable variable is true (≠ 0). For example, in the case of an Average
() output processing instruction, if, on a particular pass through the data
table, the Average () disable variable true, the value resident in the variable
to be averaged with not be included in the average. Program CRBASIC
EXAMPLE. Use of the Disable Variable has "False" entered for the disable
variable, so all readings are included in the averages; 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.
Read More!
TrigVar and DisableVar - Controlling Data
Output and Output Processing
(p. 125) discusses the
use of TrigVar and DisableVar in special applications.
CRBASIC EXAMPLE 9.
Use of the Disable Variable
'Declare Variables and Units
Public Oscillator
Public Flag
Public DisableVar
'Define Data Tables
DataTable (OscAvgData,True,-1)
DataInterval (0,1,Min)
Average (1,Oscillator,DisableVar)
EndTable
'Main Program
BeginProg
Scan (1,Sec)
'Reset and Increment Counter
If Oscillator = 2 Then Oscillator = 0
Oscillator = Oscillator + 1
'Process and Control
If Oscillator = 1
82