Constants - Mitsubishi Electric MELSEC iQ-R Series Programming Manual

Hide thumbs Also See for MELSEC iQ-R Series:
Table of Contents

Advertisement

4.6

Constants

Types of constants
The following table provides information on how to set constants to labels.
Applicable data type
Bit
• Word [unsigned]/bit string [16 bits]
• Double word [unsigned]/bit string [32 bits]
• Word [signed]
• Double word [signed]
• Single-precision real number
• Double-precision real number
• String
• String [Unicode]
Time
*1 In the notation of binary, octal, decimal, hexadecimal, and real numbers, the numbers can be separated using an underscore "_" to
make programs easy to see. (The underscores are ignored in program processing.)
Using "$" in a string type constant
"$" is used as an escape sequence.
Two hexadecimal digits following "$" is recognized as an ASCII code and the character corresponding to the ASCII code is
inserted into the string.
If the two hexadecimal digits following "$" do not correspond to the ASCII code, a conversion error occurs.
Note, however, that no error occurs when the character following "$" is one of the following.
Notation
$$
$'
$"
$L or $l
$N or $n
$P or $p
$R or $r
$T or $t
4 LABELS
48
4.6 Constants
Type
How to set
Boolean
Set FALSE or TRUE.
Binary
Add "2#" before the binary number to be used.
Octal
Add "8#" before the octal number to be used.
Decimal
Directly enter the decimal number to be used. Or, add "K" before
the number.
Hexadecimal
Add "16#" before the hexadecimal number to be used. Or, add
"H" before the number.
*1
Binary
Add "2#" before a binary number.
*1
Octal
Add "8#" before an octal number.
*1
Decimal
Directly enter a decimal number, or add "K" before the number.
*1
Hexadecimal
Add "16#" before a hexadecimal number.
Or, add "H" before the number.
*1
Real number
Directly enter a real number including the decimal point and
numerical values of decimal places. Or, add "E" before the
number.
Real number
Add "E" before the exponential notation or real number, and add
(exponential
"+" or "-" before the exponent.
notation)
String
Enclose a string in single quotation marks (') or double quotation
String [Unicode]
marks (").
Time
Add "T#" at the beginning.
Symbol used in a string or printer code
$
'
"
Line feed
New line
Page feed
Return
Tab
Example
TRUE, FALSE
2#0, 2#1
8#0, 8#1
0, 1, K0, K1
16#0, 16#1, H0, H1
2#0010,
2#01101010,
2#1111_1111
8#0, 8#337, 8#1_1
123, K123, K-123,
12_3
16#FF, HFF, 16#1_1
2.34, E2.34, E-2.34,
3.14_15
1.0E6, E1.001+5,
1.0E-6, E1.001-5
'ABC', "ABC"
T#1h,
T#1d2h3m4s5ms,
TIME#1h

Advertisement

Table of Contents
loading

Table of Contents