Object Referenced Task
Symbol:
Via the task reference you define the program blocks to be executed in a task.
When a standard PLC project is created, a task reference PlcTask is created automatically, which defines the processing if the MAIN program block.
Creating an object Referenced Task
- 1. Select the PLC project (<Project name> Project) in the Solution Explorer in the PLC project tree.
- 2. In the context menu select the command Add > Referenced Task.
- The dialog Add Referenced Task opens. The existing tasks are displayed in the Available Tasks listbox. The listbox Used Tasks shows the already referenced tasks.
- 3. To generate and integrate a new task, enter a name in the Name field and click on Create New Task.
- The new task is shown in the Available Tasks listbox. At the same time the new task appears in the TwinCAT project tree in the SYSTEM section under the Task node.
- 4. Click on Open.
- 5. If the task you wish to integrate already exists, select it in the Available Tasks listbox and click Open.
- The task reference is added to the PLC project tree. When the dialog Add Referenced Tasks is opened again, the task is shown in the Used Tasks listbox.
Dialog Add Referenced Tasks
Available Tasks | Tasks that are not referenced in the PLC project. |
Used Tasks | Tasks that are referenced in the PLC project. |
New Task
Name | Name of the new task to be created |
Create New Task | Creates a new task |
Specifying program blocks in the task
- 1. Select the task reference in the PLC project tree. In the context menu select the command Add > Existing Item…
- The Input Assistant dialog opens.
- 2. Select the program block to be executed in the task and confirm the dialog with OK.
- 3. Alternatively, you can use the mouse to drag the program block in the PLC project tree directly to the task reference.
- The program block appears in the PLC project tree below the task reference.
- 4. To view the task configuration, double-click on the task reference in the PLC project tree. In the Solution Explorer, the corresponding task is enabled in the TwinCAT project tree in section SYSTEM > Tasks. Double-click on the task again to open the task configuration in an editor.
- In the PLC project tree the program blocks that are called by the task are shown under the task reference . The task can be configured in the SYSTEM section of the task editor.
Important notes for multitasking systems
The ability of multi-core systems to execute several commands independent of each other can result in a priority reversal.
Example:
A program block that is called by a task with low priority can be assigned to an independent core. In this case, the execution of the task with the lower priority may be completed before a task with higher priority.