-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBiotron_temp_and_Irrig.CR1
224 lines (213 loc) · 9.98 KB
/
Biotron_temp_and_Irrig.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
'CR1000
'Created by Short Cut (3.0)
'Declare Variables and Units
Public BattV
Public PTemp_C
Public PotTemp(9)
Public Irrigations
Public SubIrrigations
Public Irrigations2
Units BattV=Volts
Units PTemp_C=Deg C
Public WP(4)
Public StartTemp_C(4)
Public Temp1Sec_C(4)
Public Temp30Sec_C(4)
Public DeltaT_C(4)
Public MeanWP
Dim Sensor
Const Alpha = 1
Const Beta = 0
Dim TT_K(3)
Dim SBT_K(3)
Dim m(3)
Dim b(3)
Public TT_C(3)
Public SBT_C(3)
Public TTmV(3)
'Define Data Tables
DataTable(Table1,True,-1)
DataInterval(0,30,min,0)
Average(1,BattV,FP2,False)
Average(1,PTemp_C,FP2,False)
Average(1,WP(1),FP2,False)
Average(1,WP(2),FP2,False)
Average(1,WP(3),FP2,False)
Average(1,WP(4),FP2,False)
Average(1,MeanWP,FP2,False)
Average(1,DeltaT_C(1),FP2,False)
Average(1,DeltaT_C(2),FP2,False)
Average(1,DeltaT_C(3),FP2,False)
Average(1,DeltaT_C(4),FP2,False)
Average(1,Irrigations, FP2, False)
Average(1,Irrigations2, FP2, False)
Average(1,TT_C(1),FP2,False)
Average(1,SBT_C(1),FP2,False)
Average(1,TTmV(1),FP2,False)
Average(1,TT_C(2),FP2,False)
Average(1,SBT_C(2),FP2,False)
Average(1,TTmV(2),FP2,False)
Average(1,TT_C(3),FP2,False)
Average(1,SBT_C(3),FP2,False)
Average(1,TTmV(3),FP2,False)
Average(1,PotTemp(1),FP2,False)
Average(1,PotTemp(2),FP2,False)
Average(1,PotTemp(3),FP2,False)
Average(1,PotTemp(4),FP2,False)
Average(1,PotTemp(5),FP2,False)
Average(1,PotTemp(6),FP2,False)
Average(1,PotTemp(7),FP2,False)
Average(1,PotTemp(8),FP2,False)
Average(1,PotTemp(9),FP2,False)
EndTable
'Main Program
BeginProg
'Main Scan
SubIrrigations = 1
Scan(30,min,1,0)
'Default Datalogger Battery Voltage measurement 'BattV'
Battery(BattV)
'Default Wiring Panel Temperature measurement 'PTemp_C'
PanelTemp(PTemp_C,_60Hz)
'Do soil temperature measurement and IR measurements
PortSet(6,1)
Delay(0,150,mSec) 'Delay(Option, Delay, Units)
'Switch on the first AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'SI-111 Precision Infrared Radiometer measurements 'TT_C' and 'SBT_C'
'Measure SI-111 sensor body thermistor temperature. Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(SBT_C(1),1,11,VX2,0,_60Hz,1,0)
'Measure SI-111 output of thermopile. VoltDiff(Dest, Reps, Range, DiffChan, RevDiff, SettlingTime, Integ, Mult, Offset)
VoltDiff(TTmV(1),1,mV2_5,5,True,0,_60Hz,1,0,)
'Calculate slope (m) and offset (b) coefficients for target temperature calculation
m(1)= 1560000000 +(9210000*SBT_C(1))+(64655.6*SBT_C(1)^2)
b(1)=-11900000+(-112000*SBT_C(1))+(22740.2*SBT_C(1)^2)
'Calculate target temperature using calculated slope (m) and offset (b)
SBT_K(1)=SBT_C(1)+273.15
TT_K(1)=SBT_K(1)^4+TTmV(1)*m(1)+b(1)
TT_K(1)=SQR(SQR(TT_K(1)))
'Convert target temperature into desired units
TT_C(1)=TT_K(1)-273.15
'Switch on next AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'SI-111 Precision Infrared Radiometer measurements 'TT_C' and 'SBT_C'
'Measure SI-111 sensor body thermistor temperature. Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(SBT_C(2),1,11,VX2,0,_60Hz,1,0)
'Measure SI-111 output of thermopile. VoltDiff(Dest, Reps, Range, DiffChan, RevDiff, SettlingTime, Integ, Mult, Offset)
VoltDiff(TTmV(2),1,mV2_5,5,True,0,_60Hz,1,0,)
'Calculate slope (m) and offset (b) coefficients for target temperature calculation
m(2)=1580000000+(8910000*SBT_C(2))+(72138.2*SBT_C(2)^2)
b(2)=-9770000+(-142000*SBT_C(2))+(23952.4*SBT_C(2)^2)
'Calculate target temperature using calculated slope (m) and offset (b)
SBT_K(2)=SBT_C(2)+273.15
TT_K(2)=SBT_K(2)^4+TTmV(2)*m(2)+b(2)
TT_K(2)=SQR(SQR(TT_K(2)))
'Convert target temperature into desired units
TT_C(2)=TT_K(2)-273.15
'Switch on next AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'SI-111 Precision Infrared Radiometer measurements 'TT_C' and 'SBT_C'
'Measure SI-111 sensor body thermistor temperature. Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(SBT_C(3),1,11,VX2,0,_60Hz,1,0)
'Measure SI-111 output of thermopile. VoltDiff(Dest, Reps, Range, DiffChan, RevDiff, SettlingTime, Integ, Mult, Offset)
VoltDiff(TTmV(3),1,mV2_5,5,True,0,_60Hz,1,0,)
'Calculate slope (m) and offset (b) coefficients for target temperature calculation
m(3)=1420000000 +(8330000*SBT_C(3))+(68500*SBT_C(3)^2)
b(3)=-5630000+(32700*SBT_C(3))+(21600*SBT_C(3)^2)
'Calculate target temperature using calculated slope (m) and offset (b)
SBT_K(3)=SBT_C(3)+273.15
TT_K(3)=SBT_K(3)^4+TTmV(3)*m(3)+b(3)
TT_K(3)=SQR(SQR(TT_K(3)))
'Convert target temperature into desired units
TT_C(3)=TT_K(3)-273.15
'Switch on next AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'Measure thermoster temperature Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(PotTemp(1),1,11,VX2,0,_60Hz,26.079,82.359)
'Switch on next AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'Measure thermoster temperature Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(PotTemp(2),1,11,VX2,0,_60Hz,25.745,92.438)
'Switch on next AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'Measure thermoster temperature Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(PotTemp(3),1,11,VX2,0,_60Hz,25.572,85.11)
'Switch on next AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'Measure thermoster temperature Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(PotTemp(4),1,11,VX2,0,_60Hz,24.69,68.62)
'Switch on next AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'Measure thermoster temperature Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(PotTemp(5),1,11,VX2,0,_60Hz,25.463,83.226)
'Switch on next AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'Measure thermoster temperature Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(PotTemp(6),1,11,VX2,0,_60Hz,25.839,84.611)
'Switch on next AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'Measure thermoster temperature Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(PotTemp(7),1,11,VX2,0,_60Hz,31.264,171.22)
'Switch on next AM416 Multiplexer channel. PulsePort(DataLogger channel C#, Delay)
PulsePort(7,10000)
'Measure thermoster temperature Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm109(PotTemp(8),1,11,VX2,0,_60Hz,1,0)
PulsePort(7,10000)
'Measure thermoster temperature Therm109 (Dest, Reps, SEChan, VX/ExChan, SettlingTime, Integ, Mult, Offset)
Therm108(PotTemp(9),1,11,VX2,0,_60Hz,1,0)
'Turn AM16/32 Multiplexer Off. PortSet(DataLogger channel C#, State 0=off and reset)
PortSet(6,0)
Delay(0,150,mSec) 'Delay(Option, Delay, Units)
'Do soil moisture measurements
'Do soil water potential measurements
'Measure reference temperature'
PanelTemp(PTemp_C,_60Hz)
'Measure Sensors starting temperature
'TCDiff (Dest, Reps, Range, DiffChan, TCType, TRef,RevDiff, SettlingTime, Integ, Mult, Offset)
TCDiff (StartTemp_C(1), 1, mV2_5C, 1, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
TCDiff (StartTemp_C(2), 1, mV2_5C, 2, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
TCDiff (StartTemp_C(3), 1, mV2_5C, 3, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
TCDiff (StartTemp_C(4), 1, mV2_5C, 4, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
'Switch heater on
PortSet(4,1)
'Pause for a second
Delay(0,1,Sec)
'Take 1 Second measurements
TCDiff (Temp1Sec_C(1), 1, mV2_5C, 1, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
TCDiff (Temp1Sec_C(2), 1, mV2_5C, 2, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
TCDiff (Temp1Sec_C(3), 1, mV2_5C, 3, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
TCDiff (Temp1Sec_C(4), 1, mV2_5C, 4, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
'Pause for a further 29 seconds
Delay(0,29,Sec)
'Take 30 Second measurements
TCDiff (Temp30Sec_C(1), 1, mV2_5C, 1, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
TCDiff (Temp30Sec_C(2), 1, mV2_5C, 2, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
TCDiff (Temp30Sec_C(3), 1, mV2_5C, 3, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
TCDiff (Temp30Sec_C(4), 1, mV2_5C, 4, TypeT, PTemp_C,True, 0, _60Hz, 1, 0)
'Turn header off
PortSet(4,0)
'Do calculations
DeltaT_C(1) = Temp30Sec_C(1) - Temp1Sec_C(1)
WP(1) = exp(Alpha * DeltaT_C(1) + Beta)
DeltaT_C(2) = Temp30Sec_C(2) - Temp1Sec_C(2)
WP(2) = exp(Alpha * DeltaT_C(2) + Beta)
DeltaT_C(3) = Temp30Sec_C(3) - Temp1Sec_C(3)
WP(3) = exp(Alpha * DeltaT_C(3) + Beta)
DeltaT_C(4) = Temp30Sec_C(4) - Temp1Sec_C(4)
WP(4) = exp(Alpha * DeltaT_C(4) + Beta)
'Calculate mean
MeanWP = (WP(1) + WP(2) + WP(3) )/3
'If it is dry enough turn the irrigation on for a bit
If (MeanWP >= 2.4) Then
PortSet(2,1)
Delay(1,40,sec)
PortSet(2,0)
PortSet(1,1)
Delay(1,40,sec)
PortSet(1,0)
Delay(1,20,sec)
Irrigations = Irrigations + 1
EndIf
CallTable(Table1)
NextScan
EndProg