Campbell Scientific CR9000X Measurement and Control System User Manual

Page 145

Advertising
background image

Section 4. CRBasic – Native Language Programming

EXAMPLE 4.2.4-6 CRBASIC Code: Using NSEC data type on a 2 element array.

'Because the variable is dimensioned to 2, NSEC assumes TimeOfMaxVar(1) = seconds since
00:00:00 1 'January 1990, and TimeOfMaxVar(2) = μsec into a second.

Public PtempC, MaxVar, TimeOfMaxVar(2) As Long

DataTable (FirstTable,True,-1)
DataInterval (0,1,Min,10)
Maximum

(1,PTempC,FP2,False,True)

EndTable

DataTable (SecondTable,True,-1)

DataInterval (0,5,Min,10)

Sample

(1,MaxVar,FP2)

Sample

(1,TimeOfMaxVar,Nsec)

EndTable

BeginProg

Scan (1,Sec,0,0)

PanelTemp (PTempC,250)

MaxVar

=

FirstTable.PTempC_Max

TimeOfMaxVar

=

FirstTable.PTempC_TMx

CallTable

FirstTable

CallTable

SecondTable

NextScan

EndProg

EXAMPLE 4.2.4-6 CRBASIC Code: Using NSEC data type with a 7 element time array.
A timestamp is retrieved into variable rTime(1) through rTime(9) as year, month, day, hour, minutes,
seconds, and microseconds using the RealTime () instruction. The first seven time values are copied
to variable rTime2(1) through rTime2(7).

Public rTime(9) As Long

'(or Float)

Public rTime2(7) As Long

'(or Float)

Dim x

DataTable (SecondTable,True,-1)

DataInterval (0,5,Sec,10)

Sample

(1,rTime,Nsec)

Sample

(1,rTime2,Nsec)

EndTable

BeginProg
Scan
(1,Sec,0,0)
RealTime

(rTime)

For x = 1 To 7

rTime2(x)

=

rTime(x)

Next

CallTable SecondTable

NextScan

EndProg

4-17

Advertising