Материал: m912201e

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам

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

The Editors 161

Declaration Editor

5.2.9 Keywords

Keywords are to be written in uppercase letters in all editors. Keywords may not be used as variables.

5.2.10Variables declaration

A variables declaration has the following syntax:

<Identifier> {AT <Address>}:<Type> {:=<initialization>};

The parts in the braces {} are optional.

Regarding the identifier, that is the name of a variable, it should be noted that it may not contain spaces or umlaut characters, it may not be declared in duplicate and may not be identical to any keyword. Upper/lowercase writing of variables is ignored, in other words VAR1, Var1 and var1 are not different variables. Underlines in identifiers are meaningful, e.g. A_BCD and AB_CD are interpreted as different identifiers. Multiple consecutive underlines at the beginning of an identifier or within a identifier are not allowed. The length of the identifier, as well as the meaningful part of it, are unlimited.

All declarations of variables and data type elements can include initialization. They are brought about by the ":=" operator. For variables of elementary types, these initializations are constants. The default-initialization is 0 for all declarations.

Example:

var1:INT:=12;

(* Integer variable with initial value

of 12*)

 

If you wish to link a variable directly to a definite address, then you must declare the variable with the keyword AT.

For faster input of the declarations, use the shortcut mode.

In function blocks you can also specify variables with incomplete address statements. In order for such a variable to be used in a local instance, there must be an entry for it in the variable configuration.

Pay attention to the possibility of an automatic declaration

An identifier is a sequence of letters, numbers, and underscores that begins with a letter or an underscore.

The variable identifier may not contain any blank spaces or special characters, may not be declared more than once and cannot be the same as any of the keywords. Capitalization is not recognized which means that VAR1, Var1, and var1 are all the same variable. The underscore character is recognized in identifiers (e.g., "A_BCD" and "AB_CD" are considered two different

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

162 The Editors

Declaration Editor

identifiers). An identifier may not have more than one underscore character in a row. The first 32 characters are significant.

5.2.11AT Declaration

If you wish to link a variable directly to a definite address, then you must declare the variable with the keyword AT. The advantage of such a procedure is that you can assign a meaningful name to an address, and that any necessary changes of an incoming or outgoing signal will only have to be made in one place (e.g., in the declaration).

Notice that variables requiring an input cannot be accessed by writing. A further restriction is that AT declarations can only be made for local and global variables, and not for inputand output variables from POUs.

Examples:

counter_heat7 AT %QX0.0: BOOL;

lightcabinetimpulse AT %IX7.2: BOOL;

download AT %MX2.2: BOOL;

Note:

If boolean variables are assigned to a Byte, Word or DWORD address, they occupy one byte with TRUE or FALSE, not just the first bit after the offset!

5.2.12'Insert' 'Declarations keywords'

You can use this command to open a list of all the keywords that can be used in the declaration part of a POU. After a keyword has been chosen and the choice has been confirmed, the word will be inserted at the present cursor position.

You also receive the list, when you open the Input Assistant (<F2>) and choose the Declarations category.

5.2.13'Insert' 'Type'

With this command you will receive a selection of the possible types for a declaration of variables. You also receive the list when you access the Input Assistant (<F2>).

The types are divided into these categories:

 

Standard types

BOOL, BYTE, etc.

 

Defined types

Structures, enumeration types, etc.

 

Standard function blocks

for instance declarations

 

Defined function blocks

for instance declarations

WAGO-I/O-PRO 32 supports all standard types of IEC1131-3:

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

The Editors 163

Declaration Editor

Examples for the use of the various types are found in the Appendix F.

5.2.14Syntax Coloring

In all editors you receive visual support in the implementation and declaration of variables. Errors are avoided, or discovered more quickly, because the text is displayed in color.

A comment left unclosed, thus annotating instructions, will be noticed immediately; keywords will not be accidentally misspelled, etc.

The following color highlighting will be used:

Blue

Keywords

Green

Comments in the text editors

Pink

Special constants (e.g. TRUE/FALSE, T#3s,

 

%IX0.0)

Red

Input error (for example, invalid time constant,

 

keyword, written in lower case,...)

Black

Variables, constants, assignment operators, ...

5.2.15Shortcut Mode

The declaration editor for WAGO-I/O-PRO 32 allows you to use the shortcut mode. This mode is activated when you end a line with <Ctrl><Enter>

The following shortcuts are supported:

All identifiers up to the last identifier of a line will become declaration variable identifiers

The type of declaration is determined by the last identifier of the line. In this context, the following will apply:

B or BOOL

gives the result

BOOL

I or INT

gives the result

INT

R or REAL

gives the result

REAL

S or string

gives the result

STRING

If no type has been established through these rules, then the type is BOOL and the last identifier will not be used as a type (Example 1.).

Every constant, depending on the type of declaration, will turn into an initialization or a string (Examples 2. and 3.).

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