'********************************************************************************************* ' Biomet program for use with LI-COR SmartFlux 2 Const Version = "1.0" Const RevDate = "December 20, 2016" Const Author = "LI-COR, Inc." ' Copyright 2016, LI-COR, Inc. ' 'LI-COR, EddyPro and SmartFlux are registered trademarks of LI-COR, Inc. in the United States 'and other countries. All other trademarks belong to their respective owners. '********************************************************************************************* 'Notes: ' 1. Naming conventions are used to distinguish type; Constants use camel case, variables ' use all lower case and aliases use underscores. ' 2. Aliases for biomet variables available for output from the system follow a specific ' formatting that makes them interpretable to EddyPro and SmartFlux 2. See the LI-COR ' Biomet System manual for full details. ' 3. Variables for output to SmartFlux 2 can be found in the data table "Biomet". ' 4. All biomet sensor configurations (100, 101, 102 and 103) are supported on the CR1000 ' and CR3000. The CR6 does not have enough inputs to support the CNR4 and HFP01SC used ' in the biomet 103 configuration. In this case priority is given to the CNR4 and the ' self calibration subroutine for the HFP01SC is not used. Do not connect the heater ' cables from the HFP01SC in this use case. ' '********************************************************************************************* ' Wiring guide '********************************************************************************************* 'Sensor Wire Definition CR1000 terminal CR3000 terminal CR6 terminal ' color '--------------------------------------------------------------------------------------------- 'HMP155 white Temperature signal SE1 SE1 U1 'HMP155 green Signal ground G G G 'HMP155 yellow RH signal SE2 SE2 U2 'HMP155 blue +12VDC 12V 12V 12V 'HMP155 red Ground G G G 'HMP155 black Shield G G G '--------------------------------------------------------------------------------------------- 'NR Lite2 red Signal SE3 SE3 U3 'NR Lite2 blue Reference G G G 'NR Lite2 black Shield G G G '--------------------------------------------------------------------------------------------- 'CNR4 red Upper pyranometer(+) SE3 SE3 U3 'CNR4 blue Upper pyranometer(-) G G G 'CNR4 white Lower pyranometer(+) SE4 SE4 U4 'CNR4 black Lower pyranometer(-) G G G 'CNR4 grey Upper pyrgeometer(+) SE5 SE5 U5 'CNR4 yellow Upper pyrgeometer(-) G G G 'CNR4 brown Lower pyrgeometer(+) SE6 SE6 U6 'CNR4 green Lower pyrgeometer(-) G G G 'CNR4 black(fat)Shield G G G 'CNR4 Temp. white Thermistor SE7 SE7 U7 'CNR4 Temp. black Thermistor G G G 'CNR4 Temp. black(fat)Shield G G G 'Shunt Res. bare Lead 1 VX1 VX1 U8 'Shunt Res. bare Lead 2 SE7 SE7 U7 '--------------------------------------------------------------------------------------------- 'CNF4 red Ventilator(+) *DR06D03 #3 *DR06D03 #3 *DR06D03 #3 'CNF4 green Heater(+) *DR06D03 #2 *DR06D03 #2 *DR06D03 #2 'CNF4 blue Ventilator(-) G G G 'CNF4 yellow Heater(-) G G G 'CNF4 black Shield G G G '--------------------------------------------------------------------------------------------- 'Note: Assumes a Crydom DR06D03 is used to supply power to the CNF4 heater 'DR06D03 #2 +3/A1 "coil" (+) C8 C8 C2 'DR06D03 #2 4/A2 "coil" (-) G G G 'DR06D03 #2 2/T1 Switch out *CNF4 *CNF4 *CNF4 'DR06D03 #2 +1/L1 Switch in 12V 12V 12V '--------------------------------------------------------------------------------------------- 'Note: Assumes a Crydom DR06D03 is used to supply power to the CNF4 ventilator 'DR06D03 #3 +3/A1 "coil" (+) C7 C7 C3 'DR06D03 #3 4/A2 "coil" (-) G G G 'DR06D03 #3 2/T1 Switch out *CNF4 *CNF4 *CNF4 'DR06D03 #3 +1/L1 Switch in 12V 12V 12V '--------------------------------------------------------------------------------------------- 'LI-200/R red Signal(+) G G G 'LI-200/R black Signal(-) SE4 SE4 U4 '--------------------------------------------------------------------------------------------- 'LI-190/R red Signal(+) G G G 'LI-190/R black Signal(-) SE8 SE8 U9 '--------------------------------------------------------------------------------------------- 'TR-525M black Signal P1 P1 C4 'TR-525M white Signal return G G G 'TR-525M clear Shield G G G '--------------------------------------------------------------------------------------------- 'HFP01/SC #1 white Signal(+) SE9 SE9 U10 'HFP01/SC #1 green Signal(-) G G G 'HFP01/SC #1 black Shield G G G '--------------------------------------------------------------------------------------------- 'HFP01/SC #2 white Signal(+) SE10 SE10 U11 'HFP01/SC #2 green Signal(-) G G G 'HFP01/SC #2 black Shield G G G '--------------------------------------------------------------------------------------------- 'HFP01/SC #3 white Signal(+) SE11 SE11 U12 'HFP01/SC #3 green Signal(-) G G G 'HFP01/SC #3 black Shield G G G '--------------------------------------------------------------------------------------------- 'Note: Before connecting HFP01SC see notes above about biomet configuration 103 and the CR6 'HFP01SC #1 brown Heater power *DR06D03 #1 SW12-2 SW12-2 'HFP01SC #1 green Heater signal SE12 SE12 U5 'HFP01SC #1 black Ground G G G 'Comp. Res. bare Lead 1 SE12 SE12 U5 'Comp. Res. bare Lead 2 G G G '--------------------------------------------------------------------------------------------- 'HFP01SC #2 brown Heater power *DR06D03 #1 SW12-2 SW12-2 'HFP01SC #2 green Heater signal SE13 SE13 U6 'HFP01SC #2 black Ground G G G 'Comp. Res. bare Lead 1 SE12 SE12 U6 'Comp. Res. bare Lead 2 G G G '--------------------------------------------------------------------------------------------- 'HFP01SC #3 brown Heater power *DR06D03 #1 SW12-2 SW12-2 'HFP01SC #3 green Heater signal SE14 SE14 U7 'HFP01SC #3 black Ground G G G 'Comp. Res. bare Lead 1 SE12 SE12 U7 'Comp. Res. bare Lead 2 G G G '--------------------------------------------------------------------------------------------- 'Note: Assumes a Crydom DR06D03 is used to supply power to the HFP01SC during calibration 'DR06D03 #1 +3/A1 "coil" (+) C6 N/A N/A 'DR06D03 #1 4/A2 "coil" (-) G N/A N/A 'DR06D03 #1 2/T1 Switch out *HFP01SC (all) N/A N/A 'DR06D03 #1 +1/L1 Switch in 12V N/A N/A '--------------------------------------------------------------------------------------------- 'Note: All HydraProbeII connect to the same terminals 'HydraProbeII black Ground G G G 'HydraProbeII red Power SW12 SW12-1 SW12-1 'HydraProbeII blue Data C1 C1 C1 '--------------------------------------------------------------------------------------------- '********************************************************************************************* ' Automatically configure ranges and input channels based on logger type '********************************************************************************************* #If LoggerType = CR1000 Const SHFRange = mV250C 'Measurement range for HFP01/SC Const LICORRange = mV25 'Measurement range for LI-200/R and LI-190/R Const LiteRange = mV25 'Measurement range for NR Lite Const CNR4Range = mV25 'Measurement range for CNR4 Const ThermRange = mV2500 'Measurement range for CNR4 thermistor Const HMP155Range = mV2500C 'Measurement range for HMP155 Const SHFCalPort = 6 'Switched port for HFP01SC calibration Const HydraPort = 9 'Switched port for HydraProbeII power Const CNF4HeatPort = 8 'Switched port for CNF4 heater Const CNF4VentPort = 7 'Switched port for CNF4 ventilator Const HMP155Chan = 1 'First input channel for HMP155 Const RadiometerChan = 3 'First input channel for NR Lite2 or CNR4 Const CNR4TempChan = 7 'Input channel for CNR4 thermistor Const LI200Chan = 4 'Input channel for LI-200/R Const LI190Chan = 8 'Input channel for LI-190/R Const TR525MChan = 1 'Input channel for TR-525M Const HFP01Chan = 9 'First input channel for HFP01/SC Const HFP01SCChan = 12 'First input channel for HFP01SC heaters Const HydraChan = 1 'Input channel for HydraProbeII SDI12 data Const CNR4TempExt = Vx1 'Excitation channel for CNR4 thermistor #ElseIf LoggerType = CR3000 Const SHFRange = mV50 Const LICORRange = mV20 Const LiteRange = mV50 Const CNR4Range = mV20 Const ThermRange = mV5000 Const HMP155Range = mV1000C Const SHFCalPort = 10 Const HydraPort = 9 Const CNF4HeatPort = 2 Const CNF4VentPort = 3 Const HMP155Chan = 1 Const RadiometerChan = 3 Const CNR4TempChan = 7 Const LI200Chan = 4 Const LI190Chan = 8 Const TR525MChan = 1 Const HFP01Chan = 9 Const HFP01SCChan = 12 Const HydraChan = 1 Const CNR4TempExt = Vx1 #ElseIf LoggerType = CR6 Const SHFRange = mV200 Const LICORRange = mV200 Const LiteRange = mV200 Const CNR4Range = mV200 Const ThermRange = mV5000 Const HMP155Range = mV1000C Const CNF4HeatPort = C2 Const CNF4VentPort = C3 Const HMP155Chan = U1 Const RadiometerChan = U3 Const CNR4TempChan = U7 Const LI200Chan = U4 Const LI190Chan = U9 Const TR525MChan = C4 Const HFP01Chan = U10 Const HFP01SCChan = U5 Const HydraChan = C1 Const CNR4TempExt = U8 #EndIf '********************************************************************************************* ' Constants 'Constants in constant table "BiometConstants" are user settable from the key pad or through 'support software (OS28 and above). 'Constants not in "BiometConstants" should not be messed with. Leave them alone! '********************************************************************************************* ConstTable(BiometConstants) Const BiometPackage = 100 'Biomet sensor package: 100, 101, 102, 103 Const AveragePeriod = 60 'Averaging window in seconds Const ScanInterval = 5 'Scan interval from main loop in seconds Const UsePublicVars = 0 'Flag to set variables as public or not. If set to 1 all 'variables are public and can be seen in the public table. Const LogBiometData = 9999 'Number of records to store for biomet data: -1 = max- #If BiometPackage <> 100 'imum, any positive integer = that many data rows Const LogControlFlags = 1 'Number of records to store for control flags: -1 = max- #EndIf 'imum possible, any positive integer = that many data rows 'Note: ControlFlags is called at ScanInterval, so best 'practice is to use a fixed size (not -1). Const SHF1Sens = 60.01 'HFP01 #1 sensitivity in uVW-1m-2 Const SHF2Sens = 60.01 'HFP01 #2 sensitivity in uVW-1m-2 Const SHF3Sens = 60.01 'HFP01 #3 sensitivity in uVW-1m-2 #If BiometPackage = 102 OR BiometPackage = 103 Const SHF1RSelf = 100.01 'HFP01SC #1 self resistance in Ohms Const SHF2RSelf = 100.01 'HFP01SC #2 self resistance in Ohms Const SHF3RSelf = 100.01 'HFP01SC #3 self resistance in Ohms Const CompResistor = 10.01 'Resistance of completion resistor in Ohms Const CalDuration = 3 'How long to actively heat during calibration in minutes Const CalInterval = 6 'How often to calibrate HFP01SC in hours Const PostCalDelay = 10 'How long to wait before sampling after calibration in min #EndIf Const SoilType = 3 'Soil type ID: 1=sand, 2=silt, 3=clay, 4=loam Const HydraStartAddress = 1 'Address of first HyrdaProbe Const HydraStopAddress = 3 'Address of last HydraProbe 'Note: HydraProbe addressing assumes sequential addresses 'and is only demensioned for three sensors. Const LI190Mult = -200.01 'LI-190/R multiplier #If BiometPackage = 100 OR BiometPackage = 102 Const LI200Mult = -100.01 'LI-200/R multiplier #Else Const PyranometerUpSens = 15.01 'CNR4 upper pyranometer sensitivity Const PyranometerDownSens = 15.01'CNR4 lower pyranometer sensitivity Const PyrgeometerUpSens = 8.01 'CNR4 upper pyrgeometer sensitivity Const PyrgeometerDownSens = 8.01'CNR4 lower pyrgeometer sensitivity Const CNR4Shunt = 1000 'CNR4 temperature sensor shunt resistor resistance in Ohms Const HeatStartTime = "20:00" 'CNF4 heater turn on time Const HeatStopTime = "08:00" 'CNF4 heater turn off time Const VentStartTime = "20:00" 'CNF4 ventilator turn on time Const VentStopTime = "08:00" 'CNF4 ventilator turn off time #EndIf EndConstTable Const Period = AveragePeriod/ScanInterval #If BiometPackage = 100 OR BiometPackage = 102 Const NumberMult = 3 Const NumberVar = 10 Const NumberSample = NumberVar - 1 #Else Const NumberMult = 7 Const NumberVar = 16 Const NumberSample = NumberVar - 2 #EndIf '********************************************************************************************* ' Variable declarations, aliasing and units '********************************************************************************************* #If UsePublicVars = 1 Public mult(NumberMult), raw(NumberVar), hydraraw(3,6), means(NumberVar), hydra(3,6) Public tippingbucket #Else Dim mult(NumberMult), raw(NumberVar), hydraraw(3,6), means(NumberVar), hydra(3,6) Dim tippingbucket #EndIf Dim i = 1 Alias means(1) = VIN_18_39_1_1_1 'Input Power (CR1000/CR3000/CR6) Alias means(2) = SHF_6_37_1_1_1 'Soil Heat Flux (HFP01/SC) Alias means(3) = SHF_6_37_2_1_1 'Soil Heat Flux (HFP01/SC) Alias means(4) = SHF_6_37_3_1_1 'Soil Heat Flux (HFP01/SC) Alias means(5) = TA_2_1_1_1_1 'Air Temperature (HMP155) Alias means(6) = RH_19_3_1_1_1 'Relative Humidity (HMP155) Alias means(7) = PPFD_7_21_1_1_1 'Photosynthetic Photon Flux Density (LI-190/R-SL) #If BiometPackage = 100 OR BiometPackage = 102 Alias means(8) = RG_6_4_1_1_1 'Global Radiation (LI-200/R-SL) Alias means(9) = RN_6_5_1_1_1 'Net Radiation (NR Lite2) #Else Alias means(8) = SWIN_6_10_1_1_1 'Short-wave incoming (CNR4) Alias means(9) = SWOUT_6_11_1_1_1 'Short-wave outgoing (CNR4) Alias means(10) = LWIN_6_14_1_1_1 'Long-wave incoming (CNR4) Alias means(11) = LWOUT_6_15_1_1_1 'Long-wave outgoing (CNR4) Alias means(12) = RN_6_5_1_1_1 'Net Radiation (CNR4) Alias means(13) = RG_6_4_1_1_1 'Global Radiation (CNR4) Alias means(14) = ALB_99_26_1_1_1 'Albedo (CNR4) #EndIf Alias hydra(1,1) = TS_2_38_1_1_1 'Soil Temperature (HydraProbeII) Alias hydra(1,3) = SWC_12_36_1_1_1 'Soil Water Content (HydraProbeII) Alias hydra(2,1) = TS_2_38_2_1_1 'Soil Temperature (HydraProbeII) Alias hydra(2,3) = SWC_12_36_2_1_1 'Soil Water Content (HydraProbeII) Alias hydra(3,1) = TS_2_38_3_1_1 'Soil Temperature (HydraProbeII) Alias hydra(3,3) = SWC_12_36_3_1_1 'Soil Water Content (HydraProbeII) Alias tippingbucket = P_RAIN_8_19_1_1_1 'Precipitation (TR-525M) #If BiometPackage = 102 OR BiometPackage = 103 Dim shfcal(4,3), calflag(2) As Boolean = 0 Alias mult(1) = SHFSens_99_99_1_1_1 'Computed multipler for HFP01SC #1 Alias mult(2) = SHFSens_99_99_2_1_1 'Computed multipler for HFP01SC #2 Alias mult(3) = SHFSens_99_99_3_1_1 'Computed multipler for HFP01SC #3 Alias calflag(1) = SHF_CAL_ACTIVE 'Flag to indicate whether the soil heat flux plates 'are being heated: -1 = heating, 0 = not heating Alias calflag(2) = SHF_COOL_DOWN 'Flag to indicate whether the soil heat flux plates 'are cooling down post calibration: -1 = cooling down, '0 = not in a cool down period. #EndIf #If BiometPackage = 101 OR BiometPackage = 103 Dim heattimers(2), venttimers(2), heatflag As Boolean = 0, ventflag As Boolean = 0 Alias heatflag = HEATER_ACTIVE 'Flag to indicate whether the CNF4 heater is active: '-1 = heater on, 0 = heater off Alias ventflag = VENTILATOR_ACTIVE 'Flag to indicate whether the CNF4 ventilator is on: #EndIf '-1 = ventilator on, 0 = ventilator off Units VIN_18_39_1_1_1 = V Units SHF_6_37_1_1_1 = Wm-2 Units SHF_6_37_2_1_1 = Wm-2 Units SHF_6_37_3_1_1 = Wm-2 Units TA_2_1_1_1_1 = C Units RH_19_3_1_1_1 = % Units PPFD_7_21_1_1_1 = umolm-2s-1 Units RG_6_4_1_1_1 = Wm-2 Units RN_6_5_1_1_1 = Wm-2 #If BiometPackage = 101 OR BiometPackage = 103 Units SWIN_6_10_1_1_1 = Wm-2 Units SWOUT_6_11_1_1_1 = Wm-2 Units LWIN_6_14_1_1_1 = Wm-2 Units LWOUT_6_15_1_1_1 = Wm-2 Units ALB_99_26_1_1_1 = Other #EndIf Units hydra(1,1) = C Units hydra(1,3) = m3m-3 Units hydra(2,1) = C Units hydra(2,3) = m3m-3 Units hydra(3,1) = C Units hydra(3,3) = m3m-3 Units tippingbucket = mm #If BiometPackage = 102 OR BiometPackage = 103 Units SHFSens_99_99_1_1_1 = uVW-1m-2 Units SHFSens_99_99_2_1_1 = uVW-1m-2 Units SHFSens_99_99_3_1_1 = uVW-1m-2 #EndIf '********************************************************************************************* ' Data table(s) ' Variables for output to SmartFlux 2 must be in the table "Biomet" '********************************************************************************************* DataTable(VersionInfo,True,1) Sample(3,info(),String) FieldNames("Version:, RevDate:, Author:") EndTable DataTable(Biomet,True,LogBiometData) DataInterval(0,AveragePeriod,Sec,10) Sample(NumberSample,means(),FP2) Sample(1,hydra(1,1),FP2) Sample(1,hydra(1,3),FP2) Sample(1,hydra(2,1),FP2) Sample(1,hydra(2,3),FP2) Sample(1,hydra(3,1),FP2) Sample(1,hydra(3,3),FP2) Sample(1,tippingbucket,FP2) #If BiometPackage = 102 OR BiometPackage = 103 Sample(3,mult(1),FP2) #EndIf EndTable #If BiometPackage <> 100 DataTable(ControlFlags,True,LogControlFlags) 'Data table to hold the indicator #If BiometPackage = 102 OR BiometPackage = 103 'flags for various program con- Sample(2,calflag(1),Boolean) 'trols. #EndIf #If BiometPackage = 101 OR BiometPackage = 103 Sample(1,heatflag,Boolean) Sample(1,ventflag,Boolean) #EndIf EndTable #EndIf '********************************************************************************************* ' Main program '********************************************************************************************* #If BiometPackage = 102 OR BiometPackage = 103 Sub CalibrateSHF 'Subroutine to handle calibration 'of the soil heat flux plates. If TimeIntoInterval(0,CalInterval,Hr) Then 'Check to see if it is time to calflag(1) = -1 'calibrate and set heater on. VoltSe(shfcal(1,1),3,SHFRange,HFP01Chan,TRUE,200,250,0.001,0)'Sample soil heat flux 'plates at time 0 of calibration. EndIf If calflag(1) AND TimeIntoInterval(CalDuration,CalInterval*60,Min) Then calflag(1) = 0 'Turn the heater flag off and calflag(2) = -1 'set the cooling off period flag 'on after CalDuration expires. VoltSe(shfcal(2,1),3,SHFRange,HFP01Chan,TRUE,200,250,0.001,0)'Sample soil heat flux VoltSe(shfcal(4,1),3,mV5000,HFP01SCChan,TRUE,200,250,0.001,0)'plates at end of heating. EndIf If TimeIntoInterval(2*CalDuration,CalInterval*60,Min) Then VoltSe(shfcal(3,1),3,SHFRange,HFP01Chan,TRUE,200,250,0.001,0)'Sample soil heat flux EndIf 'plates after heating stops. If calflag(2) AND TimeIntoInterval(CalDuration+PostCalDelay,CalInterval*60,Min) Then calflag(2) = 0 'Set cooling down flag off once 'the PostCalDelay expires. Dim vamp, shfres(3), tempcal, calcheck(3) shfres(1) = SHF1RSelf 'Move individual sensor resis- shfres(2) = SHF2RSelf 'tances into a local array. shfres(3) = SHF3RSelf calcheck(1) = SHF1Sens 'Move factory cal values to a calcheck(2) = SHF2Sens 'local array to use for QA/QC. calcheck(3) = SHF3Sens i = 1 For i = 1 To 3 Step 1 vamp = ABS(((shfcal(1,i)+shfcal(3,i))/2)-shfcal(2,i)) 'Compute new multipliers tempcal = (2 * vamp) * ((CompResistor^2)*38.85e-4)/((shfcal(4,i)^2)*shfres(i)) tempcal = tempcal*(10^6) If tempcal >= (calcheck(i)*0.8) AND tempcal <= (calcheck(i)*1.05) Then 'Only set a new mult(i) = tempcal 'multiplier if the measured value EndIf 'is good. Next i EndIf #If LoggerType = CR1000 OR LoggerType = CR3000 PortSet(SHFCalPort,calflag(1)) 'Set power to the plates. #Else SW12(2,calflag(1)) #EndIf EndSub #EndIf Function TimerControl(on, off) As Boolean 'Function to handle timed Dim time(9), state = 0 'controls. RealTime(time()) 'Get current time from RTC. time(1) = (time(4)*60)+time(5) 'Compute minutes since midnight. If on > off Then 'Check to see what state should If time(1) >= on OR time(1) <= off Then 'be based on current time. state = -1 EndIf Else If time(1) >= on AND time(1) < off Then state = -1 EndIf EndIf Return(state) 'Return state to orginal call. EndFunction BeginProg Dim info(3) As String info(1) = Version info(2) = RevDate info(3) = Author CallTable VersionInfo mult(1) = SHF1Sens 'Move soil heat flux plate sens- mult(2) = SHF2Sens 'itivities into an array. mult(3) = SHF3Sens #If BiometPackage = 101 OR BiometPackage = 103 mult(4) = 1000/PyranometerUpSens 'Compute CNR4 multipliers from mult(5) = 1000/PyranometerDownSens 'the individual sensitivities. mult(6) = 1000/PyrgeometerUpSens mult(7) = 1000/PyrgeometerDownSens Dim timers(2) SplitStr (timers(1),HeatStartTime,":",2,0) 'Convert CNF4 heater and vent- heattimers(1) = (timers(1)*60)+timers(2) 'ilator start and stop times to SplitStr (timers(1),HeatStopTime,":",2,0) 'minutes since midnight format. heattimers(2) = (timers(1)*60)+timers(2) SplitStr (timers(1),VentStartTime,":",2,0) venttimers(1) = (timers(1)*60)+timers(2) SplitStr (timers(1),VentStopTime,":",2,0) venttimers(2) = (timers(1)*60)+timers(2) #EndIf #If LoggerType = CR1000 'Power up the HydraProbeIIs. SW12(1) #ElseIf LoggerType = CR3000 OR LoggerType = CR6 SW12(1,1) #EndIf Delay (0,3,Sec) 'Allow HydraProbeIIs to Dim st As String * 3 'stabilize. st = "XS" + SoilType 'Build soil type output message. For i = HydraStartAddress To HydraStopAddress Step 1 'Configure HydraProbeII outputs. SDI12Recorder(hydraraw(i-HydraStartAddress+1),HydraChan,i,"XM=2!",1,0) 'Set soil type on HydraProbeIIs. SDI12Recorder(hydraraw(i-HydraStartAddress+1),HydraChan,i,st,1,0) Next i #If LoggerType = CR1000 'Power down the HydraProbeIIs. SW12(0) #ElseIf LoggerType = CR3000 OR LoggerType = CR6 SW12(1,0) #EndIf Scan (ScanInterval,Sec,0,0) Battery(raw(1)) 'Get power to logger. #If BiometPackage = 102 OR BiometPackage = 103 #If LoggerType <> CR6 AND BiometPackage <> 103 Call CalibrateSHF 'Call heat flux plate cali- #EndIf 'bration routine. If calflag(1) OR calflag(2) Then 'When calibrating soil heat i = 2 'flux plates, fill the values For i = 2 To 4 Step 1 'with the last pre-calibration raw(i) = raw(i) 'value. Next i Else 'Sample soil heat flux plates 'if not calibrating them. VoltSe(raw(2),3,SHFRange,HFP01Chan,True,200,250,1000/mult(1),0) EndIf #Else 'Sample soil heat flux plates. VoltSe(raw(2),3,SHFRange,HFP01Chan,True,200,250,1000/mult(1),0) #EndIf VoltSe(raw(5),2,HMP155Range,HMP155Chan,True,0,_60Hz,0.1,0) 'Sample the HMP155. If raw(5) > 100 Then 'Fill bad data with NAN. raw(5) = NAN raw(6) = NAN Else raw(5) = raw(5) - 40 'Compute air temperature. EndIf 'Sample PPFD from the LI-190/R. VoltSe(raw(7),1,LICORRange,LI190Chan,True,0,_60Hz,LI190Mult,0) #If BiometPackage = 100 OR BiometPackage = 102 'Sample global radiation from VoltSe(raw(8),1,LICORRange,LI200Chan,True,0,_60Hz,LI200Mult,0)'the LI-200/R. 'Sample net radiation from the VoltSe(raw(9),1,LiteRange,RadiometerChan,True,0,_60Hz,15.3,0)'NR Lite2. #Else 'Sample the CNR4. VoltSe(raw(8),4,CNR4Range,RadiometerChan,True,0,_60Hz,mult(4),0) 'Sample the CNR4 thermistor. BrHalf(raw(15),1,ThermRange,CNR4TempChan,CNR4TempExt,1,2500,True,0,250,1.0,0) raw(15) = CNR4Shunt*(raw(15)/(1-raw(15))) 'Compute CNR4 body temperature. raw(15) = 1/(1.0295e-3+2.391e-4*LN(raw(15))+1.568e-7*(LN(raw(15)))^3)-273.15 raw(15) = raw(15)+273.15 raw(10) = raw(10)+5.67e-8*raw(15)^4 'Correct long-wave up for T. raw(11) = raw(11)+5.67e-8*raw(15)^4 'Correct long-wave down for T. raw(12) = (raw(8) - raw(9)) + (raw(10) - raw(11)) 'Compute net radiation. raw(13) = raw(8) + raw(10) 'Compute global radiation. raw(14) = raw(9)/raw(8) 'Compute albedo. heatflag = TimerControl(heattimers(1),heattimers(2)) 'Check to see if CNF4 heater 'should be on or off. ventflag = TimerControl(venttimers(1),venttimers(2)) 'Check to see if CNF4 vent- 'illator should be on or off. PortSet(CNF4HeatPort,heatflag) 'Turn the heater on or off. PortSet(CNF4VentPort,ventflag) 'Turn the ventilator on or off. #EndIf AvgRun(means(),NumberSample,raw(),Period) 'Compute running averages of 'almost all variables. 'This is done in the program 'rather than the data table to 'avoid appending _avg to the 'end of the variable names. PulseCount(raw(NumberVar),1,TR525MChan,2,0,0.1,0) 'Sample the rain gauge. AvgRun(means(NumberVar),1,raw(NumberVar),Period) tippingbucket = means(NumberVar) * Period 'Compute precipitation. #If LoggerType = CR1000 'Power up the HydraProbeIIs. SW12(1) #ElseIf LoggerType = CR3000 OR LoggerType = CR6 SW12(1,1) #EndIf Delay(0,3,Sec) 'Allow HydraProbeIIs to i = 1 'stabilize. For i = HydraStartAddress To HydraStopAddress Step 1 'Sample the HydraProbeIIs. SDI12Recorder(hydraraw((i-HydraStartAddress+1),1),HydraChan,i,"M!",1,0) Next i AvgRun(hydra(1,1),18,hydraraw(1,1),Period) 'Compute running average of 'soil temperature and moisture. #If LoggerType = CR1000 'Power down the HydraProbeIIs. SW12(0) #ElseIf LoggerType = CR3000 OR LoggerType = CR6 SW12(1,0) #EndIf CallTable Biomet 'Write data to the Biomet table. #If BiometPackage <> 100 CallTable ControlFlags 'Write data to the ControlFlags #EndIf 'table. NextScan EndProg