6 Replies Latest reply on Nov 1, 2018 1:50 PM by Rick Davin

    Create a formula that utilizes Abs, Convert, TimeGE

    SReivenhart

      I'm trying to figure out how I can create a formula using all three functions and provide an explanation to what the formula is doing and what the result will be used for. So far this is what I came up with, but I'm struggling to use the function TimeGE - any suggestions?

       

       

      I tried another way and this is my result. I'm not sure if the output value is correct though.

       

      This is the summary I came up with:

      Calculates the difference between DCT3LS and DCT3RS. If the value is less than 100, it is converted to degrees Celsius. Otherwise, the formula determines the total time in the past 3 hours when DCT3LS was greater than or equal to DCT3RS at 8AM today. The formula is still comparing both attributes but only converts the temperature to Celsius if the difference is less than the specified number provided. If not, the formula identifies that DCT3LS was, at some point, equal to or greater than DCT3RS but doesn’t specify how large or small the difference in temperatures were; it specifies the timeframe the temperatures were equal or disparate, in seconds.

       

      The output value can be used to determine the temperature difference between DCT3LS and DCT3RS in Celsius rather than Fahrenheit.

        • Re: Create a formula that utilizes Abs, Convert, TimeGE
          jyi

          Hi Senterra,

           

          Your use of use of convert function seems a little weird to me. It might be better if it were written as 2 variables. Also, the temperature difference (delta) has its own UoM group, therefore, the conversion will not be different.

          Please check out the temperature (Delta) unit of measure group

           

          Best,

          Jin

          1 of 1 people found this helpful
            • Re: Create a formula that utilizes Abs, Convert, TimeGE
              SReivenhart

              Hi Jinmo,

               

              I actually don't understand what you mean by "delta has its own UoM group". I haven't used the function before so please educate me how you created your formula because I don't understand it.

                • Re: Create a formula that utilizes Abs, Convert, TimeGE
                  jyi

                  Oops. I'm using more latest version of PI AF Server, therefore, I might have more functions available. These functions are added AF 2017 SP2. Below is from release notes.

                  121485

                  A new property, DeltaUOM, has been added to the UOM object to allow applications to determine the appropriate unit for measuring the differences between two values.  For example, temperature units typically have a different unit to represent deltas because of the offset present in the conversion factors.

                   

                  If you are using Pre-2017SP2, then a simple Convert function cannot be used to convert the differences. Here's an example:

                   

                  T0 = 100 'F and T1 = 32 'F

                   

                  The difference is 68 'F. However, this does not equal to (68 - 32) *5/9 = 20 'C. This is incorrect.

                  The conversion rule does not apply to the difference. Please see below.

                  T0 = 100 'F = 37.778 'C

                  T1 = 32 'F = 0 'C

                   

                  The actual difference is 37.778 'C. The conversion factor is 0.5555 between 68 delta 'F and 37.778 delta 'C.

                  Because of this, we offer DeltaUOM class now. This is available from AF 2017SP2 and later.

                  2 of 2 people found this helpful
              • Re: Create a formula that utilizes Abs, Convert, TimeGE
                Rick Davin

                The difference of 2 temperatures is not a temperature.  Rather it is a delta temperature.  The UOMClass "Temperature (Delta)" has been around since I started using AF 2.0 in 2009, and most likely was around before then.  What Jinmo mentions as being fairly recent is a property that has no bearing on your calculations.  If you are using Asset Analytics, then your PI System version is good enough for you follow Jinmo's advice.

                 

                I would suggest you follow Jinmo's style of breaking a long, monolithic calculation into many expressions.  This makes the overall calculation more readable, but more importantly can be immensely valuable when debugging so that you can view intermediate values to see which step is going awry.

                 

                I see a couple of things wrong with your calculation.  The first is:      Convert('DCT3LS' and 'DCT3RS', "deg C")

                • What you really want to convert is their difference, not a logical conjunction.  Again, you should calculate the difference once in a separate expression before this.
                • Do you have a UOM named "deg C"?  If not, then you should use "degree Celsius" or "°C".  More importantly, if not, then you will get a Calc Failed error.

                 

                Your expression named TimeVal is confusing.  If the difference is less than 100 (implied UOM of "delta °F"), then you want to convert that to "delta °C".  I am with you up to that point.  But if the difference is greater than or equal to 100, you then want return the number of seconds from a TimeGE function.  So TimeVal will either be a temperature difference or it will be seconds.  I find this confusing, and I would think 6 months from now if you return to this analysis, or worse if someone else comes to review this analysis, that confusion will reign supreme.

                2 of 2 people found this helpful
                  • Re: Create a formula that utilizes Abs, Convert, TimeGE
                    SReivenhart

                    Hi Rick & Jinmo,

                     

                    Thank you for your replies. To be direct, I'm a novice user when it comes to PI and PI AF. Unfortunately, I don't have the function DeltaUOM available. Is there still a way to convert from Fahrenheit to Celsius?

                     

                    What I'm trying to do now is find the difference between two attributes on a specific date. If the difference is greater than 2 degree Celsius or 35.6 degree Fahrenheit, an alarm will be generated. The attributes I have are defaulted to degree Fahrenheit and I want to change the UOM to Celsius. How do I proceed to do this? I don't even know how to write this formula out either so your guidance is greatly appreciated.

                      • Re: Create a formula that utilizes Abs, Convert, TimeGE
                        Rick Davin

                        Hi Senterra,

                         

                        Again it is quite important that you understand the distinction between the UOMClasses Temperature and Temperature (Delta).  When you subtract one temperature from another, then it does not return a Temperature.  Rather it returns a Temperature (Delta).

                         

                        There is another issue of which to be aware.  If you subtract 2 temperatures, then they must be the same UOM.  If you mix °C and °F, then you get an utterly meaningless result that does not have a UOM.  So you must be sure that both values are °F or that both values are °C.

                         

                        You may enter comments in expressions.  You can have multi-lines in expressions using Shift+Enter to create a new line.  This is great to help break up long expressions or to add comments.  See image below and pay attention to the UOM's in the rightmost column.

                         

                        For image below, DCT3LS is 150 °F and DCT3RS is 75 °F.

                         

                        Click on image to expand

                        2018-11-01 08_32_46-Window.png

                         

                        I offer a little homework for you to help learn more about Analytics.  The following link is a great reference:

                        Tips and Tricks for Asset Based Analytics

                         

                        Let's review a brief example of why Temperature (Delta) is important.  Consider for this example where Temp1 is 80 °C and Temp2 is also 80 °C.

                         

                        WRONG using Temperature: Temp1 - Temp2 = 0 °C.  But 0 °C is equal to 32 °F.  How can a zero difference return something not zero?

                         

                        CORRECT using Temperature (Delta): Temp1 - Temp2 = 0 delta °C, which converts to 0 delta °F.  Using delta temperatures, no matter which way you look at it, it correctly returns a zero difference.

                        1 of 1 people found this helpful