Requirement: A project is open.
-
In the Device tree of your project, select the application in which the global variables are to be valid.
-
In the context menu, click .
CODESYS inserts the GVL in the device tree under the application and opens it in the editor.
-
Click .
The Declare Variable dialog opens.
-
In the list box Scope, select the entry VAR_GLOBAL.
-
In the field Name, enter a name for the global variable.
-
Select a data type from the Data type list box.
-
If your variable is to have an initialization value other than the standard initialization value, click
next to the Initialization value field.The Initialization Value dialog opens.
-
Double-click the Initialization value field of your variable and enter the desired valid value.
-
Click OK.
The initialization value is displayed in the Declare Variable dialog.
-
Activate one of the flags if necessary.
-
Confirm your entries by clicking the button OK.
CODESYS inserts the declared variable in the GVL.
The global variable is available in the total application of your project.
-
Click .
The POUs view opens.
-
In the POUs view, select the top node with the project name and click .
CODESYS inserts the GVL in the POUs view and opens it in the editor.
-
Click .
The Declare Variable dialog opens.
-
In the list box Scope, select the entry VAR_GLOBAL.
-
In the field Name, enter a name for the global variable.
-
Select a data type from the Data type list box.
-
If your variable is to have an initialization value other than the standard initialization value, enter it in the column Initialization.
-
Activate one of the flags if necessary.
-
Confirm your entries by clicking the button OK.
CODESYS inserts the declared variable in the GVL.
The global variable is now available in the entire project.