Product : ISaGRAF V3.2
Date : 18-Febuary-1998
File : fbl_funct.how to call function blocks in a program.htm
Subject : how to call function blocks in a program.
Keywords: Function block
Function blocks can use the cyclic languages which are: LD, FBD, ST
and IL. A function block can be called by begin section programs,
sequential section programs and end section programs, but it cannot
be called by a function or a subprogram nor by another Function
In graphical editors (FBD/LD, quick LD), when you put one block in
your graphic, compiler automatically declare one function block
That block instance name is not visible from dictionary.
Therefore, at execution time, function block hidden data space is
allocated for each block you've put.
In ST and IL program, to call a function block, you have to declare
yourself a function block instance in ISaGRAF dictionary, to assign
a name to that instance and then to use that instance name in your
So in ST and IL languages, there are as many instances as you have
declared instances in your dictionary.
The declaration of FB instances enables the target, at the
application starting, to allocate all the memory that will be used
by the application.
For example if , inside a function, you make calls to standard
function block TON, then, on target side, a structure will be
allocated to store the TON input previous state.
But even if that function is called twice in your program, and if
function input parameters are wired to TON entry, there will be
only one place in target memory to store TON entry previous state.
In such conditions, 1st call to your function will affect 2nd call,
TON may not work as you suppose.
So here are simple rules if you want to avoid bad surprise
using function blocks:
- from a function, a function block (called more than once), or
a sub-program (called more than one) :
. you may use any user function, user C. function, or standard
. you may use any standard operator
- If you're sure your function or sub-program is called only once
in your application:
. then you can call a function block (or C function block or a
standard function block) from there.
(standard functions, function blocks and operators are listed in
on-line help - Language reference)
Copyright © 1996-2009 ICS Triplex ISaGRAF Inc. All rights reserved.