Datalogger programming, 1 datatable() and tablefile() instructions – Campbell Scientific SC115 CS I/O 2G Flash Memory Drive with USB Interface User Manual

Page 14

Advertising
background image

SC115 CS I/O 2G Flash Memory Drive with USB Interface

10. Datalogger Programming

When used as a memory drive, the SC115 requires a TableFile() instruction in
the datalogger CRBasic program. TableFile() creates a file from data table
records, and writes the file to the SC115. The TableFile() instruction must be
within the DataTable() / EndTable declaration.

10.1 DataTable() and TableFile() Instructions

DataTable() and TableFile() instructions work together. The data table size
declared in DataTable() determines the size of the TableFile() buffer. For
instance, a programmer may attempt to conserve datalogger memory by setting
DataTable() Size to 0 with the thought that doing so will direct data to only be
written to the SC115 when it is attached for milking. However, such a
programming tactic will result in failure since, in setting the DataTable() size
to zero, the programmer also sets the TableFile() data buffer to zero.

At the opposing extreme, if the same memory-conscious programmer sets
DataTable() Size to auto-allocate (-1), there is a high probability that the
datalogger will allocate far more memory for TableFile() buffering than is
needed, which will consume memory that may be better used elsewhere.

Memory allocated by the DataTable() instruction acts as
the buffer for TableFile() data, so the DataTable() Size
parameter must be declared large enough to buffer the
TableFile() output between collection visits with the
SC115.

CAUTION

TableFile() syntax is reviewed below with comments specific to SC115
applications. For more detail, consult CRBasic Editor Help. TableFile() is
included in the DataTable() / EndTable declaration as shown in the
programming examples in Section 10.5, Example Programs.

TableFile(a,b,c,d,e,f,g,h)

a = “Drive:FileName.” Drive always = USB: for SC115. Set a

filename unique to each instance of TableFile() instruction. See
Section 10.1.1, FileName for required syntax.

b = Format. Most common format is code 8 (TOA5). See CRBasic

Help for details.

c = MaxFiles. -1 invokes auto allocation.
d = NumRec / Time Into Interval. Data collection modes: enter 0.

Resident modes: enter number of records (integer > 0) or enter
time into interval (integer

≥ 0). See following Table 3 and

Section 10.1.4, NumRecs/TimeIntoInterval Parameter for
explanation.

e = TFInterval. Data collection modes: enter 0 to collect newest data

or enter -1 to collect all of the datalogger’s data. Resident mode:
enter 0 if parameter d is set to number of records, otherwise enter
time interval (integer > 0). See following Table 3 and Section
10.1.5, Interval Parameter for detail.

f = TFUnits. Enter units for time interval. Ignored at compilation if

parameter e is 0 or -1.

g = OutStat. Optional. Set to 0 or see CRBasic Help.
h = LastFileName, Optional. Set to 0 or see CRBasic Help.

8

Advertising