Connect MATLAB to AVEVA PI System - MATLAB
Video Player is loading.
Current Time 0:00
Duration 6:03
Loaded: 2.71%
Stream Type LIVE
Remaining Time 6:03
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 6:03

    Connect MATLAB to AVEVA PI System

    Develop MATLAB® functions with OSIsoft® PI Asset Framework data and deploy to production to explore trends, uncover insights, and predict events using free add-on products. The MATLAB interface for OSIsoft PI System™ enables you to analyze your OSIsoft PI System data using your own algorithms that can leverage MATLAB and dozens of add-on products. You can:

    • Visualize the findings
    • Create reports and share your insights
    • Flag anomalies
    • Identify preventative maintenance patterns
    • Predict remaining useful life of assets

    Requirements for the MATLAB interface for OSIsoft PI System:

    • MATLAB (R2022a or later): included in Industrial Communication Toolbox
    • MATLAB (R2018a-R2021b): installs as a MATLAB toolbox add-on
    • PI Server (2018 SP2 or later)
    • PI Asset Framework (2018 2.10.x or later)
    • PI Asset Framework SDK
    • PI System Access License

    The MATLAB Production Server® interface for OSIsoft PI System enables you to use MATLAB functions as part of your production workflow. You can map OSIsoft PI AF asset data as MATLAB function arguments and perform live data analysis. You can also write back analysis results to OSIsoft PI AF and use them in your reports and OSIsoft tools like PI Vision. Additional capabilities let you:

    • Automate algorithm execution with production data from OSIsoft PI AF
    • Run multiple analyses at scale with MATLAB Production Server
    • Write results back to OSIsoft PI AF or other downstream systems, adding deep insight to process monitoring
    • Display results with OSIsoft user interface tools

    Requirements for the MATLAB Production Server interface for OSIsoft PI System:

    • MATLAB (R2018 and later): installs as a downloadable support package
    • MATLAB Compiler (R2018a or later)
    • MATLAB Compiler SDK (R2018a or later)
    • MATLAB Production Server (R2018a or later)
    • PI Server (2018 SP2 or later)
    • PI Asset Framework (2018 2.10.x or later)
    • PI Asset Framework SDK
    • PI System Access License

    Published: 29 Jul 2021

    MathWorks offers two ways to interface with OSIsoft PI System. The MATLAB Interface for PI System enables you to import historical PI data into MATLAB for data exploration and algorithm development. The MATLAB Production Server Interface for PI System enables you to perform periodic analytics on near real-time data from PI System. Use the following timestamps to navigate quickly to the interface that interests you.

    The MATLAB Interface for PI System is provided with Industrial Communication Toolbox. This interface has read-only access, as it is primarily designed to help import data into MATLAB for further analysis. The first step is to create a client object for the device system. There are a few ways you can do this.

    The first option is to specify the name of the server where your PI System is located. You can use localhost if your PI System is installed locally. This will create a client object with a connection type PI AF SDK. You can also create your client object using specific credentials. The example in this video connects without credentials.

    PI System uses tags to help arrange data logically. One of the first things you might do is find out what tags are available. This example does a wild card search for all tags with the letters S-I-N, which produces the following two tags. You can use the tag names to retrieve the corresponding data from PI System. This will produce a MATLAB timetable, since each data value in PI System contains a timestamp.

    You'll also note the status value, which indicates whether an entry was corrupted. This data here looks good so far. MATLAB timetables make it easy to apply useful functions to your data. The retime function quickly resamples your timetable. It can also be used to resolve duplicate or irregular times.

    You can also pull in data from another PI System tag, and then use the synchronize function to aggregate data from multiple sources into a single timetable. Many functions provided by this interface are wrappers around the functions already provided by the PI AF SDK. Here, you might recognize the function that enables you to specify a time range of data to pull from PI System. This example retrieves all the data from the last two days with a SINUSOIDU tag.

    Another example is get interpolated values, which again is ultimately provided by the PI AF SDK. The last piece of code here provides a visual interactive experience to explore your data. All of the tags in your PI System are exposed in the left column. You can add tags into the right column and use the built-in visualization tools to explore your data at an aggregate level and help narrow down which tags you want to investigate further.

    Once you have developed MATLAB algorithms for your data, you can deploy them using the MATLAB Production Server Interface for PI System. This enables you to run custom MATLAB analytics against your PI System data in near-real time. The setup instructions for installing and configuring the interface will be covered later in this video. In order to run this interface, you will need to have a license for PI System and access to the PI AF SDK DLL.

    This database contains solar plant data from two different cities. Each inverter in the plant is defined by various attributes. The attributes themselves are common to all the inverters. This example has been scaled down to this test database where the inverters and the plants are now represented by a different set of common attributes.

    The goal is to pull these two temperature attributes, which are represented in Celsius, and send them to MATLAB Production Server to be converted into Fahrenheit. Those values will be saved in out1 and out2. Here's the MATLAB function that performs the conversion. It takes two Celsius temperatures imported as a MATLAB structure-- or struct-- converts them to Fahrenheit, and outputs the results.

    If you have MATLAB Compiler SDK, you can test this function simply by opening the example project file provided with the package you download. Click on Test Client, then Start, which has the effect of converting your MATLAB session to act like an instance of MATLAB Production Server which accepts HTTP connections at this URL.

    Since this interface is implemented as a .NET application in the form of a Windows service, you will need to start the service itself. Pull up the Windows services application by typing Services into the Start menu. All of the PI-related services are located here. Find the service called PI Client for MATLAB Production Server and start it, either through the context menu or by clicking this button in the Services menu.

    If you switch back to MATLAB, you'll see that a request has come in. Currently, requests are made every 10 seconds from PI System. Suppose that this PI System is a live system, and Temp1 is changed to 50. You can examine the latest call and verify that Temp1 has a value of 50. Once PI System has refreshed its data, the new output value is reflected as expected.

    To install the interface, simply run this batch file in the package you receive to install the Windows service-- know that all the logs created by the interface are stored in this folder. You'll need to configure the interface to bridge MATLAB Production Server and PI System. The key connections are contained in the Mappings XML file. Amongst other things, it will map the input and output arguments of the MATLAB function to their counterparts in PI System.

    You will specify the URL to MATLAB Production Server here, the name of the MATLAB archive here, and the name of the MATLAB function here. The input arguments are listed in the order they are received by the MATLAB function. You need to replace these file paths with a full path to each corresponding PI attribute. You can obtain this easily by navigating to your attribute, right-clicking, and selecting Copy Path. Then, do the same for your output arguments.

    If you have multiple MATLAB functions you would like to use, make sure to specify those as well in this XML file. Once you're done, save the file, start the Windows service, and you are good to go. For more information on using either interface, check out the documentation, and don't hesitate to contact us.

    View more related videos