EasyManuals Logo

Siemens Simatic S7 Series System Manual

Siemens Simatic S7 Series
726 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #87 background imageLoading...
Page #87 background image
Programming concepts
5.2 Elements of the user program
S7-200 SMART
System Manual, 09/2015, A5E03822230-AC
87
5.2
Elements of the user program
A program organizational unit (POU) is composed of executable code and comments. The
executable code consists of a main program and any subroutines or interrupt routines. The
code is compiled and downloaded to the CPU. You can use the program organizational units
(main program, subroutines, and interrupt routines) to structure your user program.
The main body of the user program contains the instructions that control your application.
The CPU executes these instructions sequentially, once per scan cycle.
Subroutines are optional elements of your program which are executed only when called:
by the main program, by an interrupt routine, or by another subroutine. Subroutines are
useful in cases where you want to execute a function repeatedly. Rather than rewriting
the logic for each place in the main program where you want the function to occur, you
can write the logic once in a subroutine and call the subroutine as many times as needed
during the main program. Subroutines provide several benefits:
Using subroutines reduces the overall size of your program.
Using subroutines decreases your scan time because you have moved the code out of
the main program. The CPU evaluates the code in the main program every scan
cycle, whether the code is executed or not, but the CPU evaluates the code in the
subroutine only when you call the subroutine, and does not evaluate the code during
the scans in which the subroutine is not called.
Using subroutines creates code that is portable. You can isolate the code for a
function in a subroutine, and then copy that subroutine into other programs with little
or no rework.
Note
Using V
memory addresses can limit the portability of your subroutine, because it is
possible for V
memory address assignment from one program to conflict with an
assignment in another program. Subroutines that use the local
variable table
(L
memory) for all address assignments, by contrast, are highly portable because
there is no concern about address conflicts between the subroutine and another part
of the program when using local variables.

Table of Contents

Other manuals for Siemens Simatic S7 Series

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Siemens Simatic S7 Series and is the answer not in the manual?

Siemens Simatic S7 Series Specifications

General IconGeneral
CPUVaries by model (e.g., S7-300, S7-400, S7-1200, S7-1500)
Communication InterfacesPROFIBUS, PROFINET, Ethernet, MPI
ProgrammingTIA Portal, STEP 7
Programming LanguagesLAD, FBD, STL, SCL, GRAPH
I/O ModulesDigital, Analog, Specialty modules available
Operating Temperature0°C to 60°C (standard models)
MountingDIN rail mounting
Operating Voltage24V DC or 120/230V AC (varies by model)
Protection ClassIP20 (standard models)
MemoryVaries depending on the S7 model. Includes work memory (RAM) for program execution, load memory (EEPROM or Flash) for program storage, and system memory for operating system functions. Memory sizes range from kilobytes to megabytes.

Related product manuals