Hi all,
I would like to know (if possible) the order of scans.
I have a main scan of 1 sec.
I have a scan of 250ms and one at 12 seconds.
Am i right in doing the order like so:
Main scan 1 sec.
Subscan 250ms.
Slow sequence 12 seconds.
Or can i use the subscan for 12 seconds too?
With kind regards.
A SubScan is a time based loop within another scan. Subscan is part of a scan. I believe SubScan is not what you want to use in this case.
Scan Priority:
#1 Main Scan
#2 Slow Sequence 1
#3 Slow Sequence 2
#4 Slow Sequence 3
#5 Slow Sequence 4
A scan will pause when it is time for a higher priority scan to run. Put your measurements in scans according to their priority. Check the Status table for skipped scans to see when scans have been paused longer than their interval.
Hi,
Thanks for your reply.
The subscan is a 250ms scan for only the windspeed sensor.
It is used to have the windspeed measuring a running 3s average from the 250ms scan according to WMO.
The other sensors are all 1 second.
The 12 second is used for the 12s average winddirection which is pulled from the Tablename.fieldname instruction from the windvector from a 12s table.
I am even not sure where to put the "calltable" instructions regarding the scan types.
Maybe it is more clear if i add my code so it is more visible:)
With kind regards.
PreserveVariables pipelinemode 'Declare Variables and Units Dim AirTC_2 Dim SPkPa Dim Twg Dim Twpg Dim Vpg Dim Vp Dim SVp Dim Twch Dim VpgVpd Dim Top Dim Bottom Dim SVpW Dim N Dim HITF Dim AirTC_3 Dim WCTF Dim WCWSMPH Public BattV Public PTemp_C Public WS_MS_250ms Public WS_KPH_250ms Public RunAvg_WS_KPH_250ms Public twaalf_sec_avg_WindDir Public WindDir Public WindDHist(5) Public WindDHist50(50) Public WindD Public WindD50 Public deltawind Public deltaD Public lastwind Public MaxD(2), MaxD50(2) Public MinD(2), MinD50(2) Public AvgWindD, AvgWindD50 Public mostbacked, mostbacked50 Public mostveered, mostveered50 Public AvgRunWindD, AvgRunWindD50 Public twaalf_sec_avg_RunAvg_WS_KPH_250ms Public AirTC Public RH Public BP_mbar Public SlrW Public Rain_mm Public rain12sec Public rain1minuut Public Precepitation_type Public tips1 Public SlrMJ Public Tot24 Public Mode(6) Public DestMaxSpa(2) Public Lufft_R2S_Mode Public TdC Public TwC Public HI_C Public SVPWPa Public SunHrs Public PrecipitationHrs Public PotSlrW Public RTime(9) Public SolPos(5) Public WC_C Public Rain_mm_tot_hour Public Rain_inch_tot_hour Public Tot24_inch Public BP_inch Public Tdf Public AirTf Public WS_mph Public WS_kts Public RunTotal Alias RTime(1)=Year Alias RTime(2)=Month Alias RTime(3)=DayOfMonth Alias RTime(4)=HourOfDay Alias RTime(5)=Minutes Alias RTime(6)=Seconds Alias RTime(7)=Microseconds Alias RTime(8)=DayOfWeek Alias RTime(9)=DayOfYear Alias SolPos(1)=SolarAzimuth Alias SolPos(2)=SunElevation Alias SolPos(3)=HourAngle Alias SolPos(4)=Declination Alias SolPos(5)=AirMass Units BattV=Volts Units PTemp_C=Deg C Units RunAvg_WS_KPH_250ms=kilometers/hour Units WindDir=degrees Units AirTC=Deg C Units RH=% Units BP_mbar=mbar Units Rain_mm=mm Units SlrW=W/m^2 Units SlrMJ=MJ/m^2 Units TdC=Deg C Units TwC=Deg C Units HI_C=Deg C Units SVPWPa=Pa Units SunHrs=hours Units PotSlrW=W/m^2 Units WC_C=Deg C Units Year=years Units Month=months Units DayOfMonth=days Units HourOfDay=hours Units Minutes=Minutes Units Seconds=seconds Units Microseconds=microseconds Units DayOfWeek=days Units DayOfYear=days Units SolarAzimuth=degrees Units SunElevation=degrees Units HourAngle=radians Units Declination=radians Units AirMass=unitless 'Define Data Tables DataTable(Table12,True,-1) DataInterval(0,12,Sec,0) WindVector(1,RunAvg_WS_KPH_250ms,WindDir,IEEE4,0,0,0,0) FieldNames("WS_KPH_S_WVT,WindDir_D1_WVT,WindDir_SD1_WVT") Maximum(1,RunAvg_WS_KPH_250ms,FP2,False,False) Totalize(1,Rain_mm,FP2,False) FieldNames("RAIN12SEC") Sample(1,AirTC,IEEE4,False) Sample(1,RH,IEEE4,False) Sample(1,BP_mbar,IEEE4,False) EndTable DataTable(event,True,60) DataEvent (0,tips1>0,1,0) Sample (1,tips1,FP2) Sample (1,Precepitation_type,FP2) tips1=0 EndTable 'Define Data Tables DataTable(Table1,True,-1) DataInterval(0,1,Min,10) WindVector(1,RunAvg_WS_KPH_250ms,twaalf_sec_avg_WindDir,FP2,False,0,0,0) FieldNames("WS_KPH_S_WVT,WindDir_D1_WVT,WindDir_SD1_WVT") Maximum(1,RunAvg_WS_KPH_250ms,FP2,False,False) Average(1,AirTC,IEEE4,False) Maximum(1,AirTC,FP2,False,False) Minimum(1,AirTC,FP2,False,False) StdDev(1,AirTC,IEEE4,False) Average(1,RH,IEEE4,False) Maximum(1,RH,FP2,False,False) Minimum(1,RH,FP2,False,False) Average(1,BP_mbar,IEEE4,False) Maximum(1,BP_mbar,IEEE4,False,False) Minimum(1,BP_mbar,IEEE4,False,False) Totalize(1,Rain_mm,FP2,False) FieldNames("RAIN_ONE_MINUTE") Average(1,rain12sec,IEEE4,False) Maximum(1,rain12sec,IEEE4,False,False) Minimum(1,rain12sec,IEEE4,False,False) Sample(1,Lufft_R2S_Mode,IEEE4,False) Sample(1,Mode(1),IEEE4,False) Sample(1,Mode(2),IEEE4,False) Sample(1,Mode(3),IEEE4,False) Sample(1,Mode(4),IEEE4,False) Sample(1,Mode(5),IEEE4,False) Sample(1,Mode(6),IEEE4,False) Average(1,SlrW,FP2,False) Maximum(1,SlrW,FP2,False,False) Average(1,TdC,FP2,False) Maximum(1,TdC,FP2,False,False) Minimum(1,TdC,FP2,False,False) Average(1,TwC,FP2,False) Maximum(1,TwC,FP2,False,False) Minimum(1,TwC,FP2,False,False) Average(1,HI_C,FP2,False) Maximum(1,HI_C,FP2,False,False) Average(1,SVPWPa,FP2,False) Maximum(1,SVPWPa,FP2,False,False) Minimum(1,SVPWPa,FP2,False,False) Totalize(1,SunHrs,FP2,False) Totalize(1,PrecipitationHrs,FP2,False) Average(1,PotSlrW,FP2,False) Maximum(1,PotSlrW,FP2,False,False) Minimum(1,PotSlrW,FP2,False,False) Average(1,WC_C,FP2,False) Minimum(1,WC_C,FP2,False,False) Sample (1,AvgRunWindD,FP2) Sample (1,mostbacked,FP2) Sample (1,mostveered,FP2) EndTable 'Define Data Tables DataTable(Table10,True,-1) DataInterval(0,10,Min,10) WindVector(1,RunAvg_WS_KPH_250ms,twaalf_sec_avg_WindDir,FP2,False,0,0,0) FieldNames("WS_KPH_S_WVT,WindDir_D1_WVT,WindDir_SD1_WVT") Maximum(1,RunAvg_WS_KPH_250ms,FP2,False,False) Sample (1,AvgRunWindD50,FP2) Sample (1,mostbacked50,FP2) Sample (1,mostveered50,FP2) EndTable '\\\\\\\\\\\\\\\\\\\\\\\ DataTable /////////////////////// DataTable(upload,True,1) DataInterval(0,1,Min,10) Average(1,AirTC,FP2,False) Average(1,AirTf,FP2,False) Average(1,TdC,FP2,False) Average(1,Tdf,FP2,False) Average(1,RH,FP2,False) Average(1,BP_mbar,IEEE4,False) Average(1,BP_inch,IEEE4,False) WindVector(1,RunAvg_WS_KPH_250ms,AvgRunWindD,FP2,False,0,0,0) Maximum(1,RunAvg_WS_KPH_250ms,FP2,False,True) SampleMaxMin(1,WindDir,FP2,False) Average(1,WS_mph,FP2,False) Average(1,WS_kts,FP2,False) Maximum(1,WS_mph,FP2,False,True) Maximum(1,WS_kts,FP2,False,True) Average(1,SlrW,IEEE4,False) Sample(1,Tot24,IEEE4,False) Sample(1,Tot24_inch,IEEE4,False) Sample(1,Rain_mm_tot_hour,IEEE4,False) Sample(1,Rain_inch_tot_hour,IEEE4,False) EndTable AngleDegrees 'Main Program BeginProg 'Main Scan Scan(1,Sec,10,0) ' max mV - min mV = xxxx,xx 'range sensor / uitkomst van boven = 'multiplier' 'min mV x 'multiplier' = 'offset' '\\\\\\\\\\\\\\\\\\\\\\\ Direction Sensor measurements 'WindDir' /////////////////////// VoltDiff(WindDir,1,mV2500,2,True,0,250,0.1795,-0) WindDir = (WindDir-220+360)MOD 360 If WindDir>360 Then WindDir =WindDir-360 If WindDir <0 Then WindDir = WindDir+360 twaalf_sec_avg_WindDir = Table12.WindDir_D1_WVT(1) WindDir = WindDir MOD 360 '\\\\\\\\\\\\\\\\\\\\\\\ Rain Gauge measurement 'Rain_mm' /////////////////////// PulseCount(Rain_mm,1,1,2,0,0.01,0) PulseCount(Precepitation_type,1,2,2,1,1,0) TotalRun (RunTotal,1,Rain_mm,1) ''VoltDiff(WS_kph_one_sec,1,mV2500,1,True,0,250,0.081035,-40) 'Default CR1000 Datalogger Battery Voltage measurement 'BattV' Battery(BattV) 'Default CR1000 Datalogger Wiring Panel Temperature measurement 'PTemp_C' PanelTemp(PTemp_C,250) '\\\\\\\\\\\\\\\\\\\\\\\ Temperature & Relative Humidity Sensor measurements 'AirTC' and 'RH' /////////////////////// ''VoltDiff(AirTC,1,mV2500,3,True,0,_60Hz,0.05,-65) VoltDiff(AirTC,1,mV2500,3,True,0,250,0.05,-65) VoltDiff(RH,1,mV2500,4,True,0,250,0.05,-25) '' If (RH>100) AND (RH<108) Then RH=100 '\\\\\\\\\\\\\\\\\\\\\\\ Barometric Pressure Sensor measurement 'BP_mbar' /////////////////////// VoltDiff(BP_mbar,1,mV2500,6,1,0,250,0.184,600) '\\\\\\\\\\\\\\\\\\\\\\\ Pyranometer measurements 'SlrMJ' and 'SlrW' /////////////////////// VoltDiff(SlrW,1,mV250,7,True,0,250,1,0) If SlrW<0 Then SlrW=0 'Calculate total flux 'The multiplier to calculate total flux was calculated by Short Cut 'and based on a program execution rate (scan rate) of 1 Seconds. 'If you change the program execution rate outside of Short Cut with the CRBasic Editor 'you will need to recalculate this multiplier. See the sensor manual for more details. SlrMJ=SlrW*4.330879E-05 'Calculate flux density SlrW=SlrW*43.30879 SubScan(250,mSec,4) '\\\\\\\\\\\\\\\\\\\\\\\ Wind Speed 'WS_kph' /////////////////////// VoltDiff(WS_MS_250ms,1,mV2500,1,True,0,250,0.025,-12.5) VoltDiff(WS_KPH_250ms,1,mV2500,1,True,0,250,0.09,-45) AvgRun (RunAvg_WS_KPH_250ms,1,WS_KPH_250ms,12) NextSubScan '24 hour running total calculation 'Tot24' Tot24=Tot24+Rain_mm If TimeIntoInterval(0,1440,Min) Then Tot24=0 'Dew Point and Wet-Bulb calculation prep AirTC_2=AirTC SPkPa=101.325 SatVP(SVp,AirTC_2) Vp=RH*SVp/100 'Dew Point calculation 'TdC' DewPoint(TdC,AirTC_2,RH) If TdC>AirTC_2 Or TdC=NAN Then TdC=AirTC_2 'Find Wet-Bulb 'TwC' Top=AirTC_2 Bottom=TdC For N = 1 To 25 Twpg=Twg Twg=((Top-Bottom)/2)+Bottom WetDryBulb(Vpg,AirTC_2,Twg,SPkPa) VpgVpd=Vpg-Vp Twch=ABS(Twpg-Twg) If VpgVpd>0 Then Top=Twg Else Bottom=Twg EndIf If Twch<0.01 Or N=25 Then ExitFor Next TwC=Twg 'Heat Index calculation 'HI_C' HITF=1.8*AirTC+32 HI_C=-42.379+2.04901523*HITF+10.14333127*RH-0.22475541*HITF*RH-6.83783*10^-3*HITF^2-5.481717*10^-2*RH^2+1.22874*10^-3*HITF^2*RH+8.5282*10^-4*HITF*RH^2-1.99*10^-6*HITF^2*RH^2 If HITF<80 Or RH<40 Or HI_C0.4*PotSlrW AND SIN(SunElevation)>0.1 Then 'Calculate sun hours for scan time in seconds SunHrs=1/3600*1 Else 'Set sun hours for scan time in seconds to 0 SunHrs=0 EndIf If Precepitation_type >0 Then 'Calculate Precepitation hours for scan time in seconds PrecipitationHrs=1/3600*1 Else 'Set Precepitation hours for scan time in seconds to 0 PrecipitationHrs=0 EndIf tips1=RunTotal 'Wind Chill calculation 'WC_C' WCTF=1.8*AirTC+32 WCWSMPH=RunAvg_WS_KPH_250ms*0.621371 WC_C=35.74+0.6215*WCTF-35.75*WCWSMPH^0.16+0.4275*WCTF*WCWSMPH^0.16 If WC_C>WCTF OR WC_C=NAN Then WC_C=WCTF If WCTF>50 OR WCWSMPH<3 Then WC_C=WCTF WC_C=(5/9)*(WC_C-32) TotalRun (Rain_mm_tot_hour,1,Rain_mm,3600) Rain_inch_tot_hour = Rain_mm_tot_hour / 25.4 Tot24_inch = Tot24 / 25.4 BP_inch = BP_mbar / 33.864 Tdf = TdC * 1.8 + 32 AirTf = AirTC * 1.8 + 32 WS_mph = RunAvg_WS_KPH_250ms * 0.621371 WS_kts = RunAvg_WS_KPH_250ms /1.852 rain12sec = Table12.RAIN12SEC(1)/12 *0.3 rain1minuut = Table1.RAIN_ONE_MINUTE(1) twaalf_sec_avg_RunAvg_WS_KPH_250ms = Table12.WS_KPH_S_WVT(1) 'count the occurrences of each mode and put the counts into 'an array If Precepitation_type = -10 Then Mode(1) = Mode(1) + 1 If Precepitation_type = 10 Then Mode(2) = Mode(2) + 1 If Precepitation_type = 20 Then Mode(3) = Mode(3) + 1 If Precepitation_type = 30 Then Mode(4) = Mode(4) + 1 If Precepitation_type = 40 Then Mode(5) = Mode(5) + 1 If Precepitation_type = 50 Then Mode(6) = Mode(6) + 1 'use MaxSpa to find the maximum of the Mode array 'the second destination variable is the Location 'within the array where the Max occurs MaxSpa (DestMaxSpa, 6, Mode(1)) 'Return a mode, based on which index in Mode() holds the max If DestMaxSpa(2)= 1 Then Lufft_R2S_Mode = 0 If DestMaxSpa(2)= 2 Then Lufft_R2S_Mode = 10 If DestMaxSpa(2)= 3 Then Lufft_R2S_Mode = 20 If DestMaxSpa(2)= 4 Then Lufft_R2S_Mode = 30 If DestMaxSpa(2)= 5 Then Lufft_R2S_Mode = 40 If DestMaxSpa(2)= 6 Then Lufft_R2S_Mode = 50 'twaalf_seconden_temp = twaalf_sec.AirTC(1,1) 'AvgRun (RunAvgTC12sec,1,twaalf_seconden_temp,5) 'Minutely_Rain=Minutely_Rain 'Hourly_Rain=Hourly_Rain+minute_avg_WS_kph 'Daily_Rain=Daily_Rain+minute_avg_WS_kph 'Monthly_Rain=Monthly_Rain+minute_avg_WS_kph 'Total_Rain=Total_Rain+minute_avg_WS_kph 'If TimeIntoInterval (0,1,Min) Then Minutely_Rain=0 'If TimeIntoInterval (0,1,Hr) Then Hourly_Rain=0 'If TimeIntoInterval (0,1440,Min) Then Daily_Rain=0'change the zero to 9 if you want rainfall total at 9am 'If RTime(5)=0 AND RTime(4)=0 AND RTime(3)=0 Then Monthly_Rain=0 'Call Data Tables and Store Data If TimeIntoInterval(0,1,Min) Then Mode(1)=0 If TimeIntoInterval(0,1,Min) Then Mode(2)=0 If TimeIntoInterval(0,1,Min) Then Mode(3)=0 If TimeIntoInterval(0,1,Min) Then Mode(4)=0 If TimeIntoInterval(0,1,Min) Then Mode(5)=0 If TimeIntoInterval(0,1,Min) Then Mode(6)=0 If TimeIntoInterval(0,1,Min) Then Lufft_R2S_Mode=0 If TimeIntoInterval(0,1,Min) Then DestMaxSpa(2)=0 CallTable Table1 CallTable Table10 CallTable(event) CallTable Upload NextScan SlowSequence Scan (12,Sec,0,0) deltawind = twaalf_sec_avg_WindDir - lastwind lastwind = twaalf_sec_avg_WindDir deltaD = deltawind 'Default for Normal variation not crossing North If deltawind < -180 Then deltaD=deltawind+360 'Gone through North from West to East. If deltawind > 180 Then deltaD=deltawind-360 'Gone through North from East to West. AddPrecise (WindD,deltaD) AddPrecise (WindD50,deltaD) Move (WindDHist(2),4,WindDHist(1),4) Move (WindDHist50(2),49,WindDHist50(1),49) WindDHist(1)= WindD WindDHist50(1)= WindD50 MaxSpa (MaxD,5,WindDHist()) MaxSpa (MaxD50,50,WindDHist50()) MinSpa (MinD,5,WindDHist()) MinSpa (MinD50,50,WindDHist50()) AvgSpa (AvgWindD,5,WindDHist()) AvgSpa (AvgWindD50,50,WindDHist50()) mostbacked = (MinD(1)+36000) MOD 360 mostbacked50 = (MinD50(1)+36000) MOD 360 mostveered = (MaxD(1)+36000) MOD 360 mostveered50 = (MaxD50(1)+36000) MOD 360 AvgRunWindD = (AvgWindD+36000) MOD 360 AvgRunWindD50 = (AvgWindD50+36000) MOD 360 If ABS(WindD)>34200 Then WindD = twaalf_sec_avg_WindDir If ABS(WindD50)>34200 Then WindD50 = twaalf_sec_avg_WindDir CallTable Table12 NextScan EndProg
You will end up getting skipped scans, because 4 subscans at 250ms adds up to 1 second by itself. The other items in the 1 second scan will put you past the limit.
I suggest trying to fit all of your high priority measurements in a 250ms main scan. I just tried it in the compiler, and it appears that the measurements will all get done in time.
Hi JDavis,
Thanks for your reply.
If a 250ms Main scan is in use, is it valid to use "if iftime(0,1,sec) then" instead of a slow sequence for sensors which i dont want in the fast Main scan?
For example a pulse sensor which cant be in a slow sequence.
Is it with a slow sequence scan the sensor is read with that scanrate, and with if iftime the sensor is read at e.g. 250ms but doesnt update the data at that rate?
With kind regards.
Hi JDavis,
I have the Main scan set to: (250,msec,8,0) and a slowsequence of 1 second.
But the live data is updating very unpredictable.
But i dont have skipped scans.
I also see in the connect screen the recnum is counting sometimes in steps of 3 instead of 4 (4×250ms is 1 second)
I have added a counter in my crbasic script: counter=counter+1
The counter data is also very unstable, sometimes starting at 2, or just showing 1, 3, 0 instead of 0,1,2,3 etc.
It looks like it is updating most of the time at 500ms...
What can i do to have it run smooth?
I have set the graphics option in RTMC to high speed and disabled animation.
Increased the buffer size etc.
When i make a crbasic script with just the voltdiff sensors at 250ms it is running much more smooth.
Am i right in thinking the script takes too long to update at that scanrate?
MeasureTime= 6.200
ProcessTime= 3.730
MaxProcTime= 34.815
When i set the scan buffer option to zero it is much more smooth.
Or isnt it smart to set it to zero?
With kind regards.