Interrupt Routine

Interrupts are event driven. Before an interrupt routine can be invoked, an association must be established between the interrupt event and the program segment that you want to execute when the event occurs. Use the Attach Interrupt instruction (ATCH) to associate an interrupt event (specified by the interrupt event number ) and the program segment (specified by an interrupt routine number). When you attach an interrupt event to an interrupt routine, that interrupt is automatically enabled.

You can disable individual interrupt events by breaking the association between the interrupt event and interrupt routine with the Detach Interrupt instruction (DTCH). The Detach instruction returns the interrupt to an inactive or ignored state.

To create an interrupt routine, use one of the following methods:

ˇFrom the Edit menu, choose Insert>Interrupt

ˇFrom the Instruction Tree, right click on the Program Block icon and select Insert>Interrupt from the popup menu

ˇFrom the Program Editor window, right-click and select Insert>Interrupt from the popup menu

The Program Editor changes from the display of the previous POU to the new interrupt routine. A new tab appears at the bottom of the Program Editor, identifying the new interrupt routine.

You can have a total of 128 interrupts in a program. Interrupts are serviced by the PLC on a first-come-first-served basis within their respective priority assignments. Only one user-interrupt routine is ever being executed at any point in time. Once the execution of an interrupt routine begins, the routine is executed to completion. It cannot be pre-empted by another interrupt routine, even by a higher priority routine. Interrupts that occur while another interrupt is being processed are queued for later processing.

Restriction for using interrupts follows:

ˇYou cannot use the END instruction in an interrupt routine.


The unconditional POU termination instructions (END for OB1, RET for SBR, and RETI for INT) are automatically inserted by the editors. An example is shown below.

See Also:

SIMATIC Programming Interrupt Instructions




IEC Programming Interrupt Instructions



Local Variable Table