Appendix B. Example programs
These programs were written for a GRANITE 6 data logger, except where noted. With slight
modifications, they can be used with other Campbell Scientific data loggers.
NOTE:
For the GRANITE 10 and GRANITE 9 data loggers, the
CPIBusAddress
parameter must
include the CPI bus when using bus B. Bus A is the default. For example,
CP 2
specifies CPI bus B and CPI address 2.
B.1 Configuring GRANITE Measurement
Module with
CPIAddModule()
The following program sets CPI addresses and device names on TEMP 120s with serial numbers
1234, 1235, and 1236 and makes 15 Type-T thermocouple measurements on each module.
CRBasic Example 2: Using CPIAddModule()
'GRANITE 6 Datalogger
'This program sets CPI addresses and device names of three TEMP 120s and
'measures 15 input channels on each device.
'Declare Variables and Units
Public
TC_Set1(15) :
Units
TC_Set1 = DegC
Public
TC_Set2(15) :
Units
TC_Set2 = DegC
Public
TC_Set3(15) :
Units
TC_Set3 = DegC
'Main Program
BeginProg
'Set CPI Addresses
CPIAddModule
(TEMP120, 1234,
"A"
, 4)
CPIAddModule
(TEMP120, 1235,
"12345"
, 5)
CPIAddModule
(TEMP120, 1236,
"TEMP 120 in Pump House"
, 6)
'Main Scan
Scan
(5, SEC, 3, 0)
'15 TCs on each TEMP 120 w/ CPI addresses 4, 5, and 6
CDM_TCComp
(TEMP120, 4, TC_Set1(), 15, 1,TypeT, TRUE, 0)
CDM_TCComp
(TEMP120, 5, TC_Set2(), 15, 1,TypeT, TRUE, 0)
CDM_TCComp
(TEMP120, 6, TC_Set3(), 15, 1,TypeT, TRUE, 0)
NextScan
EndProg
TEMP 120
28