CRBasic Editor
Start
New Code
My Snippets
Public Snippets
Templates
Resources
'CR1000X Series Datalogger '************************* '****** CNR4 program ***** '************************* 'This program measures: ' 1. CNR4 four-component net radiometer along with the thermistor inside ' the CNR4. ' NOTE: User must enter the sensitivity values for all four component ' sensors in the program and save/compile prior to downloading it ' to the datalogger. ' Please search for the text string "unique" to find the sensitivity values. ' 2. EE181 temperature and relative humidity (RH) probe ' (RH is used to judge the status to turn on/off CNF4 fan and heater) ' 3. 03002 R.M.Young Wind Sentry Set ' (Wind speed is used to judge the status to turn on/off CNF4 fan) 'This program also controls ' 1. CNF4 to ventilate and heat CNR4. ' 2. A21 REL-12 Ralay Driver to supply power to CNF4 fan and heater ' NOTE: CR1000X SW12V power is not enough to control CNF4 fan and heater. ' Therefore, A21 REL-12 is added to supply power to CNF4. '***** Wiring Instructions***** '---------- A21REL-12 ---------- ' A21 REL-12 +12V Pos in external 12V power (Neither 12V nor SW12V in CR1000) ' A21 REL-12 G (near +12V) Neg in external 12V power (Not G in CR1000) ' A21 REL-12 G (near REL 1 COM) CNF4 ventilator and heater negative (brown, red, and blue) ' A21 REL-12 REL 1 COM Jump to A21 REL-12 +12V ' A21 REL-12 REL 1 NO CNF4 ventilator positive, 0.4A at 12 V (yellow) ' A21 CTRL 1 CR1000X C5 (user-defined color) ' A21 REL-12 REL 2 COM Jump to A21 REL 1 COM ' A21 REL-12 REL 2 NO CNF4 heater 1 positive, 0.5A at 12 V (white) ' A21 CTRL 2 CR1000X C6 (user-defined color) ' A21 REL-12 REL 3 COM Jump to A21 REL 2 COM ' A21 REL-12 REL 3 NO CNF4 heater 2 positive, 0.5A at 12 V (black) ' A21 CTRL 3 CR1000X C7 (user-defined color) '---------- CNR4 and CNF4 ---------- '*** CNR4 '1H Pyranometer signal for incoming short-wave radiation (red) '1L Pyranometer signal Reference incoming short-wave radiation (blue) 'gnd jumper to 1L '2H Pyranometer signal for outgoing short-wave radiation (white) '2L Pyranometer reference for outgoing short-wave radiation (black) 'gnd jumper to 2L '3H Pyrgeometer signal for incoming long-wave radiation (grey) '3L Pyrgeometer reference for incoming long-wave radiation (yellow) 'gnd jumper to 3L ' '4H Pyrgeometer signal for outgoing long-wave radiation (brown) '4L Pyrgeometer reference for outgoing long-wave radiation (green) 'gnd jumper to 4L 'gnd shield (clear) '8H Thermistor signal (white) '8L Thermistor reference (black) 'gnd Thermistor shield (clear) 'VX2 Thermistor voltage excitation (red) '*** CNF4 'P2 CNF4 tachometer signal (green) 'gnd CNF4 tachometer reference (grey) ' Ventilator positive, 0.4A at 12 V (yellow) A21 REL-12 REL 1 NO ' Ventilator negative (brown) A21 REL-12 G (near REL 1 COM) ' Heater 1 positive, 0.5A at 12 V (white) A21 REL-12 REL 2 NO ' Heater 1 negative (red) A21 REL-12 G (near REL 1 COM) ' heater 2 positive, 0.5A at 12 V (black) A21 REL-12 REL 3 NO ' Heater 2 negative (blue) A21 REL-12 G (near REL 1 COM) ' ---------- EE181 ---------- '5H Temperature signal (yellow) '5L Relative humidity signal (blue) 'gnd Reference for temperature and humidity (black) 'gnd Shield (clear) '12V Power (red) ' ---------- 03002 ---------- 'P1 Wind speed signal (red) 'gnd Wind speed reference (black) '7L Wind direction signal (green) 'VX1 Wind direction voltage excitation (blue) 'gnd Wind direction reference (white) 'gnd Shield (clear) '---------- CR1000 POWER IN ---------- ' +12V Pos in external 12V power ' G Neg in external 12V power '***** Variable and Constant Declarations ***** '---------- CNR4 and CNF4 ---------- '*** CNR4 'Refer to the Certificate of Calibration from Kipp & Zonen for sensitivity values 'for each probes, and enter them below. Const pyran_up_senstvty = 15.35 'unique sensitivity of face-up pyranometer (mV W-1 m-2) Const pyran_dn_senstvty = 15.41 'unique sensitivity of face-down pyranometer (mV W-1 m-2) Const pyrge_up_senstvty = 8.50 'unique sensitivity of face-up pyrgeometer (mV W-1 m-2) Const pyrge_dn_senstvty = 7.09 'unique sensitivity of face-down pyrgeometer (mV W-1 m-2) 'Convert sensitivity values to multipliers Public cnr4_mult(4) Const pyranometer_up_mult = 1000/pyran_up_senstvty '(W/m^2/mV) Const pyranometer_dn_mult = 1000/pyran_dn_senstvty '(W/m^2/mV) Const pyrgeometer_up_mult = 1000/pyrge_up_senstvty '(W/m^2/mV) Const pyrgeometer_dn_mult = 1000/pyrge_dn_senstvty '(W/m^2/mV) Public cnr4(4) Alias cnr4(1) = SW_IN 'Short-wave incoming radiation Alias cnr4(2) = SW_OUT 'Short-wave outgoing radiation Alias cnr4(3) = LW_IN 'Long-wave incoming radiation Alias cnr4(4) = LW_OUT 'Short-wave incoming radiation Units SW_IN = W m-2 Units SW_OUT = W m-2 Units LW_IN = W/m^2 Units LW_OUT = W/m^2 Public cnr4_T_C 'CNR4 thermistor temperature in Celsius Public cnr4_T_K 'CNR4 thermistor temperature in Kelvin Units cnr4_T_C = deg C Units cnr4_T_K = K Public LW_IN_TC 'Downwelling long-wave radiation with temperature correction Public LW_OUT_TC 'Upwelling long-wave radiation with temperature correction Units LW_IN_TC = W/m^2 Units LW_OUT_TC = W/m^2 Public Rn 'Full wave net radiation Public Rn_SW 'short-wave net radiation Public Rn_LW 'long-wave net radiation Units Rn = W/m^2 Units Rn_SW = W/m^2 Units Rn_LW = W/m^2 Public albedo 'Albedo Units albedo = adimensional Dim Rs, Vs_Vx 'Used to measure CNR4 body temperature '*** CNF4 Dim cnr4_fan_heater_on(3) As Boolean Alias cnr4_fan_heater_on(1) = cnr4_fan_on_f Alias cnr4_fan_heater_on(2) = cnr4_heater_1_on_f Alias cnr4_fan_heater_on(3) = cnr4_heater_2_on_f Dim cnr4_fan_heater_array(3) = {1, 1, 1} Alias cnr4_fan_heater_array(1) = cnr4_fan_secs 'Seconds of CNR4 fan on Alias cnr4_fan_heater_array(2) = cnr4_heater_1_secs 'Seconds of CNR4 heater #1 on Alias cnr4_fan_heater_array(3) = cnr4_heater_2_secs 'Seconds of CNR4 heater #2 on Units cnr4_fan_heater_array = s Public cnr4_fan_freq Units cnr4_fan_freq = Hz ' ---------- EE181 ---------- Public tmpr_rh(2) Alias tmpr_rh(1) = T 'Temperature/humidity probe: Temperature Alias tmpr_rh(2) = RH 'Temperature/humidity probe: Relative humidity Units T = deg C Units RH = % ' ---------- 03002 ---------- Public wind(2) Alias wind (1) = WS 'Wind speed Alias wind (2) = WD 'Wind direction in compass cordinate system Units WS = m s-1 Units WD = Ang deg '---------- CR1000X ---------- Public logger_temp, batt_volt Units logger_temp = degC Units batt_volt = volts '***** Data Tables ***** DataTable(cnr4_data, True, -1) DataInterval(0, 60, Min, 10) CardOut(1,-1) 'CNR4 data Average(4, cnr4(1), IEEE4, False) Average(1, cnr4_T_C, IEEE4, False) Average(1, cnr4_T_K, IEEE4, False) Average(1, LW_IN_TC, IEEE4, False) Average(1, LW_OUT_TC, IEEE4, False) Average(1, Rn, IEEE4, False) Average(1, Rn_SW, IEEE4, False) Average(1, Rn_LW, IEEE4, False) Average(1, albedo, IEEE4, False) 'CNR4 fan and heater actions Average (1, cnr4_fan_freq, IEEE4, False) Totalize (1, cnr4_fan_secs, IEEE4, ((NOT cnr4_fan_on_f) OR (cnr4_fan_freq = 0))) FieldNames("cnr4_fan_secs") Totalize (1, cnr4_heater_1_secs, IEEE4, (NOT cnr4_heater_1_on_f)) FieldNames("cnr4_heater_1_secs") Totalize (1, cnr4_heater_1_secs, IEEE4, (NOT cnr4_heater_2_on_f)) FieldNames("cnr4_heater_2_secs") 'EE181 data Average(1, T, IEEE4, False) Average(1, RH, IEEE4, False) ' 03002 data WindVector (1, WS, WD, IEEE4, 0, 0, 0, 0) 'Mean WS, unit vector WD, and STD WD 'CR1000X data Minimum(1, batt_volt, FP2, 0, False) Sample(1, logger_temp, FP2) EndTable DataTable(cnr4_ts, True, -1) DataInterval(0, 1, Sec, 10) CardOut(1,-1) 'CNR4 data Sample(4,cnr4(1), IEEE4) Sample(1,cnr4_T_K, IEEE4) 'EE181 data Sample(1, T, IEEE4) Sample(1, RH, IEEE4) EndTable '***** Program ***** BeginProg Scan(1, Sec, 3, 0) PanelTemp(logger_temp, 250) Battery(batt_volt) 'CNR4 radiation measurements VoltDiff(cnr4(), 4,mV200C, 1, True, 0, 60, cnr4_mult(), 0) 'CNR4 thermistor measurement BrHalf(Vs_Vx, 1,mV5000, 16, Vx2, 1, 2500, True, 0, 250, 1.0, 0) Rs = 1000*(Vs_Vx/(1 - Vs_Vx)) cnr4_T_K = 1/(1.0295e-3 + 2.391e-4*LN(Rs) + 1.568e-7*(LN(Rs))^3) cnr4_T_C = cnr4_T_K - 273.15 'Correct the long-wave radiation values from pyrgeometers LW_IN_TC = LW_IN + 5.67e-8*cnr4_T_K*cnr4_T_K*cnr4_T_K*cnr4_T_K LW_OUT_TC = LW_OUT + 5.67e-8*cnr4_T_K*cnr4_T_K*cnr4_T_K*cnr4_T_K 'Compute short-, long-, full-wave net radiation Rn_SW = SW_IN - SW_OUT Rn_LW = LW_IN_TC - LW_OUT_TC Rn = Rn_SW + Rn_LW 'Compute albedo albedo = SW_OUT/SW_IN ' Measure CNF4 tachometer PulseCount (cnr4_fan_freq, 1,P2,5, 1, 1, 0) ' Measure EE181 VoltSe (T, 1,mV5000, 9, TRUE, 0, 60, 1, -40) VoltSe (RH,1,mV5000,10, TRUE, 0, 60, 0.1, 0) 'Measure 03002 'Wind speed PulseCount (WS, 1,P1,5, 1, 0.75, 0.2) If WS < 0.21 Then WS = 0 'Wind direction BrHalf (WD, 1,mV5000, 14, Vx1, 1, 1000, True, 20000, 60, 352,0) If (WD >= 360) OR (WD < 0) Then WD = 0 'Control CNF4 fan and heaters If (WS > 5) Then 'User define what WS threshold for turning fan off cnr4_fan_on_f = FALSE 'Turn off fan due to strong wind if heater off Else cnr4_fan_on_f = TRUE 'Turn on fan due to low wind EndIf If (RH < 70) Then 'User define what RH threshold for turning heater off cnr4_heater_1_on_f = FALSE 'Turn heater #1 off cnr4_heater_2_on_f = FALSE 'Turn heater #2 off ElseIf (RH > 85) 'User define what RH threshold for turning one heater on cnr4_heater_1_on_f = TRUE 'Turn heater #1 on cnr4_heater_2_on_f = TRUE 'Turn heater #2 on cnr4_fan_on_f = TRUE 'Turn fan on Else 'Turn on two heater lines and fan cnr4_heater_1_on_f = TRUE 'Turn heater #1 on cnr4_heater_2_on_f = FALSE 'Turn heater #2 off cnr4_fan_on_f = TRUE 'Turn fan on EndIf PortSet (C5, cnr4_fan_on_f, 1) PortSet (C6, cnr4_heater_1_on_f, 1) PortSet (C7, cnr4_heater_2_on_f, 1) CallTable cnr4_data CallTable cnr4_ts NextScan EndProg Hello Hello
Test1
Make snippet public
Use mock deployment
Save & Share
Validate Code
Fix Missing Variables
Explain Code
Get Assistance
Simulate Code
Deploy to Datalogger
Versions
Version 2 (2024-10-22 19:38:02)
Version 1 (2024-10-19 14:56:14)
Load Selected Version