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

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

164 The Editors

Declaration Editor

An address (as in %MD12) is extended around the ATATDeclaration>Proc... attribute(Example 4.).

A text after a semicolon (;) becomes a comment (Example 4.).

All other characters in the line are ignored (e.g., the exclamation point in Example 5.).

Examples:

 

Shortcut

Declaration

A

A: BOOL;

A B I 2

A, B: INT := 2;

ST S 2; A string

ST:STRING(2); (* A string *)

X %MD12 R 5 Real Number

X AT %MD12: REAL := 5.0;(* Real

 

Number *)

B !

B: BOOL;

5.2.16Autodeclaration

If the Autodeclaration option has been chosen in the Editor category of the Options dialog box , then a dialog box will appear in all editors after the input of a variable that has not yet been declared. With the help of this dialog box, the variable can now be declared.

x Dialog Box for Declaration of Variables

With the help of the Class combobox, select whether you are dealing with a local variable (VAR), input variable( (VAR_INPUT), output variable (VAR_OUTPUT), input/output variable (VAR_INOUT), or a global variable (VAR_GLOBAL).

With the CONSTANT and RETAIN options, you can define whether you are dealing with a constant or a retain variable

The variable name you entered in the editor has been entered in the Name

field, BOOL has been placed in the Type field. The button opens the Input Assistant dialog which allows you to select from all possible data types.

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

The Editors 165

Declaration Editor

If ARRAY is chosen as the variable type, the dialog for entering array boundaries appears.

x Dialog for determining array boundaries during automatic declaration

For each of the three possible dimensions (Dim.), array boundaries can be entered under Start and End by clicking with the mouse on the corresponding field to open an editing space. The array data type is entered in the Type field.

In doing this, the button can be used to call up an input assistant dialog.

Upon leaving the array boundaries dialog via the OK button, variable declarations in IEC format are set up based on the entries in the Type field in the dialog. Example: ARRAY [1..5, 1..3] OF INT

In the field Initial value, you may enter the initial value of the variable being declared. If this is an array or a valid structure, you can open a special

initialization dialog via the button or <F2>, or open the input assistant dialog for other variable types.

In the initialization dialog for an array you are presented a list of array elements; a mouse click on the space following ":="opens an editing field for entering the initial value of an element.

In the initialization dialog for a structure, individual components are displayed in a tree structure. The type and default initial value appear in brackets after the variable name; each is followed by ":=". A mouse click on the field following ":=" opens an editing field in which you can enter the desired initial value. If the component is an array, then the display of individual fields in the array can be expanded by a mouse click on the plus sign before the array name and the fields can be edited with initial values.

After leaving the initialization dialog with OK, the initialization of the array or the structure appears in the field Initial value of the declaration dialog in IEC format.

Example:

x:=5,field:=2,3,struct2:=(a:=2,b:=3)

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

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