Subroutine example, Units – Campbell Scientific CR9000X Measurement and Control System User Manual
Page 184

Section 5. Program Declarations
Subroutine Example
'CR9000X
''Declare Variables used in Program:
Public RefT, TC(4),I
DataTable (TempsC,1,-1)
'Data output in deg C
DataInterval
(0,5,Min,10)
Average
(1,RefT,FP2,0)
Average
(4,TC(),FP2,0)
EndTable
DataTable (TempsF,1,-1
) 'Data output in F after conversion
DataInterval
(0,5,Min,10)
Average
(1,RefT,FP2,0)
Average
(4,TC(),FP2,0)
EndTable
Sub
ConvertCtoF (Tmp)
'Sub to convert temp in degrees C to degrees F
Tmp = Tmp*1.8 +32
EndSub
BeginProg
Scan
(1,Sec,3,0)
'Measure Temperatures (module + 4 thermocouples) in deg C
ModuleTemp
(RefT,1,1,250)
TCDiff (TC(),4,mV50C,1,1,TypeT,RefT,True ,0,250,1.0,0)
'Call Output Table for C
CallTable
TempsC
'Convert Temperatures to F using Subroutine:
Call ConvertCtoF(RefT)
'Subroutine call using Call statement
For I = 1 to 4
ConvertCtoF(TC(I))
'Subroutine call without Call statement
Next
I
'Call Output Table for F:
CallTable
TempsF
NextScan
EndProg
UNITS
Used to assign a unit name to a field associated with a variable.
Syntax
Units Variable = UnitName
Remarks
Units allows assigning a unit name to a variable. Maximum field length for
the Units declaration is 11 characters. Units are displayed on demand in the
real-time windows of RTDaq. The unit name also appears in the header of the
output files and in the Data Table Info file of RTDaq. The unit name is a text
field that allows the user to label data. The units are strictly for the user’s
documentation
. CRBasic and the CR9000X make no checks on their accuracy.
Example
Dim TCTemp( 1 )
Units TCTemp( 1 ) = Deg_C
5-14