How To: Bit Extraction using PI PE's

This article describes how to create a digital PI Tag based on a specific bit from an Integer PI tag. The example used is based on an ABB Bailey Infi90 interface tag which returns a single Integer value consisting of multiple bits. Each of the bits in the Integer PI tag represent certain digital flags in the DCS Tag for that Bailey Tag Type, an RCM Tag in this case. PI Performance Equations will be used to do the actual bit extraction.

The PI Bailey Infi90/Net90 interface has some limitations due to the ABB Bailey Infi90 API (See the "Bailey Infi90 Interface to the PI System" interface manual for more details). There are some Bailey Tag Types that cannot be accessed using this interface. Also there is a limit on the number of individual PI Tags that can be built to retrieve specific Bits from certain Bailey Tag Types (RCM, DD and MSDD). The important point of this article is to demonstrate how to extract some of these individual bits into separate PI tags.

For our example, we will assume that a PI Tag has been built to receive some bits of interest from a Bailey RCM tag. The bits that we will be extracting are: Bit 9 (Red Tag Status), Bit 3 (Override Value) and Bit 2 (Feedback state). These bit numbers are documented in the appendix of the "Bailey Infi90 Interface to the PI System" manual. We will want to extract these bits any time we get a new value for our Integer PI Tag from the Bailey system so we need our Performance Equation tags to be Event-based.

The idea of this method is to check to see if a particular bit is "turned on" in some value (Integer PI Tag value). Knowing how these multiple bits are stored in a single Integer value helps to understand how to extract them from that Integer. Here is a simple table that shows each bit and it's corresponding value in an Integer:

Bit Power Value
0 2^0 1
1 2^1 2
2 2^2 4
3 2^3 8
4 2^4 16
5 2^5 32
6 2^6 64
7 2^7 128
8 2^8 256
9 2^9 512
10 2^10 1024
11 2^11 2048
12 2^12 4096
13 2^13 8192
14 2^14 16384
15 2^15 32768

The values above are computed based on raising 2 to the power of the bit. 2^0 = 1, 2^1 = 2, 2^3 = 8, etc. So an Integer value of 17 would mean that bit 4 and bit 0 are "turned on". 2^4 + 2^0 = 16 + 1 = 17. The Integer value is simply a total of all of the values that each bit represents. What we need now is a simple comparison check of each bit we want versus an Integer value. This can be accomplished by using the AND operator in a PI Performance Equation. If we compare the Integer value to the value that a single bit represents, we will get a 0 or 1. What this will do is compare the exact bit positions in the PI Integer value with the value of the single bit position. If they are both "turned on", the result will be 1, otherwise the result will be 0. This will then become the source of the value of our new PI Digital Tag. The 0 and 1 will represent the zero and one states of the digital set that we use for this PI Performance Equation Tag. By setting the value of a digital PI tag to a 0 or 1, PI will interpret that into the appropriate digital state and store that value in the PI tag.

The PI Extended Descriptor (Exdesc) for these Performance Equations will contain the equation plus the event qualifier. In our example, the source tag is 28-MC-094.MultiBits. We need to build our Performance Equations based on that PI tag using the bit numbers required for each attribute that we would like to extract. Here is the specific attributes we need for our new PI Performance Equation tags:

Attribute Bit PntSrc PntTyp DigSet Loc3 Loc4 Exdesc
Red Tag Status 9 C Digital GR_REDTAG 1 1 event=28-MC-094.MultiBits, if ('28-MC-094.MultiBits' and 2^9) <> 0 then 1 else 0
Override Value 3 C Digital GR_NOYES 1 1 event=28-MC-094.MultiBits, if ('28-MC-094.MultiBits' and 2^3) <> 0 then 1 else 0
Feedback State 2 C Digital GR_TWOSTATE 1 1 event=28-MC-094.MultiBits, if ('28-MC-094.MultiBits' and 2^2) <> 0 then 1 else 0