'' 5-18-2016 Joel Bailey added Raind gauge and Net radiometer, changed to 5 sec delay for AT '' 10-07-2016 Joe Bailey Movesd the PB measurements inside 5 sec scann interval, changed offset for PB to 500 from 600 ' soil-thermistors: const MUX_PULSE_USEC = 10000 '' Steinhart & Hart constants for PS302J2, calculated on host hayes: '' steinhart-hart-constants -10.00 16598.58 0.00 9795.00 10.00 5970.16 const kA = 0.001393520 const kB = 0.000238918 Const kC = 0.000000093 Const NR_WS_CORR = 0.021286 constTable ' pakbus-info: const PAKBUS_INFO = 13 ' site-info: const SITE_NAME = "East Old Murphy Dome Road" 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 ' soil-moisture-cs650: const SM_MODL = "CS650" const SM_QTY = 3 const SM_DEPTHS_CM = "10,30,50" const SM_SDI__CP = 3 const SM1_SDI_ADDR = 1 const SM2_SDI_ADDR = 2 const SM3_SDI_ADDR = 3 ' soil-thermistors: const ST_TYPE = "PS302J2" const ST_QTY = 8 const ST_DEPTHS_CM = "5,10,20,30,50,70,90,110" const MUX_SE_QTY = 1 const MUX_THERM__SE = 16 const MUX_RESET__CP = 1 const MUX_CLOCK__CP = 2 const MUX__EX = Vx2 const R_REF_KOHMS = 15.000 const SETTLING_USEC = 25000 ' 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 ' Rain gauge Const P_MODL = "TE525MM" Const P_TIP = 0.1 Const P_UNITS = "mm" Const P__PP = 2 ' NR-Lite Radiometer Const NR_MODL = "NR-LITE" Const NR_SN = "114115" Const NR_CALIB = 12.3 Const NR_CALIB_UNITS = "uV/W/m^2" Const NR_UNITS = "W/m^2" Const NR__DIFF = 4 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 ' soil-moisture-cs650: ' volumetric water content public sm_vwc(3) : units sm_vwc() = m^3/m^3 ' soil electrical conductivity public sm_ec(3) : units sm_ec() = dS/m ' soil temperature at probe public sm_st(3) : units sm_st() = deg C public sm_sdi_addr(3) dim j dim cs650(3) ' soil-thermistors: ' brhalf() measurement yields ratio of thermistor to reference R: dim st_X(ST_QTY) ' thermistor resistance is resolved by Ohms Law and ref R from ratio: public st(ST_QTY) : units st() = degC ' thermistor temperature calculated by Steinhart & Hart curve fit: public st_R(ST_QTY) : units st_R() = kOhms dim lnR Dim i ' 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 ' precip-te525m: Public precip Units precip = P_UNITS ' netrad-nrlite: Public nr(2) Alias nr = netRad_raw,netRad Units nr() = NR_UNITS ' 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) Totalize(1,precip,fp2,0) Average(1,netRad,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) Totalize(1,precip,fp2,0) Average(1,netRad,fp2,0) endTable ' Soil: prog-signature air-soil-cs109 soil-moisture-cs650 soil-thermistors 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) average(SM_QTY,sm_vwc(),fp2,0) average(SM_QTY,sm_ec(),fp2,0) average(SM_QTY,sm_st(),fp2,0) average(ST_QTY,st(),fp2,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,60,Min,0) sample(1,progSig,uint2) average(ST_QTY,st_R(),fp2,0) 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 soil-moisture-cs650: sm_sdi_addr(1) = SM1_SDI_ADDR sm_sdi_addr(2) = SM2_SDI_ADDR sm_sdi_addr(3) = SM3_SDI_ADDR ' 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 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 ' precip-te525m: PulseCount(precip,1,P__PP,2,0,P_TIP,0) ' netrad-nrlite: VoltDiff(nr,1,mv25,NR__DIFF,True,0,250,1000/NR_CALIB,0) netRad = netRad_raw If ws > 5 Then netRad = netRad_raw * (1 + NR_WS_CORR * (ws-5)) ' 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(600,sec,0,0) ' soil-moisture-cs650: for j = 1 To SM_QTY SDI12Recorder(cs650(1),SM_SDI__CP,sm_sdi_addr(j),"M!",1.0,0) sm_vwc(j) = cs650(1) sm_ec(j) = cs650(2) sm_st(j) = cs650(3) next j ' soil-thermistors: portSet(MUX_RESET__CP,1) i = 1 subScan(0,Sec,ST_QTY) pulsePort(MUX_CLOCK__CP,MUX_PULSE_USEC) brHalf(st_X(i),1,mV2500,MUX_THERM__SE,MUX__EX,1,2500,True,SETTLING_USEC,250,1.0,0) i = i + 1 nextSubScan portSet(MUX_RESET__CP,0) for i=1 To ST_QTY st_R(i) = R_REF_KOHMS * st_X(i) / (1-st_X(i)) lnR = ln(st_R(i)*1000) st(i) = (1/(kA + kB*lnR + kC*lnR^3)) - 273.15 next i nextScan endProg