Use Tasks, Programs, and Routines

You use tasks, programs, and routines to define the execution of your logic.
  • Tasks are the scheduling mechanism for executing a program.
  • Programs are a set of related routines and a collection of tags.
    The term program is used to refer to programs, phases, sequences, and an organizational unit.
  • Routines are a sequence of logic that is executed as a block, similar to program files in the
    PLC-5
    and
    SLC
    .
Every routine is contained in a program. A program always contains one routine that has to be designated the main routine and several subroutines called from the main routine (or another subroutine) by using the JSR instruction.
You can also define a routine in a program as the fault routine to handle program faults. All the routines in a program can access the data in the program's tag collection (program scope). Those routines can also access tags defined as controller scope. However, routines in another program cannot access the tags in this program or call its subroutines.
In order to execute, a program must to be scheduled in a task. However, a program can be placed in the unscheduled programs folder in the Controller Organizer. In addition, there are two special programs that you can define for dealing with fault and power loss conditions. These are the Controller Fault Handler program and the Power Up Handler program.
A task defines which programs will execute, and when. They start to run in sequence in the order they appear in the Controller Organizer. After that, they are performed as defined within periodic attributes. Up to 32 programs can be scheduled in a single task, and up to 32 tasks can be configured in the controller. A watchdog can be set in each task to trigger a controller fault if the task runs too long. (You can look at the scan times for each task and program to see how long they take to run.)
A continuous task runs continuously at the lowest priority. When the programs scheduled within it finish executing, they are executed again.
A periodic task runs every time a specified time interval elapses at a priority that you specify. If a periodic task is triggered again before it finishes executing, a task overlap controller fault results.
For additional information about the execution of logic, see:
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.