Campbell Scientific PWS100 Present Weather Sensor User Manual

Page 84

Advertising
background image

Section 7. Operation

'Main Program
BeginProg


'Open Serial Port to the PWS100
SerialOpen (Com1,115200,3,0,10000)


'Commands can be included here to setup the
'sensor if it has not been preconfigured


Scan (60,Sec,0,0)

'Read the data using the STX and ETX characters as delimiters
'If a whole message is not in the serial buffer this will

'store "NAN" in the string
SerialInRecord(COM1,InString,STX,0,ETX,PWS_Bytes,01)
'If a full string has been read then parse the data and store it

If PWS_Bytes>0 Then
SplitStr (PWS100data(),InString," ",11,0)
CallTable PWS100

EndIf
NextScan

EndProg

The following is an example program for the Campbell Scientific CR1000
datalogger using polled output settings (see Section 7.5.1).

'CR1000 Series Datalogger
'Campbell Scientific Ltd. PWS100 Present Weather Sensor

'Example of data capture in a single message that is polled
'for by the logger. The sensor is connected to COM1

'Declare variables
'Incoming PWS100 Data buffer
Public InString As String * 500


'Final PWS100 Data - define the array large enough to match the
'number of fields in the message

Public PWS100data(11)
'Define aliases so the results are easier to identify
'Need to match the fields selected in the message

Alias PWS100data(1) = MessageID
Alias PWS100data(2) = PWSID

Alias PWS100data(3) = Visibility
Alias PWS100data(4) = PWS
Alias PWS100data(5) = NWS

Alias PWS100data(6) = Intensity
Alias PWS100data(7) = Accumulation
Alias PWS100data(8)= DayCount

Alias PWS100data(9) = Hour
Alias PWS100data(10) = Minute
Alias PWS100data(11) = Second


'Declare Constants

Const CR = CHR(13)
Const LF = CHR(10)

DataTable (PWS100,True,-1)
Sample (11,PWS100data(),IEEE4)
EndTable


'Main Program
BeginProg

7-48

Advertising