Appendix B. Example Programs
B-2
B.2 Control Port Example Programs
The following examples measure a TB4 rain gage using a control port on the
datalogger. Wire the sensor as shown in TABLE
Function, Datalogger Connection
(p. 5)
.
B.2.1 CR1000 Control Port Example
Although this example is for the CR1000 datalogger, our CR800, CR850,
CR3000, and CR5000 are programmed similarly.
CRBasic Example B-3. CR1000 Control Port Example
'CR1000
'CR1000 Program for TB4
'Declare Public Variables and Units
Public
Rain_mm
Units
Rain_mm=mm
DataTable
(Rain,True,-1)
DataInterval
(0,60,Min,0)
Totalize
(1,Rain_mm,FP2,0)
EndTable
'Main Program
BeginProg
Scan
(1,Sec,1,0)
PulseCount
(Rain_mm,1,18,2,0,.254,0) ; Black wire connected to C8
CallTable
(Rain)
NextScan
EndProg
B.2.2 CR200(X) Series Control Port Example
CRBasic Example B-4. CR200(X) Series Control Port Example
'CR200
' A 20 kOhm pull up resistor is required to read a switch closure on C1 or C2
' as a Pulse Counter. The 20 kOhm resistor uses the battery voltage.
'Declare Public Variables and Units
Public
Rain_mm
Units
Rain_mm=mm
'Define Data Tables
DataTable
(Rain,True,-1)
DataInterval
(0,60,min)
Totalize
(1,Rain_mm,0)
EndTable
'Main Program
BeginProg
Scan
(1,Sec)
'TB4 Rain Gage measurement Rain-mm
PulseCount
(Rain_mm,C2,2,0,.254,0) ; Black wire connected to C2
'Call Data Tables and Store Data
CallTable
(Rain)
NextScan
EndProg