PLC Interrupt Guide: 5 Essential Task Types for Smooth Logic

Share:
PLC
PLC Interrupt Guide: 5 Essential Task Types for Smooth Logic

Some signals cannot wait for the main scan to come around again, and some loops need an exact, repeatable time base. Interrupt driven tasks give both, as long as you keep them short and plan their priorities carefully.

Event Tasks Periodic Tasks Cyclic OB Priorities

A normal PLC program runs in a loop, but some logic must respond instantly or at a fixed rate. Interrupt tasks and organisation blocks make that possible without slowing the rest of the program.

Hello everyone, today we are going to learn what a PLC interrupt is, how event and periodic tasks work in Siemens and Rockwell controllers, and how to calculate the CPU load they add.
PLC interrupt

What Is a PLC Interrupt?

A PLC interrupt is a signal or timer that pauses the normal program and runs a separate block of logic immediately, then returns to where it stopped. It lets critical code run faster or more regularly than the main PLC scan cycle allows.

Siemens calls these blocks organisation blocks, or OBs, while Rockwell calls them tasks. The idea is the same in both families.

MainTask properties window in RSLogix 5000 showing task type and scheduling settings
Image credit: Contact and Coil

In Studio 5000 each task has a type, a priority and a watchdog time. The image shows an event task set to run when a chosen trigger occurs.

5 Essential Task Types

Continuous

Runs again and again in the background.

Best for: general machine logic
Main
Periodic

Runs at a fixed time interval.

Best for: PID loops and filters
Timed
Event

Runs when a trigger such as an input change occurs.

Best for: fast registration marks
Trigger
Hardware Interrupt

Siemens OB started by an input or counter.

Best for: high speed counting
Input
Fault Handler

Runs when an error is detected.

Best for: safe recovery logic
Error

A fault routine is also a PLC interrupt of sorts, see PLC fault handling. The other types are the focus of this article.

Siemens Organisation Blocks

PLCblog explains that S7 CPUs support up to eight hardware interrupt OBs, numbered OB40 to OB47. Cyclic interrupt OBs run from OB30 to OB38, with default intervals from 5 s down to 10 ms.

A higher priority PLC interrupt always pauses a lower priority one. OB1, the main cycle, has the lowest priority, so any interrupt can pause it.

BlockPurposeTypical Use
OB1Main cyclic programMachine sequences
OB30 to OB38Cyclic interruptPID and sampling
OB40 to OB47Hardware interruptFast inputs
OB80 onwardsError handlingFaults and diagnostics

How a PLC Interrupt Runs

TriggerTimer expires or input changes
SuspendCurrent lower priority task pauses
ExecuteInterrupt logic runs to completion
UpdateImmediate I/O or tags are written
ResumePaused task continues where it stopped

AutomationPrimer gives a simple example of a 50 ms main scan with a 10 ms periodic task. The periodic task runs five times during each main scan, stretching that scan a little each time.

If an interrupt runs too long, the watchdog may fault the CPU, as explained in PLC watchdog timer. Keep interrupt code short.

Rockwell Event and Periodic Tasks

In ControlLogix and CompactLogix controllers, a periodic task runs at a set rate and priority. An event task runs on triggers such as module input changes, motion events or an EVENT instruction.

Rockwell recommends limiting the number of tasks, since each PLC interrupt and task switch costs time. Newer platforms such as the ControlLogix 5590 handle more tasks but the rule still applies.

Good Interrupt Design Practices

1
Keep It Short
Put only time critical logic inside the task.
2
Set Priorities
Faster tasks get higher priority.
3
Avoid Overlaps
Leave time for tasks to finish before the next trigger.
4
Protect Shared Data
Copy data once to avoid mid scan changes.
5
Watch CPU Load
Monitor task overlap and scan time statistics.

Timers inside periodic tasks behave differently, see PLC timer instructions. Status bits for overlap counts are listed in PLC diagnostic status bits.

CPU Load Formula

Periodic load = Σ (Execution time ÷ Period) × 100
Stretched scan = Continuous scan ÷ (1 minus Load)

Example:
Task A runs 2 ms every 10 ms, load 20 percent
Task B runs 5 ms every 50 ms, load 10 percent
Total load 30 percent, continuous logic needs 40 ms
Stretched scan = 40 ÷ 0.7 ≈ 57.1 ms

This is an average estimate that ignores task switching overhead. Check the real value in the controller diagnostics.

Task Load Calculator

Periodic Task CPU Load
Result
Periodic load 30.0 percent, continuous scan stretches from 40 ms to 57.1 ms

Keep total PLC interrupt load well below 50 percent. Other ways to speed up programs are shared in how to increase PLC speed.

Advantages
  • Fast response to critical inputs.
  • Exact timing for control loops.
  • Less load than running everything often.
  • Clear priority structure.
Limitations
  • Long interrupts stretch the main scan.
  • Shared data can change mid logic.
  • Harder to debug and trace.
  • Too many tasks waste CPU time.

PLC interrupt support should be part of controller selection, see how to select the right PLC.

Rockwell Event Tasks White Paper

PDF
Using Event Tasks With Logix5000 Controllers
Rockwell Automation white paper on triggers, priorities and timing

ControlLogix Tasks Video

PLC Interrupt FAQ

What is a PLC interrupt?
It is a trigger that pauses the main program and runs a separate block of logic right away. The main program resumes when that block finishes.
What is a periodic task?
A periodic task runs at a fixed interval such as every 10 ms. It suits PID loops, filters and sampling that need steady timing.
What is an event task?
An event task runs only when a chosen trigger occurs, such as an input change. It gives fast response without running logic every scan.
Which Siemens OBs are cyclic interrupts?
PLCblog lists OB30 to OB38 as cyclic interrupt blocks. Their default intervals range from 5 s down to 10 ms, and each one can be changed.
What happens if interrupts overlap?
The controller counts an overlap and skips or delays the late execution. Frequent overlaps mean the task is too long or too frequent.
Can interrupts cause a watchdog fault?
Yes, long or frequent interrupts can stretch the main scan past its watchdog limit. Keep interrupt logic short and check scan statistics regularly.
How many tasks should I use?
Use as few as the application allows, usually one continuous and a few periodic tasks. Every extra task adds switching overhead and makes the program harder to follow.

Related Articles

External References

What We Learn Today

  • A PLC interrupt pauses the main scan to run urgent or timed logic.
  • Periodic and event tasks each have priorities and watchdogs.
  • Keep interrupt code short and total periodic load low.
I hope you like above blog. There is no cost associated in sharing the article in your social media. Thanks for reading!! Happy Learning!!

Leave a Reply

Your email address will not be published. Required fields are marked *