OPC UA Read
Libraries:
Industrial Communication Toolbox /
OPC Unified Architecture
Description
The OPC UA Read block reads data from one or more nodes on an OPC Unified Architecture (UA) server. The read operation takes place synchronously at a specified sample time.
The block outputs the values of the selected nodes as a Simulink® bus signal. It optionally outputs the timestamps and the quality value associated with each node in separate outputs. The nodes that you select in the block can have different data types, which remain unchanged in the Simulink bus signal. The block outputs the timestamp as a serial date number (real-world time), or as the number of seconds from when you start simulating the model (simulation time).
Note
You need a license for both Industrial Communication Toolbox™ and Simulink software to use this block.
Note
You must connect at least one OPC UA server to use the OPC UA Read block. You can create an OPC UA client using the OPC Configuration pane in the Configuration Parameters dialog box of the model. You must add at least one OPC UA Read or OPC UA Write block in the model to enable this pane. For more information, see Configure OPC UA Client in Simulink.
Examples
Get Started with OPC UA in Simulink
Read and write data to nodes available on an OPC Unified Architecture (UA) server using Simulink® blocks from Industrial Communication Toolbox™. You can connect to the server using a Simulink model that acts as an OPC UA client. You can perform read and write operations in the model using the OPC UA Read and OPC UA Write blocks.
Monitor Data Value and Quality of OPC UA Nodes in Simulink
Implement a dashboard showing instantaneous values and quality metrics related to specific OPC Unified Architecture (UA) nodes using Simulink® blocks from Industrial Communication Toolbox™.
Use OPC UA Data to Test Binary Distillation Column Plant Model
Use data from an OPC UA server to test composition control of a binary distillation column model.
Ports
Output
Value — Current data values of selected nodes
scalar | bus
The block outputs the values of the selected nodes as one of these:
A scalar Simulink signal when you select a single node. The signal has the same data type as the selected node.
A Simulink bus signal when you select multiple nodes. Each signal in the bus inherits the data type of its corresponding node. Extract the value of a node from the Simulink bus signal using a Bus Selector (Simulink) block.
For more information on the data types supported at the Value port, see OPC UA Server Data Types.
Dependencies
To enable this port, specify one or more nodes in the Nodes parameter.
Data Types: Boolean
| single
| double
| datetime
| int8
| int16
| int32
| int64
| uint8
| uint8 vector
| uint16
| uint32
| uint64
| struct
| char vector
| bus
Timestamp — Timestamp of selected nodes data
seconds (default) | date number
The block outputs the timestamp of the selected nodes data as one of these values:
Seconds since start
(default): Represents the simulation time at which the Simulink client received data from the server.Serial date number
: Represents the real-world time at which the source provided data to the server.
Dependencies
To enable this port, select the Show timestamp port parameter.
Data Types: double
Quality — Quality of read data from selected nodes
boolean
The block outputs the quality of read data from selected
nodes as Boolean values. A logical 0
output indicates 'Bad'
or
'Uncertain'
quality and logical
1
indicates
'Good'
quality. For details on
the quality format, see OPC UA Quality.
Dependencies
To enable this port, select the Show quality port parameter.
Data Types: Boolean
Parameters
Server — Define OPC UA server for block
drop-down list
Select the OPC UA client associated with the block.
To add the required clients using the OPC configuration pane, click Configure servers. For more information, see Configure OPC UA Client in Simulink.
To update the block to the latest OPC configuration, click Refresh.
Programmatic Use
Block Parameter:
ServerList |
Type:
string | character
vector |
Nodes — List of OPC UA server nodes
table
Select nodes to read from the specified server.
To add variable type nodes, click Add. This action opens the Browse Name Space dialog box for the selected OPC UA server. Using this browser, you can select the nodes that you want to add to the Nodes list.
To delete selected nodes, click Delete.
To change the order of the selected nodes in the list, click Move Up or Move Down. The serial number of the nodes determines the order in which the block outputs the signals in the bus at the Value port.
Programmatic Use
Block Parameter:
NodeList |
Type:
string | character
vector |
Show quality port — Add quality output to block
on (default) | off
When you select this parameter, the block outputs the quality of the read data at the
Quality port, as a Boolean value. A
quality value of 'good'
is indicated by
logical 1
and a value of either
'bad'
or 'uncertain'
is indicated by a logical 0
.
Programmatic Use
Block Parameter:
ShowQualityPort |
Type:
string | character
vector |
Values:
'on' | 'off'
|
Default:
'on' |
Show timestamp port — Add timestamp output to block
on (default) | off
When you select this parameter, the block outputs the timestamps of the selected nodes data at the Timestamp port, as a vector of doubles. You can select the timestamp basis using the Show timestamp port as parameter.
Programmatic Use
Block Parameter:
ShowTimestampPort |
Type:
string | character
vector |
Values:
'on' | 'off'
|
Default:
'on' |
Show timestamp port as — Set timestamp basis
Seconds since start
(default) | Serial date number
Set the timestamp basis as Seconds since
start
or Serial date
number
.
Programmatic Use
Block Parameter:
ShowTimestampPortAs |
Type:
string | character
vector |
Values:
'Seconds since start' |
'Serial date number'
|
Default:
'Seconds since start' |
Sample time — Sample time for read operation
-1 (default) | numeric
Define the sample time of the block in seconds. The block reads the data from the server synchronously at the specified sample time. For more information, see Specify Sample Time (Simulink).
Programmatic Use
Block Parameter:
SampleTime |
Type:
string | character
vector |
Values: numeric |
Default:
'-1' |
Version History
Introduced in R2024a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)