8 Replies Latest reply on Sep 7, 2011 8:49 PM by kilgored

    Using PI Data with MATLAB: new white paper on the Library

      Just in case you were not following this other discussion thread, I am please to announce a new white paper was just posted to the vCampus Library: Using PI Data with MATLAB (it's under the "White Papers and Tutorials > Miscellaneous" branch).

       

      This was announced on Twitter a little while ago but I preferred to wait since I got great feedback from colleagues and I wanted to incorporate it and make sure you got the most out of it (and admittedly, my 3-week leave did not help ). You'll most likely see a couple revisions of this paper in not too long, as my colleagues had other great ideas that were not yet incorporated (I just didn't want to delay this any longer).

       

      Anyhow, I hope the MATLAB users will enjoy - please do not hesitate to provide feedback!

        • Re: Using PI Data with MATLAB: new white paper on the Library
          Daniel Takara

          Very instructive white paper, Steve!

           

          I just took a look at it and have a couple of comments:

           

          1. It looks like a minor update needs to be done on page 4: there it says "WHAT YOU NEED TO START - You must have the following software installed to write PI ACE calculations in C#: (...)". It looks like the white paper was elaborated using a previous one as template and this section was not updated to reflect the subject of the current white paper.

           

          2. Regarding the piconfig script on page 15, it seems like it was intended to generate a text file with sampled data of a tag from the previous day, having 1 second as time interval. If this was indeed the idea, then the count should be 86401, instead of 86400. Also, we can prevent most of logging lines from being printed to the output, using the command

          @echo none

          I just have not found a way not to print the line

          * End Repeat...

           

          So, the script could be like this:

           

          @table piarc
          @istru tag, starttime, endtime, count, mode
          @ostr time, value
          @ostr ...
          @echo none
          cdt158,y,t,86401,even

           

          Good work, Steve! Look forward to seeing the updated versions!

            • Re: Using PI Data with MATLAB: new white paper on the Library

              Daniel Takara

              a minor update needs to be done on page 4

               

              Good catch! I fixed this in prevision of the next revisions.

               

              Daniel Takara

              If this was indeed the idea, then the count should be 86401, instead of 86400

               

              Another good catch!

               

              Daniel Takara

              we can prevent most of logging lines from being printed to the output

               

              Good suggestion. However, I think I prefer to keep it as it is, since we'll have some cleaning to do anyways (i.e. the "End Repeat" line). I think not having the @echo none will keep it more straightforward.

               

               

               

              Thanks for sharing your feedback and may that inspire others to do so!
              Happy PI/MATLAB coding!

            • Re: Using PI Data with MATLAB: new white paper on the Library
              maggiepakula

              One thing I would find helpful is a discussion on the pro's and con's of each connection strategy.

               

              For instance, I'm looking to pull large amounts of historical data to analyze. Ideally I want to use the fastest and most reliable connection protocol, and one that allows me to do flexible queries. I'm deciding between ADO and JDBC, but it seems the only difference between the two is that the latter requires a $1000 toolbox. Is there anything else you could elaborate on distinguishing the two?

               

               

                • Re: Using PI Data with MATLAB: new white paper on the Library
                  Ahmad Fattahi

                  Well there are other differences too. For example, if you are working in a Linux environment you want to pick PI JDBC as opposed to ADO. With ADO, you would have to have PI OLEDB Provider installed on the same machine as MATLAB; this is not the case with PI JDBC; this can be important in some environments and configurations. Last but not least, some developers are more comfortable to work in Java environment than creating their own ADO wrappers, or other way around.

                   

                  Having said that, I should add that you are trying to compare two methods of the same family. Comparing PI JDBC with text files or PI SDK would probably result in more differences in functionality. 

                    • Re: Using PI Data with MATLAB: new white paper on the Library

                      As Ahmad pointed out, ADO deals with the OLE DB and we have the PI OLEDB Provider and PI OLEDB Enterprise for that. These are Microsoft technologies and MATLAB has "out-of-the-box" support for this. JDBC is similar to OLE DB, but typically used in the Java programming language - MATLAB provides support for this (as well as ODBC) through an additional component called the 'Database Toolbox'. Ahmad accurately pointed out that these are very similar in nature and function, and are mostly a matter of preference on your side.

                       

                      Other possibilities from within MATLAB are PI SDK, PI OPC DA/HDA Server or text files; otherwise you can develop an external application using any technology you would like and the MATLAB libraries. It all really depends on your use case, your environment, the type of data you need to deal with, your preference/skills in terms of programming languages, etc.

                       

                      If you want to discuss that further, I suggest you initiate a new discussion thread on this same forum, with more specific information on what it is you want to do and the technologies involved. (creating a new topic will make this more easily searchable/viewable, as opposed to being buried deep inside another discussion thread )