-
Notifications
You must be signed in to change notification settings - Fork 0
/
BOM.CR1
279 lines (238 loc) · 9.26 KB
/
BOM.CR1
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
'============================================
' CR1000 Series Datalogger
' Program Name:
' Date: 22/11/2010
' Program Author: Gavin Hewitt, CSA
' Revision: 10/12/2010 by Gunawan vai7strings@yahoo.com
'============================================
'--------------------------------------------
' Wiring Diagram:
' Sensor: RMY 03002 Wind Sentry
' Wire Colour | Function | CR1000 Connection|
' Red | Wind Spd Sig. | P1 |
' Black | Wind Spd Ref. | AG |
' Clear | Shield | AG |
' Green | Wind Dir Sig. | SE1 |
' White | Wind Dir Ref. | AG |
' Blue | Wind Dir Excite | VX1 |
'
' 108 Temperature Sensor (Wet Bulb)
' Black | Voltage Excite | VX2 |
' Red | Temp Sig. | SE9 |
' Purple | Signal Gnd | AG |
' Clear | Shield | AG |
'
' 108 Temperature Sensor (Dry Bulb)
' Black | Voltage Excite | VX3 |
' Red | Temp Sig. | SE10 |
' Purple | Signal Gnd | AG |
' Clear | Shield | AG |
'
' CS106 PA_meas Sensor
' Blue | PA_meas Sig | SE3 |
' Yellow | Sig Ref | SE4 |
' Green | Trigger | C1 |
' Red | PWR | 12V |
' Black | PWR Ground | G |
' Clear | Shield | AG |
' Li200x Pyranometer
' Red | Signal | SE5 |
' Black | Signal Ref | SE6 |
' White | Signal GND | AG |
' Clear | Shield | AG |
' NR-Lite Net Radiometer
' Red | Rad Sig. | SE7 |
' Blue | Signal Ref | SE8 |
' Jumper from SE8 to AG | |
' AG |
' Clear | Shield | AG |
' CS700 Tipping Bucket PR_meas Gauge
' Black | Signal | P2 |
' White | Signal Return | G |
' Clear | Shield | AG |
'--------------------------------------------
'Declare Public Variables
'Example:
Public PTemp 'Internal pannel temperature
Public batt_volt'Battery voltage
Public WS_meas 'Wind speed
Public WD_meas 'Wind direction
Public TA1_meas 'Wet Bulb Thermistor
Public TA2_meas 'Dry Bulb Thermistor
Public RH_meas 'Relative Humidity measurement
Public PA_meas 'Barometric Pressure
Dim QFF_offset
Public PA_QFF 'Barometric Pressure adjusted to sea level
Public SR_meas 'Solar Radiation
Public SlrMJ 'Solar Radiation in MJ/m2
Public SD 'Sunlight duration per 24 hours
Dim NR_Wm2
Public NR_meas 'Net Radiation Measurement
Public PR_meas 'Rain measurement
Public RainIntensity5min '5 minute rainfall intensity
Dim rfAvg 'Running average to calculate intensity
Public rain10min '10 minute intensity
Public rainHourly '60 min intensity
Dim DisableRainfall_10 As Boolean
Dim DisableRainfall_Hour As Boolean
' formula RH
Dim ea
Dim esbk
Dim esbb
Dim rh
'hujan
Dim hujan
Dim ch
Public PR_meas_Total 'Total Rain
Public DP_meas 'Dew Point
Dim VAP_Pres
Dim SAT_VP
'Declare Other Variables
'Example:
'Dim Counter
'Declare Constants
Const scan_rate = 1
Const NRLite_Cal = 1000/13.1 'Calibration constant shipped with the NR-Lite --> Cal constant is the denominator x eg: 1000/xx.x
Const A = 0.021286 'Empirical constand for NR-lite wind correction
'====== THESE CONSTANTS NEED TO BE CHANGED TO SITE SPECIFIC VALUES ============
Const LATITUDE = 1 ' Latitude of the site
Const LONGTITUDE = 1 'Longitude of the site
Const ALTITUDE = 94' 1 'Altitude of the site above sea level in m
'Define Data Tables
DataTable (L0,1,-1)
DataInterval (0,10,Min,10)
Average (1,TA1_meas,FP2,False)
Average (1,TA2_meas,FP2,False)
Average (1,RH_meas,FP2,False)
Average (1,DP_meas,FP2,False)
Average (1,PA_meas,FP2,False)
Average (1,PA_QFF,FP2,False)
Average (1,SR_meas,FP2,False)
Average (1,NR_meas,FP2,False)
Maximum (1,WS_meas,IEEE4,False,False)
Average (1,WS_meas,IEEE4,False)
Minimum (1,WS_meas,FP2,False,False)
Average (1,WD_meas,FP2,False)
WindVector (1,WS_meas,WD_meas,IEEE4,False,0,0,0)
Sample (1,rain10min * 6,FP2)
FieldNames ("RainIntensity:mm/hour")
Maximum (1,RainIntensity5min,FP2,DisableRainfall_10,False)
EndTable
DataTable (L1,1,-1)
DataInterval (0,1,Hr,10)
Sample (1,PTemp,FP2)
Average (1,TA1_meas,FP2,False)
Average (1,TA2_meas,FP2,False)
Average (1,RH_meas,FP2,False)
Average (1,DP_meas,FP2,False)
Average (1,PA_meas,FP2,False)
Average (1,PA_QFF,FP2,False)
Average (1,SR_meas,FP2,False)
Average (1,NR_meas,FP2,False)
Maximum (1,WS_meas,IEEE4,False,False)
Average (1,WS_meas,IEEE4,False)
Minimum (1,WS_meas,FP2,False,False)
Average (1,WD_meas,FP2,False)
WindVector (1,WS_meas,WD_meas,IEEE4,False,0,0,0)
Sample (1,rainHourly,FP2)
FieldNames ("RainIntensity:mm/hour")
Maximum (1,RainIntensity5min,FP2,DisableRainfall_Hour,False)
EndTable
DataTable (L2,True,365)
DataInterval (0,24,Hr,10)
Minimum (1,batt_volt,FP2,False,False)
Totalize (1,PR_meas,FP2,False)
Sample (1,SD,FP2)
EndTable
'Define Subroutines
'Sub
'EnterSub instructions here
'EndSub
'Main Program
BeginProg
Scan (scan_rate,Sec,0,0)
If IfTime(0,10,Min) Then DisableRainfall_10 = True
If IfTime(5,10,Min) Then DisableRainfall_10 = False
If IfTime(0,60,Min) Then DisableRainfall_Hour = True
If IfTime(5,60,Min) Then DisableRainfall_Hour = False
PanelTemp (PTemp,250)
Battery (batt_volt)
'03002 Measurements
PulseCount (WS_meas,1,1 ,1,1,0.75,0.2)
If WS_meas <0.21 Then WS_meas = 0 'If windspeed is below the threshold then it is zero
BrHalf (WD_meas,1,mV2500,1,Vx1,1,2500,True ,0,250,352,0)
If WD_meas >= 360 OR WD_meas <0 Then WD_meas = 0 'Correction for wind direction.
'Temperature Measurments
Therm108 (TA1_meas,1,9,Vx2,0,250,1.0,0) 'Dry bulb temperature measurement
Therm108 (TA2_meas,1,10,Vx3,0,250,1.0,-0.7) 'Wet bulb temperature measurement
WetDryBulb (VAP_Pres,TA2_meas,TA1_meas,PA_meas) 'Calculate the vapour pressure from the wet and dry bulb measurements
SatVP (SAT_VP,TA2_meas) 'Calculate the saturated vapour pressure from the dry bulb measurement
'Rearrange VP=RH*SVP/100 to calculate humidity
'''''''''''''RH_meas = (VAP_Pres * 100) / SAT_VP
''' create for PT.TATA
esbb = 6.1078 * EXP (17.239 * TA1_meas/(TA1_meas + 237.3))
ea = esbb - 0.661 * (TA2_meas - TA1_meas)
esbk = 6.1078 * EXP (17.239 * TA2_meas / (TA2_meas + 237.3))
rh = (ea / esbk) * 100
RH_meas = rh-10
'Calculate Dew Point
DewPoint (DP_meas,TA1_meas,RH_meas)
'CS106 Pressure Measurement
If TimeIntoInterval(0,10,Sec)
PortSet (1,1)
Delay(0,1,Sec)
VoltDiff (PA_meas,1,mV2500,2,1,0,250,0.240,501.6)
PortSet(1,0)
EndIf
'Using Altitude, calculate Barometric Pressure offset To adjust pressure To sealevel
QFF_offset = (1013.25*(1-(1-(ALTITUDE/44307.69231))^5.25328)) 'calculate sealevel adjustment
PA_QFF = PA_meas + QFF_offset 'Calculate Barometric pressure corrected for sea level
'Li200X Measurement
VoltDiff (SR_meas,1,mV7_5C,3,True ,0,250,1.0,0)
If SR_meas<0 Then SR_meas=0 'Set Negaitive Values to Zero
SlrMJ = SR_meas*(scan_rate* 0.0002) 'Convert mV to MJ/m2 for the scan interval
SR_meas=SR_meas*200 'Convert mV to W/m2
'NR-Lite Measurement
VoltDiff (NR_Wm2,1,mV25C,4,True ,0,250,100,0)
If WS_meas >= 5 Then 'If the windspeed is greater than 5m/s then apply the correction.
NR_meas = NR_Wm2*(1+A*(WS_meas-5))
Else
NR_meas = NR_Wm2 'If the windspeed is less than 5m/s then apply no correction.
EndIf
SD = Timer (1,Sec,4) 'Keep a timer of the Sunshine duration
If NR_Wm2 > 120 Then 'If the sunlight passes the WMO 2003 standard (120 W/m2) then start the timer, if it drops below it then stop the timer.
Timer (1,Sec,0 )
Else
Timer (1,Sec,1)
EndIf
'CS700 Measurement
PulseCount (PR_meas,1,2,2,0,0.2,0)
PR_meas_Total = PR_meas + PR_meas_Total 'Keep a running total of the PR_meas experienced by the station.
ch=PR_meas+ch
hujan =PR_meas+hujan
'keep 10 minute rainfall total
''''''''''rain10min += PR_meas
rain10min = ch
'keep hourly rainfall total
''''''''''rainHourly += PR_meas
rainHourly = hujan
'Take a 5 minute running average
AvgRun (rfAvg,1,PR_meas,300)
'Calculate the rainfall intensity in mm/hour
RainIntensity5min = rfAvg * 300 * 12
CallTable L0
CallTable L1
CallTable L2
If TimeIntoInterval (0,24,Hr) Then 'At midnight of each day, stop and reset the SD timer.
Timer (1,Sec,3)
EndIf
If IfTime(0,10,Min) Then
rain10min = 0
ch=0
EndIf
If IfTime(0,60,Min) Then
rainHourly = 0
hujan=0
EndIf
NextScan
EndProg