OPC UA is a standardized communication interface with built in transmission and access security that is supported by numerous software manufacturers (e.g. visualization software).

The Device Manager values can also be accessed via OPC UA. The Device Manager comes with its own OPC UA server for data access.


The address for accessing the OPC UA server of an IPC is:

opc.tcp://<Device IP>:4852



The OPC UA Server is disabled on IPCs with Windows CE (Windows Embedded Compact) at delivery and must be started manually (or by configuring Autostart accordingly), if required: \Hard Disk\BkIpcDiag\UA\_DevMgrSvr-UA-CE.

OPC UA port blocked by firewall

By default, the OPC UA port is blocked by the firewall in all current images. In this case the port in the firewall must be opened if necessary.


OPC UA .NET sample

Via OPC UA the following .NET application reads the current values for CPU frequency, CPU load, CF card memory capacity, TwinCAT version, TwinCAT build, and CPU temperature.

Download: mdpoverua.zip


Execute the following steps:

1. Unpack the sample.
2. Open the file settings.xml in directory MDPOverUA\MDPOverUA folder.
3. In the file find the line <Session Url="opc.tcp://<DeviceName>:4852" Security="None" RefreshInterval="1000" KeepAlive="10000" />.
4. Modify the value for <DeviceName> according to your device.
5. Compile the project and execute it.


Access to files and folders via OPC UA

From OPC UA specification version 1.02, OPC UA contains a specialized ObjectType for file transfer, which is described in Appendix C of the specification. This special ObjectType called "FileType" describes the information model for the data transfer. Files can be modeled as simple variables in OPC UA with ByteStrings. FileType is a file with methods for accessing the file. The OPC UA specification provides further information about FileType and the structure and handling of the underlying methods and properties for accessing a file in the OPC UA namespace.

Beckhoff has implemented a generic way to load files and folders from a local hard disk into the OPC UA namespace. Each file is represented by a FileType and allows read and write operations for this file. In addition, each folder contains a CreateFile() method to create new files on the hard disk and a separate FolderPath to specify the actual path to the folder on the OPC UA Server.


FileTransfer in the OPC UA Server Device Manager

Only the OPC UA server of the Beckhoff Device Manager has this function. The TwinCAT OPC UA Server also provides some parts of this file transfer. However, the general function that enables disclosure of all files and folders is only available in the OPC UA Server, which is part of the device manager that is automatically available on every Beckhoff Industrial PC or Embedded PC. See the Device manager documentation for more information.



FileType objects are created in a separate namespace called "FileTransfer". An XML file (files.xml) is used to configure this namespace and to select the files and folders available via OPC UA. The file must be located in the same directory as the executable file of the OPC UA Server. The system must be restarted in order to activate the configuration. The XML file contains information about the folder path and a search mask that defines which files are published in the OPC UA namespace:

  <FolderObject DisplayName="TwinCAT">
    <FolderObject DisplayName="3.1">
      <FolderObject DisplayName="Boot" Path="c:/TwinCAT/3.1/Boot" Search="*.*" >
        <FolderObject DisplayName="Plc" Path="c:/TwinCAT/3.1/Boot/Plc" Search="*.*" ></FolderObject>
        <FolderObject DisplayName="Tmi" Path="c:/TwinCAT/3.1/Boot/Tmi" Search="*.*" ></FolderObject>


Example: Reading a file with UA Expert

General file handling is described in Appendix C of the OPC UA specification. Reading a file via UA can be divided into the following steps:

  1. Calling the Open method of a file. This method returns a file handle that must be saved for later access. The mode defines whether the file is read or written to (see File modes).
  2. Determining the file size with the property "Size". In this way, the entire file can be read when the Read method is called.
  3. Calling the Read method. Inserting the file handle and file size as inputs. Selecting the destination folder in which the file contents are to be saved AFTER the method call.
  4. Calling the Close method to enable the file handle.

File modes

The following table shows all available file modes.






The file is opened for reading. If this bit is not set, Read cannot be executed.



The file is opened for writing. If this bit is not set, Write cannot be executed.



The existing file contents are deleted, and an empty file is made available.



The file is opened and positioned at the end, otherwise it is moved to the beginning. This position can be changed with SetPosition.