StationName (DFR4) Const SITE_ID = 4611 ' PakBus_ID = 611 Const RADIO_ON_MIN = 0 Const RADIO_OFF_MIN = 10 Const RADIO_V_LIM = 12.2 Const RADIO_HOLD_V_LIM = 12.6 '' END OF SITE-SPECIFIC PARAMETERS '' rep.cr1 01sep2008 10p kirving '' control port allocations: Const HMP_PWR = 8 ' optional 12V relay ''' thermistor bridge resistor value: Const Rf_kOhms = 1.0 ' Steinhart & Hart constants for YSI thermistors: Const a = 0.0014654354 Const b = 0.0002386780 Const c = 0.0000001000 Dim Time(9) ' entry 5 of realtime clock is aliased to thisMinute Dim i Dim lnR '' first 7 public variables appear on first keypad screen: public batt_volt, SolarPnlV public AT, RH ' air temp & humidity from HMP45C public ATB_degC(3) ' backup AT thermistors public StationID public PanelT public BBT_degC public DP ' calculated dewpoint '' radio control variables public RadioOnMin, RadioOffMin public RadioVlim, RadioHldVlim public Dim RadioHold as Boolean public Dim RadioForceOn as Boolean '' "current" values only updated near top of the hour: ' (these are intended to comply with NWS/NOAA standards) public CRNT_AT, CRNT_RH, CRNT_DP public CRNT_ATB(3) '' various diagnostic or intermediate variables: public ATB_X(3), ATB_kOhm(3) ' backup AT thermistors public BBT_X, BBT_kOHM public CRNT_ATB_X(3), CRNT_ATB_R(3) Alias Time(5) = thisMinute Alias AT = AirTemperature Alias RH = RelativeHumidity Alias BBT_degC = Batt_Box_T Alias DP = DewPt Units AT = deg C Units RH = % Units DP = deg C Units ATB_degC (1) = deg C Units ATB_degC (2) = deg C Units ATB_degC (3) = deg C Units BBT_degC = deg C Units CRNT_AT = deg C Units CRNT_RH = % Units CRNT_DP = deg C Units CRNT_ATB (1) = deg C Units CRNT_ATB (2) = deg C Units CRNT_ATB (3) = deg C Units CRNT_ATB_R (1) = kOhm Units CRNT_ATB_R (2) = kOhm Units CRNT_ATB_R (3) = kOhm Units BBT_kOHM = kOHM DataTable (HrlyDiag,1,-1) DataInterval (0,60,Min,0) Sample (1,StationID,fp2) Average (1,batt_volt,FP2,False) Sample (1,BBT_kOHM,fp2) Sample (1,BBT_degC,fp2) Sample (1,PanelT,FP2) Average (1,SolarPnlV,FP2,False) EndTable DataTable (HrlyRaw,True,-1) DataInterval (0,60,Min,0) Sample(1,StationID,fp2) Average (3,CRNT_ATB_R(),FP2,False) Average (3,ATB_kOHM(),FP2,False) EndTable DataTable (HrlyAtms,1,-1) DataInterval (0,60,Min,0) Sample(1,StationID,fp2) Average (1,CRNT_AT,FP2,False) Average (1,CRNT_RH,FP2,False) Average (1,CRNT_DP,FP2,False) Average (3,CRNT_ATB_X(),FP2,False) Average (1,AT,FP2,False) Maximum (1,AT,FP2,False,False) Minimum (1,AT,FP2,False,False) Average (1,RH,FP2,False) Maximum (1,RH,FP2,False,False) Minimum (1,RH,FP2,False,False) Average (3,ATB_degC(),FP2,False) EndTable DataTable (DailyRaw,True,-1) DataInterval(0,1440,Min,0) Sample(1,StationID,fp2) Average (3,ATB_kOHM(),FP2,False) Maximum (3,ATB_kOHM(),FP2,False,False) Minimum (3,ATB_kOHM(),FP2,False,False) EndTable DataTable (Daily,1,-1) DataInterval(0,1440,Min,0) Sample(1,StationID,fp2) Average (1,AT,FP2,False) Maximum (1,AT,FP2,False,False) Minimum (1,AT,FP2,False,False) Average (3,ATB_degC(),FP2,False) Maximum (3,ATB_degC(),FP2,False,False) Minimum (3,ATB_degC(),FP2,False,False) Maximum (1,RH,FP2,False,False) Minimum (1,RH,FP2,False,False) EndTable Sub Read_HMP45AC VoltSE (AT,1,mV2500,6,1,0,250,0.1,-40.0) VoltSE (RH,1,mV2500,5,1,0,250,0.1,0) DewPoint (DP,AT,RH) '' save "current" values near the top of the hour: If thisMinute >= 55 Then CRNT_AT = AT CRNT_RH = RH CRNT_DP = DP EndIf EndSub ' Read_HMP45AC Sub Read_AT_Therms '' read and process 3 AT thermistors: BrHalf (ATB_X(),3,mV2500,14,Vx2,3,2500,0,0,250,1.0,0) For i=1 To 3 ATB_kOhm(i) = Rf_kOhms*ATB_X(i)/(1-ATB_X(i)) lnR = LN (1000*ATB_kOhm(i)) ATB_degC(i) = (1/(a + b*lnR + c*lnR^3)) - 273.15 Next i '' save "current" values near the top of the hour: If thisMinute >= 55 Then CRNT_ATB(1) = ATB_degC(1) CRNT_ATB(2) = ATB_degC(2) CRNT_ATB(3) = ATB_degC(3) CRNT_ATB_R(1) = ATB_kOhm(1) CRNT_ATB_R(2) = ATB_kOhm(2) CRNT_ATB_R(3) = ATB_kOhm(3) EndIf EndSub ' Read_AT_Therms Sub RadioControl ( onMin, offMin, batV, Vlimit, holdVlimit ) '' turn SW12() on & off at specified minutes into interval '' battery voltage must be above Vlimit to turn radio on '' global RadioHold flag prevents turning radio OFF if set '' RadioHold flag is cleared if battery < holdVlimit '' special case: radio turns on at noon regardless of V limits '' subroutine should normally run every minute If RadioForceOn Then SW12(1) If thisMinute = onMin Then If batV >= Vlimit then SW12(1) if RadioHold AND batV < holdVlimit Then RadioHold = 0 Endif If IfTime(12, 24, hr) Then SW12(1) If thisMinute = offMin Then If NOT RadioHold Then SW12(0) Endif EndSub ' RadioControl Sub Read_BattBoxTemp '' read battery box thermistor voltage ratio, '' calculate resistance, calculate temperature: BrHalf (BBT_X,1,mV2500,8,Vx1,1,2500,0,0,250,1.0,0) BBT_kOHM = Rf_kOhms*BBT_X/(1-BBT_X) lnR = LN (1000*BBT_kOHM) BBT_degC = (1/(a + b*lnR + c*lnR^3)) - 273.15 EndSub ' Read_BattBoxTemp BeginProg Dim Running ' value = 0 only when program starts Scan (10,Sec,0,0) StationID = SITE_ID '' once per minute: '' set thisMinute value from logger clock If IfTime(0, 60, Sec) then RealTime(Time()) ' sets thisMinute variable Endif '' every 10 seconds: '' read AT & RH, calculate DP '' read ATB thermistors PortSet (HMP_PWR, 1) Delay (0,150,mSec) ' allow sensor to settle call Read_HMP45AC PortSet (HMP_PWR, 0) call Read_AT_Therms '' every minute, check: '' panel temp, voltages, radio control If IfTime (0,60,Sec) Then '' read built-in sensors: PanelTemp (PanelT,250) Battery (batt_volt) '' read solar panel voltage: VoltSE (SolarPnlV,1,mV2500,12,1,0,250,0.011,0) '' SPECIAL CASE for startup: '' turn radio and RadioHold on when the program starts! If Running = 0 Then ' just started... SW12(1) RadioOnMin = RADIO_ON_MIN RadioOffMin = RADIO_OFF_MIN RadioVlim = RADIO_V_LIM RadioHldVlim = RADIO_HOLD_V_LIM RadioHold = 1 Running = 1 Endif call RadioControl (RadioOnMin, RadioOffMin, batt_volt, RadioVlim, RadioHldVlim ) Endif '' every hour, check: '' battery box temperature: If IfTime (0,60,Min) Then call Read_BattBoxTemp CallTable HrlyDiag CallTable HrlyRaw CallTable HrlyAtms CallTable DailyRaw CallTable Daily NextScan EndProg