Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
In the general case function is more preferable. It takes a little bit less memory and easy to use (you need not to declare instances). If you can use a function (you need not internal memory in the POU and 1 output is enough) then you have to use it.
With one exception , if we need POU with many 'parameter' (constant) inputs FB can be more suitable, especially in cycles. For example:
Function:
Indeed I have only one 'x' varying value, but I have to write in all places:
And each time the compiler will generate code for transferring all parameters.
With FB I can write input parameters only once:
Further in all places (or in cycles) I can write only:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi developers,
could you explain me what's the real benefit of using FBs rather than functions
IMHO they are quite similar.
Best regards
In the general case function is more preferable. It takes a little bit less memory and easy to use (you need not to declare instances). If you can use a function (you need not internal memory in the POU and 1 output is enough) then you have to use it.
With one exception , if we need POU with many 'parameter' (constant) inputs FB can be more suitable, especially in cycles. For example:
Function:
Indeed I have only one 'x' varying value, but I have to write in all places:
And each time the compiler will generate code for transferring all parameters.
With FB I can write input parameters only once:
Further in all places (or in cycles) I can write only:
Thank you for the explanation