Add / modify / delete parameters

The properties and functionalities of a TwinCAT class can be added, edited and deleted with the aid of the TwinCAT Module Class (TMC) Editor.

This article describes:

Step 1: Create new parameters

1. After starting the TMC Editor, select the target Parameters.
2. Extend the list of parameters by a new parameter by clicking on the + button Add a new parameter.
A new "Parameter" is then listed as a new entry:
Add / modify / delete parameters 1:
3. Select Parameter in the left-hand tree or double-click on the red-marked "Parameter3" or select the node in the tree to obtain details of the new parameter.
Add / modify / delete parameters 2:
4. Configure the parameter as well as the Data Types.
5. Give it a more meaningful name – in this sample "bEnable" – and select the data type "BOOL".
Add / modify / delete parameters 3:
6. Save the changes you have made in the TMC file.

Step 2: Start the TwinCAT TMC Code Generator to generate code for the module description.

1. Right-click on your project file and select TwinCAT TMC Code Generator to receive the parameters in your source code:
Add / modify / delete parameters 4:
You can see the parameter declaration in the header file "Module1.h" of the module.
Add / modify / delete parameters 5:
The implementation of the new parameter can be found in the get and set methods of the module class "module1.cpp".
Add / modify / delete parameters 6:

To add a further parameter, use the TwinCAT TMC Code Generator again.

Step 3: State machine transitions

Note the different state transitions of your state machine:

Add / modify / delete parameters 7:

The parameters are specified during the transition Init->Preop and perhaps Preop->Safeop.