'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 ///////////////////////// 'Variables for Iridium Configuration Public SetupStr As String * 51 Public configure_modem As Boolean public i1 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 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 alias Snow(1) = SnowDepth ' added Alias Snow(2) = Quality ' added '\\\\\\\\\\\\\\\\\\\\\\\\ 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, 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) 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 voltage. Battery(Batt_Volt) '**********************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 'new logic for freewave and iridium, freewave is only on 15 min each hour and only if 'battery voltage is more than 12.1V 'If (Batt_Volt > 12.1) Then 'If TimeIntoInterval(1,60,Min) Then 'PortSet(8, 1) 'EndIf 'If TimeIntoInterval(16,60,Min) Then ' PortSet(8,0) ' EndIf ' Else ' PortSet(8,0) ' EndIf 'iridium control' 'Turn on power to the Iridium Modem 3 times per day for 10-15 minutes each time, use port 6 'Only activate the modem if battery voltage is above 12.1V 'iridium control' 'Turn on power to the Iridium Modem 3 times per day for 10-15 minutes each time, use port 6 'Only activate the modem if battery voltage is above 12.1V 'PortSet (6,1) 'PortSet (6,0) If (Batt_Volt > 12.1) Then 'Activate Iridium Modem initialization string setting once per day and keep on for transmission 'If TimeIntoInterval (630,1440,Min) Then PortSet (8,1) 'If TimeIntoInterval (650,1440,Min) Then PortSet (8,0) 'Allow the modem 1 minute for warm up before sending settings. Once settings are 'sent to the modem allow another 4 minutes to ensure the modem is registered on 'the network before attempting communications. If IfTime (656,1440,min) Then configure_modem = true If configure_modem = true Then SerialOpen (ComRS232,19200,0,0,2000) Delay (0,1,Sec) 'Send the correct settings SetupStr = "AT&F0 S0=1 &D0 +IPR=6,0 V0 &K0 &W0 &Y0" & CHR(13) & CHR(10) SerialOut (ComRS232,SetupStr,"",0,0) configure_modem = false SerialClose (ComRS232) EndIf Else PortSet(8,0) EndIf If (Batt_Volt > 12.1) Then If TimeIntoInterval(660,1440,Min) Then PortSet(8,1) If TimeIntoInterval(680,1440,Min) Then PortSet(8,0) Else PortSet(8,0) EndIf If (Batt_Volt > 12.1) Then If TimeIntoInterval(760,1440,Min) Then PortSet(8,1) If TimeIntoInterval(780,1440,Min) Then PortSet(8,0) Else PortSet(8,0) EndIf If (Batt_Volt > 12.1) Then If TimeIntoInterval(840,1440,Min) Then PortSet(8,1) If TimeIntoInterval(860,1440,Min) Then PortSet(8,0) Else PortSet(8,0) EndIf '-----END OF RADIO CONTROL STATEMENTS----- '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(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 ù