CFC element function block

Symbol: CFC element function block 1:

You can use the element to insert an operator, a function, a function block or a program. By default, TwinCAT adds the element with the name ???. You can edit this field directly by clicking on it and enter a function block name. Alternatively, you can open the input assistant by clicking CFC element function block 2: and select a function block.

In the case of a function block, TwinCAT also displays an input field above the function block symbol (???). You have to replace this name with the name of the function block instance. If you instantiate a function block with constant input parameters, the function block element displays the field Parameter... in the lower left corner. You can edit the parameters by clicking on this field.

To replace an existing box, simply replace the currently inserted identifier with the desired new name. Note that TwinCAT adapts the number of input and output pins according to the definition of the POU and therefore deletes any existing assignments.

CFC element function block 3:

As in the CFC feedbacks are allowed, implicit variables with data type of the input variables are generated at the output of a function block (in the sample temp_USINT). If the result of the operation of a function block is a value that exceeds the number range of the data type of the input variable, the overflow is written to the implicit variable. The actual output variable receives the value of the implicit variable, i.e. the overflow and not the actual result of the operation (see sample).

Sample

Implicitly generated variables at the function block output:

CFC element function block 4:

Implicitly generated code:

temp_USINT := USINT1 * temp_USINT;
UDINT1     := temp_USINT;

See also: