Section 9. Programming
82
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 = Osci 1
'Process and Control
If Oscillator = 1
Summary of Contents for CR200
Page 32: ...Section 2 Quickstart Tutorial 22 ...
Page 45: ...Section 3 Overview 35 3 3 Specifications ...
Page 46: ...Section 3 Overview 36 ...
Page 58: ...Section 4 Sensor Support 48 ...
Page 62: ...Section 5 Measurement and Control Peripherals 52 ...
Page 78: ...Section 8 CR200 X Configuration 68 ...
Page 102: ...Section 9 Programming 92 ...
Page 138: ...Section 11 Programming Resource Library 128 ...
Page 156: ...Section 16 Support Software 146 ...
Page 160: ...Section 17 Care and Maintenance 150 ...
Page 167: ...Section 18 Troubleshooting 157 18 3 3 2 Charging Circuit Test Solar Panel ...
Page 168: ...Section 18 Troubleshooting 158 18 3 3 3 Charging Circuit Test Transformer ...
Page 169: ...Section 18 Troubleshooting 159 18 3 3 4 Adjusting Charging Circuit Voltage ...
Page 170: ...Section 18 Troubleshooting 160 ...
Page 184: ...Appendix A Glossary 14 ...
Page 190: ...Appendix B Status Table and Settings 20 ...
Page 192: ...Appendix C Serial Port Pin Outs 22 ...
Page 211: ......