24.01.2015 Views

PLC Programming

  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5 - Editors in CoDeSys<br />

• All identifiers up to the last identifier of a line will become declaration variable identifiers<br />

• The type of declaration is determined by the last identifier of the line. In this context, the following<br />

will apply:<br />

B or BOOL gives the result BOOL<br />

I or INT gives the result INT<br />

R or REAL gives the result REAL<br />

S or string gives the result STRING<br />

• If no type has been established through these rules, then the type is BOOL and the last identifier<br />

will not be used as a type (Example 1.).<br />

• Every constant, depending on the type of declaration, will turn into an initialization or a string<br />

(Examples 2. and 3.).<br />

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

• A text after a semicolon (;) becomes a comment (Example 4.).<br />

• All other characters in the line are ignored (e.g., the exclamation point in Example 5.).<br />

Examples:<br />

Shortcut<br />

Declaration<br />

A<br />

A: BOOL;<br />

A B I 2 A, B: INT := 2;<br />

ST S 2; A string ST:STRING(2); (* A string *)<br />

X %MD12 R 5 Real<br />

Number<br />

B !<br />

X AT %MD12: REAL := 5.0;(* Real Number *)<br />

B: BOOL;<br />

Autodeclaration<br />

If the Autodeclaration option has been chosen in the Editor category of the Options dialog box , then a<br />

dialog box will appear in all editors after the input of a variable that has not yet been declared. With<br />

the help of this dialog box, the variable can now be declared.<br />

Dialog Box for Declaration of Variables<br />

With the help of the Class combobox, select whether you are dealing with a local variable (VAR),<br />

input variable( (VAR_INPUT), output variable (VAR_OUTPUT), input/output variable (VAR_INOUT),<br />

or a global variable (VAR_GLOBAL).<br />

With the CONSTANT, RETAIN, PERSISTENT options, you can define whether you are dealing with a<br />

constant or a retain variable<br />

CoDeSys V2.3 5-7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!