6-67
6 Programming
NJ-series CPU Unit Software User’s Manual (W501)
6-4 Constants (Literals)
6
6-4-1 Constants
6-4 Constants (Literals)
This section describes constants in detail.
The value of a variable changes depending on the data that is assigned to that variable. The value of a
constant never changes. Unlike variables, constants are not stored in memory. You can use constants
in the algorithm of a POU without the need to declare them. In the NJ-series Controllers, constants
have a data type in the same way as variables,
The following types of constants can be used with NJ-series Controllers.
• Bits
• Numbers
• Bit strings
• Times
• Text strings
• Enumerators of enumerated variables
The following tables show the notation for different constants in an NJ-series Controller. A building error
is detected if you use any other notation in programming.
Precautions for Correct UsePrecautions for Correct Use
You cannot express a BOOL value as 0 or 1. A building error will occur.
Example: Wrong: BOOL_variable:=1;
Correct: BOOL_variable:=TRUE; or BOOL_variable:=BOOL#1;
Integers
6-4-1 Constants
6-4-2 Types of Constants
Bits
Notation Example Remarks
TRUE or FALSE TRUE or FALSE TRUE is equivalent to BOOL#1.
FALSE is equivalent to BOOL#0.
{data_type}#{numeric_value] BOOL#1 or BOOL#0
Numbers
Notation Example Remarks
{data_type}#{base}#{numeric_value] INT#10#1 • Data types: SINT, USINT, INT, UINT, DINT, UDINT,
LINT, or ULINT
• Base: 2, 8, 10, or 16
{data_type}#{numeric_value]INT#1 This is interpreted as decimal data.
{numeric_value} 1 This is interpreted as DINT decimal data.