Sie sind auf Seite 1von 1

Diferencias entre FB y FC

FB and FC are two types of subroutines that make STEP 7 a very flexible and powerful tool.As
subroutines, FC and FB can be used to optimize the programming.

Main uses for FC and FB:

 Divide and organize the user program. Divided in small parts the units can be easily understood. This
helps specially maintenances and alterations of the program.

 Rationalize and optimize the programming. FC and FB can be created and used as users’ library. So, an
algorithms is programming just one time, and can be used many times in one our more projects.

 Reduce and rationalize resources of the CPU (e.g. memory occupation).

Both FB and FC has an important feature that is the possibility to have input/output parameters. This
permits that a same algorithm could be used many times, each with different set of variables.While a FC
uses the address of the given parameter to read and write directly in then, a FB copy this parameters
to/from a associated DB, and work internally just with the DB variables. The uses of an associated DB for
each call (so called Instance DB), open the possibility to store variables internally. The follow table shows
the difference between FC and FB

Characteristic FC FB
Can be used as subroutine Yes Yes
Can use parameters for Inputs, Outputs and Yes Yes
Inout
Can use temporary variables Yes Yes
Can use static variables (with remanence) No Yes
Need a auxiliary (instance) DB for each call No Yes
Parameters are passed as address for Yes No
internal use
Parameters are copied to/from a DB No Yes
(instance) for internal use
Can call internally a FB or FC Yes Yes
Can be called for a FB or FC Yes Yes
Can call a FB as multi instance No Yes
Can be called without fill all parameters No Yes

Note:The FB copy the input parameters to the instance DB at start call and, at end, copy back from the
instance DB to the outputs. This could take a little bit more memory and processing time as a FC. In other
hand, internally it works just with instances DB variables; this means that the internal processing of a FB
could be a little faster as FC. However, these differences will depends of many factors like ratio
parameters / codes, type of parameters, etc.

Das könnte Ihnen auch gefallen