24.01.2015 Views

PLC Programming

  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Constants<br />

(see also Appendix C: Datentypen, Time Data Types)<br />

DATE_AND_TIME Constants<br />

Date constants and the time of day can also be combined to form so-called DATE_AND_TIME<br />

constants. DATE_AND_TIME constants begin with "dt#", "DT#", "DATE_AND_TIME#" or<br />

"date_and_time#". Place a hyphen after the date followed by the time.<br />

Examples:<br />

DATE_AND_TIME#1996-05-06-15:36:30<br />

dt#1972-03-29-00:00:00<br />

(see also Appendix C: Datentypen, Time Data Types)<br />

Number Constants<br />

Number values can appear as binary numbers, octal numbers, decimal numbers and hexadecimal<br />

numbers. If an integer value is not a decimal number, you must write its base followed by the number<br />

sign (#) in front of the integer constant. The values for the numbers 10-15 in hexadecimal numbers will<br />

be represented as always by the letters A-F.<br />

You may include the underscore character within the number.<br />

Examples:<br />

14 (decimal number)<br />

2#1001_0011 (dual number)<br />

8#67 (octal number)<br />

16#A (hexadecimal number)<br />

These number values can be from the variable types BYTE, WORD, DWORD, SINT, USINT, INT,<br />

UINT, DINT, UDINT, REAL or LREAL.<br />

Implicit conversions from "larger" to "smaller" variable types are not permitted. This means that a<br />

DINT variable cannot simply be used as an INT variable. You must use the type conversion.<br />

REAL/LREAL Constants<br />

REAL and LREAL constants can be given as decimal fractions and represented exponentially. Use<br />

the standard American format with the decimal point to do this.<br />

Example:<br />

7.4 instead of 7,4<br />

1.64e+009 instead of 1,64e+009<br />

STRING Constants<br />

A string is a sequence of characters. STRING constants are preceded and followed by single<br />

quotation marks. You may also enter blank spaces and special characters (umlauts for instance).<br />

They will be treated just like all other characters.<br />

In character sequences, the combination of the dollar sign ($) followed by two hexadecimal numbers<br />

is interpreted as a hexadecimal representation of the eight bit character code. In addition, the<br />

combination of two characters that begin with the dollar sign are interpreted as shown below when<br />

they appear in a character sequence:<br />

$$ Dollar signs<br />

$'<br />

$L or $l Line feed<br />

$N or $n New line<br />

Single quotation mark<br />

10-26 CoDeSys V2.3

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

Saved successfully!

Ooh no, something went wrong!