OPC Toolbox lets you discover, access, and read raw and processed data from any data historian compliant with the OPC Historical Data Access standard. You can also access live data from an OPC Data Access server in three ways:
When used in MATLAB, the toolbox employs an intuitive, hierarchical object structure to help you manage connections to OPC servers and collections of server items, or tags. You create an OPC Data Access Client object to connect to an OPC server. This connection lets you browse the server namespace and retrieve properties of each item stored on the server. You create Data Access Group objects to control sets of Data Access Item objects, which represent server items. The toolbox lets you configure and control all client, group, and item objects by modifying their properties.
In Simulink, the toolbox uses a Configuration block to specify the OPC Data Access clients to use in the model, define the behavior for OPC errors and events, and set the real-time behavior. During simulation, the model executes in pseudo real time, matching the system clock as closely as possible by automatically slowing the simulation. You can use the Configuration block to define the toolbox’s behavior if the simulation runs more slowly than the system clock.
Explore gallery (2 images)
Once you create a group object containing item objects, you can read from or write to individual items or all the items in the group simultaneously. In MATLAB, read and write operations can occur either synchronously (MATLAB execution is blocked until the operation is complete) or asynchronously (MATLAB can continue processing while the operation is in progress). You can log data to memory or disk.
In Simulink, OPC Read and OPC Write blocks retrieve and transmit data synchronously or asynchronously to and from the OPC DA server. The blocks contain a client manager that lets you specify and manage the OPC DA server, select items, and define block sample times.
You create an OPC Historical Data Access Client object to connect to an OPC HDA server. This client lets you browse the server namespace and retrieve fully qualified IDs of each item stored on the server. You use these IDs to request historical data from the server. You can retrieve raw or processed data stored on the OPC HDA server, specifying the IDs you want to retrieve, a time period for which to retrieve data, and optional parameters. OPC Toolbox supports the following read operations:
Data is retrieved into OPC HDA Data objects, which allow you to visualize and preprocess the historical data for further analysis in the MATLAB environment. Preprocessing operations include resampling, data conversion, and data display functions.
With the toolbox, you can browse for available OPC UA servers. You then connect to an OPC UA server by creating an OPC UA Client object. The toolbox provides functions that enable you to browse and search the nodes in the server namespace to determine available data nodes. You can interact with multiple nodes at the same time by creating an OPC UA node array. When you read the current value for a node or node array, you receive the value, timestamp, and an estimate of the quality of the data, and can determine whether the data is a raw or interpolated value. You can also write a current value to a node.
You can read historical data from nodes on the UA server. To find the nodes available on your server, you can use the Browse Name Space graphical utility function. The browser displays the index and IDs for all the nodes on the server.
To read the data into MATLAB, you specify the nodes and a time range for which you would like to read data. OPC UA servers also provide aggregate functions for returning preprocessed data to clients. You can query the aggregate functions that your server supports, and read the preprocessed data that results from applying aggregate functions to the nodes. Examples of aggregate functions include average, maximum, minimum, and delta.
All OPC UA historical data is stored in OPC UA Data objects which contain
datetime objects to represent the timestamp. You can then easily visualize and process the data for further analysis in the MATLAB environment.