Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
21
Добавлен:
11.10.2020
Размер:
3.39 Mб
Скачать

The Editors 157

Declaration Editor

5.1.1.3 Zoom to POU

Shortcut: <Alt>+<Enter>

With this command a selected POU is loaded into its editor. The command is available in the context menu (<F2>) or in the 'Extras' menu, if the cursor is positioned on the name of a POU in a text editor or if the POU box is selected in a graphic editor.

If you are dealing with a POU from a library, then the library manager is called up, and the corresponding POU is displayed.

5.1.1.4 Open instance

This command corresponds to the 'Project' 'Open instance' command.

This command corresponds to the command 'Project' 'Open instance'. It is available in the context menu (<F2>) or in the 'Extras' menu, if the cursor is positioned on the name of a function block in a text editor or if the function block box is selected in a graphic editor.

5.2 Declaration Editor

The declaration editor is used to declare variables of POUs and global variables, for data type declarations, and in the Watch and Receipt Manager. It gives access to the usual Windows functions, and even those of the IntelliMouse can be used if the corresponding driver is installed.

In Overwrite mode, 'OV' is shown in black on the status bar; switching between Overwrite and Insert modes can be accomplished with the <Ins> key.

The declaration of variables is supported by syntax coloring.

The most important commands are found in the context menu (right mouse button or <Ctrl>+<F10>).

5.2.1 Declaration Part

All variables to be used only in this POU are declared in the declaration part of the POU. These can include: input variables, output variables, input/output variables, local variables, retain variables, and constants. The declaration syntax is based on the IEC61131-3 standard. An example of a correct declaration of variables in WAGO-I/O-PRO 32-Editor:

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

158 The Editors

Declaration Editor

5.2.2 Input Variable

Between the key words VAR_INPUT and END_VAR, all variables are declared that serve as input variables for a POU. That means that at the call position, the value of the variables can be given along with a call.

Example:

VAR_INPUT

in1:INT

(* 1. Inputvariable*)

END_VAR

5.2.3 Output Variable

Between the key words VAR_OUTPUT and END_VAR, all variables are declared that serve as output variables of a POU. That means that these values are carried back to the POU making the call. There they can be answered and used further.

Example:

VAR_OUTPUT

out1:INT; (* 1. Outputvariable*)

END_VAR

5.2.4 Input and Output Variables

Between the key words VAR_IN_OUT and END_VAR, all variables are declared that serve as input and output variables for a POU.

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

The Editors 159

Declaration Editor

Attention:

With this variable, the value of the transferred variable is changed ("transferred as a pointer", Call-by-Reference). That means that the input value for such variables cannot be a constant. For this reason, even the VAR_IN_OUT variables of a function block can not be read or written directly from outside via <functionblockinstance><in/outputvariable>.

Example:

VAR_IN_OUT

inout1:INT;

(* 1. Inputoutputvariable *)

END_VAR

5.2.5 Local Variables

Between the keywords VAR and END_VAR, all of the local variables of a POU are declared. These have no external connection; in other words, they can not be written from the outside.

Example:

VAR

loc1:INT; (* 1. Local Variable*)

END_VAR

5.2.6 Remanent variables

Remanent variables can retain their value throughout the usual program run period. These include Retain variables and Persistent variables.

Retain variables are identified by the keyword RETAIN. These variables maintain their value even after an uncontrolled shutdown of the controller, or a reset. When the program is run again, the stored values will be processed further. A practical example would be an operations timer that recommences timing after a power failure.

All other variables are newly initialized, either with their initialized values or with the standard initializations.

Persistent variables are identified by the keyword PERSISTENT. Unlike Retain variables, these variables retain their value even after a cold start, that is when the controller is shut down and restarted in an orderly fashion, or after a download. Persistent variables are not automatically Retain variables !

Example:

VAR RETAIN

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

160 The Editors

Declaration Editor

rem1:INT; (* 1. Retain variable*)

END_VAR

5.2.7 Constants, Typed Literals

Constants are identified by the key word CONSTANT. They can be declared locally or globally.

Syntax:

VAR CONSTANT

<Identifier>:<Type> := <initialization>;

END_VAR

Example:

VAR CONSTANT

con1:INT:=12;

(* 1. Constant*)

END_VAR

A listing of possible constants can be found in the Chapter Operands of the Online Help chapters. See there also regarding the possibility of using typed constants (Typed Literals).

5.2.8 External variables

Global variables which are to be imported into the POU are designated with the keyword EXTERNAL. They also appear in the Watch window of the declaration part in Online mode.

If the VAR_EXTERNAL declaration does not match the global declaration in every respect, the following error message appears: "Declaration of '<var>' does not match global declaration!"

If the global variable does not exist, the following error message appears: "Unkown global variable: '<var>'!"

Example:

VAR EXTERNAL

var_ext1:INT:=12;

(* 1st external variable *)

END_VAR

WAGO-I/O-SYSTEM 759 WAGO-I/O-PRO 32

Соседние файлы в папке 759-332