Easy To Design Your User Program - Siemens SIMATIC S7-1200 Manual

Hide thumbs Also See for SIMATIC S7-1200:
Table of Contents

Advertisement

5.2

Easy to design your user program

When you create a user program for the automation tasks, you insert the instructions for the
program into code blocks (OB, FB, or FC).
An OB is a code block that you use to structure or organize the user program for your
application. For many applications, a continuously cycling OB, such as the program cycle OB
1, contains the program logic. In addition to the program cycle OB, the CPU provides other
OBs that perform specific functions, such as startup tasks, the handling of interrupts and
errors, or the execution of specific program code at specific time intervals. Every OB
responds to a specific event in the CPU and can interrupt the execution of the user program,
according to pre-defined priority groups and classes..
An FB is a subroutine that is executed when called from another code block (OB, FB, or FC).
The calling block passes parameters to the FB and also identifies a specific data block (DB)
that stores the data for the specific call or instance of that FB. Changing the instance DB
allows a generic FB to control the operation of a set of devices. For example, one FB can
control several pumps or valves, with different instance DBs containing the specific
operational parameters for each pump or valve. The instance DB maintains the values of the
FB between different or consecutive calls of that FB, such as to support asynchronous
communication.
An FC is a subroutine that is executed when called from another code block (OB, FB, or FC).
The FC does not have an associated instance DB. The calling block passes parameters to
the FC. The output values from the FC must be written to a memory address or to a global
DB.
Choosing the type of structure for your user program
Based on the requirements of your application, you can choose either a linear structure or a
modular structure for creating your user program.
A linear program executes all of the instructions for your automation tasks in sequence, one
after the other. Typically, the linear program puts all of the program instructions into one
program cycle OB (OB 1) for cyclic execution of the program.
A modular program calls specific code blocks that perform specific tasks. To create a
modular structure, you divide the complex automation task into smaller subordinate tasks
that correspond to the functional tasks being performed by the process. Each code block
provides the program segment for each subordinate task. You structure your program by
calling one of the code blocks from another block.
Linear structure:
Easy Book
Manual, 11/2009, A5E02486774-01
Modular structure:
Programming concepts made easy
5.2 Easy to design your user program
49

Advertisement

Table of Contents
loading

Table of Contents