Campbell Scientific PWS100 PWS100 Present Weather Sensor - Page 84

The following is an example program for the Campbell Scientific CR1000, datalogger using polled

Page 84 highlights

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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134

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