3 Replies Latest reply on Sep 18, 2013 12:44 PM by Marcos Vainer Loeff

    Writing values to PI using Matlab

    rehanna

      I am reading and writing data from the PISDK using Matlab and am looking for an example wherein a new value is written to a PI tag using Matlab.  If someone has an example or can point me in the right direction, I would be very grateful!  Also, what are additional considerations when writing data to PI (e.g., I have read that one should ensure the data point is not read-only)?

       

      Thanks,

       

      Ryan

        • Re: Writing values to PI using Matlab
          Marcos Vainer Loeff

          Hello Ryan,

           

           To insert a value on the PI Server through PI SDK, you should use the function PIData.UpdateValue. According to the PI SDK Programming Reference, the syntax is:

           

          object.UpdateValueNewValue, TimeStamp, [MergeType], [AsyncStatus]

           

          The code snippet below works perfectly on Visual Studio:

           
                      PISDK.PISDK sdkroot = new PISDK.PISDK();
          
                      Server myPIServer = sdkroot.Servers["MARC-PI2012"];
          
                      PIPoint myPoint = myPIServer.PIPoints["sinusoid"];
          
                      myPoint.Data.UpdateValue(-10, "*");
          

           On Matlab, I would try something like:

           

           

           
          timestamp = System.String('15-Sep-2013 11:01:00');
          
          value=-10;
          
          PI_POINT.PV.Data.UpdateValue(value,timestamp);
          

           But again, I am not sure how to handle a .Net library under Matlab. 

           

          Please, let us know the results.

           

          Hope this helps!!