11 Replies Latest reply on Aug 6, 2012 9:02 PM by gkrueger

    Performance Equation to combine data from two PI tags

    gkrueger

      Can anyone point me in the direction I'd need to go (functions to use etc.) to create a Performance Equation that can be used to aggregate the data from two or more PI tags into a single PI tag.  I basically need something like ...  If tagA snapshot time>(Now-1scan) then TagA else if TagB snapshot time>(Now-1 scan) then TagB etc.  I couldn't see in the PE function reference a way to get the current snapshot time for a Tag, I just saw functions for getting archive timestamps.  

       

      The application I'm working on is to collect lab data from multiple pieces of analytical equipment and get it into PI so we can run reports and trend it.  The issue we have is that there are multiple vessels in the lab and also multiple analyzers that they use for each vessel.  We want to trend data for a particular vessel, so we need to figure a way to separate the measurements coming in from the different analyzers to get assigned to their particular vessel tags.  

       

      The raw data comes in from each analyzer using OPC, so we have a separate OPC interface for each analyzer and they have their own set of PI tags which get all the results coming from the analyzer (with vessels ID's random based on how the operators are running the samples for the day (ie they might run Vessel 1 first then Vessel 4, then Vessel 3, etc.)

       

      We were thinking of doing this all in one PE  (if VesselID on analyzer 1equals Vessel 1 then the Vessel 1 tags set their values to the current values of analyzer 1, if Vessel ID on analyzer 2 equals vessel 1, then set value to the current values of analyzer 2, etc.)  But the PE's get complex quickly.

       

      Now we're thinking it might make more sense to try to combine the data coming from the multiple analyzers (we have 3 max) into a single set of PI tags, then we can run Datalink queries direct against that set of Tags and filter by Vessel ID.  And then for the individual vessel tags to use for trending, we can create PE's that just say if Vessel ID = Vessel 1, then value = value of the aggregate data stream.  

       

      Any input for approaches to solve this issue is greatly appreciated.  

       

      Thanks,

       

      Greg

       

       

        • Re: Performance Equation to combine data from two PI tags

          I take it that Analyzer1, Analyzer2 and Analyzer3 readings can each go to their corresponding tag - and that's straight forward.

           

          How do the Analyzers indicate the VesselID?

           

          Can you show a sample of the data coming from the OPC?

            • Re: Performance Equation to combine data from two PI tags
              gkrueger

              You are correct, getting the data from an analyzer into PI is fairly straight forward.  And the vessel ID is an OPC string parameter that we are reading.

               

              See below for some sample data from an analyzer.  The analyzers run internal calibrations fairly regularly, and twe believe that is what is causing the Bad value for the GLU tag (which is a result field, Glucose concetration).  

               

               

                  • Re: Performance Equation to combine data from two PI tags
                    gkrueger

                    Sorry it's not the best post of data, it looked fine in my edit view before I hit the post button.  If anyone can give me a tip on how to paste from Excel into this forum, that would be very helpful as well.

                      • Re: Performance Equation to combine data from two PI tags

                        I don't see the VesselID info in your screen shot.

                          • Re: Performance Equation to combine data from two PI tags
                            gkrueger

                            Currently we're just assessing the feasability of using PI in the labs, the operators running the samples enter all the data manually into Excel and don't use the Vessel ID field.  We're working to get some of the operators trained up to start using that field to get us some test data, but that could be a few days.  

                             

                            But outside of the VesselID issue, do you know about the PE to aggregate two tags into one?  for these tags, since it's lab data, we have compression essentially turned off (we found if we set all compmax, compmin, excmax, excmin values to 0 it didn't seem to turn compressin off, so we now have excmax at 1 hour and compmax at 1 year, which essentially disables it), so any snapshot point that comes in goes to the archive, so I'm wondering if I can just use the PrevEvent() function with a timestamp of * to determine if a new tag has come in.  DO you think that would work?  I haven't worked with many PE functions up to this point, mostly just If, then, else with simple comparisons.

                              • Re: Performance Equation to combine data from two PI tags
                                gkrueger

                                I think saying we want compression off is a bit inaccurate, what we want is one value in the archive for every sample...the analyzers update OPC after every analysis, so the snapshot updates and we want that value to go into PI.  We don't want compression to send any timeout values which would be duplicates.  So what we ended up setting was a compmax for 1 year and excmax as 1 hour and that seems to be giving us the data we are looking for.

                                  • Re: Performance Equation to combine data from two PI tags
                                    Ahmad Fattahi

                                    Quick tip: If you have a big screenshot or any other file type not fitting in the text box here, you can attach it as a file to your post by clicking on "Use rich formatting" and then going to the "Options" tab. Hope it helps.

                                    • Re: Performance Equation to combine data from two PI tags

                                      I'm trying to get the full context of the problem you are trying to solve instead of restricting this to a PE related response.

                                       

                                      If these are lab samples, where are you capturing the Sample IDs?

                                       

                                      Have you looked at Event Frames to keep the data related to Sample ID, Vessel ID, Tag data etc. together?

                                        • Re: Performance Equation to combine data from two PI tags
                                          gkrueger

                                          Gopal,

                                           

                                          So we have a PI Batch/PIBaGen system in place.  And we have units configured for each vessel, with aliases as well.  The users enter a batch ID on the DCS system which controls the vessels and PiBaGen captures that and the start and end times for the run.

                                           

                                          What the user is looking for is for us to produce a report that looks similar to their existing batch report.  In their existing batch report, they have their operators enter the results from the analyzers by hand, one row for each sample, and they have a separate worksheet for each vessel.  Typically they sample once a day and their runs are about 1 month.  

                                           

                                          Right now, I've developed a fairly nice batch report template that lets them select a batch using their BatchID, then I have some VB code that runs a query to determine the vessel, updates an alias list based on that vessel (unit) and does Sampled Data queries at an interval they configure for the PI tags which come from the DCS (pH, DO, agitator speed etc.)  So it's regularly spaced, interpolated data from a continuous source.

                                           

                                          The end result as I see it would be the batch report would switch to instead of using sampled data, we would run a Compressed Data query against the analyzer data for that vessel, that should return a single row with a timestamp for each analysis they did on that vessel between the batch start/stop times (so about 1/day).  Then I would have the remaining tags use Archive Value (or Timed Data) queries to return the values for the other analysis tags and for the on-line DCS tags using the timestamps returned from the Compressed Data Query.

                                           

                                          So the end result is they have a batch report which combines data from the analyzers and from their on-line DCS tags.  And they'd like it so they come in, hit a button to refresh and it updates with the latest values if it's for a batch that is currently running.

                                           

                                          In addition they would like to be able to use the BatchView tool to compare batches between runs and between vessels using aliased tags and to have both DCS online tags and analyzer tags on the same trend.  That's why we're looking for a way to sort the data into a set of tags for each vessel.  I don't think aliased BatchView trends allow you to do complicated equations and filters in the trend.

                                           

                                          -Greg