Function Blocks
Note: Logic Modeling is still in Early Access. Logic Modeling features created during Early Access, including plugins and integrations, may not be fully compatible with future versions of Visual Components.
Function blocks are reusable units of logic used to model component- and layout-level behavior in Logic Modeling. Function blocks can be added to Function Block Diagrams and connected to other blocks to create the control logic of a simulation.
Each function block contains a Logic Program that defines the functionality of the block. A Logic Program consists of Structured Text (ST) code and a set of ports that define how the function block exchanges data with other elements.
Ports
Ports define the interface of a function block. Logic Modeling supports the following port directions:
- Input ports receive data into the Logic Program.
- Output ports send data from the Logic Program.
- Local ports store values that are used internally by the Logic Program and are not exposed as inputs or outputs of the function block. Local ports cannot be connected to other function blocks. However, they can be linked to component properties, allowing the Structured Text code to read or modify values in the simulation.
Each port has a name and data type. Depending on the function block, ports can also be linked to component properties or signals. Ports are created and configured using the Logic Program Editor. For more information, see Logic Program Editor.
Function block types
Logic Modeling provides Component, Custom, and Standard Function Blocks. The function block types differ mainly in how they are created,what they are associated with, and whether their Logic Programs can be modified.
Component Function Blocks
Component Function Blocks provide an interface between components and Logic Modeling. To use a component as a Component Function Block in a Function Block Diagram, the component must contain a Function Block (Early Access) behavior. The behavior contains the Logic Program that defines the interface and functionality of the component in Logic Modeling.
A Component Function Block can expose component properties and signals through its ports, allowing the component to exchange data with other elements in a Function Block Diagram. Its Logic Program can also contain Structured Text code for implementing component-specific logic.
Custom Function Blocks
Custom Function Blocks allow you to create user-defined logic within a Function Block Diagram. Unlike Component Function Blocks, which are associated with components, Custom Function Blocks are owned by the Function Block Diagram in which they are created.
A Custom Function Block contains a Logic Program that defines its interface and functionality. It can optionally be linked to a component, allowing its ports to be linked to compatible properties and signals of the selected component.
If no component is linked, the Custom Function Block can be used for logic that does not require direct access to component properties or signals.
Standard Function Blocks
Standard Function Blocks provide predefined operations for use in Function Block Diagrams. Unlike Component and Custom Function Blocks, their implementation cannot be modified.
Standard Function Blocks are available from the Function Block Library and can be added to a Function Block Diagram as needed.
Using Function Blocks in a Diagram
Function blocks added to a Function Block Diagram are represented as nodes. Connections between the ports of the nodes determine how data is transferred between function blocks.
When a Function Block Diagram is executed, its function blocks process their inputs, execute their logic, and update their outputs according to the diagram execution order.