svego Posted September 28, 2016 Share Posted September 28, 2016 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 Link to comment Share on other sites More sharing options...
AzeoTech Posted September 28, 2016 Share Posted September 28, 2016 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. Link to comment Share on other sites More sharing options...
svego Posted September 30, 2016 Author Share Posted September 30, 2016 Hi, Can you correct me where is problem here ? temco_temp[0] and temco_hum[0] are values that must be calculated in function Link to comment Share on other sites More sharing options...
AzeoTech Posted October 3, 2016 Share Posted October 3, 2016 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. Link to comment Share on other sites More sharing options...
svego Posted October 3, 2016 Author Share Posted October 3, 2016 you have ctl file...Page name is DEW_point... KucnaSCADA_8_2016.ctl Link to comment Share on other sites More sharing options...
AzeoTech Posted October 4, 2016 Share Posted October 4, 2016 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. Link to comment Share on other sites More sharing options...
svego Posted October 4, 2016 Author Share Posted October 4, 2016 I was my mistake..I called function inside sequence, CalcDewPoint(Tc, Rh), so it must be sequence name like DEW_point(temco_temp[0],temco_hum[0]) in my example.. pls, see screens... now it works, calculations should be OK Link to comment Share on other sites More sharing options...
AzeoTech Posted October 4, 2016 Share Posted October 4, 2016 Yes, that is why I suggest naming the sequence the same as the function prototype in the sequence. Its more for your benefit than DAQFactory's. DAQFactory doesn't really use the name in the function prototype except inside classes. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.