Declaring variables in FBD

Use one of the following possibilities to declare one or more →variables within a →POU in →FBD:

Good to know

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg You are able to change some properties of an already declared variable later on. See under "Modifying variables" for the possibilities.

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/lightbulb.svg If you require a →constant, →retentive or →non-retentive variable, use the content assist. At present, logi.CAD 3 supports only this possibility to declare such variables.

Creating variables by using a dialog in the list of the declared variables

  1. Make the list of declared variables visible.
    Alternative for an →input variable, →output variable or →in-/out variable: Open the interface editor for the object (from within the project explorer).

  2. From the context menu, select New Variable... Alternative: Press the Ctrl-key and the +-key.

  3. In the dialog, enter the following properties for the variable and click OK.

    1. name – The name must be an →IEC-identifier.
      images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg If you want to declare several variables in one go, enter the name with , separating the names. Example: UpErr, QuitErr, MotorUp, MotorDown

    2. section (= the variable section), e.g. LOCAL ( for →local variable, also known as →internal variable ), INPUT (for →input variable ) etc.

      Restrictions

      →Temporary variables are not possible in FBD. →In-out variables cannot be declared in a →program, →global variables cannot be declared in a →function block or →function.

    3. →data type
      images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg Multi-dimensional array data types are not supported for connecting to a block in-/output with a →generic data type (e.g. the in-/output of the MOVE block).
      images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg Enter one or several letters so that a selection list with the corresponding data types and function blocks is provided.
      See "STRING variables cannot be created within the graphical editor", if you require some assistance when creating STRING variables.

    4. →initial value (only optional required) – This initial value may be a →constant expression (in compliance with the →data type ).

Creating a Boolean local variable fast

  1. Make the list of declared variables visible.

  2. From the context menu, select New Variable (LOCAL, BOOL). Alternative: Press Ctrl+Shift and the +-key.
    images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/information.svg If necessary, you are able to change the name as well as the data type later on. See under "Modifying variables".

Creating values fields with new variables (by using the content assist)

Use the content assist in order to create one or more →value fields with the new variables. The necessary variables are automatically declared.

  1. Position the mouse pointer over an empty space of the →graphical FBD-editor – where you need the value field.
    Double-click or press Ctrl+Space.
    Result: An input field is opened.

    Declare the variables according to this syntax: X, Y : name_1, name_2, ..., name_n : type := initial-value (with the parts X, Y : and :=initial-value being optional).

    Examples
    • var1, var2 : BOOL
      2 value fields will be created; one to contain an internal variable (due to the missing prefix for X ) named var1, the other to also contain an internal variable but named var2. Both variables are of →data type BOOL. There is no →initial value and no keyword (due to the missing prefix for Y ) .

    • I: var3 : INT := 5
      One value field will be created; It is to contain the input variable (due to I ) named var3 of data type INT and the initial value 5. There is no keyword (due to the missing prefix for Y ) .

    • C : var4 : INT := 5
      One value field will be created; It is to contain the internal variable ( due to the missing prefix for X ) named var4 of data type INT and the initial value 5. Due to C, the variable is declared with the keyword CONSTANT, so it is a →constant internal v ariable.

    • L, C : var5 : BOOL
      One value field will be created; It is to contain the internal variable ( due to L) named var5 of data type BOOL . There is no initial value. Due to C, the variable is also declared with the keyword CONSTANT.

    • I, R : var6 : INT
      One value field will be created; It is to contain the input variable (due to I) named var6 of data type INT . There is no initial value. Due to R, the variable is also declared with the keyword RETAIN , so it is a →retentive input v ariable.

    • O, NR : var7 : SINT
      One value field will be created; It is to contain the output variable (due to O) named var7 of data type SINT . There is no initial value. Due to NR, the variable is also declared with the keyword NON_RETAIN, so it is a non-retentive out put variable.

  2. Press the Enter-key.

  3. Position the value field by pressing the primary mouse button or the Enter-key. The necessary variables are automatically declared. Hence, the variables are listed in the list of the declared variables.

See "Creating value fields or calls of blocks by using the content assist in FBD", if you need more information on creating value fields.