C++
This section describes how to configure the namespace of the TwinCAT OPC UA Server in order to obtain access to the symbols of a TwinCAT 3 C++ module. This requires the following steps to be carried out:
- Activating the symbol file
- Enabling symbols
- Configuration of the server
These steps are described in more detail below.
Activating the symbol file
To configure certain symbols contained in an instance of a C++ module so that they become accessible via OPC UA, you must first activate the download of the symbol file for the module instance. This copies the symbol file to the boot directory of the target device when the configuration is activated.
Activate the download of the symbol file by setting the following option in the properties of the module instance:
The generated symbol file (TMI) is always named after the ObjectId of the module instance and is now copied to the boot directory of the target device when activated, for example:
%TwinCATInstallDir%\3.1\Boot\Tmi\Obj_01010010.tmi
Enabling symbols
You can use the TMC Code Generator to define which symbols are to be enabled via OPC UA. Two settings are required for this. First activate the "Create Symbol" checkbox for each symbol to be enabled in the TMC Code Generator. Then add an optional property with the key "OPC.UA.DA" and the value "1".
Configuration of the server
You can now use the TwinCAT OPC UA Configurator to configure the TwinCAT OPC UA Server so that it reads the generated symbol file and makes the C++ module instance available as a data access device in its address space.
To do this, add a new device in the Data Access tab of the TwinCAT OPC UA Configurator. Select the AMS Net ID of your device and enter the ADS port of the TwinCAT 3 C++ module instance. You can find the ADS port in the properties of the task connected to the C++ module instance:
Now select the entry "TwinCAT 3 C++ (TMI) - Filtered" from the selection list in the "Type" field. In the "SymbolFile" field, select the symbol file (TMI) that was created after activating the TwinCAT 3 C++ project and should now be located in the boot directory. Alternatively, you can also use the online symbolism.
You can leave all other settings at their default values.