Performance Equation Pitfalls: Logic, Tag Update Synchronization, and Data Freshness in PI System
Troubleshooting why a Performance Equation (PE) in PI System returns unexpected results. Understand the role of Boolean logic, tag update rates, and triggering methods, and learn practical solutions for robust tag comparison in PE analysis.
Roshan Soni
Diagnosing Performance Equation Evaluation Issues in PI System: OR vs AND Logic and Data Freshness
Performance Equations (PEs) in OSIsoft PI System are powerful tools for real-time data analysis. However, subtle configuration choices can have significant effects on the results, leading to outcomes that may initially seem perplexing. In this post, we address a common scenario: a PE intended to flag a process as "OK" if either of two tags is "OK", but which sometimes returns unexpected values. We'll explore the nuances of Boolean logic and the critical role of triggering and data freshness.
The Scenario
Suppose you have two status tags, tag1 and tag2, and you want to create a PE that returns "OK" if either tag is reporting "OK", otherwise "FAILED". It's tempting to write something like:
IF TagVal('tag1', '*') = "OK" OR TagVal('tag2', '*') = "OK" THEN "OK" ELSE "FAILED"
Yet, in practice, you find the PE returns "OK" even when only one tag is "OK" and the other is "FAILED" or, conversely, it doesn’t return as expected in some situations. What’s going on?
1. Confirming the Boolean Logic
First, let’s clarify the logic:
- OR means either tag can be
"OK"for the result to be"OK". - AND means both tags must be
"OK"for the result to be"OK"; otherwise, you get"FAILED".
Truth Table Example:
| tag1 | tag2 | OR result | AND result |
|---|---|---|---|
| OK | OK | OK | OK |
| OK | FAIL | OK | FAIL |
| FAIL | OK | OK | FAIL |
| FAIL | FAIL | FAIL | FAIL |
If the goal is to show "OK" when either tag is "OK", then the original equation is logically correct. But why might the PE return unexpected results?
2. Data Freshness and Sampling Synchronization
A less obvious—but common—culprit is data freshness due to how and when calculations are triggered in PI AF Analytics or PE Scheduler:
- If your tags are updated at different intervals or scan classes, one may still have an old value when the calculation runs.
- For example, if
tag1updates every minute andtag2every 10 seconds, a PE triggered by new data fromtag2might use the most recent (possibly stale)tag1value.
This means that, depending on which tag triggers the calculation and their update frequencies, your PE might:
- Use a current value for one tag but a stale one for the other.
- Return incorrect results based on non-synchronized tag values.
3. Solutions and Best Practices
a) Triggering Mechanism
- Natural Scheduling: Calculation triggered when new data arrives on either tag (default). Can lead to the use of stale values.
- Clock-based Scheduling: Forces calculation at fixed intervals using the most recent values for both tags, reducing data skew.
Recommendation: For multi-tag logic, favor clock-based scheduling.
b) Data Age Checks
You can explicitly check the time difference between now and the latest sample for each tag. If a tag’s value is too old, output an error indicator (e.g., "I/O Timeout" or "Calc Failed").
Example:
IF SecSinceEvent('tag1','*') > 60 OR SecSinceEvent('tag2','*') > 60 THEN "I/O Timeout" ELSE IF TagVal('tag1','*')="OK" OR TagVal('tag2','*')="OK" THEN "OK" ELSE "FAILED"
This will alert you to stale data situations.
c) Re-check Logic Requirements
Make sure the Boolean logic matches your operational requirements:
- Do you want OK if either tag is OK (use OR)?
- Or only if both are OK (use AND)?
4. Key Takeaways
- Boolean logic in PEs must align with process requirements (
ORvsAND). - Calculation schedules and data age can impact PE results—especially with tags updating at different rates.
- Clock-based triggering and data age checks help ensure accurate, up-to-date evaluations.
Conclusion
Performance Equations are central to process status monitoring in PI. When results seem off, it's often not a logic error but a matter of data freshness and triggering. By understanding and adjusting the scheduling and adding data age validation, you can make your PEs more reliable and insightful.
Have you run into unexpected results with your PI Analytics or PE setups? How did you resolve the issues? Share in the comments below!
Tags
About Roshan Soni
Expert in PI System implementation, industrial automation, and data management. Passionate about helping organizations maximize the value of their process data through innovative solutions and best practices.
No comments yet
Be the first to share your thoughts on this article.
Related Articles
Enhancing PI ProcessBook Trends with Banding and Zones: User Needs, Workarounds, and the Road Ahead
A look at the user demand for trend banding/zoning in OSIsoft PI ProcessBook, current VBA workarounds, UI challenges, and how future PI Vision releases aim to address these visualization needs.
Roshan Soni
Migrating PIAdvCalcFilVal Uptime Calculations from PI DataLink to PI OLEDB
Learn how to translate PI DataLink's PIAdvCalcFilVal advanced calculations—like counting uptime based on conditions—into efficient PI OLEDB SQL queries. Explore three practical approaches using PIAVG, PIINTERP, and PICOunt tables, and get tips for validation and accuracy.
Roshan Soni
Understanding PI Web API WebID Encoding: Can You Generate WebIDs Client-Side?
Curious about how PI Web API generates WebIDs and whether you can encode them client-side using GUIDs or paths? This article explores the encoding mechanisms, current documentation, and best practices for handling WebIDs in your applications.
Roshan Soni