Enabling symbols

As you have already learned in the Quick Start tutorial, symbols are enabled in the TwinCAT 3 PLC via a so-called pragma (also known as an "attribute"). In other real-time environments, the enabling mechanism may be different. The following chapter provides an overview.

Enabling symbols 1:

The term "Symbol"

The term "Symbol" is used in this documentation as a substitute for variable, structure, function block instance, method, etc.

Symbolism

The TwinCAT OPC UA Server receives its information via real-time variables (e.g. addresses and data types), the so-called "symbolism". Depending on the real-time environment used (e.g. TwinCAT PLC or TwinCAT 3 C++), various so-called "symbol files" are available for reading the symbolism (also known as "offline symbolism"). In addition, the symbolism can be read via TwinCAT ADS when the runtime environment is started (also referred to as "online symbolism").

Enabling symbols 2:

The advantage of using online symbolism is that no symbol files need to be exchanged. Especially in the installation variant, in which the TwinCAT OPC UA Server is operated on a gateway PC, the manual copying process of the symbol files of all connected controllers is no longer necessary. The disadvantage of online symbolism is that the symbols are only available when the PLC environment is running.

The symbol file must be imported by the server to access the address information of the symbols. Alternatively, the server can also work directly with the online symbolism. The symbols are then only available in the server's address space when the real-time environment is available.

The TwinCAT OPC UA Configurator can be used to configure the server and which symbol file it should read. The corresponding path to the symbol file can be configured there as part of the data access device.

Depending on the real-time environment used, the symbol file that must be imported from the server in order to obtain address information for the existing symbols and the symbol enabling mechanism will vary. While the TwinCAT 3 PLC works with so-called pragmas to enable a symbol for OPC UA, TwinCAT 2 still uses specially formatted comments on the symbol for this purpose. TwinCAT 3 C++, on the other hand, uses the so-called TMC code generator to enable symbols for OPC UA.

Symbol files can be configured in the TwinCAT engineering interface so that they are automatically copied to the boot directory of the target device when the project is activated. The TwinCAT OPC UA Server is usually configured to read the symbol file from the boot directory.

The following table provides an overview of the various symbol files in relation to their real-time environment and the enabling mechanism.

Real-time environment

Symbol file

Enable via...

Path in the boot directory

TwinCAT 2 PLC

TPY

Comment

CurrentPlc_1.tpy

TwinCAT 3 PLC

TMC

Pragma

Plc\Port_%AdsPort%.tmc

TwinCAT 3 C++

TMI

TMC code generator

Tmi\%ObjectId%.tmi

TwinCAT 3 Matlab/Simulink

TMI

TMC code generator

Tmi\%ObjectId%.tmi

TwinCAT 3 I/O Task

XML

Comment

CurrentConfig.xml

Online symbolism

---

Pragma

TMC code generator

---

For more information, see the sub-chapters for each real-time environment.