Share this

A simple and clear explanation of PLC interrupt functions

2026-04-06 04:35:39 · · #1

Interrupt functionality is frequently used in PLC programs. An interrupt is equivalent to a subroutine, and a subroutine is equivalent to a main program. In reality, interrupts in a PLC are rarely used. For example, pulse processing can achieve its function without interrupts, using only a 1ms timer, but it is not as accurate as interrupt-based timing. After all, without interrupts, the program scan is constrained by the scan cycle.

However, some programs require interrupts, a typical example being PID control, where the detection and reading cycle must be precise. Whether it's writing your own PID interrupt program in the past or using an integrated PID interrupt block now, precise timing control is used to process interrupted information immediately.

In this article, we'll discuss how to use the PLC interrupt function.

The PLC Project Training Camp gives you a higher perspective on PLCs. Using the Feynman Technique, you will learn systematically through 62 topics, enabling you to quickly get started with any brand and series of PLCs.

To understand the interrupt function of a PLC, one must first understand the PLC's operation cycle or scan cycle. It is necessary to explain the PLC's sequential control loop execution flow, which is a prerequisite for understanding interrupts and must be mastered. It is divided into three parts: input processing, program processing, and output processing.

1. Input processing: Before executing the program, the programmable controller reads the ON/OFF status of all input terminals into the input image area. Even if the input changes during program execution, the content of the input image area will not change. The change is read when the input processing of the next cycle is executed.

2. Program Processing: The PLC reads the ON/OFF status of each soft element from the input image area and the image areas of other soft elements according to the instructions in the program memory. Then, it starts the calculation sequentially from step 0, writing the result of each step into the image area. Therefore, the image areas of each soft element gradually change their contents as the program executes. In addition, the internal contacts of the output relays perform actions according to the contents of the output image area.

3. Output processing: After all instructions are executed, the ON/OFF status in the output Y image area will be transferred to the output latch memory, which will then serve as the actual output of the programmable controller.

The time required to execute one action is called the operation cycle or scan time. So what is the relationship between interrupts and scan cycles? Interrupts are not executed in a complete order from top to bottom. Instead, interrupt routines run independently and are processed immediately without participating in the entire cycle operation.

What is the purpose of interrupts? We know that the PLC scan cycle is very short, making it difficult to observe the sequential execution process. Let's assume a scan cycle of 10 seconds, meaning the entire program takes 10 seconds to execute. Consider a simple program: LDX0, OUTY0. According to the diagram, when X0 is ON, Y0 doesn't output immediately; it outputs after 10 seconds. Similarly, when X0 is OFF, Y0 doesn't immediately close either; both require the scan to complete. In practical applications, this would render the PLC unusable and the device unable to function. This is where interrupt handling comes in. Input interrupts allow for immediate input execution. While the PLC's computation time is typically only a few milliseconds, sufficient for most needs, tasks like high-frequency pulse input and pulse capture, which take microseconds, will inevitably be affected by the cycle.

Therefore, if many ON/OFF state processes need to be completed within a single cycle, the interrupt function must be used. In general, interrupts are rarely used. Even high-speed instructions in a PLC already have interrupt functionality, eliminating the need to write dedicated interrupt subroutines. For example, a high-speed counter uses an interrupt method to process high-speed pulses from a specific input relay, allowing counting to continue regardless of the computation time. The counting result is either immediately output using a dedicated comparison instruction for the high-speed counter, or the counter value is processed using a specific program executed via a high-speed counter interrupt.

Instead of using a high-speed counter to count high-frequency pulses, we use an interrupt function to count high-speed inputs. For example, the main program runs from EI to FEND, and the interrupt subroutine runs from pointer I101 (the interrupt pointer for input X0) to IRET. Whenever a rising edge of X1 is detected, the subroutine is executed to immediately transfer the value to D10, thus avoiding the influence of the PLC operation cycle.


Read next

CATDOLL 123CM Sasha TPE

Height: 123cm Weight: 23kg Shoulder Width: 32cm Bust/Waist/Hip: 61/54/70cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22
CATDOLL 123CM Momoko TPE

CATDOLL 123CM Momoko TPE

Articles
2026-02-22
CATDOLL 136CM Mila

CATDOLL 136CM Mila

Articles
2026-02-22