Reference (Variables)

Variable Data Types

A variable's data type determines the type of data that you can store in the variable.

There are 2 groups of variable types: basic variables and user data type variables.

BOOL

BOOL variable stores either 0 or 1.

SINT, USINT, INT, UINT, DINT, UDINT, LINT, ULINT, BYTE

The data range for a variable varies depending on: Data Length and Signed.

Integer type variables:

Data Range for Integer Types:

Integer Type

Signed

Data Length

Data Range

SINT

2's complement

8 bit

-128 to 127

USINT

-

8 bit

0 to 255

INT

2's complement

16 bit

-32768 to 32767

UINT

-

16 bit

0 to 65535

DINT

2's complement

32 bit

-2147483648 to 2147483647

UDINT

-

32 bit

0 to 4,294,967,295

LINT

2's complement

64 bit

-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

ULINT

-

64 bit

0 to 18,446,744,073,709,551,615

BYTE

-

8 bit

0 to 255

WORD, DWORD, LWORD

Data Range for Word Types :

Word Type Data Length Data Range

WORD

16 bit

0...65,535

DWORD

32 bit

0...4,294,967,295

LWORD

64 bit

0...18,446,744,073,709,551,615

STRING, WSTRING

STRING variable stores from 1 to 512 bytes.

You can define the number of bytes the string can store in the [Number of Bytes/Words] property.

WSTRING variable stores multi-byte strings, up to 512 words.

You can define the number of words the multi-byte strings can store in the [Number of Bytes/Words] property.

Note: The WSTRING variable is available only when an external device is added to the System Configuration.

REAL, LREAL

REAL variables can hold larger values than integer types. You can use REAL variables to store calculations, constants, and so on, when data precision is not an issue. If data precision is necessary, use an integer type.

Data Range for Real Types:

Real Type Data Length Data Range
REAL

32 bit

+/-3.402823E38 to +/-1.1754944E-38

LREAL

64 bit

+/-4.19E-307 to +/-1.67E308

Although REAL variables can store large values, their precision is limited to seven digits (Example: In the value 1.2345678, only the first seven digits (1.234567) are guaranteed. Any digits after the first seven are calculated approximations only).

In an operating display unit, processing a REAL variables takes more time than processing an integer type variable.

Note:

TIME

TIME stores the duration of time.

Range: -T#24d20h31m23s648ms...+T#24d20h31m23s647ms

DATE

DATE stores the date.

Range:

Supported Model

Range

SP5000 Series Open Box (SP-5B40)

IPC Series

1970/01/01 00:00:00 UTC ... 2106/02/07 06:28:15 UTC

SP5000 Series Power Box (SP-5B10)

GP4000 Series

GP-4100 Series

1970/01/01 00:00:00 UTC ... 2038/01/19 03:14:07 UTC

TIME_OF_DAY

Clock time.

Range: TOD#00:00:00 ... TOD#23:59:59

TOD

Clock time.

Range: TOD#00:00:00 ... TOD#23:59:59

DATE_AND_TIME

Date and time combines DATE and TIME_OF_DAY.

DT

Date and time combines DATE and TIME_OF_DAY.

Readable or Writable Property

Property Description Data Type Minimum Value Maximum Value Read Write
InitialValue Stores the initial value for the internal variable. BOOL, Integer, Real, Date, Time, Date And Time, String Default value of the selected data type. Default value of the selected data type. -
Min Stores the minimum value for data input to the variable. BOOL, Integer, Real, Date, Time, Date And Time, String Default value of the selected data type. Default value of the selected data type. -
Max Stores the maximum value for data input to the variable. BOOL, Integer, Real, Date, Time, Date And Time, String Default value of the selected data type. Default value of the selected data type. -
Value Stores the variable value. BOOL, Integer, Real, Date, Time, Date And Time, String Default value of the selected data type. Default value of the selected data type.
Quality Displays the scan status of the selected variable.
0 VARIABLE_QUALITY_GOOD (0x00)
1 VARIABLE_QUALITY_BAD (0x01)
 
Integer 0 1 -