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 a new parameter in the TMC file.
- Step 2: Start the TwinCAT TMC Code Generator to generate code for the module description in the TMC file.
- Step 3: Observe the transitions of the state machine
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:
- 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.
- 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".
- 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:
- You can see the parameter declaration in the header file "Module1.h" of the module.
- The implementation of the new parameter can be found in the get and set methods of the module class "module1.cpp".
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:
The parameters are specified during the transition Init->Preop and perhaps Preop->Safeop.