User Manual

Operation
12/06 AWB2724-1584GB
52
Interrupt processing
If an interrupt occurs, the program is interrupted and the program
routine associated with the system event is processed. figure 53
shows a list of interrupt sources.
The program routine called by the interrupt can be interrupted by
a new interrupt (different channel).
If the current interrupt is followed by a new interrupt (same
channel), the new interrupt is not executed until the processing of
the current one has been completed.
The interrupts are enabled in the RUN state of the CPU and
disabled in the STOP state. Interrupt sources which are not
enabled in the configuration do not initiate an interrupt.
The timer interrupts I1...I4 can be disabled and enabled from the
user program. The functions “DisableInterrup and
“EnableInterrupt” are provided for this purpose. A call parameter
determines whether a single interrupt or all interrupts are to be
disabled/enabled. A disabled interrupt must be enabled with the
same parameter that was used to disable it.
The two functions DisableInterrup and EnableInterrupt are
provided as part of the library EC_UTIL.lib. This library must be
included if necessary in your project by the Library Manager of the
programming software.
DisableInterrupt: With this function, you disable (deactivate) a
parameterized physical interrupt by accessing it from the user
program.
EnableInterrupt: With this function, the physical interrupt which
was deactivated beforehand can now be re-enabled as an active
interrupt.
Steps for interrupt processing
X Define the interrupt properties:
X Create the program routine (POU).
Another program routine (POU) must be added to the existing POU
PLC_PRG . This is of type PRG and calls an interrupt.
X Assign the program routine to an interrupt source:
To do this call the PLC configurator and click Task
Configuration l System Events. The interrupt sources (names)
are listed in the “System Events” tab with a free entry field
for the name of the “Called POU”.
Enable the interrupt by clicking the box next to the required
interrupt and entering the name of the POU in the same line.
Further details on this are described in the .Example for
interrupt processing
Example for interrupt processing
A “PLC_PRG” POU has to be processed continuously. An
additional POU “Fastprog” has to be processed when a rising
edge (L l H) at input I3 generates an interrupt.
X Create the POUs “PLC_PRG” and “Fastprog” as shown in
.figure 54
X Move to the PLC configuration, click on the Local I/O[SLOT]
folder and open the “Other Parameters” tab
X Assign the “Rising edge” type to input I3.
Figure: 53: Interrupt sources
h
Execution of the POU is time-monitored.
START/STOP
COLDSTART
WARMSTART
(Start of controll.er)
TIMER INTERRUPT
(periodic)
Interrupt inputs
(voltage at I1, I2, I3, I4)
High-speed counter
(Actual value = Preset)
Program for
processing the
interrupt
Startup behaviour Select type
TIMER INTERRUPT Call function
TIMERINTERRUPTENABLE
Interrupt inputs Define edges
High-speed counters Select type
Figure: 54: Writing a program