Structuring Your User Program - Siemens SIMATIC S7 System Manual

Hide thumbs Also See for SIMATIC S7:
Table of Contents

Advertisement

Programming concepts

5.2 Structuring your user program

Recommended steps
Create the
configuration drawings
Create a list of
symbolic names
5.2
Structuring your user program
When you create a user program for the automation tasks, you insert the instructions for the
program into code blocks:
● An organization block (OB) responds to a specific event in the CPU and can interrupt the
● A function block (FB) is a subroutine that is executed when called from another code
● A function (FC) is a subroutine that is executed when called from another code block
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,
● A modular program calls specific code blocks that perform specific tasks. To create a
80
Tasks
Based on the requirements of the functional specification, create configuration drawings of the
control equipment:
Overview drawing that shows the location of each PLC in relation to the process or machine.
Mechanical layout drawing of each PLC and any I/O modules, including any cabinets and
other equipment.
Electrical drawings for each PLC and any I/O modules, including the device model numbers,
communications addresses, and I/O addresses.
Create a list of symbolic names for the absolute addresses. Include not only the physical I/O
signals, but also the other elements (such as tag names) to be used in your program.
execution of the user program. The default for the cyclic execution of the user program
(OB 1) provides the base structure for your user program and is the only code block
required for a user program. If you include other OBs in your program, these OBs
interrupt the execution of OB 1. The other OBs perform specific functions, such as for
startup tasks, for handling interrupts and errors, or for executing specific program code at
specific time intervals.
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 of valve.
(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.
one after the other. Typically, the linear program puts all of the program instructions into
the OB for the cyclic execution of the program (OB 1).
modular structure, you divide the complex automation task into smaller subordinate tasks
that correspond to the technological functions of 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.
S7-1200 Programmable controller
System Manual, 11/2009, A5E02486680-02

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic s7-1200

Table of Contents