beckhoff TwinCAT 2 PLC Control — 6.1 Global Variables

Ressources Here two local I/O-variables are defined, a local-In (%I*) and a local-Out (%Q*). If you want to configure local I/Os, for variables configuration in the Object Organizer in the Ressources register card, the object Variable_Configuration will generally be available. The object can then be renamed, and other objects can be created for the variables configuration. The editor for variables configuration functions like the declaration editor. Variables for local I/O- configurations must be located between the key words VAR_CONFIG and END_VAR.

The name of such a variable consists of a complete instance path through which the individual POUs and instance names are separated from one another by periods. The declaration must contain an address whose class (Input/output) corresponds to that of the incompletely specified address (%I*, %Q*) in the function block. Also the data type must agree with the declaration in the function block. Configuration variables, whose instance path is invalid because the instance does not exist, are also denoted as errors. On the other hand, an error is also reported if no configuration exists for an instance variable.

In order to receive a list of all necessary configuration variables, the "All Instance Paths" menu item in the "Insert" menu can be used. Example: Assume that the following definition for a function block is given in a program: PROGRAM PLC_PRG VAR Hugo: locio; Otto: locio; END_VAR Then a corrected variable configuration would look this way: VAR_CONFIG PLC_PRG.Hugo.loci AT %IX1.0 : BOOL; PLC_PRG.Hugo.loco AT %QX0.0 : BOOL; PLC_PRG.Hugo.loci AT %IX1.0 : BOOL; PLC_PRG.Otto.loco AT %QX0.3 : BOOL; END_VAR Here two local I/O-variables are defined, a local-In (%I*) and a local-Out (%Q*).

NOTE Be aware not to describe an output, which is used in the variables configuration, additionally within the project or by a variable (AT declaration). This would not be noticed. 'Insert' 'All Instance Paths' With this command a VAR_CONFIG - END_VAR-block is generated that contains all of the instance paths available in the project. Declarations already on hand do not need to be reinserted in order to contain addresses already in existence. This menu item can be found in the window for con-figuration of variables if the project is compiled ( "Project" "Rebuild All" ).

Document Frame If a project is to receive multiple documentations, perhaps with German and English comments, or if you want to document several similar projects that use the same variable names, then you can save yourself a lot of work by creating a docuframe with the "Extras" "Make Docuframe File" command. The created file can be loaded into a desired text editor and can be edited. The file begins with the DOCUFILE line. Then a listing of the project variables follows in an arrangement that assigns three lines to each variable: a VAR line that shows when a new variable comes; next, a line with the na-me of the variable; and, finally, an empty line.

You can now replace this line by using a comment to the variable. You can simply delete any variables that you are unable to document. If you want, you can create several document frames for your project. TwinCAT 2 PLC Control 164 Version: 1.0