An interrupt is a process that suspends the currently running program to execute an interrupt service routine written to respond immediately to a signal. After the routine completes, it returns to the previously suspended program and continues execution. The Siemens S7-200 SMART CPU supports a maximum of 38 interrupt events, 8 of which are reserved. For easy identification, the system assigns a unique number to each interrupt event, also known as an interrupt event number.
S7-200 SMART interrupt
All interrupt events can be categorized into three main types: communication interrupts, I/O interrupts, and timer interrupts. Communication interrupts allow the CPU's serial communication port to be controlled by the user, a mode known as free port mode. In this mode, interrupt events are generated upon completion of receiving or sending information, or even upon receiving a single character. Utilizing receive and send interrupts simplifies program control over communication. I/O interrupts include rising edge interrupts, falling edge interrupts, and high-speed timer interrupts. The CPU can generate interrupts for rising or falling edges of input points I0.0 to I0.3, as well as optional signal boards I7.0 and I7.1. High-speed counter interrupts allow responses to HSC interrupt events such as the current counter value equaling the set value, a change in counting direction, and an external counter reset.
Interruption event
Timer interrupts can be used to perform periodic operations in 1-millisecond increments, with period durations ranging from 1 to 255 milliseconds. The time intervals for Timer Interrupt 0 and Timer Interrupt 1 are written to special register bytes SMB34 and SMB35, respectively. Timer interrupts are typically used to acquire analog signals or periodically execute PID control programs. Timer interrupts T32 and T96 allow for timely responses to the end of a given time interval, with only 1-millisecond resolution on-delay (TON) and off-delay (TOF) timers. T32 and T96 support this type of interrupt; when the current timer value equals the preset value, the connected interrupt routine is executed within a 1-millisecond CPU refresh interval.
Timer interrupt
Different interrupt events within each interrupt category have different priorities. When multiple interrupt events occur simultaneously, the priority group and its internal priority determine which interrupt event is processed first. When priorities are the same, the CPU processes interrupts according to a first-come, first-served principle. The CPU can only execute one user interrupt routine at any given time. Once an interrupt routine begins execution, it continues until completion, even if a higher-priority interrupt event occurs. Interrupts occurring while another interrupt is being processed are queued for processing. Each priority group has its own queue, and interrupt events are queued in their respective queues, processed on a first-come, first-served basis. The maximum number of interrupts each queue can hold and the queue overflow special register bits are shown in the following diagram.
interrupt queue
The interrupt priorities specified by Siemens S7-200SMART, from highest to lowest, are communication interrupts, I/O interrupts, and timer interrupts. Interrupt management in S7-200SMART is accomplished through instructions, including interrupt enable and disable instructions, and interrupt join and disconnect instructions. When the CPU enters RUN mode, all interrupts are automatically disabled.
Interrupt command
Interrupt enable instructions globally enable the handling of interrupt events for all connections. Interrupt disable instructions globally disable the handling of all interrupt events, but already associated interrupt events will continue to be queued. Conditional return instructions from interrupt routines return from the interrupt routine when the logical condition controlling it is met. The compiler automatically adds unconditional return instructions to each interrupt routine.
Interrupt Enable and Interrupt Disable
The interrupt connection instruction is used to establish a connection between the interrupt event number (EVNT) and the interrupt routine number, and automatically allows the interrupt event to enter the corresponding queue. Whether it can be processed depends on whether it is disabled. Multiple interrupt events are allowed to be associated with the same interrupt routine, but the same interrupt event is not allowed to be associated with multiple interrupt routines.
Interrupted connection
The interrupt detach instruction removes the association between the interrupt event EVNT and all interrupt routines, preventing the specified interrupt event from entering the interrupt queue and thus disabling the individual interrupt event. The clear interrupt instruction removes all interrupt events numbered EVNT from the interrupt queue. This instruction can be used to clear unnecessary interrupt events.
Interruption and Separation
Disclaimer: This article is a reprint. If it involves copyright issues, please contact us promptly for deletion (QQ: 2737591964). We apologize for any inconvenience.