Symbol Properties and Attribute Pragmas

What are properties and attributes?

For TcCOM objects, you can assign properties to all definitions, e.g. DataAreas, DataTypes, SubItems, etc. A property is defined as a name-value pair. Any additional information can be included.

Attributes are usually used in the PLC in the declaration part and can also bind any additional information to a variable, for example. Please refer to the PLC documentation for a list of PLC attributes.

Many TwinCAT functions use attributes and properties. Examples are:

Attributes and properties can also be defined by the user and used for own applications.

How do I use symbol properties and attributes together with the TwinCAT target?

It is possible to assign properties to ADS symbols with the TwinCAT target. ADS symbols are to be understood in the sense of variables.

(TcCOM) TMC Properties

In Simulink® you can freely assign Properties as a string in the Configuration Parameters under TC TcCom Interface. Properties can be defined for the DataArea:

In addition, you can use the Additional TMC Symbol Properties field to assign properties independently of the DataArea.

Symbol Properties and Attribute Pragmas 1:

The following notation is used for DataArea specific TMC properties:

SymbolName1:PropertyName1=Value1

Sample: FeedbackTemp:OPC.UA.DA=1

If several properties are to be assigned, they must be separated with |:

SymbolName1:PropertyName1=Value1|SymbolName2:PropertyName2=Value2

Sample: HeaterOn:OPC.UA.DA=1|HeaterOn:OPC.UA.DA.Access=3

wildcards can be used from MATLAB R2020b:

*:PropertyName1=Value1 

The * character is used as a wildcard and in this sample assigns the PropertyName1 with Value1 to all symbols in the DataArea. Substrings can also be combined with wildcards. The following sample assigns the specified property to all symbols that begin with Sum.

Sum*:OPC.UA.DA=1 

The same structure must be used in the Additional TMC Symbol Properties field. However, the DataArea must be added for addressing.

DataAreaName1.SymbolName1:PropertyName1=Value1

Sample: TempCtrl_B.current:OPC.UA.DA=1

PLC Attributes

The same procedure as for TcCOM applies to the PLC-FB, but there only possible for the inputs and outputs. When using the TcCOM-Wrapper-FB a TcCOM is referenced, so that you make the configuration according to TMC Properties.

The configuration for the PLC-FB is done under TC PlcFb Interface.

Symbol Properties and Attribute Pragmas 2:
Symbol Properties and Attribute Pragmas 3:

Sample code in MATLAB®

Open the appropriate sample with: TwinCAT.ModuleGenerator.Samples.Start('Simulink TMC Symbol Properties')

What are properties and attributes used for?

An example is the use of attributes in the PLC or Symbol Properties for TcCOM in connection with TwinCAT 3 OPC-UA. See the OPC-UA list of attributes.

The following example shows how all input variables of the Input DataArea and only the signal e from the BlockIO DataArea are provided with the OPC-UA data access property. The wildcard * is used for the input DataArea.

Symbol Properties and Attribute Pragmas 4:

You have to select TwinCAT 3 C++ (TMI) - Filtered on the right side under Type in the OPC-UA configurator, so that only the symbols with the corresponding property are displayed in the server. If you want to see all symbols in the server, simply select TwinCAT 3 C++ (TMI) - All at this point. Then all symbols will be displayed, regardless of the properties. Also select the TMI file of the TcCOM on the TwinCAT Target Device as SymbolFile (Boot\TMI Folder).

Symbol Properties and Attribute Pragmas 5:

Connect to the OPC-UA Server with a client to inspect the namespace. Here the OPC-UA Sample Client of TwinCAT 3 was used. You can see that only those symbols are displayed in the server that have been explicitly assigned the OPC.UA.DA=1 property.

Symbol Properties and Attribute Pragmas 6: