Programming in CFC

Connecting Elements

  1. Drag a Box element and an Output element in the editor.

  2. Click the output of the Box element.

    The output is marked by a red square.

  3. Drag a connecting line from the output of the Box element to the input of the Output element.

    The cursor symbol changes when it reaches the input pin.

  4. Release the mouse button.

    CODESYS connects the two elements together by a connecting line.

    78fa1c97315145aec0a8640e00b4a721_2530b9869303f43ec0a8640e00705e1e

Alternatively you can also select the two pins with the Ctrl key pressed and select the Connect Selected Pins command.

See also

Creating of connection marks

Requirement: A CFC POU has connected elements.

  1. Select a connecting line between two elements.

    The connecting line is marked; the input or the output of each element is marked with a red square 78fa1c97315145aec0a8640e00b4a721_7628e1f16ebcad9cc0a8640e01bf23c5 .

  2. Select the command CFC ‣ Connection Mark.

    The connection is disconnected and replaced by a connection mark - source and a connection mark - sink. The names of the marks are automatically generated.

  3. Click in the connection mark - source.

    The name can be edited.

  4. Change the names of the source and the target to the same names.

../_images/6793a38e6ec864f8c0a8640e0052aa68

Example 1

../_images/6438ea476ec9fecec0a8640e00c2d9ef

Example 2

../_images/c3aecb1b6eca8a6ac0a8640e01717d3c

Example 3

See also

Resolving collisions - Adapting connecting lines by control points

The following example shows you how to use the Route All Connections command, as well as how to use control points.

  1. Position the Input and Output elements in accordance with the following example and connect the elements

    78fa1c97315145aec0a8640e00b4a721_fae8d266754b315fc0a8640e01f15dc8

  2. Position two Box elements on the line.

    78fa1c97315145aec0a8640e00b4a721_9af1a1f8754b5d65c0a8640e00477c83

    The connecting line and the function blocks are drawn in red due to the collision.

  3. Execute the command CFC ‣ Routing ‣ Route All Connections.

    78fa1c97315145aec0a8640e00b4a721_fa46fada754e2e12c0a8640e017652c2

    The collision is dissolved

  4. Change the connecting lines in 3 steps in accordance with the following example

    78fa1c97315145aec0a8640e00b4a721_9960363f754b853dc0a8640e01801134

    The connecting line was manually changed, so that CODESYS disables it for the automatic routing. This is indicated by a lock at the end of the connection.

    78fa1c97315145aec0a8640e00b4a721_c2f46f0e7556649bc0a8640e011e9de9

  5. Position a control point on the connecting line.

    78fa1c97315145aec0a8640e00b4a721_88b9f53c7559cef1c0a8640e00eb071a

  6. Change the connection in accordance with the following example

    78fa1c97315145aec0a8640e00b4a721_f3c78b097559f8d6c0a8640e01e64020

    Through the control point you can change the connecting line individually. You can set as many control points as you wish.

  7. Remove the control point using the context command Routing ‣ Remove Control Point. Disconnect the connection with the Unlock Connection command or by clicking on the lock symbol.

    78fa1c97315145aec0a8640e00b4a721_97e40dd7755d1201c0a8640e0028acc3

  8. Select the connecting line and select the Route All Connections command.

    The connecting line will be drawn automatically as illustrated in step 3.

Attention

Autorouting does not affect grouped connections.

See also

Changing the execution order

The order in which the elements of a CFC network in online mode are successively executed is indicated by the element numbers in the top right corner of each element. Execution starts with the element with the lowest number, “0”.

When pasting in an element, CODESYS automatically assigns the number in the topological order (from left to right and from top to bottom). If the order has already been changed, the new element receives the number of its topological successor and all higher numbers are increased by one.

The number of an element remains constant when it is moved.

Please bear in mind that the order has an effect on the result and has to be changed in certain cases.

  1. Select the element whose order of execution you wish to change

    The element is displayed with a red border

  2. Select the command Execution Order ‣ Move Up

    Select the command Execution Order ‣ Move Up

See also

See also