Operation
10/10 MN05003003Z-EN
52
Interrupt processing
If an interrupt occurs, the program is interrupted and the program
routine associated with the system event is processed. figure 54
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.
You can disable or enable the interrupt inputs I1....I4 and the timer
interrupt from the 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
parameterised 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 of
interrupt processing.
Example of 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 55.
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 54: Interrupt sources
h
The execution time of the program routines is monitored.
START/STOP
COLD START
WARM START
(start of controller)
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 55: Writing a program
Summary of Contents for easyControl EC4-200
Page 4: ...II...
Page 10: ...10 10 MN05003003Z EN 6...
Page 14: ...10 10 MN05003003Z EN 10...
Page 22: ...10 10 MN05003003Z EN 18...
Page 38: ...10 10 MN05003003Z EN 34...
Page 62: ...10 10 MN05003003Z EN 58...
Page 78: ...10 10 MN05003003Z EN 74...
Page 96: ...10 10 MN05003003Z EN 92...