Campbell Scientific CR9000X Measurement and Control System User Manual
Page 138

Section 4. CRBasic – Native Language Programming
EXAMPLE PROGRAM 4.2.3-2
.
CRBasic Program Structure
'
Program name: EXAMPLE.C9X
'
DECLARATIONS
Public VBlk1(1)
'Block1 dimensioned source
Dim OVBlk1(1)
'Block1 dimensioned offset
Units VBlk1 = psi
'Block1 default units (psi)
Public Flag(8)
'General Purpose Flags
Alias VBlk1(1) = Press_1
'Assign alias name "Press_1" to VBlk1(1)
'OUTPUT SECTION
DataTable(Table1,True,-1)
'Trigger, auto size
DataInterval(0,1,Sec,100)
'1 Sec interval, 100 lapses, autosize
CardOut(0,-1)
'PC card , size Auto
Sample (1,VBlk1(),IEEE4)
'1 Reps,Source,Res
EndTable
'End of table Table1
'
SUBROUTINES
Sub Zero8
'Begin zero measure routine
Scan(5,mSec,0,100)
'Scan 100 times. 1.00 Seconds.
VoltDiff(OVBlk1(),1,mV50,4,1,True,0,100,-5,0)
Next Scan
'Loop up for the next scan
Flag(8) = False
'Reset Flag(8)
End Sub
'End gauge zero measure routine
'PROGRAM: MAIN SEQUENCE
BeginProg
'Program begins here
OVBlk1(1) = 1
'Initialize offset value
'MainSequence
Scan(5,mSec,0,0)
'Scan once every 10 mSecs, non-burst
VoltDiff(VBlk1(),1,mV50,4,1,True,0,100,5,OVBlk1(1)) 'Measurement
If Flag(8) Then Zero8
'Go do Zero8 subroutine
CallTable Table1
'Output Control
Next Scan
'Loop up for the next scan
'LOW PRIORITY
'
BackgroundSequence
SlowSequence
'Used for slow measurements
Dim TripVolt
'Dimension TripVolt
Scan(1,Sec,0,0)
'Scan once every 1 second
Battery(TripVolt,0)
'Battery voltage measurement
If TripVolt < 11.5 Then
PowerOff(0,0,Min)
'Test for less than 11.5 volts
Endif
Next Scan
'Loop up for the next scan
EndProg
'Program ends here
4-10