Campbell Scientific CR9000X Measurement and Control System User Manual

Page 144

Advertising
background image

Section 4. CRBasic – Native Language Programming

Specific uses include:
• Placing a timestamp in a second position in a record.
• Accessing a timestamp from a data table and subsequently storing it as part

of a larger data table. Maximum, Minimum, and FileTime instructions
produce a timestamp that may be accessed from the program after being
written to a data table. The time of other events, such as alarms, can be
stored using the RealTime instruction.

• Accessing and storing a timestamp from another datalogger in a PakBus

network.

NSEC is used in a CRBASIC program one of the following three ways. In all

cases, the time variable is only sampled with Sample () instruction reps = 1.

• Time variable dimensioned to (1). If the variable array (must be LONG) is

dimensioned to 1, the instruction assumes that the variable holds seconds
since 1990 and microseconds into the second is 0. In this instance, the
value stored is a standard datalogger timestamp rather than the number of
seconds since January 1990. Example 4.2.4-5 shows NSEC used with a
time variable array of (1).

• Time variable dimensioned to (2). If the variable array (must be LONG) is

dimensioned to two, the instruction assumes that the first element holds
seconds since 1990 and the second element holds microseconds into the
second. shows NSEC used with a time variable array of (2). Example 4.2.4-
6 is an example.

• Time variable dimensioned to (7). If the variable array (FLOAT or LONG)

is dimensioned to 7, and the values stored are year, month, day of year,
hour, minutes, seconds, and milliseconds. Example 4.2.4-7 shows NSEC
used with a time variable array of (7).

EXAMPLE 4.2.4-5 CRBASIC Code: Using NSEC data type on a 1 element array.

'Variable, TimeVar(1) is dimensioned to 1 so the value is seconds since Jan.1, 1990

Public Ptemp
Public TimeVar (1) As Long

DataTable (FirstTable,True,-1)

DataInterval (0,1,Sec,10)

Sample (1,PTemp,FP2)

EndTable

DataTable (SecondTable,True,-1)

DataInterval (0,5,Sec,10)

Sample (1,TimeVar,Nsec)

EndTable

BeginProg

Scan (1,Sec,0,0)

TimeVar

=

FirstTable.TimeStamp

CallTable

FirstTable

CallTable

SecondTable

NextScan

EndProg

4-16

Advertising