9 Replies Latest reply on Feb 28, 2018 5:56 PM by stuart.watson

    Event frame Trigger/End on the same tag value change


      We are working on an application that requires an event frame to trigger when a tag value changes from "A" to "B" , stay "recording data" while the tag remains in "B" state and end the frame when the tag changes from "B" to "C" and at the same time open a New one given the tag changed again...


      Any idea on how can this be done?





        • Re: Event frame Trigger/End on the same tag value change
          John Messinger

          Hi Jaime,


          Unfortunately this type of 'step' trigger is not currently supported in Event Frame generation analyses. The PI Event Frames Generator interface does support the use of step triggers. There is a blog post in PI Square called Step triggered Event Frame - easy and smoothly that may be of some assistance to you. I haven't tried this out for myself, and reading through the comments it looks like you could potentially run into circular reference issues. Also, the post refers to using integer values as the step trigger, and that they must be sequentially increasing in increments of 1. If you are looking to use digital states as your trigger, then you may have to experiment to adapt this solution to your needs.


          The EF Generator interface may not fully meet your requirements, but it sounds like it may be the best option to look at.



          3 of 3 people found this helpful
          • Re: Event frame Trigger/End on the same tag value change
            Roger Palmen

            And here another one, including the feedback item to get this supported in AF. So please upvote!


            Re: How to create back-to-back EventFrames?

            2 of 2 people found this helpful
            • Re: Event frame Trigger/End on the same tag value change

              You can use "NOT HasValueChanged()" and trigger it periodically and it will catch events. They won't line up at exact start times, but will be within 2 periods of your trigger time. I have done this numerous times and it works well as long as you don't need exact start and end times. This seems to work more consistently that using PrevValue <> CurrentValue type logic. I have had issues with this, it just depends on triggering and how often the tag updates. If the value updates only when the tag value actually changes (from 1 to 2, then 2 to 3, etc.) and you use event based triggering, you will never get triggers.


              One thing I will add to the post above about the step triggering smoothly blog post - Sometimes the batch numbers (or whatever number) resets back to 1 at the beginning of the day/month/year. You have to include an "Odd," "Even," and "first (batch)" as if the last batch number of the year is 1813, and then you reset to batch number 1 on January 1, you will miss the first batch of the year using the Odd/even approach outlined in the post. However, that post was incredibly helpful to me in several applications.


              Thank you Steve for getting this fixed.

              • Re: Event frame Trigger/End on the same tag value change

                Hi Jaime,

                If I understand you correctly, you wanted to create event frame on value change of a tag. ?

                To achieve this, multiple start triggers can be used. then  analysis engine automatically will create a new event by closing previously opened one.

                Trigger1: Tag1 = "A"

                Trigger2: Tag1 = "B"

                Trigger3: Tag1 = "C"


                during the day if tag changes from A to B to C - 3 child event frames will be created along with parent event frame.  here is example events created in our case ( on status change of a digital = OPEN To CLOSED etc)


                Only drawback is , there is parent event frame also created for start and end time.




                1 of 1 people found this helpful
                • Re: Event frame Trigger/End on the same tag value change

                  I am noob, I came up with a work around for this.

                  I had the same task ,


                  Original Idea which came on my mind ...


                  Start Trigger = HasValueChanged(`TagA`)
                  End Trigger = HasValueChanged(`TagA`)


                  Tag A represents a BatchNumber scanned and sent via LinkedTable to an attribute,


                  So ,
                  As you can see ,
                  My original idea was a Circular reference or an invalid reference for the triggers ... 


                  Solution : ( It may not be perfect )


                  I have stored my TagA`s prevval into another attribute via analysis and stored the attributes value into another pipoint --> This inturn gives me a 10second gap between TagA and NewTagA.
                  prevval('TagA','*') -> 'NewAttribute'
                  --> Here comes another problem , Due to compression on my tagA the prevval is always the same as the current value .... so i used prevval('tagA',prevevent('tagA','prevevent('tagA','*'))) to get the prevval -- which seems somewhat efficient


                  --> i have stored the value into another pipoint and used it as my trigger


                  Starttrigger --> hasvaluechanged('NewTagA')
                  EndTrigger --> If TagVal('NewTagA')<>TagVal('TagA') Then HasValueChanged('TagA') Else NoOutput()


                  Please comment on my work if its efficient ?

                  • Re: Event frame Trigger/End on the same tag value change

                    Really don't remember where I picked this up from, but I cannot claim credit.

                    But these are my go to triggers based on step changes. Works like a charm.


                    You have to reverse your thinking. For step triggers, the logical start trigger (current value is different from previous) is always true.

                    So, you need to make that your End Trigger. Works just fine for AF 2016 R2.

                    2 of 2 people found this helpful