Which Task To Run My Ladder Logic Program?

Contoller Organizer-Tasks

Placing a program in a task simply lets the processor know when to run your ladder logic program.

In order to place your program in the proper task you need to know when your program should execute. Ask yourself the following questions:

  • Should the program run continuously when the controller is powered up over and over until the end of time?
  • Should the program execute once every two minutes, or once every 25 milliseconds?
  • Should the ladder logic program execute in response to an external event like someone pressing a button?
  • Should the program have priority over other programs in the project, or should it have the lowest priority?

To answer these questions let’s take a look at an RSLogix 5000 project and the various tasks a little more closely.

Task Program RoutineA project is made up of one or more tasks that contain one or more programs. A program can have one or more routines. The routines are containers for programming ladder logic. Each program has tags which are visible only to the program in which they are defined, however each program also has the ability to access tags defined at the controller scope level.

There are three types of tasks available to put ladder logic programs in:

Continuous Task-By default when a new project is created the software creates a Task named “Main Task” of task-type continuous. What does that mean?  It means the task is run over and over again. There is no time limit given to the task other than the watchdog timer. This is the most used Task out of any, probably because it’s the default task and it takes no configuration. For most applications the Continuous Task works fine. It is important to note that the Continuous Task is the lowest priority task; it can be interrupted by all other tasks. There can be only one continuous task in each project.

Periodic Configure WindowPeriodic Task – Periodic tasks are time driven tasks. A Periodic Task has a configurable Period attribute. This attribute lets the processor know how often to run the task. Placing a value of 5000 milliseconds in this attribute will run the task every 5000 milliseconds. The valid range is .1 to 2000000 milliseconds.

Periodic tasks also have a priority attribute to let the processor know which Tasks have the highest priority. If a project is configured with more than one task it is inevitable that one task will have to interrupt another task at a given point of time in the cycle. The priority attribute is set by selecting a number. One gives the Task the highest priority and 10 the least. If a project has multiple tasks, be careful when assigning priorities and periods. If you assign multiple periodic tasks priorities of 1 with time periods of 25 milliseconds each there is a good chance some unexpected results will occur.

Task OverlapIf the current processor is running the Continuous Task and a Periodic Task is triggered the Continuous Task will be interrupted and the Periodic Task will be run. If a Periodic Task is running and another Periodic Task with a higher priority is triggered the current task will be interrupted to run the task with more priority. If a Periodic Task is running and another Periodic Task with a lower priority is triggered the current task will not be interrupted to run the task with less priority.

There can be up to 32 tasks in a single controller.

Tasks are listed alphabetically not by priority or the order in which they run.

It is important to note that setting a periodic task to a period in which the task cannot fully complete will cause a task overlap error. If the task has not completed before the time period has expired the task is triggered again, causing a task overlap.  From the task properties window go to the Monitor tab to check the Task Overlap Count as well as task execution time and time between triggers.

Event Task– An event task is triggered by an event, go figure. ThisEvent Configure Window event can be anything really. Maybe the event is called out at midnight or in response to an operator or an alarm.

When setting up the event task a trigger method must be set. The options are:

  •                 Axis Watch
  •                 Axis Registration 1
  •                 Axis Registration 2
  •                 Motion Group Execution
  •                 EVENT instruction only
  •                 Module input data state change
  •                 Consumed tag

The event task can also be triggered after a settable time period. This option is provided in the event the task needs to be executed however the task has not been triggered from one of the above methods.