'' 2-18-2016 Joel Bailey Changed hold time for HC2S3 to 5 seconds to allow warm up time for -20C and colder '' 4-12-2016 Joel Bailey Added NR-Lite radiometer to Diff port 4 '' 5-18-2016 Joel Bailey Added Precip gauge '' 6-09-2016 Joel Bailey Added Pieziometers '' 10-07-2016 Joe Bailey Movesd the PB measurements inside 5 sec scann interval, changed offset for PB to 500 from 600 constTable ' pakbus-info: const PAKBUS_INFO = 12 ' site-info: const SITE_NAME = "Goldstream Pond" const SITE_DESCR = "met station" const TZ_HOURS = -9 ' rh-pwr-on: const RH_RELAY__CP = 4 ' air-hc2s3: const ATRH_MODL = "HC2S3" Const RH_MULT = 0.1 Const RH_OFS = 0 const AT_MULT = 0.1 const AT_OFS = -50 const AT__SE = 1 const RH__SE = 2 ' wind-rmyoung: const WSWD_MODL = "RMY 05103" const WS_MULT = 0.098 const WD_OFS = 0 const WD_MULT = 355 const WS__PP = 1 const WD__SE = 3 const WD__EX = Vx1 ' air-soil-cs109: const ATB_MODL = "CS109" const ATB__SE = 4 const ST0__SE = 5 const CS109__EX = Vx3 ' solar-panel: const SPANEL_VDIV__SE = 9 ' barometer-cs106: const PB_MODL = "CS106" const PB_UNITS = "mBar" const PB_MULT = 0.24 Const PB_OFS = 500 const PB__SE = 15 ' snow-sr50a: const SNW_MODL = "SR50A" const SNW_SDI_ADDR = 0 const SDI12__CP = 5 Const SNW_HT_CM = 200 ' NR-Lite Const NR_MODL = "NR-LITE" Const NR_SN = "XXXX" Const NR_CALIB = 12.7 Const NR_CALIB_UNITS = "uV/W/m^2" Const NR_UNITS = "W/m^2" Const NR__DIFF = 4 ' radio: const RDIO_PWR__CP = 9 const RDIO_MODL = "FGR" const RDIO_ON_MIN = 0 const RDIO_PERIOD_MIN = 30 Const RDIO_TIMER_SEC = 300 const RDIO_V_LIM = 12.4 Const RDIO_HOLD_V_LIM = 12.6 ' thermistor probe ' Mux: CSI AM16/32B in 2*32 Mode ' Mux wiring: Group 1-16 HI GIPL subsurface thermistors ' Logger Wiring: Resistor SE 16 to Vx2 ' SE 16 to mux COM odd H ' G to mux COM G ' 12V to mux 12V ' G to mux G ' C1 to mux Res ' C2 to mux Clk ' Steinhart-Hart Fit Constants for thermistor probe Const C1 = 0.0011281 Const C2 = 0.0002343 Const C3 = 0.000000086946 Const Rf = 25000 ' Resistor Value Const ST_QTY = 16 Const ST_DEPTHS_CM = "0,5,10,15,20,25,30,35,40,50,60,70,80,100,125,150" const MUX_SE_QTY = 1 Const MUX_THERM__SE = 16 const MUX_RESET__CP = 1 const MUX_CLOCK__CP = 2 Const MUX__EX = Vx2 ' Rain gauge Const P_MODL = "TE525MM" Const P_TIP = 0.1 Const P_UNITS = "mm" Const P__PP = 2 EndConstTable ' prog-signature: Public progSig As Long ' air-hc2s3: public at : units at = degC public rh : units rh = percent public dp : units dp = degC ' wind-rmyoung: public ws : units ws = m/s public wd : units wd = deg ' air-soil-cs109: public atb : units atb = degC public st0 : units st0 = degC ' battery: public battery : units battery = Volts ' solar-panel: public solarPanel : units solarPanel = Volts ' logger-panel-temp: public panelTemp : units panelTemp = degC ' barometer-cs106: Public pb units pb = mbar ' snow-sr50a: public sr50_raw(2) public sr50_down public snowdepth public sr50_height Alias sr50_raw(2) = sr50_quality 'nr-lite sensor Public nr Units nr=W/m^2 ' precip-te525m: Public precip Units precip = P_UNITS ' time-variables: Dim Time(9) alias time(4) = thisHour alias time(5) = thisMinute alias time(9) = thisDOY ' radio: public radioOnMin, radioPeriod, radioTimer, radioTimerPreset, radioVlim, radioHoldVlim Public radioHold As Boolean, radioForce As Boolean ' Thermistor probe related variables Public Thermistors(16) : Units Thermistors = Deg C Public Thermistors_offset(16) Public TP_Rt, TP_ratio ' thermistor voltage to resistance variables Dim i Alias Thermistors(1) = Deep_Probe_Thermistor_1 Alias Thermistors(2) = Deep_Probe_Thermistor_2 Alias Thermistors(3) = Deep_Probe_Thermistor_3 Alias Thermistors(4) = Deep_Probe_Thermistor_4 Alias Thermistors(5) = Deep_Probe_Thermistor_5 Alias Thermistors(6) = Deep_Probe_Thermistor_6 Alias Thermistors(7) = Deep_Probe_Thermistor_7 Alias Thermistors(8) = Deep_Probe_Thermistor_8 Alias Thermistors(9) = Deep_Probe_Thermistor_9 Alias Thermistors(10) = Deep_Probe_Thermistor_10 Alias Thermistors(11) = Deep_Probe_Thermistor_11 Alias Thermistors(12) = Deep_Probe_Thermistor_12 Alias Thermistors(13) = Deep_Probe_Thermistor_13 Alias Thermistors(14) = Deep_Probe_Thermistor_14 Alias Thermistors(15) = Deep_Probe_Thermistor_15 Alias Thermistors(16) = Deep_Probe_Thermistor_16 Dim Count Public FCLoaded Public AVWRC Public VW(3,6) Public CReps Public ZMode Public CIndex Public CAvg Public Freq(3) Public Amp(3) Public SNRat(3) Public NFreq(3) Public DRat(3) Public TR(3) Public TT(3) Public TT0(3) Public Digits(3) Public Digits0(3) Public Lvl(3) Public G_Factor(3)={-.007028,-.006669,-.006829} Public T_Factor(3)={-.003505,-.005019,-.003622} Public F0Digits(3)={9891,9952,10025} Public F0Temp(3)={24.9,22.7,22.4} Public F0BP(3)={972.4,972.5,972.6} Alias Lvl(1) = GSP1_1_91CM Alias Lvl(2) = GSP1_3_291.9CM Alias Lvl(3) = GSP1_2_191.2CM Units Freq=Hz Units Amp=mV RMS Units NFreq=Hz Units TR=ohms Units TT=deg C Units TT0=deg C Units Digits=digits Units Digits0=digits Units Lvl=m ' Atms: prog-signature air-hc2s3 air-soil-cs109 barometer-cs106 snow-sr50a DataTable(Atms,1,-1) dataInterval(0,60,Min,0) sample(1,progSig,uint2) sample(1,at,fp2) average(1,at,fp2,0) minimum(1,at,fp2,0,0) maximum(1,at,fp2,0,0) Sample(1,rh,fp2) minimum(1,rh,fp2,0,0) maximum(1,rh,fp2,0,0) sample(1,dp,fp2) average(1,dp,fp2,0) minimum(1,dp,fp2,0,0) maximum(1,dp,fp2,0,0) sample(1,atb,fp2) average(1,atb,fp2,0) minimum(1,atb,fp2,0,0) maximum(1,atb,fp2,0,0) sample(1,pb,fp2) average(1,pb,fp2,0) Average(1,snowdepth,fp2,0) Average(1,nr,FP2,False) Totalize(1,precip,fp2,0) EndTable ' Diag: prog-signature battery solar-panel logger-panel-temp DataTable(Diag,1,-1) dataInterval(0,60,Min,0) sample(1,progSig,uint2) average(1,battery,fp2,0) average(1,solarPanel,fp2,0) average(1,panelTemp,fp2,0) EndTable ' Met: prog-signature air-hc2s3 wind-rmyoung air-soil-cs109 barometer-cs106 snow-sr50a DataTable(Met,1,-1) dataInterval(0,60,Min,0) sample(1,progSig,uint2) average(1,at,fp2,0) sample(1,rh,fp2) sample(1,ws,fp2) sample(1,wd,fp2) windVector(1,ws,wd,fp2,0,0,0,0) fieldnames("ws_mean:,wd_mean:,wd_stdev:") maximum(1,ws,fp2,0,0) average(1,atb,fp2,0) average(1,pb,fp2,0) Average(1,snowdepth,fp2,0) Average(1,nr,FP2,False) Totalize(1,precip,fp2,0) endTable ' Soil: prog-signature air-soil-cs109 DataTable(Soil,1,-1) dataInterval(0,60,Min,0) sample(1,progSig,uint2) sample(1,st0,fp2) average(1,st0,fp2,0) maximum(1,st0,fp2,0,0) minimum(1,st0,fp2,0,0) endTable ' SR50: prog-signature air-hc2s3 snow-sr50a DataTable(SR50,1,-1) dataInterval(0,60,Min,0) sample(1,progSig,uint2) average(1,at,fp2,0) average(1,SnowDepth,fp2,0) sample(1,SR50_height,fp2) average(1,sr50_quality,fp2,0) endTable ' Therm-R: prog-signature soil-thermistors DataTable(Therm-R,1,-1) DataInterval(0,180,Min,0) Sample(1,progSig,uint2) Average(16,Thermistors(),FP2,False) EndTable 'Calibration history table DataTable(CalHist,NewFieldCal,10) SampleFieldCal EndTable 'Define Data Tables DataTable(Waterlev,True,-1) DataInterval(0,60,Min,10) Sample(1,TT(1),FP2) Sample(1,Digits(1),IEEE4) Sample(1,Lvl(1),FP2) Sample(1,TT(2),FP2) Sample(1,Digits(2),IEEE4) Sample(1,Lvl(2),FP2) Sample(1,TT(3),FP2) Sample(1,Digits(3),IEEE4) Sample(1,Lvl(3),FP2) EndTable ' relay-control:relayControl() sub relayControl(relay, condition, onMin, periodMin, timerSec, timerPreset, optional hold=0, optional forceOnce=0, optional scanSec=60) timerSec = timerSec - scanSec if onMin < 0 then onMin = (onMin + periodMin) mod periodMin if condition AND (public.timestamp(1,1) intdv 60) mod periodMin = onMin OR forceOnce then if timerSec < timerPreset then timerSec = timerPreset if forceOnce then forceOnce=0 endif if relay = 9 then if timerSec > 0 then if NOT status.SW12Volts then SW12(1) else if NOT hold AND status.SW12Volts then SW12(0) endif else if timerSec > 0 then if NOT status.portStatus(relay) then call setPortState(relay,1) else if NOT hold AND status.portStatus(relay) then call setPortState(relay,0) endif endif endSub ' relay-control:setPortState() sub setPortState(port,state as boolean) ' port 9 is SW12V ' skip ports 3 and 4 (com2) ' skip ports 5 and 6 (com3) ' skip ports 7 and 8 (com4) select case port case 9: portSet(9,state) case 2: portSet(2,state) case 1: portSet(1,state) endSelect endSub BeginProg ' for prog-signature: progSig = status.ProgSignature ' for snow-sr50a: sr50_height = SNW_HT_CM ' for radio: radioOnMin = RDIO_ON_MIN radioPeriod = RDIO_PERIOD_MIN radioTimerPreset = RDIO_TIMER_SEC radioVlim = RDIO_V_LIM radioHoldVlim = RDIO_HOLD_V_LIM radioHold = 1 radioForce = 1 'thermistor offsets Thermistors_offset(1) = 0.005 'Thermistor 1 TP 1221 Thermistors_offset(2) = 0.111 'Thermistor 2 TP 1221 Thermistors_offset(3) = 0.086 'Thermistor 3 TP 1221 Thermistors_offset(4) = 0.047 'Thermistor 4 TP 1221 Thermistors_offset(5) = 0.003 'Thermistor 5 TP 1221 Thermistors_offset(6) = 0.002 'Thermistor 6 TP 1221 Thermistors_offset(7) = 0.008 'Thermistor 7 TP 1221 Thermistors_offset(8) = 0.004 'Thermistor 8 TP 1221 Thermistors_offset(9) = -0.033 'Thermistor 9 TP 1221 Thermistors_offset(10) = 0.046 'Thermistor 10 TP 1221 Thermistors_offset(11) = -0.009 'Thermistor 11 TP 1221 Thermistors_offset(12) = 0.048 'Thermistor 12 TP 1221 Thermistors_offset(13) = 0.046 'Thermistor 13 TP 1221 Thermistors_offset(14) = 0.013 'Thermistor 14 TP 1221 Thermistors_offset(15) = 0.003 'Thermistor 15 TP 1221 Thermistors_offset(16) = 0.045 'Thermistor 16 TP 1221 SerialOpen(ComSDC7,115200,0,0,0) 'Initialize calibration variables for 'Geokon 4500 Series Vibrating Wire Piezometer calculation 'Lvl()' CReps=3 : CIndex=1 : CAvg=1 For Count = 1 To 3 Digits0(Count)=F0Digits(Count) : TT0(Count)=F0Temp(Count) Next 'Load the most recent calibration values from the CalHist table FCLoaded=LoadFieldCal(True) Scan(60,sec,0,0) ' air-hc2s3: VoltSe(at,1,mV2500,AT__SE,1,0,250,AT_MULT,AT_OFS) VoltSe(rh,1,mV2500,RH__SE,1,0,250,RH_MULT,RH_OFS) DewPoint(dp,at,rh) ' barometer-cs106: VoltSe(pb,1,mV2500,PB__SE,1,0,250,PB_MULT,PB_OFS) ' rh-pwr-off: PortSet(RH_RELAY__CP,0) ' wind-rmyoung: PulseCount(ws,1,WS__PP,1,1,WS_MULT,0) BrHalf(wd,1,mV2500,WD__SE,WD__EX,1,2500,1,0,250,WD_MULT,WD_OFS) ' air-soil-cs109: Therm109(atb,1,ATB__SE,CS109__EX,0,250,1.0,0) Therm109(st0,1,ST0__SE,CS109__EX,0,250,1.0,0) ' battery: battery(battery) ' solar-panel: VoltSe(solarPanel,1,mV5000,SPANEL_VDIV__SE,True,0,250,0.01,0) ' logger-panel-temp: panelTemp(panelTemp,250) ' snow-sr50a: SDI12Recorder(sr50_raw, SDI12__CP, SNW_SDI_ADDR, "M1!", 1, 0) sr50_raw = sr50_raw * -100.0 sr50_down = sr50_raw * SQR((at+273.15) / 273.15) snowdepth = sr50_height + sr50_down 'NR-LITE2 Net Radiometer (dynamic wind speed correction) measurement 'nr' and 'corr_nr' VoltDiff(nr,1,mv25,NR__DIFF,True,0,250,1000/NR_CALIB,0) If ws>=5 Then nr=nr*(1+0.021286*(ws-5)) Else nr=nr EndIf ' precip-te525m: PulseCount(precip,1,P__PP,2,0,P_TIP,0) ' thermistors: If TimeIntoInterval (0,10,Min) Then PortSet(MUX_RESET__CP,1) i = 1 SubScan(0,uSec,ST_QTY) PulsePort(MUX_CLOCK__CP,10000) BrHalf (TP_ratio, 1, mV2500, MUX_THERM__SE,MUX__EX, 1, 2500, False, 0, 250,1.0,0) TP_Rt = Rf*(TP_ratio/(1-TP_ratio)) 'calculate resistance Thermistors(i) = 1/(C1+C2*LN(TP_Rt)+C3*LN(TP_Rt)^3) - 273.15 - Thermistors_offset(i) 'calculate temperature with correction for zero offset i = i+1 NextSubScan PortSet(MUX_RESET__CP,0) EndIf ' call-datatables: CallTable Met CallTable Atms CallTable Diag CallTable SR50 CallTable Soil CallTable Therm-R ' time-variables: RealTime(Time()) ' radio: If IfTime(12,24,hr) Then radioForce = 1 relayControl(RDIO_PWR__CP, battery>radioVlim, radioOnMin, radioPeriod, radioTimer, radioTimerPreset, radioHold, radioForce) If IfTime(30,60,min) AND radioHold AND battery < radioHoldVlim Then radioHold = 0 NextScan SlowSequence Scan(5,sec,0,0) ' rh-power-on: If IfTime(55, 60, sec) Then PortSet(RH_RELAY__CP,1) NextScan SlowSequence Scan(15,min,0,0) 'Geokon 4500 Series Vibrating Wire Piezometer measurement 'Freq()' AVW200(AVWRC,ComSDC7,0,200,VW(1,1),1,1,3,1000,4000,1,_60Hz,1,0) For Count=1 To 3 Freq(Count)=VW(Count,1) Amp(Count)=VW(Count,2) SNRat(Count)=VW(Count,3) NFreq(Count)=VW(Count,4) DRat(Count)=VW(Count,5) TR(Count)=VW(Count,6) 'Calculate thermistor temperature 'TT()' TT(Count)=1/(1.4051E-3+2.369E-4*LN(TR(Count))+1.019E-7*LN(TR(Count))^3)-273.15 'Calculate digits 'Digits()' Digits(Count)=Freq(Count)^2/1000 'Calculate water level 'Lvl()' (PSI) Lvl(Count)=(Digits0(Count)-Digits(Count))*G_Factor(Count)+(TT(Count)-TT0(Count))*T_Factor(Count) 'Convert water level 'Lvl()' from PSI to m Lvl(Count)=Lvl(Count)*-0.70432 Next 'Zeroing calibration for 'Geokon 4500 Series Vibrating Wire Piezometer calculations 'Digits()' and 'TT()' FieldCal(4,Digits(),CReps,0,Digits0(),ZMode,0,CIndex,CAvg) FieldCal(4,TT(),CReps,0,TT0(),ZMode,0,CIndex,CAvg) 'Call Data Tables and Store Data CallTable Waterlev CallTable CalHist NextScan EndProg