CR200/CR200X Series Dataloggers - Campbell Scientific
CR200/CR200X Series Dataloggers - Campbell Scientific
CR200/CR200X Series Dataloggers - Campbell Scientific
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Section 9. Programming<br />
Consider the Average () instruction as an example of output processing<br />
instructions. Average () stores the average of a variable over the data storage<br />
output interval. Its parameters are:<br />
• Reps-number of elements in the variable array for which to calculate<br />
averages. Reps is set to 1 to average Batt_Volt, and set to 2 to average 2<br />
thermistor temperatures, both of which reside in the variable array<br />
"T109_C".<br />
• Source-variable array to average. Variable arrays Batt_Volt (an array of 1)<br />
and T109_C() (an array of 2) are used.<br />
• DisableVar-controls whether or not a measurement or value is included in<br />
an output processing function. A measurement or value will not be included<br />
if the disable variable is true (≠ 0). For example, in the case of an Average<br />
() output processing instruction, if, on a particular pass through the data<br />
table, the Average () disable variable true, the value resident in the variable<br />
to be averaged with not be included in the average. Program CRBASIC<br />
EXAMPLE. Use of the Disable Variable has "False" entered for the disable<br />
variable, so all readings are included in the averages; the average of<br />
variable "Oscillator" does not include samples occurring when Flag 1 is<br />
high, producing an average of 2, whereas, when Flag 1 is low (all samples<br />
used), an average of 1.5 is calculated.<br />
Read More! TrigVar and DisableVar - Controlling Data<br />
Output and Output Processing (p. 125) discusses the<br />
use of TrigVar and DisableVar in special applications.<br />
CRBASIC EXAMPLE 9.<br />
'Declare Variables and Units<br />
Public Oscillator<br />
Public Flag<br />
Public DisableVar<br />
Use of the Disable Variable<br />
'Define Data Tables<br />
DataTable (OscAvgData,True,-1)<br />
DataInterval (0,1,Min)<br />
Average (1,Oscillator,DisableVar)<br />
EndTable<br />
'Main Program<br />
BeginProg<br />
Scan (1,Sec)<br />
'Reset and Increment Counter<br />
If Oscillator = 2 Then Oscillator = 0<br />
Oscillator = Oscillator + 1<br />
'Process and Control<br />
If Oscillator = 1<br />
82