Key Features

  • OPC Unified Architecture (UA) standard v1.02 support
  • OPC Foundation Data Access (DA) standard v2.05a support
  • OPC Foundation Historical Data Access (HDA) standard v1.20 support
  • Simultaneous data logging and numerical processing
  • Simultaneous connections to multiple OPC servers
  • Access to historical data for analysis and statistical processing
  • Communication with OPC servers using synchronous or asynchronous operations

OPC Data Access Techniques

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:

  • Execute all OPC Toolbox functions directly from the MATLAB® command line or incorporate them into your own MATLAB applications
  • Use the OPC Client app to rapidly connect to OPC DA servers; to create and configure OPC Toolbox objects; and to read, write, and log data
  • Use the Simulink® blocks from OPC Toolbox to read and write data to and from an OPC DA server while simulating a system
Simulink model created using Simulink blocks from OPC Toolbox. These blocks let you communicate with OPC data directly to and from Simulink and your process system.

OPC Data Access Object

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)

OPC Client app, which lets you browse the server namespace, configure objects, and read and write OPC DA data. The tool also lets you log OPC DA data into MATLAB for analysis and plotting.

OPC DA Data Reading and Writing

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.

The OPC Read block for Simulink. You can choose items from an OPC server and read online plant data directly into your Simulink model.

OPC Historical Data Access

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:

  • Retrieve raw data as it was stored on the server.
  • Retrieve data aggregated (processed) by the server. Each server implements different aggregate types, such as minimum, maximum, and average.
  • Retrieve data from specific time intervals. The server interpolates data from surrounding raw measurements.
  • Retrieve data that has been modified on the server. Some OPC HDA servers allow historical values to be modified, storing a history of values that have changed.

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.

MATLAB code, used to connect to an OPC HDA server and access historical data for processing.

OPC UA Data Access

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.

MATLAB code, used to connect to an OPC UA server and read the current value of a node array.

OPC UA Historical Data Access

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.

Browse Name Space utility lets you find the OPC UA nodes available on your server.