Fbs And Fcs Make Programming The Modular Tasks Easy - Siemens SIMATIC S7-1200 Manual

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

Advertisement

Programming made easy
6.1 Easy to design your user program
Creating an additional OB within a class of OB: You can create multiple OBs for your user
program, even for the program cycle and startup OB classes. Use the "Add new block"
dialog to create an OB. Enter the name for your OB and provide an OB number of 200 or
greater.
If you create multiple program cycle OBs for your user program, the CPU executes each
program cycle OB in numerical sequence, starting with the lowest numbered OB, typically
OB 1. For example, after the first program cycle OB (OB 1) finishes, the CPU executes the
second program cycle OB (such as OB 200).
6.1.2

FBs and FCs make programming the modular tasks easy

A function (FC) is like a subroutine. An FC is a code block that typically performs a specific
operation on a set of input values. The FC stores the results of this operation in memory
locations. Use FCs to perform the following tasks:
● To perform standard and reusable operations, such as for mathematical calculations.
● To perform functional tasks, such as for individual controls using bit logic operations.
An FC can also be called several times at different points in a program. This reuse simplifies
the programming of frequently recurring tasks.
Unlike an FB, an FC does not have an associated instance DB. The FC uses its temp
memory (L) for the data used to calculate the operation. The temporary data is not saved. To
store data for use after the execution of the FC has finished, assign the output value to a
global memory location, such as M memory or to a global DB.
A function block (FB) is like a subroutine with memory. An FB is a code block whose calls
can be programmed with block parameters. The FB stores the input (IN), output (OUT), and
in/out (IN_OUT) parameters in variable memory that is located in a data block (DB), or
"instance" DB. The instance DB provides a block of memory that is associated with that
instance (or call) of the FB and stores data after the FB finishes.
You typically use an FB to control the operation for tasks or devices that do not finish their
operation within one scan cycle. To store the operating parameters so that they can be
quickly accessed from one scan to the next, each FB in your user program has one or more
instance DBs. When you call an FB, you also open an instance DB that stores the values of
the block parameters and the static local data for that call or "instance" of the FB. These
values are stored in the instance DB after the FB finishes.
90
You can modify the operational
parameters for an OB. For example, you
can configure the time parameter for a
time-delay OB or for a cyclic interrupt OB.
Manual, 11/2011, A5E02486774-04
Easy Book

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents