plctwincatstructured-text

Is there a difference when using function block rather than functions in TwinCat?


I started making the structure for a new PLC program, but I was wondering when is convenient to use a funtion rather than a function block, if there's any benefit on using them in TwinCat.


Solution

  • The defining characteristic is that a FUNCTION does not have internal memory of its variables.

    In contrast:

    This pretty much describes why you would use one over the other.

    If you are writing a repeated segment of code that doesn't require memory of its previous state use a FUNCTION. Otherwise use a FUNCTION_BLOCK.