To create new variables, you can use the declaration editor or the Variables pane. You can also declare new variables directly from within the POU body. The procedure for this depends on which programming editor (LD/FBD, ST/IL or SFC) you use.
The following procedure requires that the Variables pane be opened.
- Select New variable from the context menu or use
The dialog Create new variable opens.
A warning indicates invalid field entries. Move the mouse over the triangle to display a tooltip on the data required.
- Under Location, select the location of the variable
The variable can be declared in the header of the current POU header, in the global variable list or in a user-defined library (if available).
- Under Class, select a variable class
The available classes depend on the declaration location.
- Under Identifier, enter a symbolic name
- Do not use special characters such as !, ", $, %, brackets, etc.
- The first character may not be a digit.
- The last character may not be an underscore. An underscore may not be followed by another underscore.
- The identifier may not consist of only an address, e.g. 'R0', 'DT0', 'LD0'. The identifier may not consist of only a keyword, e.g. 'ADD', 'ARRAY', 'INT'.
- For global variables: Enter address
- Select Type
- Enter initial value (optional)
- Under Comment, enter a text, if desired
- OK
The new variable is created in the desired location.
If you have created a global variable with this dialog, the new global variable is automatically declared in the GVL and inserted in the POU body as VAR_EXTERNAL.