You are on page 1of 16

System 800xA Training

Chapter 12 Task Assignment / Memory

TABLE OF CONTENTS

Chapter 12 Task Assignment / Memory.................................................................................................................................. 1


12.1 General Information ................................................................................................................................................... 2
12.1.1 Objectives............................................................................................................................................................ 2
12.1.2 Legend................................................................................................................................................................. 2
12.1.3 Reference Documentation .................................................................................................................................... 2
12.2 Task Handling ............................................................................................................................................................ 3
12.2.1 Introduction and Definitions................................................................................................................................. 3
12.2.2 Task Assignment.................................................................................................................................................. 4
12.2.3 Assignment Rules ................................................................................................................................................ 5
12.2.4 How to Create a Task........................................................................................................................................... 6
12.3 Task Settings.............................................................................................................................................................. 7
12.3.1 Interval Time ....................................................................................................................................................... 7
12.3.2 Priority ................................................................................................................................................................ 8
12.3.3 Offset .................................................................................................................................................................. 8
12.3.4 Example .............................................................................................................................................................. 9
12.3.5 Communication Considerations...........................................................................................................................10
12.3.6 Debug Mode .......................................................................................................................................................11
12.3.7 Overrun and Latency...........................................................................................................................................11
12.4 Controller Diagnostics ...............................................................................................................................................12
12.4.1 System Diagnostic Window ................................................................................................................................12
12.4.2 Cyclic Load ........................................................................................................................................................14
12.4.3 Application Information ......................................................................................................................................15

Chapter 12 - 1
T314-12 Task Assignment - RevC

12.1 General Information

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

12.1.3 Reference Documentation


3BSE041434 Industrial IT 800xA – System
System Guide – Technical Data
3BSE035980 Industrial IT 800xA – Control and I/O
Basic Control Software – Introduction and Configuration
3BSE043732 Industrial IT 800xA – Control and I/O
Application Programming – Introduction and Design

Chapter 12 - 2
System 800xA Training

12.2 Task Handling

12.2.1 Introduction and Definitions


A task is defined as an execution control element that is capable of starting, on a
periodic basis, the execution of a set of Program Organization Units (also called
POUs). All POUs connected to a task execute with the same priority, interval time
and offset.
The controller first copies the states of all connected input signals into RAM. (Input
Copy), it then executes the code that the programmer has written, and finally copies
the results of that execution to the output signals (Output Copy). This is called a cycle
or a scan.

Copy Inputs from Process

Execute Code

Write Outputs to Process

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.

NOTE! However, it is possible to write the outputs when the task


is started.
The update of the outputs will then, of course, be delayed, but in return, they will be
updated at a more exact time interval, since the execution time of the task will not be
affected.

Chapter 12 - 3
T314-12 Task Assignment - RevC

12.2.2 Task Assignment


You can connect a task to:
• Applications
• Control modules
• Programs
• Function blocks
If you connect a task to an application, then all the POUs of this application (control
modules, programs and function blocks) are running in this task. If you connect for
instance a program to a different task than the application belongs to, then this
program is disconnecting from the application task and runs in its assigned task.
NOTE! A task can only execute POUs in one application. Hence,
POUs from different applications can not be connected
to the same task.

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.

For connecting a task, right click on the:


• Application object and select “ Properties > Task Connection”
• Program object and select “Properties > Task Connection”
• Function Block object and select “Properties > Task Connection”
• Control Module object and select “Properties > Task Connection”

Chapter 12 - 4
System 800xA Training

12.2.3 Assignment Rules


Once the tasks have been created in a controller, individual applications, programs,
control module instances or function block instances may be allocated to a task.
There are a few rules:
• Only one application may be connected to any one task. Each individual
application must be allocated to its own task.
• One or more programs from any one application may be connected to the same
task. But you can’t connect programs belonging to different applications to the
same task.
• Within an application, individual instances of control modules may be connected
to different tasks. This means that you can select some control modules to execute
faster or slower than the parent application.
• Within a program, individual instances of function blocks may be connected to
different tasks. This means that you can select some function blocks to execute
faster or slower than the parent application.

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

12.2.4 How to Create a Task


1. Right mouse click onto the Tasks folder and click onto “New Task”.

2. Type in the task name and press the “OK” button.

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).

NOTE! One controller may be allocated up to 32 tasks.

Chapter 12 - 6
System 800xA Training

12.3 Task Settings


The three most important task parameters that can be set to optimize program
execution are:
• Interval time
• Priority
• Offset

12.3.1 Interval Time


The interval time during which the program is executed, can be changed at any time.
Default values are 50 ms (Fast), 250 ms (Normal) and 1000 ms (Slow).
For a time-critical task, the interval time can be as short as 1 ms. The interval time of
tasks of priority 1-5 cannot be less than 10 ms.
NOTE! If two tasks have the same priority and both are waiting
to execute, the task with the shortest interval time will be
executed first.

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.

Execution of two tasks with different priorities


In the figure below, task 1 has higher priority than task 2, and interrupts the execution
of task 2. Hence task 1 is not delayed much by task 2.

Chapter 12 - 9
T314-12 Task Assignment - RevC

12.3.5 Communication Considerations


POU execution has higher priority than other functions, such as communication. These
functions are performed in the gaps between the execution of different tasks. If several
tasks with long execution times are executed immediately, one after the other, the time
gaps are few but long

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

12.3.6 Debug Mode


You can set up a task for non-cyclic execution. Use non-cyclic execution to reduce the
system load, and to simplify the debugging of a program. After you enable the debug
mode, you can halt the cyclic execution of a task.

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.

12.3.7 Overrun and Latency


Overrun and Latency are two functions for supervising a task.
Overrun checks if each task finishes before it is supposed to start the next time, and
detects if the task runs for too long. Latency on the other hand, checks that a task starts
on time (on each cyclic start), and detects if the task starts too late.
The Overrun function is configured per controller via the Controller Settings dialog,
while the Latency function is configured per task (and SIL classification per task) via
the Task Properties dialog.

For High Integrity controllers:


Overrun Supervision is automatically enabled and cannot be switched off. Load
balancing is not available in High Integrity controllers.
Latency Supervision is mandatory and therefore automatically enabled for all SIL
tasks.

Chapter 12 - 11
T314-12 Task Assignment - RevC

12.4 Controller Diagnostics


The Basic library contains a function block type called System Diagnostics.

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.

12.4.1 System Diagnostic Window


The system diagnostics window is only available in online mode. Right click on the
SystemDiagnostics function block in the Project tree and select “Interaction Window”.

NOTE! The numbers in the interaction window are not valid in


Simulate mode.

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:

12.4.2 Cyclic Load


The cyclic load is the percentage of controller CPU power used for program execution
of application code. If the cyclic load exceeds 70% in the controller, so-called load
balancing is initiated automatically – if enabled! The interval time for all tasks, except
the time-critical task, is then generally increased, to limit the cyclic load to 70%.
Running a controller at close to 70% CPU load will result in poor performance and
longer response times for peer-to-peer and OPC communication.
Under all conditions peak cyclic load should be maintained at 65% and “static” cyclic
load at 60%. If high communication throughput is important, the cyclic load should be
30-40%.

Chapter 12 - 14
System 800xA Training

12.4.3 Application Information


You can also get some information about the application used by selecting “Tools >
Maintenance > Analysis >Application Information”.

Select the application and press “OK”:

Chapter 12 - 15
T314-12 Task Assignment - RevC

The information about the particular application opens in a Notepad.

Chapter 12 - 16

You might also like