In the task configuration, you define one or more tasks for controlling and executing the application program in the PLC. Each application has to include a “Task Configuration” object.
A task is a time-based flow unit of an IEC program. It is defined by a name, a priority, and a type, which determines which condition triggers the start of the task. You can define this condition either by time (cyclic-interval, freewheeling) or by the occurrence of an internal or external event to process the task. Examples of an event are the rising edge of a global project variable or an interrupt event of the controller.
A task calls one or more program blocks (POUs). These programs can be application-specific (objects below the application in the device tree) or project-specific (objects available in the POU view). In the case of a project-specific program, the application instances the project-global program. If CODESYS processes the task in the current cycle, then the programs are executed for the duration of a cycle.
With the combination of priority and condition, you define the order in which the tasks are processed.
You can configure a watchdog for each task. It is also possible to couple Start, Stop, and Reset directly with the execution of the project POU.
Rules for the processing order of the defined tasks
-
If the task condition is fulfilled, then CODESYS processes the task.
-
If multiple tasks fulfill the condition for processing at the same time, then CODESYS processes the tasks with the highest priority first.
-
If multiple tasks with the same priority level fulfill the condition for processing at the same time, then CODESYS processes the task first which has been in the queue the longest.
-
The program calls are processed in the order they appear in the configuration dialog of the task.
-
If a called program has the same name in the device tree of the application and in a library or project-global in the POU view, then the application program is used.
Important notes
All tasks share one process image. The reason is that having an individual process
image per task would compromise performance. However, the process image can be consistent
only with one task. When you create a project, you must ensure that the application
copies the input and output data to a safe location in case of conflicts. Modules,
such as the library SysSem
, provide the capability of solving consistency and synchronization problems.
Consistency problems can also occur when accessing other global objects, such as global
variables or blocks. Consistency problems always occur if several tasks read and write
to one variable. Modules, such as the library SysSem
, are available as a solution.
-
See also:⮫ Task Configuration, ⮫ Task Configuration
-
Creating a Task Configuration
-
Definitions of Jitter and Latency
-
Multicore