Entry type: FAQ, Entry ID: 23657941, Entry date: 12/20/2010
(0)
Rate

What is a hardware interrupt and how do they work in the S7-300 system?

  • Entry
  • Associated product(s)

Instructions:
Events can occur in the current process which require responses which are quicker than are possible in the current program cycle. Events also occur which do not last long enough to be identified in the current program cycle. Therefore, there is hardware interrupt processing in SIMATIC S7-300 controllers.
Together with:

  • analog input modules (AI),
  • digital input modules (DI) and
  • function modules (FM)

with hardware interrupt capability, a program which is adapted to suit the event can be called in real time.
Hardware interrupts approximate to interrupts.
This entry is intended to serve as a guide to hardware interrupts in S7-300 CPUs.

General:
If an alarm-triggering event occurs during program processing, the operating system calls the alarm OB 40, interrupting the processing of the program cycle or lower-priority program blocks. The alarm-triggering event (or events (multiple bits can be set)) is/are specified more precisely via the alarm OB 40's temporary local data. The temporary local data can be evaluated by the user program in the alarm OB.
If there is no alarm OB 40 in the CPU when an alarm-triggering event occurs, the CPU goes into STOP mode. The alarm OB has a fixed priority setting of 16.

Hardware interrupt-triggering events in the different modules:

Analog input modules: A value can be monitored in analog input modules with hardware interrupt capability. The hardware interrupt can be configured to be triggered off if values drop below or rise above specified thresholds. More information about the individual analog input modules is available in the manual "Programmable Logic Controller S7-300 Module Data" in Entry ID 8859629 in chapter 4.

Digital input modules: Individual bits can be monitored in digital input modules with hardware interrupt capability. The hardware interrupt can be configured to be triggered off in the event of a negative or positive edge to the bit. More information about the individual digital input modules is available in the manual "Programmable Logic Controller S7-300 Module Data" in Entry ID 8859629 in chapter 3.

Function modules: Since function modules with hardware interrupt capability perform a wide range of different tasks, allowing the hardware interrupts to be configured for different events, it is advisable to consider the FM 350-1 counter module by way of an example.
The FM 350-1 enables a hardware interrupt to be triggered off in the CPU whenever comparison values are reached, or in the event of an over-run or under-run and/or if the counter passes through zero. More information about the FM 350-1 module is available in the manual "FM 350-1 Function Module" in Entry ID: 1086726. More information about the other function modules is available in the module-specific documentation.
Warning:
Many function modules require special parameterization software which is supplied with the function module and corresponding documentation. Hardware interrupt-triggering events can only be configured together with STEP 7 and this software.

Alarm OBs in SIMATIC S7-300:
In SIMATIC S7-300 CPUs, temporary local data is made available in the alarm OB40. The channel/bit where the hardware interrupt event occurred is specified through this temporary local data.
You can find the description of the alarm OBs in STEP 7 whenever you create the new alarm OB40 in the CPU's block folder (right click > Insert new object > Organization block  > OB40), select the newly created OB40 and then press "F1". This opens the S7 Help for the alarm OB40. Needless to say, if there already is an alarm OB40 present, you can select it straight away and then press "F1".
More information about the module-specific evaluation of the local data is available in the manual "Programmable Logic Controller S7-300 Module Data" in Entry ID 8859629 Chapter 3 (Digital Modules) and Chapter 4 (Analog Modules) or in the special manuals relating to the function modules.

Two alarm OBs (40 and 41) can be used in the CPU 318-2 DP. More information about the CPU 318-2 DP is available in the manual "Programmable Logic Controller S7-300 CPU Data, CPU 312 IFM to CPU 318-2 DP" in Entry ID: 8860591.

There are up to eight alarm OBs available in the S7-400 CPUs. More information about hardware interrupts for S7-400 CPUs is available in Entry ID: 23659324 

Configuring a hardware interrupt:
Hardware interrupts can be configured in the hardware configuration under the properties for the modules with alarm capability.
You can find an example of how to calculate the alarm-response time for the S7-400 in the manual "S7-300 CPU 31xC and CPU 31x, Technical Data" in Entry ID: 12996906 section 5.5 ff.

Configuring hardware interrupt modules:
The modules with hardware interrupt capability can also be configured during an ongoing program cycle by means of system functions SFC 55 (WR_PARM), SFC 56 (WR_DPARM) and SFC57 (PARM_MOD). You can find out how to configure the corresponding data records with the system functions in the manual "Programmable Logic Controller S7-300 Module Data" in Entry ID: 8859629.
Information about the different SFCs is available in the S7 Online Help and in the manual "System Software for S7-300/400 System and Standard Functions" in Entry ID: 1214574 in section 7.1.
Warning:

System functions SFC 55, SFC56 and SFC 57 cannot be used with PROFINET IO.

Note:
Some digital modules (e.g. 6ES7321-7BH0X or 6ES7321-7RD00) require a data length of 6 bytes to write the data record DS1. In the "RECORD" parameter of SFC55 increase the ANY data type by 2 bytes to 6 bytes. The additional 2 bytes must have the value zero.

Blocking, delaying, releasing hardware interrupts:
Hardware interrupts can be blocked, delayed and released again by means of system functions SFC 39 (DIS_IRT IRT_FUNC), SFC 40 (EN_IRT IRT_FUNC), SFC 41 (DIS_AIRT IRT_FUNC) and SFC 42 (EN_AIRT IRT_FUNC).
Information about the different SFCs is available in the S7 Online Help and in the manual "System Software for S7-300/400 System and Standard Functions" in Entry ID: 1214574 in chapter 12.