PI Performance Equations John Daniels, Technical Instructor Show Me How Webinar Series © Copyright 2009, OSIsoft Inc. All rights Reserved. 6 PI Performance Equations Subsystem Executes real time calculations May use multiple tags Stores calculation results in a PI tag Contains a rich library of built-in functions 7 Performance Equations Scheduler Start up file: \pi\bin\pipeschd.bat /f : Scan class period and phase. The period is the amount of time between scans. The phase is the time to start the first scan as an offset from midnight. Example: /f=08:00:00,07:00:00 This example will execute the calculation every 8 hours starting at 07:00:00 8 Scan Classes - Offsets Ten seconds scan class with no offset (/f = 00:00:10) Ten seconds scan class with a five seconds offset (/f = 00:00:10, 00:00:05) 9 Calculation Dependencies Tag Scan class A /f=08:00:00,07:00:00 B /f=08:00:00,07:00:00 C /f=08:00:00,07:00:00 Tag Scan class A /f=08:00:00,07:00:00 B /f=08:00:00,07:00:00 C /f=08:00:00,07:00:01 If all tags have the same Scan Class and Tag C relies on data from Tags A and B, calculations could be done out of order. If Tag C has a later Scan Class, a Calculation Dependency will be set and the data will be correct. Note: An easier way would be to make Tag C an Event Triggered tag based on Tag B. 10 DEMO: Bat file and ICU Go configure the BAT file and the ICU D:\PI\bin Change host name Add scan classes Import in ICU 11 PI PE Expression Syntax Numbers 0, 0.125, 34.56 Tag names in single quotes 'sinusoid' , 'trc4226.pv' Timestamps in single quotes '*' , '14-dec-02', 't-8h' Strings in double quotes "This is a string" 12 PI PE Expression Syntax Relational, Logical and Mathematical Operators A PE expression can use the following relational operators: >, <, >=, <=, =, <> A PE expression can use the following logical operators: And, Or, Not, In .., In () A PE expression can use the following mathematical operators: +, - , *, /, ^, Mod 13 PI PE Expression Syntax If-Then-Else Operator A PE expression can use If-Then-Else operators IF expr0 THEN expr1 ELSE expr2 Ex.: IF ‘Tag1’ < 50 THEN “under limit” ELSE “good” You must include the IF, the THEN, and the ELSE Nested operations are supported Possibility to use the NoOutput() function, which does not send anything to PI Ex.: IF TagAvg(‘sinusoid’, ‘*-1h’, ‘*’) > 80 THEN “Alarm” ELSE NoOutput() 14 PI PE Expression Syntax Built-In Functions A PE expression can use built-in functions Mathematical functions (Abs, Sin, Cos, Sqr, …) Aggregate functions (Avg, Max, Min, …) Archive retrieval (NextEvent, PrevVal, TagVal, …) Archive search (FindEQ, FindGT, TimeLT, …) Archive statistics (TagAvg, Range, EventCount, …) Point attributes (TagSpan, TagType, TagDesc, …) Time functions (Bod, Bom, Hour, Minute, …) String functions (Len, Trim, Concat, …) Functions can be nested and combined in expressions 15 DEMO: View the help file Use the PEReference.chm help file to view the available functions On the PI server in the \pipc\help folder On the training web site (http://training.osisoft.com) 16 Built-In Functions Archive Search Example TimeEQ or TimeNE: returns the number of seconds that a tag was equal or not equal to a specified value TimeLT or TimeLE: returns the number of seconds that a tag was less than or equal to a specified value TimeGT or TimeGE: returns the number of seconds that a tag was greater than or equal to a specified value Time??(tag, start time, end time, value) Ex: TimeGT(‘trc322.pv’, ‘y’, ‘t’,10) 17 Conversion Factors It is important to supply the correct conversion factor when calculating TOTALS with PI because PI assumes the engineering units of the rate tag are units per day. Rate tag engineering units Units/day Units/hour Units/minute Units/second Assumption of the PI Server Units/day Units/day Units/day Units/day Conversion Factor 1 24 1440 86400 Example: For a flow measured in gpm, a conversion factor of 1440 must be supplied to convert between the engineering units of the rate tag and the units/day assumption of PI. 18 What is a Conversion Factor? A multiplier used to change a number from one unit of measure to another Ex: 1000 g/kg, 2.54 cm/inch, 24 hours/day, 1440 minutes/day When using the tagtot function in a PE expression, it is used to correct PI’s assumption that the data is in units per day 19 Computing Totals Flow 7 (gpm) 5 PI assumes this measurement to be units/day 3 1 0 0 1 2 3 4 5 6 7 8 9 10 11 Time (m) Normal total = (3 gpm x 3m) + (5 gpm x 2m) + (1 gpm x 3m) = 22 gallons PI total = ((3 gallons per day x 3m x 1day/1440m) + (5 gallons per day x 2m x 1day/1440m) + (1 gallon per day x 3m x 1day/1440m)) * 1440m/1d = 22 gallons The total computed by PI must be multiplied by a factor of 1440 20 DEMO: Build Tags in SMT and Excel Use the Performance Equations PI SMT plug-in to create, set scheduling and validate an equation’s syntax before putting it online 21 DEMO: PI Performance Equations Tag Configuration PointType: Digital, Float64, Float32, Int32, Int16, String PointSource: often C, as set in the interface start up file (pipeschd.bat) Configuration parameters for scan based calculations ExDesc: PE Expression Ex: tagavg(‘sinusoid’, ‘*-1h’, ‘*’) Location3: 0 Location4: scan class number 22 DEMO: PI Performance Equations Tag Configuration Configuration parameters for event triggered calculations ExDesc: event=Trigger_Tag_Name, PE_Expression Ex: event=sinusoid, tagavg(‘sinusoid’, ‘*-1h’, ‘*’) Location4: 0 Location3: determines the timestamp of the result 0: sets the timestamp to the time when the expression is evaluated 1: sets the timestamp to the time of the triggering event 23 DEMO: PI Performance Equations Tag Configuration It is appropriate to turn off data compression for calculated tags since each event is significant in itself ExcDev: 0 ExcMax: 0 Compressing: 0 (off) The step attribute can be used to ensure no interpolated data is returned to end users Step: 1 (on) 24 DEMO: PB Trend with PE tag YesterdayComp vs BA:Conc.1 25 DEMO: PIPETEST D:\PI\ADM Can load text files Gives error location Installed on Server 26 PI PE’s versus PI ACE Performance Equations PI ACE Installed with each PI Server Comes with Enterprise Server Professional or separately Simple deployment More complex deployment Accesses data from a single PI Server Can access multiple PI Servers Built in library of functions Anything in VB or coded Simple logic (4096 character limit) Logic limited only by coding ability Note: For more information about PI ACE, please see our PI ACE course offering or our webinar Building Calculations in ACE to Support Plant Performance Monitoring 27 For Further Information PEReference.chm In \PIPC\Help On OSIsoft website PI Server Applications User Guide www.techsupport.osisoft.com Previous webinar: Recalculating Performance Equation and ACE Calculation Results 28 Questions 29