I. Interrupts and Interrupt Events
In our daily work, we follow the normal procedures. If an emergency occurs or we need to attend to another task after a certain period of time, we must stop what we are doing to deal with the emergency or the other task. This stop is called an interruption, and the emergency or the other task we are dealing with is called an interrupted procedure. After the problem is resolved, we can return to our original work.
PLCs also have interrupts. The CPU executes the program normally, but if a system-recognized action or parameter meets the set requirements, the program execution is interrupted to process the set program. After completion, it returns to continue executing the original program.
The PLC system has defined some interrupt actions, such as when input points I0.0 and I0.1 are turned on (rising edge) or turned off (falling edge), or when the time relay's set time has expired. These actions are called interrupt events. The PLC assigns a number to each interrupt event, called the interrupt event number. For example, the rising edge of I0.0 turning on corresponds to event number "0".
The program that stops to handle (the work it does) is called an interrupt routine.
The following diagram shows commonly used interrupt events and their numbers:
Partial interruption event details and numbers
II. Interrupt Instructions
The PLC is designed to handle the above interrupt event instructions. The interrupt event handling steps are as follows:
Associate (connect) interrupt event numbers with interrupt routine numbers.
As shown in the diagram below, interrupt event 1 (falling edge of I0.0) is connected to interrupt routine INT1.
2. Enable interrupt function
Because PLCs disable interrupt handling by default, the interrupt function must be enabled. See the diagram below.
Interrupt routines can be renamed
There are also two other instructions: interrupt detach and interrupt clear.
III. Example of interrupting a program:
The requirement is to design an indicator light Q0.0 that flashes. When I0.0 is on, the flashing frequency is halved (slow flashing), and when I0.1 is on, it flashes quickly.
The design utilizes timer interrupts SMB34 and SMB35 to set the blinking period of Q0.0: 100ms for fast blink and 200ms for slow blink. The interrupt event numbers for SMB34 and SMB35 are 10 and 11, respectively. The program is as follows:
Interrupt procedure INT0:
Interrupt procedure for interrupt 10 event
Interrupt procedure INT1:
Interrupt procedure for interrupt 11 event
Summarize:
3. Write an interrupt routine and describe the tasks to be performed.
If a new interrupt event is executed or the original interrupt event is changed, the connection between the original event number and the interrupt routine must be severed before a new connection is established.
If there are multiple interrupt events to handle, they are queued according to their priority, with those of the same priority being processed first.
The simpler the interrupt routine, the better.