Creating and using a global-object

How to create a global-object:

  1. Select a folder in the project in which you want to create the global-object.
    In the application navigator: The best practice is to create new global-objects below Application so that the global variables in these created global objects are displayed in a structured way.

  2. In menu File or from the context menu of the folder, select New and the command Global-Object.

  3. In the dialog, enter a name under File Name.
    (info) If possible, do not enter invalid characters (e.g. umlauts, blanks, the character –, numbers at the start) because the file name is automatically used as global-object-name and this name must be a valid →IEC-identifier. But if you need such invalid characters in the file name, delete or replace the invalid characters in Global-Object-Name before you click Finish.
    It is possible to change the global-object-name at any time later. 

  4. Afterwards click Finish.
    Result:

    1. The global-object (with icon ) is displayed in the views with projects and resources.

    2. The global-object is opened in the →graphical editor.

  5. Create or edit the content, e.g. the →global variables. Details: See"Actions within the global-variables-editor".

  6. In order to use the global variables within the application, assign the global-object to an ST-→program or a →resource or →configuration. Best practice is to drag the global-object within the application navigator onto the corresponding object:

    1. Make the application navigator visible.

    2. Point to the global-object that is displayed below the folder Application (or a subfolder of it).

    3. Press and hold the primary mouse button and drag the global-object onto the program type (usually displayed below the folder Application) or onto the resource or configuration that is displayed within the application navigator.

    4. Release the primary mouse button.
      Result: The ST-program or the PLC-object (containing the resource or configuration) is enhanced by the necessary reference. This reference is an INCLUDE_GLOBALS directive (see "Declaration of global variables in global-object and its usage in ST", if you need more information on this directive). If you assigned the global-object to a resource or configuration, this global-object is also displayed in the folder Configuration-Global Variables or Resource-Global Variables.

Good to know

(grey lightbulb) In order to unassign the global-object from a resource or configuration, proceed as follows:

  1. Make the application navigator visible.

  2. Select one or various global-objects that are displayed in the folder Configuration-Global Variables or Resource-Global Variables and for which you want the revoke the assignment.

  3. From the context menu of the global-objects, select Delete or press the Del-key.
    Result: The global-object in the folder Configuration-Global Variables or Resource-Global Variables is deleted while the actual global-object in the folder Application is kept. Moreover, the INCLUDE_GLOBALS directive in the PLC-object (for the resource or configuration) is deleted.

    (grey lightbulb) In order to unassign the global-object from an ST-program, proceed as follows:

  1. Open the ST-editor for the program.

  2. Search for the INCLUDE_GLOBALS directive, delete the corresponding line and save the change.

    (grey lightbulb) It is possible to undo or redo the assignment as well as the revoking of the assignment of a global-object within the application navigator.

    (grey lightbulb) If you want to declare external variables in POUs based on the global variables of the global object, the application navigator also provides a way to do this. Details: See "Declaring external variables by dragging and dropping global variables into POUs".