Campbell Scientific WINDSONIC 2-D Sonic Wind Sensors User Manual

Page 43

Advertising
background image

Appendix B. Updating an Older Program for Measuring a WindSonic1 With the New Settings

New CR1000 SDM-SIO1 Program (from Section 7.3.2)

(Public variables change. Data table structure stays the same.)

Dim windsonic(4) As String
Public wind_direction

Public wind_speed
Public diag
Public nmbr_bytes_rtrnd

Units wind_direction = degrees
Units wind_speed = m/s
Units diag = unitless

Dim in_bytes_str As String * 21
Dim checksum_flg As Boolean
Dim disable_flg As Boolean

Dim n
Units n = arb
BeginProg

n = 1
SerialOpen (40,9600,3,0,105) 'SDM-SIO1 SDM address set To 8.
Scan (1,Sec,3,0)

'Get data from WindSonic.
SerialInRecord (40,in_bytes_str,&h02,0,&h0D0A,nmbr_bytes_rtrnd,01)
SplitStr (windsonic(),in_bytes_str,",",4,4) 'Split the string and convert to floats.

wind_direction = windsonic(1)
wind_speed = windsonic(2)
diag = windsonic(4)

checksum_flg = ( (HexToDec (Right (in_bytes_str,2))) EQV (CheckSum(in_bytes_str,9,Len (in_bytes_str)-3)) )
disable_flg = ( NOT (checksum_flg) OR (nmbr_bytertrnd=0) OR (diag<>0) )

B-3

Advertising