Skip to main content
Call Eric:863-698-8266
CURRYCONTROLS.COMControls & Automation Knowledge Hub
ReferencePLCFundamentalsProgrammingPID

Tasks and Execution Priority

How a controller schedules its work: the continuous task, periodic tasks at a fixed rate, event tasks triggered by something happening, how priority preempts, and where each kind of logic belongs.

7 min readUpdated Sep 5, 2026Published Sep 5, 2026By Eric Sullivan

The short answer

Tasks and Execution Priority

A modern controller does not run one scan; it runs tasks. The continuous task runs the main program over and over as fast as it can. Periodic tasks run at a fixed interval, preempting the continuous task at a set priority, which is where PID loops, fast counting, and anything that must run at a known rate belong. Event tasks run when something happens, an input changes or data arrives. Getting the assignment right is what makes a loop tune the same on a busy day as on a quiet one.

Key points

  • The continuous task runs whenever nothing of higher priority needs the processor, so its scan time varies with everything else.
  • A periodic task runs on a fixed interval and its logic sees a constant time step, which is what closed-loop control needs.
  • A higher priority task interrupts a lower one; a task that overruns its period is a fault waiting to happen.
  • Put fast, timing-sensitive logic in short periodic tasks and everything else in the continuous task.
  • Each task has its own watchdog, and the tasks together must fit within the processor time available.

One scan is not enough

The simple picture of a controller is one program executed top to bottom in a loop. Small controllers still work that way, and it is fine for a lift station. But a program that handles a plant has logic that must run every 10 milliseconds beside logic that would be happy running every second, and running all of it at the rate the fastest piece needs wastes the processor. Tasks are how the controller runs different parts of the program at different rates with different urgency.

The three kinds

Continuous
Runs the programs assigned to it repeatedly, restarting as soon as it finishes, in whatever processor time the other tasks leave. Its scan time is whatever it happens to be, and it changes with communication load and with what the periodic tasks are doing. Most sequencing, interlocking, alarming, and general logic lives here.
Periodic
Runs at a fixed interval, 10 ms, 100 ms, 1 s, at a set priority. When the interval elapses, the controller suspends whatever lower-priority task is running, executes the periodic task, and resumes. Its logic sees a constant time between executions, which is what a PID instruction, a rate calculation, or a totalizer needs.
Event
Runs when a trigger occurs: a change of state on a designated input module, a consumed tag arriving from another controller, a motion event, or an instruction in another task. It is how the controller reacts to something within microseconds of it happening rather than at the next scan.

The names and the details vary by platform. One vendor calls them tasks with programs inside them; another has a cyclic main block and cyclic interrupt blocks at fixed intervals; a third has a single scan with a high-speed interrupt routine. The behavior is the same everywhere: some logic runs on a fixed clock with priority, and the rest runs in the gaps.

Priority and preemption

Each periodic and event task has a priority. A higher priority task interrupts a lower one wherever it is, even in the middle of a rung, runs to completion, and hands the processor back. Two tasks at the same priority take turns. The continuous task has the lowest priority of all. The practical rule is that the fastest task gets the highest priority, so that a 10 ms task is never held up by a 500 ms task that happened to be running.

What goes where

LogicTaskWhy
PID loopsPeriodic, at the loop update rateThe integral and derivative terms assume a constant time step
Flow totalizing and rate calculationsPeriodicA total accumulated on a variable scan is wrong by the scan variation
High-speed counting or pulse handlingEvent or fast periodicA pulse shorter than the continuous scan is missed
Sequencing, interlocks, alarmsContinuousTens of milliseconds of variation do not matter
Communication and SCADA handlingContinuous or slow periodicNeither fast nor time critical
Safety-related logicNot in the standard controllerA safety function belongs in a safety-rated controller or a hardwired circuit
Assigning logic to tasks

Overlap and overrun

A periodic task that takes longer to execute than its interval has overrun: the next execution is due before this one has finished. The controller flags it, on most platforms as a task overlap counter, and depending on configuration either skips an execution or faults. An overrun is a design error: the task has too much logic for its interval, or a higher priority task is starving it. The fix is to move logic out of the task, lengthen its interval, or reconsider the priorities, and the task overlap counter is the diagnostic to watch after any change.

All the tasks together have to fit in the processor. If periodic tasks consume most of the available time, the continuous task starves, its scan time stretches to seconds, and the plant slows down without anything faulting. The controller reports the time consumed by each task, and keeping the total well under the capacity is part of the design.

Watchdogs per task

Each task has its own watchdog, a maximum execution time after which the controller faults. The default is generous for the continuous task and tighter for periodic ones. A watchdog fault names the task, which is the first clue to where a loop or a blocking instruction lives. The watchdog page covers it.

Frequently asked questions

Should I put my PID loop in a periodic task?
Yes. The integral and derivative calculations assume a constant time between executions. In the continuous task that time varies with load, and the loop behaves differently on a busy scan than a quiet one. A periodic task at the loop update rate gives it the constant step it assumes.
What rate should a periodic task run at?
As slow as the logic in it allows. A pressure loop might need 50 to 100 ms; a level loop is fine at one second. Faster rates consume processor time and leave less for everything else.
What happens if a periodic task overruns?
The controller records an overlap, and skips or delays the next execution. It is a design error: too much logic for the interval, or starvation by a higher priority task. Move logic out or lengthen the interval.
Can safety logic go in a fast periodic task?
Speed is not the issue; integrity is. Logic that protects people belongs in a safety-rated controller or a hardwired circuit, where a single fault cannot defeat it, not in a task of the standard controller, however fast.

Direct contact

Have a controls question?

Reach Eric Sullivan directly about anything on this site, a controls or automation topic, or one of his personal projects.