Appendix B. Example Program
B-3
Average
(1,PTemp,FP2,0)
EndTable
DataTable
(One_Minute,1,-1)
DataInterval
(0,60,Sec,10)
Sample
(NumTempSensors,TempC(),IEEE4)
EndTable
'Define Subroutines
'*****************************************************************************
'* ------------------------- ConvertSDI12addr() -------------------------- *
'* Convert SDI-12 character address (0->9, A->Z, and a->z) to number value *
'* (0->61). *
'*****************************************************************************
Function
ConvertSDI12addr(address
As
Long
)
As
String
* 1
Select
Case
address
Case
0
To
9
'ASCII Code 48->57 = 0->9
Return
(
CHR
(a 48))
Case
10
To
35
'ASCII Code 65->90 = A->Z = 10->35
Return
(
CHR
(a 55))
Case
36
To
61
'ASCII Code 97->122 = a->z = 36->61
Return
(
CHR
(a 61))
EndSelect
Return
("")
EndFunction
'ConvertSDI12addr()
'EndSub
'Main Program
BeginProg
Scan
(5,Sec,0,0)
PanelTemp
(PTemp,250)
Battery
(batt_volt)
CallTable
Daily
CallTable
Hourly
NextScan
'Poll CS230/CS231 in Slow Sequence every minute
SlowSequence
Scan
(60,Sec,3,0)
'Read the current temperature value
For
i=1
To
NumTempSensors
SDI12Recorder
(TempC(i),SDI12_Port,ConvertSDI12addr(i),"R0!",1.0,0)
Next
CallTable
One_Minute
NextScan
EndProg
B.3 CR1000X Program to Read Metadata of 15
Temperature Sensors
In this example, a CS230/CS231 is on control terminal 1 of a CR1000X. The
CS230/CS231 includes 15 sensors with SDI-12 addresses 1 through 9 and A
through F. Each temperature sensor is polled on power up and daily with the
aR1!
command to determine metadata, which is stored in a daily data table.