Professional Documents
Culture Documents
TABLE OF CONTENTS
Chapter 12 - 1
T314-12 Task Assignment - RevC
12.1.1 Objectives
Upon completion of this chapter, you will be able to:
• Define tasks and set priorities
• Assign tasks where required
• Analyze the effect of different tasks settings
• Analyze controller diagnostics
12.1.2 Legend
> Indicates when you go from one menu to a sub-menu
Italic Indicates object and file names
“ “ Indicates dialog box buttons, tabs, menus etc.
Bold Indicates important topics
Indicates start/explanation of student activity
Chapter 12 - 2
System 800xA Training
Execute Code
When the controller is running, this cycle is repeated at regular intervals determined
by the task interval.
In this way the state of the process is examined during each scan, any corrective
calculations made to keep it under control and written to via any connected actuators.
Typical scan times for a medium application are 250 ms.
Chapter 12 - 3
T314-12 Task Assignment - RevC
Before you are able to connect a task to a POU, first of all you have to assign the
application to the controller. Open the context menu for the Connected Applications
folder of a controller and select the application from the list.
Chapter 12 - 4
System 800xA Training
If no task connection is made then the object inherits the task connection of the first
connected object upward in the hierarchy. An unconnected program or control module
instance, will inherit the task of the connected application to which it belongs.
This last rule is important; otherwise it would be necessary to connect all instances of
control modules and function blocks when writing the application.
Chapter 12 - 5
T314-12 Task Assignment - RevC
3. After the task has been created, it is time to configure the task with new properties
(see “Task Settings” later on in this chapter).
Chapter 12 - 6
System 800xA Training
Note that the task interval is NOT the same as the execution time. The execution time
is the total time for the code belonging to that task to be executed. It must be always
(considerably) less than the task interval.
Chapter 12 - 7
T314-12 Task Assignment - RevC
12.3.2 Priority
There are six levels of priority, numbered from 0 to 5. The tasks are executed
according to their priority where the time-critical task has the highest priority.
• 0 = Time Critical
• 1 = Highest
• 2 = High
• 3 = Normal
• 4 = Low
• 5 = Lowest
Tasks with higher priorities may interrupt execution of those with a lower priority.
Interruption always occurs at the end of a code block in the interrupted program
(Never during execution of a code block). When the interrupting program has
executed, execution passes back to the interrupted program which resumes where it
left off.
There can only be one time-critical task. Such a task may interrupt the execution at
any point, while other tasks may only interrupt execution at defined points. A time-
critical task is driven from the system’s real-time clock with a resolution of 1 ms.
12.3.3 Offset
The periodic execution of tasks implies that all tasks will sooner or later be scheduled
to execute at the same time. When tasks are scheduled to execute at the same time, the
task with the highest priority will be executed first. If tasks have the same priority the
task with the shortest interval time will be executed first.
When a number of tasks are scheduled, it is possible that the execution of one is
delayed because another is currently executing. Offset allows a task to be offset in
time and is used to even the load on the CPU.
NOTE! The compiler will detect inappropriate offset settings.
You can turn off the task collision warning: Right-click on the Project and select
“Settings > Compilation Warnings”.
Chapter 12 - 8
System 800xA Training
12.3.4 Example
If two tasks have the same priority, and both wait for execution, the task with the
shortest interval time will be executed first.
Execution of two tasks with the same priority
The figure below shows two tasks executing in the same system. Task 1 and task 2
have interval times of 30 and 200 ms, and execution times of 10 and 50 ms,
respectively. When the tasks have been assigned the same priority, the execution start
time of task 1 is very much delayed. It also drops one execution.
Chapter 12 - 9
T314-12 Task Assignment - RevC
The result of having no offset for three tasks with long execution times. The gap
(Ta+Tb) is the time available for the execution of other functions, for example
communication.
The offset mechanism can be used to make the time gaps more frequent.
The result of assigning offset to tasks 2 and 3, is that the time available for the
execution of other functions occurs more often (Ta).
Chapter 12 - 10
System 800xA Training
You can command a task that is in halt to execute one scan each time you click the
“One Scan” button.
NOTE! Debug mode can be enabled only in Online Mode.
Chapter 12 - 11
T314-12 Task Assignment - RevC
You can use this function block type to measure and display the following functions.
• Cyclic load resulting from task execution
• Down time and memory usage during a controller download
• Current memory in use
• Total CPU load
Note that you need a separate System Diagnostics function block in each application,
if the stop time during download is an important factor.
NOTE! Values can be updated either on command or cyclically.
Chapter 12 - 12
System 800xA Training
The interaction windows can be displayed in two versions, Simple and Advanced.
“Cyclic load” shows the load due to task execution in percent, whereas “Total system
load” shows the total CPU load for the controller.
The figure “Maximum used memory” is presented in actual bytes, and as a percentage
of the memory size. It gives a good indication when determining how close you are to
being unable to make on-line changes. It is still possible to make on-line changes as
long as the maximum used memory value is less than 100%.
NOTE! The function block reports used memory based on the
memory size, not on the available memory.
Chapter 12 - 13
T314-12 Task Assignment - RevC
You may also do diagnosis by opening the faceplate of the function block in 800xA:
Chapter 12 - 14
System 800xA Training
Chapter 12 - 15
T314-12 Task Assignment - RevC
Chapter 12 - 16