8 program access to data tables – Campbell Scientific CR5000 Measurement and Control Module User Manual

Page 86

Advertising
background image

Section 4. CRBasic - Native Language Programming

4-10

calibrated sensors, applying the correct calibration to each sensor. If the
multiplier and offset are not arrays, the same multiplier and offset are used for
each repetition.

VoltSE(Dest,Reps,Range,ASlot,SEChan,Delay,
Integ,Mult,Offset)

'Calibration factors:
Mult(1)=0.123 : Offset(1)= 0.23
Mult(2)=0.115 : Offset(2)= 0.234
Mult(3)=0.114 : Offset(3)= 0.224
VoltSE(Pressure(),3,mV1000,6,1,1,100,Mult(),Offset()

4.8 Program Access to Data Tables

Data stored in a table can be accessed from within the program. The format
used is:

Tablename.Fieldname(fieldname index,records back)

Where Tablename is the name of the table in which the desired value is stored.
Fieldname is the name of the field in the table. The fieldname is always an
array even if it consists of only one variable; the fieldname index must always
be specified. Records back is the number of records back in the data table
from the current time (1 is the most recent record stored, 2 is the record stored
prior to the most recent). For example, the expression:

Tdiff=Temp.TC_Avg(1,1)–Temp.TC_Avg(1,101)

could be used in the example program (Section 4.3) to calculate the change in
the 10 ms average temperature of the first thermocouple between the most
recent average and the one that occurred a second (100 x 10 ms) earlier.

In addition to accessing the data actually output in a table, there are some
pseudo fields related to the data table that can be retrieved:

Tablename.record(1,n) = the record number of the record output n records ago.

Tablename.output(1,1) = 1 if data were output to the table the last time the
table was called, = 0 if data were not output.

Tablename.timestamp(m,n) = element m of the timestamp output n records ago
where:

timestamp(1,n) = microseconds since 1990
timestamp(2,n) = microseconds into the current year
timestamp(3,n) = microseconds into the current month
timestamp(4,n) = microseconds into the current day
timestamp(5,n) = microseconds into the current hour
timestamp(6,n) = microseconds into the current minute
timestamp(7,n) = microseconds into the current second

Advertising