You could use PI DataLink to pull your 5 second samples to Excel.
What do you refer to with nx2 array? Is that an array of cells? If so, this is what PI DataLink creates when you pull PI data.
You mention that the array will have to be "long". What's the time period you envision to query?
Thanks for your response, I rather have it in VBA since I wish to make an automated program and rather not have all values display in excel and then mapping them to arrays. It all depends on how many days has elapsed since the last updated I envision a week tops so 7 x24x60x12 array
Sent from my iPhone
Could you clarify that you really want 5 second data versus 5 minutes? Your original post stated 5 seconds. The formula 7x24x60x12 suggests 5 minutes. If it is 5 minutes, perhaps you could edit your original post to reflect that.
It's 5 second data I am needing. Let me break down the formula listed below for clarity
7days x 24hours/day x 60min/hour x 60 seconds / min x 1 sample/ 5 seconds.
The last two values 60/5 equals 12 which is I am getting 12 samples per minute since the sample rate is 5 seconds.
Hope this clarifies your question.
However I feel that your question is missing the overall goal of my post, to be able to pull a pi point in VBA regardless of sampling rate.
Please let me know if you have any guidance.
Sent from my iPhone
Sorry. You're right about the 5 seconds. Mental error on my part. I blame it on watching the Olympics while reading forums.
Since you are using Excel VBA, you are limited to the legacy, COM-heavy PISDK, which is expected to be deprecated in the future.
Since you desire a N*2 array, it will have to be a Variant to accommodate Timestamps, floating points values, as well as possible System Digital States.
The following code example may point you in the right direction:
Option Explicit Public Function LoadPIValuesToArray() As Variant() Const ArrSize As Long = 7& * 24& * 60& * 12& Dim myArray(1 To ArrSize, 1 To 2) As Variant Dim piserver As PISDK.Server Dim pipoint As PISDK.pipoint Dim pivalues As PISDK.pivalues Set piserver = Servers.DefaultServer If Not piserver.Connected Then piserver.Open End If Set pipoint = piserver.PIPoints("Sinusoid") Set pivalues = pipoint.Data.InterpolatedValues("*-7d", "*", ArrSize) Dim i As Long For i = 1 To ArrSize myArray(i, 1) = pivalues(i).TimeStamp myArray(i, 2) = pivalues(i).Value Next i LoadPIValuesToArray = myArray End Function