# PI/PI-ACE/MATLAB (prospective & retrospective analysis)

**jngai**Feb 9, 2016 6:30 PM

Hello,

I am new to the PI Square Community (but have had some experience with PI, primarily using PI SDK within MATLAB), and am working on something that I'm hoping others have experienced and can provide good feedback on:

--> looking initially at feasibility

--> **challenges to assumptions greatly appreciated!**

Objective: Generate new calculated value for each batch, based on time-series data from each batch

- to be done for historical batches as well as new batches

- calculated value should be contextualized (i.e., related to the particular batch)

Given:

1) PI tag containing continuous data (sent from DCS)

2) Associated unique IDs and other batch info in PI Batch DB (sent from DCS)...not yet using Event Frames

- batches are regularly generated (though they vary somewhat in duration)

- batches are not continuously generated (one immediately after another)

3) MATLAB script to perform complex calculation, and output value

General Plan:

1) Use PI ACE as liaison between PI and MATLAB (passing/receiving COM objects)

2) Use triggers for scheduling PI ACE data transfers/MATLAB calculations

3) Write value to PI Archive in a new PI tag

**QUESTIONS**:

1) As I have heard that PI ACE itself is batch-agnostic, even with a batch-end-related trigger to initiate PI ACE, how does PI ACE know what data to select for the purposes of performing the calculation?

- can PI-SDK be used within PI ACE to access the PI Batch DB to perform segmentation of the continuous data?

2) How can the calculated value be contextualized? Assuming the value is calculated and written back to PI fairly quickly, I see how it can be somewhat associated with the batch based on timestamp.

- looking for a more direct link between new PI tag value and batch info

3) Assuming the first two questions are addressed, and things are set up properly, can I have a secondary trigger to perform the calculations on all historical batches available in PI?

- perhaps a for loop in VBA in PI ACE to run all batches, and calculate values? (the contextualization of values mentioned in question 2 would be even more critical here)

Thanks all in advance for your input!

Jerry