2 Replies Latest reply on Nov 1, 2010 11:13 PM by Ahmad Fattahi

    Problem getting PI values into MATLAB


      Hi everyone, i had a post from an earlier date, i managed to resolves the connection issues with MATLAB turned out to be an issue with OLEDB not being installed correctly, but i have another issue right now. I m currently running this one a server 2008 rev2 , with matlab 64bit


      ArchiveValue = PI_ArchiveValue('servername.XXXXX','cdt158','*-1h')
      Warning: ActiveX - unsupported VARIANT type encountered
      > In adodbquery at 40
        In PI_ArchiveValue at 36

      ArchiveValue =



      Here is my code

      function Output = PI_ArchiveValue(server,tag,timestamp,cn)


      % Detect if an existing connection was passed
      if nargin<4
          % Build connection string

         cnstr = ['Provider=PIOLEDB;User ID=' dbUserName ';Password=' dbPassword ';Data Source=' dbSource ';Initial Catalog = ' archive ';Connection Timeout =60'];
          % Open connection

      % Query to execute
      sql=strcat('SELECT tag, time, value FROM piarchive..piinterp2 WHERE tag = ''',tag,''' AND time = ''',timestamp,'''');

        • Re: Problem getting PI values into MATLAB

          Hi Vikneshan,


          I'm not sure if I can help, but do you think you maybe getting back a digital state for a value instead of a Float32?  Just food for thought. 


          By the way, thanks for the help with my connection issue.  I read back through your earlier postings and I decided to downgrade my PI-SDK to 1.3.6.x from 1.3.8.x and now on the second call to the PI-OLEDB it doesn't hang.  Thank you.  Good luck with your issue.







            • Re: Problem getting PI values into MATLAB
              Ahmad Fattahi



              I have a few things to try:


              1) Why you're not passing anything to the function for the cn parameter?


              2) Can you run the sql query (the last line in PI_ArchiveValue) separately and make sure it brings you back the expected archive value?


              3) What's line 36 in PI_ArchiveValue?


              4) Did you have a chance to check out Jimmy's suggestion?


              By the way I created a new thread for your question as the old one was getting too long and the subject line was quite different than what we are discussing now