Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Conditional data


Makada Jan 25, 2019 06:52 PM

Hi,

I would like to have an solution for my precipitation type sensor.

There are two pulsecount public data.

One is for the amount of precipitation in mm, and one for the type of precipitation 0-50.

The precipitation types are:

10= rain

20= snow

30= sleet

40= freezing rain

50= hail

So for example when the precipitation is 30, the amount counting from the first pulsecount sensor must be stored as sleet mm.

Any idea how to accomplish this?

With kind regards.


JDavis Jan 29, 2019 06:04 PM

Use the DisableVar parameter of Totalize(). You would have a separate Totalize() instruction for the different types of precipitation. Use FieldNames() to label the different values.

 

Public Precip_mm
Public PrecipType As Long

DataTable (FifteenMin,1,-1)
  DataInterval (0,15,Min,10)
  Totalize (1,PrecipType,FP2,PrecipType<>10)
  FieldNames ("RainTot_mm")
EndTable

 

Not that I declared PrecipType as Long. That will make sure it contains exact integers to look for.


Makada Jan 30, 2019 05:58 PM

Hi JDavis,

Thanks alot for your example, that realy helped me.

Question 1: Is it also possible to have the duration from the 5 different precipitation types in hours, minute and seconds? Probably with an example like in previous post?

Example: as soon as its type 10 (rain) AND amount is >0.00 mm. Its starts counting in h:m:s

An example if possible is greatly appreciated. 

Question 2: the precipitation type is sometimes showing a value between the 0, 10, 20, 30, 40 and 50. And sometimes the amount is displayed sooner then the type, and because of that misread the type.

So (if possible) the type and amount has to be displayed (from a 1 second public datasource) exactly simultainious every second.

Example: when the amount is displayed sooner then the type, the amount is displayed as rain (10) instead of (20), because now and then the type is showing the type 10 frist before displaying type 20...

With kind regards


JDavis Jan 30, 2019 10:53 PM

Counting the time is not as simple. You could count seconds. For example, if you have a 5 second scan have a variable that always equals 5. Then totalize it with a condition checking for the right precipitation type.

Regarding question 2, the only way to resolve that issue would be to use the digital interface of the sensor instead of the pulse output. With the digital interface, there is not a timing issue when the precipitation type changes. The sensor tells you both amount and type synchronized.


Makada Jan 31, 2019 09:15 AM

Hi JDavis,

Thanks for your reply.

Ive used the instruction from my sunhours instruction, see below.

See if this will work.

Maybe you have suggestions to make it (work) better?

If Precepitation_type =0 Then
Precepitation_Hrs=0
Precepitation_mm=0
EndIf

If Precepitation_type =10
Rain_Hrs=(1/86400)*1
Precepitation_Hrs=(1/86400)*1
Rain_mm=Precepitation_mm
Else
Rain_Hrs=0
Rain_mm=0
EndIf

If Precepitation_type =20
Snow_Hrs=(1/86400)*1
Precepitation_Hrs=(1/86400)*1
Snow_mm=Precepitation_mm
Else
Snow_Hrs=0
Snow_mm=0
EndIf

If Precepitation_type =30
Sleet_Hrs=(1/86400)*1
Precepitation_Hrs=(1/86400)*1
Sleet_mm=Precepitation_mm
Else
Sleet_Hrs=0
Sleet_mm=0
EndIf

If Precepitation_type =40
Freezing_Rain_Hrs=(1/86400)*1
Precepitation_Hrs=(1/86400)*1
Freezing_Rain_mm=Precepitation_mm
Else
Freezing_Rain_Hrs=0
Freezing_Rain_mm=0
EndIf

If Precepitation_type =50
Hail_Hrs=(1/86400)*1
Precepitation_Hrs=(1/86400)*1
Hail_mm=Precepitation_mm
Else
Hail_Hrs=0
Hail_mm=0
EndIf

TotRain_H=INT(TotRainHrs*24)
TotRain_M=INT((TotRainHrs*24-TotRain_H)*60)
TotRain_S=Round((((TotRainHrs*24-TotRain_H)*60)-TotRain_M)*60,0)
TotRain_HMS=FormatFloat(TotRain_H,"%02.00f")+":"+FormatFloat(TotRain_M,"%02.00f")+":"+FormatFloat(TotRain_S,"%02.00f")
TotRainHrs=TotRainHrs+Rain_Hrs

TotSnow_H=INT(TotSnowHrs*24)
TotSnow_M=INT((TotSnowHrs*24-TotSnow_H)*60)
TotSnow_S=Round((((TotSnowHrs*24-TotSnow_H)*60)-TotSnow_M)*60,0)
TotSnow_HMS=FormatFloat(TotSnow_H,"%02.00f")+":"+FormatFloat(TotSnow_M,"%02.00f")+":"+FormatFloat(TotSnow_S,"%02.00f")
TotSnowHrs=TotSnowHrs+Snow_Hrs

