Function blocks are code blocks that store their output, input, o and in-out parameters permanently in idata blocks, so that they remain available even after the block has been executed. Therefore they are also referred to as blocks “with memory”.
Function blocks can also operate with temporary tags. Temporary tags are will not be stored in the instance DB, but are available for one cycle only.
FC Blocks are part of the program called from within the main program. For example, instead of typing multiple times in the main loop, an operation that is to be repeated more than once is written into the FC block, and only this block is called every time it is needed. Written program is shorter.
Creating Functions and Function Blocks
To create a function (FC) or afunction block (FB), follow these steps:
>>> Create New Project or use existing Project.
>>> Double-click the “Add new block” command.
>>> The "Add new block"dialog box opens.
>>> Click the “Function block(FB)” or “Function (FC)” button.
>>> Enter a name for the new block.
>>> Enter the properties of the new block.
>>> Enter the properties of the new block.To enter additional properties for the new block, click “Additional information”.
An area with further input fields is displayed.
>>> Enter all the properties you require.
>>> Activate the “Add new and open” check box if the block does not open as soon as it is created.
>>> Confirm your entries with"OK".
What is the Differences Between FB and FC Block?
Main difference is memory. Whilea FC uses the address of the given parameter to read and write directly inthen, a FB copy this parameters to/from a associated DB, and work internallyjust with the DB variables. The uses of an associated DB for each call (socalled Instance DB), open the possibility to store variables internally.
The table below shows the difference between FC and FB
Both FCs and FBs can hold parameters (IN, OUT, IN-OUT and TEMP), it allows the re-use of the blocks with different calling environments.
When you call an FB, you are required to generate an instance DB (Instance Data Block) that accompanies this particular call of an FB; this DB contains all the STATIC parameters of the FB, and these are available at any time by any other block in your program. this DB contains all the static parameters of the FB and can be used at any time by any other block in your program.
Reference - howtoparrot