Siemens Simatic S7-200 System Manual page 119

Programmable controller
Hide thumbs Also See for Simatic S7-200:
Table of Contents

Advertisement

Example Program Using Subroutines and Interrupts
Figure 6-7 shows a sample program for a timed interrupt, which can be used for applications
such as reading the value of an analog input. In this example, the sample rate of the analog
input is set to 100 ms.
Ladder Logic
Network 1
SM0.1
Network 2
Network 3
0
SBR
Network 4
SM0.0
100
0
10
Network 5
Network 6
0
INT
Network 7
AIW4
Network 8
Figure 6-7
S7-200 Programmable Controller System Manual
C79000-G7076-C230-02
Basic Concepts for Programming an S7-200 CPU
Main Program
Network 1
LD
0
CALL
CALL
Network 2
END
MEND
Subroutines
Network 3
SBR
Network 4
LD
MOVB
MOV_B
ENI
EN
ATCH
IN
OUT SMB34
Network 5
ENI
RET
ATCH
EN
INT
EVENT
RET
Interrupt Routines
Network 6
INT
Network 7
MOVW
MOV_W
Network 8
RETI
EN
IN
OUT
VW100
RETI
Sample Program for Using a Subroutine and an Interrupt Routine
Statement List
SM0.1
//When first scan bit
//comes on
0
//Call subroutine 0.
0
//Begin subroutine 0
SM0.0
//Always on memory bit,
100, SMB34
//set timed int. 0.
//interval to 100 ms
//Global Interrupt Enable
0, 10
//Attach timed int. 0 to
//int. routine 0.
//Terminate subroutine.
0
//Begin Int. routine 0.
AIW4,VW100
//Sample Analog Input 4
//Terminate interrupt
routine
6-9

Advertisement

Table of Contents
loading

Table of Contents