Interrupt Example - Siemens Simatic S7-200 CPU 210 System Manual

Table of Contents

Advertisement

Instruction Set

Interrupt Example

Network 1
I0.1
Network 2
SM0.0
Network 3
T0
>=I
+50
Network 4
M0.0
Network 5
M0.0
/
Network 6
0
LBL
Network 7
END
Network 8
0
INT
Network 9
INC_W
EN
MW2
IN
Network 10
RETI
Figure 5-12 Using an Interrupt Routine to Provide a High-Speed Counter
5-16
Main Program
M0.0
T0
TON
IN
+0
PT
P
EN
+0
IN
ENI
M0.0
Network 1: Turn on timer T0, enable the
S
interrupt routine, and initialize the counter
1
variable (MW2).
Network 2: Turn the timer on after it has
been turned off.
DISI
Network 3: After 5 seconds, turn off the
timer and disable the interrupt routine.
M0.0
Network 4: While the timer is executing,
R
jump over the logic that tests the number
of counts.
1
Network 5: If timer has stopped, turn on
0
Q0.0 if the number of counts is between
JMP
14550 and 15200.
I0.1
MW2
MW2
>=I
<=I
+14550
+15200
Network 6: Destination for the jump
instruction (Network 4).
Network 7: End of the main program
segment.
Interrupt Routine
Network 8: Identifies the high-speed
counter interrupt routine. This interrupt
routine can count up to 3 kHz.
Network 9: Increments the counter (MW2)
for each positive transition of I0.0.
Network 10: Returns to the main program
OUT
MW2
segment.
Ladder
Network 1
LD
A
TON
EU
MOVW
ENI
MOV_W
Network 2
LD
OUT
MW2
S
Network 3
LDW>= T0, +50
DISI
R
Network 4
LD
JMP
Network 5
LDN
A
AW>=
AW<=
=
Network 6
LBL
Network 7
MEND
Q0.0
Network 8
INT
Network 9
INCW
Network 10
RETI
S7-200 Programmable Controller, CPU 210
C79000-G7076-C235-01
STL
I0.1
M0.0
T0, +0
+0, MW2
SM0.0
M0.0, 1
M0.0, 1
M0.0
0
M0.0
I0.1
MW2, +14550
MW2, +15200
Q0.0
0
0
MW2

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents