# Calculated values

## Recommended Posts

what is the best way to set formula and use it many times in our aplication...

For example...

I found somewhere formula to calculate DEW point from temperature and relative humidity from many sensors..

X= 1-(0.01*RH)
K= Tc-(14.55+0.114*Tc)*X-((2.5+0.007*Tc)*X)^3- (15.9+0.117*Tc)*X^14

##### Share on other sites

Do you want to apply this to a bunch of channels?  In that case, you should use a Conversion.  Replace the variable that should get the channel value with the word Value.

But I'm guessing that since you are calcing this from two channels you probably can't do that.  In that case, create a sequence that returns the result, something like:

function CalcDewPoint(Tc, Rh)

return( Tc-(14.55+0.114*Tc)*( 1-(0.01*RH) )-((2.5+0.007*Tc)*( 1-(0.01*RH) ))^3- (15.9+0.117*Tc)*( 1-(0.01*RH) )^14

Note how I replaced X with the calc.  This is faster than doing it in two lines.  Once you've created this sequence, you can calc dew point by doing:

calcDewPoint(x,y)

If you want to trend dewpoint (or log it), you probably will want to create a channel to hold the value and calculate it at some interval, then use the Event on RH or Tc to call your function and then use AddValue() on the dew point channel to stick the result into the channel.

##### Share on other sites

I'd have to see the doc.  Can you post it? But one thing: you really should name the sequence the same as the what you put in the function prototype.  Meaning, name the sequence CalcDewPoint.

##### Share on other sites

The function works fine for me.  I just went to the command alert and typed:

? dew_point(1,2)

I'm guessing that when you call the function one, or both, of the channels are empty and don't have values yet.

##### Share on other sites

I was my mistake..I called function inside sequence, CalcDewPoint(Tc, Rh), so it must be sequence name like DEW_point(temco_temp,temco_hum) in my example..

pls, see screens...

now it works, calculations should be OK  