
Appendix B. Introduction to CRBasic Programming
B-8
CRBasic Example B-6. Definition and Use of a Data Table
'This program example demonstrates definition and use of data tables.
'Declare Variables
Public
BattV
Public
PTemp_C
Public
Temp_C
'Define Units
Units
BattV=Volts
Units
PTemp_C=Deg_C
Units
Temp_C=Deg_C
'Define Data Tables
DataTable
(OneMin,True,-1)
'Required beginning of data table declaration
DataInterval
(0,1,Min,10)
'Optional instruction to trigger table at one-minute interval
Average
(1,BattV,FP2,False)
'Optional instruction to average variable BattV
Average
(1,PTemp_C,FP2,False)
'Optional instruction to average variable PTemp_C
Average
(1,Temp_C,FP2,False)
'Optional instruction to average variable Temp_C
EndTable
'Required end of data table declaration
'Main Program
BeginProg
Scan
(1,Sec,1,0)
'Default Datalogger Battery Voltage measurement ‘BattV’
Battery
(BattV)
'Processing Board Temperature measurement ‘PTemp_C’
PanelTemp
(PTemp_C,400)
'Type T (copper-constantan) Thermocouple measurement ‘Temp_C’
TCDiff
(Temp_C,1,mV34,1,TypeT,PTemp_C,True,0,60,1,0)
'Call Data Tables and Store Data
CallTable
OneMin
NextScan
EndProg
Typical Data Table
(p. 24)
, shows a data file as it appears after the
data table is downloaded from a CR300 programmed with the code in CRBasic
. See Section
(p. 23)
, for more information on
final data files.
As shown in CRBasic Example
, data table declaration begins with the
DataTable()
instruction and ends with the
EndTable()
instruction. Between
DataTable()
and
EndTable()
are instructions that define what data to store
and under what conditions data are stored. A data table must be called by the
CRBasic program for data storage processing to occur. Typically, data tables
are called by the
CallTable()
instruction once each
Scan
.
DataTable()
instruction and parameters are as follows:
DataTable
(Name, TrigVar, Size)
•
Name
— The table name can be any combination of numbers, letters,
and underscore up to 20 characters in length. The first character must
be a letter or underscore.
•
TrigVar
— Controls whether or not data records are written to
storage. Data records are written to storage if
TrigVar
is true and if
other conditions, such as
DataInterval()
, are met. Default setting is
Summary of Contents for CR300 series
Page 2: ......
Page 6: ......
Page 68: ...CR300 Series Datalogger 58...
Page 70: ......
Page 85: ......