Declare Functions or Function Blocks

This section explains how to create a new function or UDFBClosed "User Defined Function Block" UDFB can be used as a sub-function block in another program of the application. It is described using FBD, LD, ST or IL language. Input / output parameters of a UDFB (as well as private variables) are declared in the variable editor as local variables of the UDFB.

  1. Expand the PLCClosed "Programmable Logic Controller" A Programmable Logic Controller, PLC, or Programmable Controller is a digital computer used for automation of industrial processes, such as control of machinery on factory assembly lines. Used to synchronize the flow of inputs from (physical) sensors and events with the flow of outputs to actuators and events node in the Project Explorer, and right-click on the Subprograms item and select the action you wish to perform (i.e., New FunctionClosed A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. or New UDFB). The New Program dialog box will open.
  2. Enter the program name (MyFBD, for example), and click OK.
  3. The Program Properties dialog box opens. This is where you will enter the input and output parameters for the function or UDFB.
  4. Clicking on the editable space ("…") in Inputs or Outputs enables the Edit button. Clicking the Edit button or double-clicking on the editable space opens the Parameters dialog which lets you add variables for Inputs and Outputs.
Item Description
Edit Press this button to change the definition of the selected parameter. Pressing this button when the last line (...) of the list is selected lets you add a new parameter.
Delete Press this button to remove the selected parameter.
Move Up/Down Press these buttons to move the selected parameter in the list to arrange the order of parameters. The order is very important as it defines the calling prototype of the UDFB or sub-program.
Swap Pressing this item moves the selected parameter between the Inputs and Outputs lists. When an item is selected the button's text changes to show where the parameter will be moved.