OPC-UA

Open Platform Communications Unified Architecture is an open standard for data exchange among OPC-UA compatible devices. Packet Tracer supports a simplified OPC-UA described in the help.

 

Server

An OPC Server is a device that utilizes the OPC script module and provides data to OPC clients.

 

Client

An OPC Client is a device that utilizes the OPC script module and requests data from an OPC Server.

 

Running OPC

Create a topology with devices that support script module programming.

In this topology, the MCU acts as a server while two PCs act as clients.

OPC topology

Create an empty JavaScript program and write OPC server code for the MCU.
In the sample code, the server supports two variables: "my_val1" and "my_val2".

OPC server programming

 

Client sample code that reads values from the server.

PROFINET discovery

 

JavaScript API

Program Structure and Events

Function 

Return Type

Description 

Usage

Example 

setup()

N/A

Enables OPC-UA server functionality on the device.

Server

OPC.setup();

connect(ip)

N/A

Opens a TCP/IP connection to the IP address

Client

var client = new OPCClient();
client.connect("1.1.1.1");

close()

N/A

Closes the outstanding connection.

Client

client.close();

getServerTime()

N/A

Gets the current server clock.

Client

client.getServerTime();

getValue(name)

N/A

Gets the value of the variable specified.

Client

client.getValue("temperature");

setValue(name, value)

N/A

Updates the value of the variable specified.

Client

client.setValue("temperature", "98.6");

addVariable(name, value)

N/A

Creates a new variable with the value specified.

Server

OPC.addVariable("temperature", "75.2");

updateVariable(name, value)

N/A

Updates the value of the specified variable.

Server

OPC.updateVariable("temperature", "82.9");

onOpcOpened

N/A

Sets the callback that is invoked when the client is connected to the server.

Client

client.onOpcOpened = function() {};

onOpcClosed

N/A

Sets the callback that is invoked when the connection to the server is terminated.

Client

client.onOpcClosed = function() {};

onReceive(name, value)

N/A

Sets the callback that is invoked when data is received.

Client

client.onReceive = function(name, value) {};

onConnectionChange(type)

N/A

Sets the callback that is invoked when the TCP connection state changed.

Client

client.onConnectionChange = function(type) {};

onReceive(data)

N/A

Sets the callback that is invoked when I/O data is received.

Server

OPC.onReceive = function(data) {};

onDataReceive(ip, data)

N/A

This event handler receives data from the specified IP Address with data.

Server

OPC.onDataReceive = function(ip, data) {};

 

Examples

Sample File Description

hmi-arm-opc.pkt

Demonstrates how to use OPC in an industrial setting.

opc-script.pkt

Provides step-by-step instructions on how to configure OPC in Packet Tracer.

 

Current Modeling Limitations

OPC PDUs can be viewed in simulation by enabling the "TCP" filter. The TCP PDUs do not show OPC in detail.