'CRBasic angle units are in Radians by default. 'Switch to Degrees as CR10 used Degrees. AngleDegrees ' ' Declare array of flags as the CR10 had. 'Public Flag(8) as boolean '\\\\\\\\\\\\\\\\\\\\\\\\\ DECLARATIONS ///////////////////////// Dim I Dim NextAddr As String * 4 'public i1 Public CS230Temp(10) 'Public ID Public PROG_SIG Public SrlNum Public Vt Public AIR_TEMP Public IN_PYRAN Public OUT_PYRAN Public SNOW(2) 'Public Ve 'Public Vf(11) Public Batt_Volt 'Public BattVoltBank Public It Public T_KELVIN Public REF_TEMP Public MULT Public Z_dir Public Z_spd Public smstV1 Public smstV2 Public smstV3 Public smstV4 Public BP_mbar Public RAIN 'Public TWC Units BP_mbar=mbar Units Temp5=Deg C Units Temp10=Deg C Units Temp15=Deg C Units Temp20=Deg C Units Temp25=Deg C Units Temp30=Deg C Units Temp45=Deg C Units Temp70=Deg C Units Temp90=Deg C Units Temp120=Deg C alias Snow(1) = SnowDepth ' added Alias SNOW(2) = Quality ' added Alias CS230Temp(1)=Temp5 Alias CS230Temp(2)=Temp10 Alias CS230Temp(3)=Temp15 Alias CS230Temp(4)=Temp20 Alias CS230Temp(5)=Temp25 Alias CS230Temp(6)=Temp30 Alias CS230Temp(7)=Temp45 Alias CS230Temp(8)=Temp70 Alias CS230Temp(9)=Temp90 Alias CS230Temp(10)=Temp120 '\\\\\\\\\\\\\\\\\\\\\\\\ OUTPUT SECTION //////////////////////// DataTable(Table1,true,-1) OpenInterval DataInterval(0,60,Min,10) Average(1, Vt, FP2, 0) Average(1, IN_PYRAN, FP2, 0) Average(1, OUT_PYRAN, FP2, 0) Average(1,Temp5,FP2,False) Average(1,Temp10,FP2,False) Average(1,Temp15,FP2,False) Average(1,Temp20,FP2,False) Average(1,Temp25,FP2,False) Average(1,Temp30,FP2,False) Average(1,Temp45,FP2,False) Average(1,Temp70,FP2,False) Average(1,Temp90,FP2,False) Average(1,Temp120,FP2,False) 'Average(1, Ve, FP2, 0) 'Average(11, Vf, FP2, 0) Average(1, It, FP2, 0) WindVector (1,Z_spd,Z_dir,FP2,False,0,0,1) Totalize(1, RAIN, FP2, 0) Sample(1,SnowDepth,fp2) ' added Sample(1,Quality,fp2) ' added Sample(1, smstV1, FP2) Sample(1, smstV2, FP2) Sample(1, smstV3, FP2) Sample(1, smstV4, FP2) Sample(1,BP_mbar,FP2) Minimum(1, Batt_Volt, FP2, 0, False) Maximum(1, Batt_Volt, FP2, 0, False) 'Minimum(1, BattVoltBank, FP2, 0, False) ' Maximum(1, BattVoltBank, FP2, 0, False) EndTable DataTable(Table2,true,-1) OpenInterval DataInterval(0,60,Min,10) Average(1,AIR_TEMP, FP2, 0) WindVector (1,Z_spd,Z_dir,FP2,False,0,0,1) Totalize(1, RAIN, FP2, 0) 'Average(1,TWC,FP2,0) Sample(1,BP_mbar,FP2) EndTable '\\\\\\\\\\\\\\\\\\\\\\\\\ SUBROUTINES ////////////////////////// '\\\\\\\\\\\\\\\\\\\\\\\\\\\ PROGRAM //////////////////////////// BeginProg Scan(30,Sec, 3, 0) 'Read the battery voltages. Battery(Batt_Volt) 'VoltDiff ( BattVoltBank,1,mV2500,8,True ,0,250,0.01,0) '**********************Radio Control Section************************* ' RADIO CONTROL STATEMENTS ' IF BATT V > 12.4 V, TURN ON RADIO (LEAVE RADIO ON) ' IF BATT V > 12.4 V CHECK EVERY HOUR ' IF BATT V < 12.2 V SET FLAG 1 LOW ' IF BATT V >= 12.1 V LEAVE RADIO ON ' IF BATT V < 12.1 V TURN RADIO OFF AT 10 MIN PAST HOUR ' RADIO IS ALWAYS ON UNLESS BATT V < 12.2 V, THEN RADIO IS ON ONLY FOR 10 MIN EVERY HOUR ' 'Configure Port 8 as an output for toggling the radio 'If (Batt_Volt < 12.4) Then ' If TimeInToInterval(0,60,Min) Then ' If (Batt_Volt < 12.2) Then Flag(1) = False ' If (Batt_Volt >= 12.1) Then PortSet(8, 1) ' EndIf ' If TimeInToInterval(0,60,Min) Then PortSet(8, 1) ' If Flag(1) = False then ' If TimeInToInterval(10,60,Min) Then PortSet(8, 0) ' EndIf ' Else ' PortSet(8, 1) ' EndIf '-----END OF RADIO CONTROL STATEMENTS----- 'iridium control' 'Turn on power to the Iridium Modem 3 times per day for 10-15 minutes each time, use port 7 'Only activate the modem if battery voltage is above 12.1V If (Batt_Volt > 12.1) Then If TimeIntoInterval(550,1440,Min) Then PortSet(6,1) If TimeIntoInterval(605,1440,Min) Then PortSet(6,0) Else PortSet(6,0) EndIf If (Batt_Volt > 12.1) Then If TimeIntoInterval(715,1440,Min) Then PortSet(6,1) If TimeIntoInterval(735,1440,Min) Then PortSet(6,0) Else PortSet(6,0) EndIf If (Batt_Volt > 12.1) Then If TimeIntoInterval(840,1440,Min) Then PortSet(6,1) If TimeIntoInterval(855,1440,Min) Then PortSet(6,0) Else PortSet(6,0) EndIf 'Read the 107 air temperature probe. This must be done prior to the 'snow depth so that it can use the air temperature as an input. Read the raw 'voltage (Vt) for final storage. BRHalf(Vt, 1, mV7_5, 7, VX1, 1, 2000, true, 0, 250, 2000, 0) Therm107(AIR_TEMP,1,7,VX1,0,_60Hz,1,0) ' Convert air temperature to kelvin for the SR50 snow depth sensor. T_KELVIN = AIR_TEMP + 273.15 'Read the incoming (downwelling) pyranometer. VoltDiff(IN_PYRAN, 1, mV7_5, 2, true, 0, _60Hz, 1, 0) 'Read the outgoing (upwelling) pyranometer. VoltDiff(OUT_PYRAN, 1, mV7_5, 3, true, 0, _60Hz, 1, 0) 'Read the Wind Direction BrHalf(Z_dir, 1, mV2500, 12, VX2, 1, 2500,True, 200, 250, 355, 0) 'Read the Wind Speed PulseCount(Z_spd, 1, 1, 1, 1, 0.098, 0) 'Read the TE525 Tipping Bucket Rain Gage PulseCount(RAIN, 1, 2, 2, 0, 0.1, 0) 'Calculate wind chill for provisional telemetry data 'TWC = 13.127+(0.6215*AIR_TEMP)-13.947*(Z_spd^0.16)+0.486*AIR_TEMP*(Z_spd^0.16) 'Read the internal temperature, and soil temperatures once per hour. 'Read the internal dataloger temperature. PanelTemp(It, 250) If TimeIntoInterval(55,60,Min) Then 'CS230/CS231 SDI-12 Temperature Profiler measurements 'CS230Temp()' NextAddr="1" For I=1 To 10 SDI12Recorder(CS230Temp(I),3,NextAddr,"R0!",1,0) NextAddr=CHR(ASCII(NextAddr)+1) If ASCII(NextAddr)=58 Then NextAddr=CHR(65) If ASCII(NextAddr)=91 Then NextAddr=CHR(97) Next EndIf 'If TimeInToInterval(0,60,Min) Then 'Set control port 4 high to turn 5 volts on to the MRC probe (Ve - switches on 'transistors to gate the Campbell 5-volt output to the probe). Power-on resets 'the probe control. Set control port 5 to a 10 millisecond pulse width. 'PortSet (4,1 ) 'P20 'Delay 20 milliseconds before reading the excitation voltage. ' Delay(0,20,MSEC) 'Read the excitation voltage Ve) on single ended channel 1. Use the 2500 millivolt 'scale and multiply by .002 (the voltage is through a 2:1 [100k x 100k) voltage 'divider). ' VoltSE(Ve, 1, mV2500, 1, False, 0, _60Hz, 0.002, 0) 'Loop 11 times to measure the thermistors and the precision resistor. ' For i1 = 1 to 11 'Pulse the MRC probe to clock in the first/next thermistor. ' PulsePort(5,10000) 'Delay 20 milliseconds between measurements. Use excitation channel 2 (nothing 'connected) and an excitation voltage of "zero" to preserve power. ' Delay(0,20,MSEC) 'Read the MRC probe voltage drop across the field resistor with single-ended 'channel 2. Use the 25 millivolt range with 60 HZ rejection. 'VoltSE(Vf(i1), 1, mV25, 2, False, 0, _60Hz, 1, 0) 'Next i1 'Set control ports 4 and 5 low. 'PortSet (4,0) 'PortSet (5,0) ' EndIf 'Read the snow depth once per hour. If TimeInToInterval(0,60,Min) Then 'Read the SR50 snow depth - Use a multiplier of 1000 to convert to millimeters. SDI12Recorder (SNOW(), 1,"0","M1!", 1, 0)) REF_TEMP = 273.15 MULT = T_KELVIN / REF_TEMP MULT = SQR(MULT) SNOW = SNOW * MULT EndIf 'Read the Hydraprobe Soil Moisture once per hour 'Stevens Vitel Hydraprobe soil moisture measurement sequence 'Delay 1.5 seconds to allow the snow depth sensor readings to complete If TimeInToInterval(0,60,Min) Then Delay(0,1500,MSEC) ' Activate the switched 12V supply to the sensor by switching 12V to it with the port "9" command PortSet(9, 1) ' Delay 3 seconds to allow hydraprobe to start up and stabilize Delay (0,3000,mSec) 'Make the four single ended voltage measurements from the Hydraprobe VoltSE(smstV1, 1, mV2500, 8, False, 0, _60Hz, 0.001, 0) VoltSE(smstV2, 1, mV2500, 9, False, 0, _60Hz, 0.001, 0) VoltSE(smstV3, 1, mV2500, 10, False, 0, _60Hz, 0.001, 0) VoltSE(smstV4, 1, mV2500, 11, False, 0, _60Hz, 0.001, 0) PortSet(9, 0) EndIf 'CS105 Barometric Pressure Sensor measurement BP_mbar: If IfTime(59,60,Min) Then PortSet(7,1) If IfTime(0,60,Min) Then VoltSE(BP_mbar,1,mV2500,13,1,0,_60Hz,0.184,600.0) BP_mbar=BP_mbar*1.0 PortSet(7,0) EndIf ' Read the program signature once per day If TimeInToInterval(0,1440,Min) Then PROG_SIG=Status.ProgSignature(1,1) SrlNum=Status.SerialNumber(1,1) EndIf ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 'Output section 'Store 1-hour data to final storage. CallTable Table1 'Store 1-hour provisional telemetery data to final storage. CallTable Table2 NextScan EndProg