5 Replies Latest reply on Oct 17, 2012 12:52 AM by hanyong

    Counting Change of Value

    rdube02

      When I started this task, I really thought it would be simple, but it's turning out to be quite difficult. I have a machine that counts "cycles", which is a quick process that lasts about 15 to 30 seconds. However, I would like to keep track of those cycles per "tool" on the machine. Meaning, I have tags especially for tool1, tool2, tool3 and tool4.

       

      When tool1 is on the machine, I want to increment that counter alongside the machine's "general" counter. When tool2 is on the machine, I would instead increment that tool's counter tag, etc...

       

      There's no "reset" point, because this is a long-term counter, so totalizer doesn't really work because I want the tool counter changes to basically have the same time/date stamp as the general machine counter changes.

       

      I've tried writing a performance equation to do this - and I can filter by tool# easily enough, but I can't seem to accomplish the "simple" task of having a second tag count whenever another PI value changes.  Am I missing something simple?

       

      -Ryan

        • Re: Counting Change of Value

          Performance Equations can be scheduled or event based.  Sounds like you want each of your tool counter tags to be triggered when the machine counter is incremented.  Your PE would be prefixed with "Event=", for example Tool1Counter would have "Event=MachineCounter, if 'MachineTool' = 1 then 'Tool1Counter' + 1 else NoOutput()"  You can set the flag (location attributes) to use the timestamp of the event tag.

           

          If you only have one machine with a few tools then PE is fine.  If you have a larger scope then consider ACE, or even better StreamInsight.

            • Re: Counting Change of Value
              rdube02

              This is really helpful  Rhys, thank you.  I have the PE tag set up and was able to schedule it based on that event. The only difference between your example and what I'm trying to do is that I want to increment "Tool1counter" by 1 every time "MachineTool" changes value, not only when it equals 1. Is it safe to assume that I'd just have to remove the 'MachineTool'=1 from the expression and just increment Tool1Counter on every event?

                • Re: Counting Change of Value
                  rdube02

                  What exactly is an "event" in this case anyway. I have the trigger value defined, and I'm watching it updating every minute or so, but when it changes value the performance equation does not run. Oddly enough, when I do a manual "Evaluate" in the performance equation configurator, then and only then will it actually update the value of the tag. It's like the Event trigger is not working as expected.

                   

                  I assumed here that an "event" is a change in value of a tag?

                    • Re: Counting Change of Value
                      Marcos Vainer Loeff

                      Hello Ryan,

                       

                      One way to make sure to write a value only if the most recent two values are different is to use the following expression:

                       

                       

                       

                      if PrevVal('MachineTool','*')<> PrevVal('MachineTool',PrevEvent('MachineTool','*')) then 'Tool1Counter' + 1 else NoOutput()

                       

                       

                       

                      PrevVal('MachineTool','*') -->Returns the snapshot value of the tag MachineTool

                       

                      PrevVal('MachineTool',PrevEvent('MachineTool','*'))--> Returns the most recent value not including the snapshot.

                       

                       

                       

                      I hope this expression is useful to you.

                      • Re: Counting Change of Value
                        hanyong

                        Hi Ryan,

                         

                        Ryan Dube

                        I assumed here that an "event" is a change in value of a tag?

                         

                        You are almost correct. An "event" here means a new snapshot value received by the tag you have specified as a trigger tag.

                         

                        It may not always be a change in value because it is possible for a tag to receive a new value that has the same value as the previous value. Hence Marcos' suggestion to compare the snapshot value and the previous value to identify if there is a change in value. 

                         

                        By setting up the PE tag for event trigger, what happens in the background is that Performance Equation Scheduler signs up for snapshot update for the trigger tag with the PI Update Manager. So that it will know then the trigger tag gets a new snapshot value, and in turn initiate the calculation. 

                         

                        I am not sure why you are seeing the behavior that you described. If you are still getting it, you can post the configuration of the tag so we can quickly verify the configuration, or you can contact our Techsupport Team to get some assistance on this.