OPC Toolbox

Key Features

  • OPC Foundation Data Access standard v2.05a support
  • OPC Foundation Historical Data Access 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.

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.

OPC Tool, which lets you browse the server namespace, configure objects, and read and write OPC DA data.

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.

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.

The OPC Configuration block for Simulink, which lets you specify and configure settings for your OPC DA clients in your Simulink model.

The OPC Configuration block for Simulink, which lets you specify and configure settings for your OPC DA clients in your Simulink model.

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.

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 Client Object

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.

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

Try OPC Toolbox

Get trial software

Access and Organize Data with MATLAB

View webinar