38 Replies Latest reply on Apr 20, 2017 10:00 PM by yyang

    How to calculate the time of an object movement from the speed depending on the time

    Nicolas.Isambourg

      Dear Forum Members,

       

      I need to calculate the time how long objects have covered a distance D by using the speed depending on the time V(t) (in m/min) and the timestamp when the object is gone (starttime).

       

      The speed is a PI Point. The timestamp when the object is gone is given by the starttime of the PI EF attached to the object. The EF endtime isn't the timestamp when the object has covered the distance.

      The distance depends on the objects.

       

      For example:

       

      Object 1, D: 7,60m     PI EF Starttime: 01/12/2016 06:57:18

      Object 2, D: 8,34m     PI EF Starttime: 01/12/2016 08:43:17

      Object 3, D: 5,74m     PI EF Starttime: 02/12/2016 18:57:23

       

      Is it possible to calculate it with PI-DataLink or with PI-Analysis ?

       

      Thanks,

      Best regards,

      Nicolas

        • Re: How to calculate the time of an object movement from the speed depending on the time
          Asle Frantzen

          Hi

           

          Wouldn't this simply be a matter of dividing the speed with the distance covered? Your result would be in minutes, which you can add to the start time using an expression analysis.

           

          I assume you're using an event frame generation analysis to start the event frames. If so I would move the logics for that into an expression analysis and write the output to an attribute. Then use that output attribute to trigger the event frame. This means you have access to the timestamp of the event frame in your expression analysis by using Timestamp(MyOutputAttribute), which you can then use to add your resulting minutes from the calculation of time.

            • Re: How to calculate the time of an object movement from the speed depending on the time
              Nicolas.Isambourg

              Hello Asle,

               

              thank you for replying to my discussion.

              Actually, I cannot divide the speed with the distance because the speed isn't constant. That's my difficulty.

              For the moment, the PI EF are generated with PI EF GEN.

               

              Thanks,

              Best regards,

              Nicolas

                • Re: How to calculate the time of an object movement from the speed depending on the time
                  Asle Frantzen

                  Hmm, that's what I thought

                   

                  You'll have to calculate the distance travelled between each event in the speed tag then. Let's say you get 10 events in the speed tag during one minute (and they're not evenly distributed) you'll calculate each time period separately, and then you can use a TagTot-function for your intermediate calculation to totalize the movement across a given time period.

                   

                  Things are made a bit complicated by the fact that you're generating EF's in the EF generator, but we can work this out by using OLEDB Enterprise to query the list of EF's and then pull this into PI System Explorer again using an AF Table.

                   

                  1. Install OLEDB Ent on your AF Server, or "publish" it as a linked server on your SQL Server box.

                  2. Set up a table connection to the data source (PI System Explorer->Library->Table Connections)

                  3. Set up a linked AF Table and collect the list of EF's from a SQL query

                  4. Link this AF Table into your AF element by using Table Lookup data referenced attributes.

                  5. Use the timestamp (and possibly object movement and type found in the EF's) in your analyses for further calculation

                  • Re: How to calculate the time of an object movement from the speed depending on the time
                    Asle Frantzen

                    I kept on thinking about this one, and it's probably not as straight forward as I thought.

                     

                    Even if you create an analysis calculating the length of the movement between '*' and PrevEvent('SpeedTag','*') you'll struggle to get the exact time, unless the speed tag frequency is high enough. You'll be left with lots of individual parts of movement length, which you can sum up and compare with your known movement length of the object.

                     

                     

                    The higher the frequency of the tag, the more accurate you'll be in your summary of length travelled. It needs to be triggered by the speed tag, and you need to compare the sum with the length you already know. Once your sum is >= the known length, you can calculate the time span between the start time and now.

                     

                    What do think of this procedure? Anyone else have another way, perhaps?

                • Re: How to calculate the time of an object movement from the speed depending on the time
                  Nocodes79

                  Hi Nicolas,

                   

                  mathematcally it would be the integral of v(t) in dt so in AF it would be a total.

                   

                  Supposing the speed is meters per second you can use an attribute template (PI Point data reference) in the element frame template:

                  3 of 3 people found this helpful
                    • Re: How to calculate the time of an object movement from the speed depending on the time
                      Nocodes79

                      I misundertood the question. You need the time it took to cover the distance, while I calculated the distance covered.

                      Well, this case is different and you could just get the time speed has been greater than 0 during the Event Frame.

                      If it was moving, it was covering distance independently from the speed. Or there is something I am missing?

                       

                      So you can create an intermediate attribute (Formula DR) of the element to be 1 when speed is higher than 0 and 0 otherwise and then do the total of it as in my previous post (I have not tried but it should work, I suppose).

                      3 of 3 people found this helpful
                    • Re: How to calculate the time of an object movement from the speed depending on the time
                      pthivierge

                      I think Nicola Gargano got it right here, object is moving when speed is greater than 0. 

                      ( That reminds me some math problems at university where I was trying to use too much variable to what was actually necessary! )

                      • Re: How to calculate the time of an object movement from the speed depending on the time
                        Nicolas.Isambourg

                        Hello,

                         

                        thank you for your replies.

                        Nicola, I did what you suggested. Even although I want to calculate the time when the object has covered a distance D, your calculation of the distance is interesting for another case.

                        Unfortunately, it doesn't seem to work because I get a value too high, 68020m whereas the value should be 1147m.

                         

                        Well, this case is different and you could just get the time speed has been greater than 0 during the Event Frame.

                        If it was moving, it was covering distance independently from the speed. Or there is something I am missing?

                        The time to cover the distance depends on the speed. So, I don't think it would be enough to check if the speed is higher than 0.

                        Moreover, the endtime of the PI EF isn't the moment when the distance D is covered. I don't know when the distance is covered.

                         

                        Thanks,

                        Best regards,

                        Nicolas

                          • Re: How to calculate the time of an object movement from the speed depending on the time
                            yyang

                            Looks like what you want is: you know the speed v(t) and its time stamp: t = 0, t1, t2, t3...tn, you supply a distance s(tx) at any time point tx, you want to know tx -0.  This tx can be in between the given time stamps such as t2 and t3.

                             

                            From a rigid body dynamics point of view, as long as you have the full information of the velocity, you will have the full information of the time and displacement (or distance).  So I am not sure why you need the "distance" information again such as: Object 1, D: 7,60m    PI EF Starttime: 01/12/2016 06:57:18.

                             

                             

                            Note that the velocity is a vector that contains directions but the speed is just a scalar.  One thing you might want to check is: do you always measure the speed and distance in the same direction?

                             

                            From a numerical method point of view,  if your speed is not a step function then you will always run into numerical errors.  This error can be huge. That is the reason why Asle Frantzen suggested you to increase the frequency of the tag to reduce this error. I also noticed that 68020/1147 is roughly 60.  So could you double check your engineering unit as suggested here?

                            https://livelibrary.osisoft.com/LiveLibrary/content/en/server-v7/GUID-F46E6FF2-2275-4A1E-AE98-3EE2A5D2CCF8

                             

                            Finally, again you have both distance and speed values, but you should only use one of them.  If you decide to use the speed,  then the only option is, as Nicola Gargano suggested, perform time integral of your v(t) at each time point.  In this way, you should have s(t) at each time point as shown below.

                             

                            Note that PI uses the trapezoidal rule to calculate the integral.  So that at any given s(tx), the value of tx can be obtained from linear interpolations.

                             

                              • Re: How to calculate the time of an object movement from the speed depending on the time
                                Nicolas.Isambourg

                                Hello Justin,

                                 

                                thank you for replying to my discussion.

                                 

                                Looks like what you want is: you know the speed v(t) and its time stamp: t = 0, t1, t2, t3...tn, you supply a distance s(tx) at any time point tx, you want to know tx -0.  This tx can be in between the given time stamps such as t2 and t3.

                                Exactly.

                                So I am not sure why you need the "distance" information again such as

                                Object 1, D: 7,60m PI EF Starttime 01/12/2016 06:57:18.

                                I meant "D" is the distance covered by the object 1. I want to know the timestamp when the object has covered the distance D, knowing the object is left its position at 01/12/2016 06:57:18.

                                I don't know S(t). I have to calculate it from the speed v(t). So I will do as Nicola Gargano suggested.

                                 

                                One thing you might want to check is: do you always measure the speed and distance in the same direction?

                                Yes I do. Actually, the object moves on a production line.

                                 

                                So could you double check your engineering unit as suggested here?

                                 

                                I configured the Distance attribute in the PI EF library like below:

                                 

                                The speed is in m/s.

                                Did I configured it correctly ?

                                 

                                So that at any given s(tx), the value of tx can be obtained from linear interpolations

                                So I suppose I have to create PI Point mapped to the attribute. Can I map a PI Point to a PI EF attribute ?

                                How can I obtain the value of tx from linear interpolations in PI AF ?

                                 

                                Thanks,

                                Best regards,

                                Nicolas

                              • Re: How to calculate the time of an object movement from the speed depending on the time
                                Nocodes79

                                Hi Nicolas,

                                 

                                the time to cover the distance depends on the speed, but the total time is the time the object it was moving (unless you have more than 1 movement per Event Frame and you want to get the time per movement), so calculating the time speed is greater than 0 should make the trick.

                                Regarding the higher than expected value you got... did you use the intermediate element attribute I suggested (Formula: IF v(t)>0 THEN 1 ELSE 0) and then make the total of this latest (using as source UOM [s]?

                              • Re: How to calculate the time of an object movement from the speed depending on the time
                                Nicolas.Isambourg

                                Hello Nicola,

                                 

                                thank you for replying.

                                I think there is a misunderstanding about my problem. Sorry, I will try to be more clear. I drew a production line with an uncoiler at the entry and a coiler at the exit. We use a welding seam to join together the next coil to the previous coil. The welding seam moves along the production line with a speed V(t). The event frame starts when the welding seam leaves its original position at the line entry and finishes when the welding seam is located at the end of the production line. The event frame is generated by PI EF Gen and a process digital signal.

                                 

                                 

                                I want to calculate the time when the welding seam has covered for example 7.6m, 12.5m, 57.8m, 87.3m.

                                That's why I cannot use the Formula: IF v(t)>0 THEN 1 ELSE 0 because the time depends on the speed value.

                                 

                                As Justin told me, the distance S(t) is obtained from the time integration of V(t). So that at any given s(tx), the value of tx can be obtained from linear interpolations.

                                How can I obtain the value of tx from linear interpolations in PI AF ?

                                 

                                Thanks,

                                Best regards,

                                Nicolas

                                  • Re: How to calculate the time of an object movement from the speed depending on the time
                                    yyang

                                    Thank you Nicolas Isambourg for sticking to the syntax I used.  And thanks a lot for the nice picture!

                                     

                                    Before I provide you more insights in Mechanical Engineering at a high level though...

                                     

                                    One more comment for your plot is:  s(tx) is a input variable that has nothing do with your Event Frame.  The only information your Event Frame provides is the t0 (the starting time point) and (possibly) the length between Coil A and B.  That could be the reason why Patrice Thivierge and Nicola Gargano were confused by "the distance D" you mentioned in your first post.

                                     

                                    Your welding seam is moving in one direction only so the short answer to your question is: create a PI point for s(tx), map it to an AF attribute and use FindEq.  Please note that as shown below, you can always find all of the functions in the Functions explorer in PI System Explorer in Analyses.   Then witness the PI server performs the linear interpolation for you.

                                     

                                     

                                     

                                    Now, as a Mechanical Engineer, I want to go one step further: I am curious to know the reason why you need to know that tx. Again from a Rigid Body Dynamics point of view,  if the acceleration of your wield seam is not a constant, you may have enormous numerical errors.

                                    So you probably want to share the screenshot of your full v(ti) data with me to prove that your calculation is meaningful.

                                     

                                    Also is the uncoiler you mentioned the actual physical stuff or is it just something you draw in CAD?

                                     

                                    Is there anything moving in a direction that is  perpendicular to the plane you draw?

                                     

                                    This is what I meant by perpendicular

                                     

                                    1 of 1 people found this helpful
                                  • Re: How to calculate the time of an object movement from the speed depending on the time
                                    Nicolas.Isambourg

                                    Hello Justin,

                                     

                                    thank you for answering to my questions.

                                     

                                    s(tx) is a input variable that has nothing do with your Event Frame

                                    I don't agree, (or I don't understand), because s(tx) is calculated from the speed v(t) between the starttime and the endtime of a PI Event Frame. (The event frame starts when the welding seam leaves its original position at the line entry and finishes when the welding seam is located at the end of the production line). For each PI Event Frame, I need to calculate the time offset at different positions.

                                    How do I calculate the distance s(tx) from the speed v(t) between the startime and the endtime of a PI Event Frame ? The PI Event Frames are generated by PI EF Gen.

                                    How can I use the FindEq function in the attributes of the PI Event Frame ?

                                     

                                     

                                    Now, as a Mechanical Engineer, I want to go one step further: I am curious to know the reason why you need to know that tx.

                                    I want to know when the welding seam go through the different painting zones of the production line.

                                     

                                    Again from a Rigid Body Dynamics point of view,  if the acceleration of your wield seam is not a constant, you may have enormous numerical errors.

                                    So you probably want to share the screenshot of your full v(ti) data with me to prove that your calculation is meaningful.

                                    Generally, the speed is constant. Sometimes, the production line may stop or slow down.

                                     

                                    Is there anything moving in a direction that is  perpendicular to the plane you draw?

                                    No, there isn't.

                                    The coil is charged at the entry of the line on a uncoiler. The coil is rolled up at the exit of the line with a coiler. Between the uncoiler and the coiler, the coil is painted in different zones.

                                     

                                    Thanks,

                                    Best regards,

                                    Nicolas

                                      • Re: How to calculate the time of an object movement from the speed depending on the time
                                        yyang

                                        Clarification 1:

                                        For those who are still confused, I recommend you to take a step back and look at this from a Mechanical Engineering perspective at a high level:

                                         

                                        Speed v(ti) is known but distance s(ti) at each ti is unknown  except that the total length s(Event Frame EndTime) is known.  So to find the tx that corresponds to a specific s(tx), time integration and interpolation is a must, especially when tx does not equal to ti, there is no free lunch

                                         

                                        An example of tx and ti data may look like this:

                                        ti = [1,2,3,4,5]

                                        tx = [1.5,2.5,3.5,4.5]

                                         

                                        I think Nicolas Isambourg and I are on the same page for this now.

                                         

                                        Clarification 2:

                                        What I meant by "s(tx) has nothing to do with the Event Frame" is:  as shown on your plot, in terms of PI data, these s(tx) values 7.6, 12.5, 57.8 and 87.3 etc are not existing PI AF attributes/PI points or AF attributes that are calculated within the PI Event Frame.

                                         

                                        I guess Patrice Thivierge and Nicola Gargano may think you might have stored these s(tx) values somewhere in PI therefore they suggested you to calculate the "time when the speed is not zero".  To be fair, yes, I understand your frustration: if the solution is really that simple then you wouldn't have asked us how to calculate s(t) from v(t) in the first place.  There is indeed no free lunch.

                                         

                                        Anyway, since you are on the same page with me. Let's move on to the next topic, the solution.

                                         

                                        Clarification 3:

                                         

                                        TagTot functions or the "Total"method you saw in  EF always thinks the integrand has the unit = something/day.  Unfortunately It is hard-coded.

                                         

                                        So even if you have changed the UOM or Eng Units of v(t) to be m/s.  You have to convert the integral to the correct values yourself.

                                         

                                        Now let's make our life easy and create a PI point called st with Unit: m. Did you notice that I didn't use stx here because of the clarification 2?

                                         

                                        Unit of vt is m/s.  Again witness the following 4 things:

                                        1. st value in Archive Editor is correct;

                                        2. If I move my cursor to anywhere on the st curve, for example when stx = 17.7833 m, Time Stamp is: 12/30/2016 09:34:03 AM;

                                        Witness FindEq gave you the same 12/30/2016 09:34:03 AM.

                                        3. TagTot('vt',TimeStamp(PrevVal('vt','*')),'*')*1440*60, did you see the reason why I have to multiply the value by 1440*60?  It is your job to figure out the correct conversion factor.

                                         

                                        Now test my solution on your own machine, use the exact same data as I used (same value and same time stamp) before you do anything and see if you can get it to work.  After your test is successful, then use your own data and add the attribute to your EF.

                                         

                                        1.

                                         

                                        2.

                                        3.

                                        1 of 1 people found this helpful
                                      • Re: How to calculate the time of an object movement from the speed depending on the time
                                        Nicolas.Isambourg

                                        Hello Justin,

                                         

                                        thank you very much for the clarifications.

                                        Sorry, I was unavailable last week.

                                        So the values of the "st" PI Point aren't calculated between the starttime and endtime of the event frame ?

                                        When is the value reset ?

                                         

                                        Thanks,

                                        Best regards,

                                        Nicolas

                                        • Re: How to calculate the time of an object movement from the speed depending on the time
                                          Nicolas.Isambourg

                                          Hello,

                                           

                                          sorry, I was on holiday the 2 last weeks and a lot of work before.

                                          I tried your solution.

                                          Don't you think the calculation of st should be

                                           

                                          st + TagTot('vt',TimeStamp(PrevVal('vt','*')),'*')*1440*60

                                           

                                          Thanks,

                                          Best regards,

                                          Nicolas

                                          • Re: How to calculate the time of an object movement from the speed depending on the time
                                            Nicolas.Isambourg

                                            Hello Justin,

                                             

                                            I woud like to be sure to understand correctly.

                                            By calculating st between TimeStamp(PrevVal('vt','*')) and '*', you calculate the distance covered by the object when vt changes, isn't it ?

                                            Below are some archived values of vt:

                                             

                                            12,0323801/02/2017 21:43:36
                                            11,9257701/02/2017 23:11:20
                                            10,5364601/02/2017 23:11:23
                                            10,5364601/02/2017 23:11:25
                                            9,2028301/02/2017 23:11:27
                                            8,4240301/02/2017 23:11:28
                                            8,3278301/02/2017 23:11:29
                                            5,7603301/02/2017 23:11:39
                                            7,429501/02/2017 23:11:40
                                            10,5025701/02/2017 23:11:43
                                            11,9468501/02/2017 23:11:44
                                            11,9204301/02/2017 23:11:47
                                            12,0326102/02/2017 07:02:07
                                            12,0306202/02/2017 14:52:31

                                             

                                            Below are the event frames for which I need to calculate the distance covered by the object between 01/02/2017 21:43 and 02/02/2017 14:52

                                            EF 1 StartTime: 01/02/2017 21:54:17 EndTime: 02/02/2017 01:43:18

                                            EF 2 StartTime: 02/02/2017 01:43:21 EndTime: 02/02/2017 03:12:47

                                            EF 3 StartTime: 02/02/2017 03:12:50 EndTime: 02/02/2017 05:21:25

                                            EF 4 StartTime: 02/02/2017 05:21:28 EndTime: 02/02/2017 07:43:12

                                            EF 5 StartTime: 02/02/2017 07:43:15 EndTime: 02/02/2017 09:12:32

                                            EF 6 StartTime: 02/02/2017 09:12:35 EndTime: 02/02/2017 11:41:56

                                            EF 7 StartTime: 02/02/2017 11:41:59 EndTime: 02/02/2017 14:31:43

                                             

                                            I am not sure I will be able to calculate st between the starttime and endtime for each event frames with your calculation.

                                            What do you think about  it ?

                                             

                                            Thanks,

                                            Best regards,

                                            Nicolas