beautypg.com

C = century, Hh = hour – Campbell Scientific CR9000X Measurement and Control System User Manual

Page 169

background image

Section 4. CRBasic – Native Language Programming

where:

M =

Month

D =

D

Y =

Year

C =

Century

hh =

Hour

mm =

Minute

ss.sssss = Seconds (10 microsecond resolution)

Tablename.TableFull(1,1) = -1 (True)or 0 (False) to indicate if a “Fill and
Stop” table is full, or if a “Ring” memory table has begun overwriting its oldest
data. 0 (False) indicates the table is not full/overwriting. -1 (True) indicates
that the table is full/overwriting.

Example program 4.3-1 tracks # of data table events, tracks whether data was
stored during the current scan interval, sets Flag(2) to True if the Data Table
becomes full, and tracks the number of records written to the table with the
variable RecordNum. It also uses the RecordNum value to ensure that enough
records have been written to the table to compare the current value of TC(1)
with the value of TC(1) 100 records back.

EXAMPLE 4.3-1; CRBasic Code: Data Table Access

Public RefTemp, TC(6)
Public EventNum, Flag(8)

DataTable(Table1,True,2000)
DataEvent(50,TC(1)>100,TC(2)<50,100)
DataInterval(0,100,msec,10)
CardOut(0,-1)
Average(1,RefTemp,fp2,0)
Average(6,TC(),fp2,0)
EndTable

BeginProg
Scan(1,MSEC,3,0)
ModuleTemp(RefTemp,1,4,0)
TCDiff(TC(),6,mV50,4,1,TypeT,RefTemp,1,30,40,1,0)
CallTable Table1

'Call Data Table

EventNum = Table1.EventCount(1,1)

'Track # of data trigger events

If Table1.Output(1,1) then Flag(1)=-1 else Flag(1)=0

'Set Flag(1) based on if data was stored this Scan

If Table1.TableFull(1,1) then Flag(2)=-1 else Flag(2)=0

'Set Flag(2) based on if Table is full

RecordNum

=

Table1.Record(1,1)

'Track # records written to Table

If RecordNum > 100 then

' If sufficient records then

:

Tdiff = Table1.TC_Avg(1,1) - Table1.TC_Avg(1,101)

'Diff between the current TC(1) value and the

Endif

'

TC(1) value from 100 records back calculated

NextScan

Loop up for next Scan

EndProg

4-41