TotSleet_H=INT(TotSleetHrs*24)
TotSleet_M=INT((TotSleetHrs*24-TotSleet_H)*60)
TotSleet_S=Round((((TotSleetHrs*24-TotSleet_H)*60)-TotSleet_M)*60,0)
TotSleet_HMS=FormatFloat(TotSleet_H,"%02.00f")+":"+FormatFloat(TotSleet_M,"%02.00f")+":"+FormatFloat(TotSleet_S,"%02.00f")
TotSleetHrs=TotSleetHrs+Sleet_Hrs

TotFreezingRain_H=INT(TotFreezingRainHrs*24)
TotFreezingRain_M=INT((TotFreezingRainHrs*24-TotFreezingRain_H)*60)
TotFreezingRain_S=Round((((TotFreezingRainHrs*24-TotFreezingRain_H)*60)-TotFreezingRain_M)*60,0)
TotFreezingRain_HMS=FormatFloat(TotFreezingRain_H,"%02.00f")+":"+FormatFloat(TotFreezingRain_M,"%02.00f")+":"+FormatFloat(TotFreezingRain_S,"%02.00f")
TotFreezingRainHrs=TotFreezingRainHrs+Freezing_Rain_Hrs

TotHail_H=INT(TotHailHrs*24)
TotHail_M=INT((TotHailHrs*24-TotHail_H)*60)
TotHail_S=Round((((TotHailHrs*24-TotHail_H)*60)-TotHail_M)*60,0)
TotHail_HMS=FormatFloat(TotHail_H,"%02.00f")+":"+FormatFloat(TotHail_M,"%02.00f")+":"+FormatFloat(TotHail_S,"%02.00f")
TotHailHrs=TotHailHrs+Hail_Hrs

TotPrecepitation_H=INT(TotPrecepitationHrs*24)
TotPrecepitation_M=INT((TotPrecepitationHrs*24-TotPrecepitation_H)*60)
TotPrecepitation_S=Round((((TotPrecepitationHrs*24-TotPrecepitation_H)*60)-TotPrecepitation_M)*60,0)
TotPrecepitation_HMS=FormatFloat(TotPrecepitation_H,"%02.00f")+":"+FormatFloat(TotPrecepitation_M,"%02.00f")+":"+FormatFloat(TotPrecepitation_S,"%02.00f")
TotPrecepitationHrs=TotPrecepitationHrs+Precepitation_Hrs

If Precepitation_type<10 Then Precepitation_type=0
If Precepitation_type>=10 AND Precepitation_type<20 Then Precepitation_type=10
If Precepitation_type>=20 AND Precepitation_type<30 Then Precepitation_type=20
If Precepitation_type>=30 AND Precepitation_type<40 Then Precepitation_type=30
If Precepitation_type>=40 AND Precepitation_type<50 Then Precepitation_type=40
If Precepitation_type>=50 Then Precepitation_type=50

If TimeIntoInterval(0,1440,Min) Then TotRainHrs=0
If TimeIntoInterval(0,1440,Min) Then TotSnowHrs=0
If TimeIntoInterval(0,1440,Min) Then TotSleetHrs=0
If TimeIntoInterval(0,1440,Min) Then TotFreezingRainHrs=0
If TimeIntoInterval(0,1440,Min) Then TotHailHrs=0
If TimeIntoInterval(0,1440,Min) Then TotPrecepitationHrs=0


Makada Feb 5, 2019 04:07 PM

Hi JDavis,

Maybe you do have some suggestions as to how the above can be simplyfied or other ways to achieve this?

With kind regards.


Makada May 8, 2019 05:15 PM

Hi JDavis,

I tried your suggestion above but i got an error in line 23, expecting Float "PulseCount(PrecipType,1,2,0,1,1,0)"

Public Precip_mm

Public PrecipType As Long


DataTable (Precipitation,1,-1) 

DataInterval (0,1,Min,10) 

Totalize (1,PrecipType,FP2,PrecipType<>8-12) 

FieldNames ("RainTot_mm") 

Totalize (1,PrecipType,FP2,PrecipType<>18-22) 

FieldNames ("SnowTot_mm") 

Totalize (1,PrecipType,FP2,PrecipType<>28-32) 

FieldNames ("SleetTot_mm") 

Totalize (1,PrecipType,FP2,PrecipType<>38-42) 

FieldNames ("FreezingRainTot_mm") 

Totalize (1,PrecipType,FP2,PrecipType<>48-52) 

FieldNames ("HailTot_mm")

EndTable
'Main Program

BeginProg

'Main Scan Scan(250,mSec,10,0)

PulseCount(Precip_mm,1,1,2,0,0.01,0)

PulseCount(PrecipType,1,2,0,1,1,0)

CallTable Precipitation

NextScan

EndProg

Log in or register to post/reply in the forum.