4 Replies Latest reply on May 22, 2015 10:54 PM by gachen

# How to interprt the numerical negative digital state values from the PI archive

We have an application the recovers PI data from the PI archive using the PI API and these calls:

piar_timedvalues

piar_interpvalues

The program is old and cannot be modified due to the strict controls maintained by our plant computer management policies.  We need to understand how to convert the negative digital state values back in to the literal equivalent without using another PI API call. In other words can you please describe how to manually interpret the negative numbers from the PI archive?

We need more than just the definitions that state use the upper and lower 16 bits etc. we need an example to really understand what it is we need to do.

Thank you!

• ###### Re: How to interprt the numerical negative digital state values from the PI archive

Hi Elwyn,

This is very similar to the question asked in this thread. It is indeed confusing to interpret the value, so let me use the same example as in that thread. Let's say that I get a value of -13303809 returned for my archived event. To interpret this value to the actual digital state,

0n13303809 = 0b1100 1011 0000 0000 0000 0001

upper 16 bits = 0b1100 1011 = 0n203 (digital state set 203)

lower 16 bits = 0b1 = 0n1 (first offset within set 203)

So in this case, the value -13303809 means go to the digital state set 203 and return the value at the first offset (offsets are zero-based). To get the state set numbers, you can use piconfig:

```@tabl pids
@ostr setno,set
@ends
```

Hope that helps!

• ###### Re: How to interprt the numerical negative digital state values from the PI archive

Thank You - Please let me digest this to see if I get it!

• ###### Re: How to interprt the numerical negative digital state values from the PI archive

OK I don’t understand! When I convert the example below to either 32 bit binary or 16 bit binary I get different numbers from what you are showing – I clearly am missing something!

For example if I assume a short singed integer I get –13303809 = 0x 0000 = 00000000 00000000

Which is not the same as what you have. What is with the “On”