PLC Tasks
32 tasks can be configured with the task configuration. Each task can be assigned to a series of program blocks. The program blocks are executed when calling the task. The task priority and task condition specify, which chronological order the tasks are processed. A PLC program can consist of several tasks. The tasks can have the same or different priority. The Tasks are processed cyclically in parameterized time intervals or when particular events occur.
|
The cycle times and priorities of the used tasks must be chosen applications specific, that no timeouts may occur.
|
AMK standard task configuration
POU |
Typ |
Priority |
---|---|---|
FPLC_PRG |
external, PGT event-controlled PGT cycle time= ID2 'SERCOS cycle time' |
1 |
PLC_PRG |
free-running |
5 |
VISU_TASK |
cyclic, interval 100 ms |
10 |
Example
Add new task
Assign task name
Task configuration
Priorities
Possible values: 0 ... 31, 0 is the highest and 31 is the lowest priority.
The AMK controllers have a Linux operating system. The CODESYS priorities are mapped to Linux Task priorities:
CODESYS priority |
Linux priority |
Meaning |
---|---|---|
0 ... 15 |
Linux Real-time priority |
True prioritization, higher priority tasks to interrupt lower priority tasks
A 'real-time task' is a prerequisite for a defined cycle time. An active task occupies the processor until the program code is processed, or the active task is interrupted by a higher priority task. |
16 ... 31 |
Linux Standard priority |
Faires Scheduling, all tasks with Linux standard priority will receive the same amount of processing power.
These tasks can not interrupt 'real-time tasks'. All tasks in this priority area are equivalent and share the free system resources which are not occupied by the 'real-time tasks'. With this priority also run many background processes. |
Example:
Task 1, priority: 5, type: cyclic, interval 5 ms, max. processing time 1 ms
Task 2, priority: 10, type: cyclic, interval 50 ms, max. processing time 20 ms
Individual contemplation of tasks:
Processing of the tasks by CODESYS
The higher-priority task 1 interrupts the low-priority task 2
Example:
Task 1, priority: 5, type: cyclic, interval 5 ms, max. processing2 ms
Task 2, priority: 10, type: cyclic, interval 50 ms, max. processing 20 ms
Task 1 required in the example a higher processing time (1 ms → 2 ms). The low-priority task 2 is thereby often interrupted and less time is available. Thus, the processing time of the task 2 increased from 25 ms to 34 ms.
Type
External Event
The task is started, as soon as in the box 'External Event' registered event arrives . AMK controllers only support the AMK PGT event.
Fixed configuration FPLC_PRG: PGT cycle time = ID2 'SERCOS cycle time'
|
CODESYS V3 The Task FPLC_PRG must receive the highest priority. Default by the template, priority =. 1 |
|
CODESYS V2 A task of this type has the highest priority of all PLC tasks. The selected priority is irrelevant. |
Event
CODESYS starts processing the task as soon as the global variable defined in the input field 'Event' contains a rising edge.
Cyclic
CODESYS processes the task in cycles. The cycle time of the task is defined in the input field 'Interval'.
Freewheeling
CODESYS starts processing the task again automatically in a continuous loop at program start and at the end of a complete pass. Cycle time is not defined
Status
CODESYS starts task processing if the variable defined in the 'Event' input field the boolean value is TRUE.
Watchdog
A 'watchdog' can be activated for each task in the task configuration. The permissible time, and a sensitivity can be defined
Respond the 'watchdog', the task is stopped.
|
Regardless of the function CODESYS 'Watchdog' are realized in the AMK control following time monitoring functions:
|
Add call
With this function, the program blocks are appended to the task