Data Types

There are two types of variables.

 

Note:

 

Basic Variables

The following is a list of the types of basic variables.

Data Type

Description

BOOL This variable stores either 0 or 1.
SINT, USINT, INT, UINT, DINT, UDINT, LINT, ULINT, BYTE These variables store integral values. Processing is faster compared to floating point type variables.

WORD, DWORD, LWORD

These variables store word type values.

STRING, WSTRING

These variables store text strings.

REAL, LREAL

These variables store floating point values. REAL variables can store larger values (such as calculations and constants) than integer type variables.

TIME, DATE, TIME_OF_DAY, DATE_AND_TIME

These variables store time and date values.

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

Data Type

Signed

Data Length

Data Range

SINT

2's complement

8 bit

-128...127

USINT

-

8 bit

0...255

INT

2's complement

16 bit

-32768...32767

UINT

-

16 bit

0...65535

DINT

2's complement

32 bit

-2147483648...2147483647

UDINT

-

32 bit

0...4,294,967,295

LINT

2's complement

64 bit

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

ULINT

-

64 bit

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

BYTE

-

8 bit

0...255

WORD, DWORD, LWORD

Data 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

Data Type Description

STRING

Stores up to 512 bytes of text.

When using an external variable, string encoding is defined by the variable's [String Encode] property.

Available string encode values are: UTF8, UTF16, ShiftJIS, Code Page850, GB2312, BIG5, KSC5601, CodePage1251, CodePage874, and CodePage1252.

Note:

  • You can also configure string encoding in equipment properties. The variable property setting takes priority over the equipment property. In the variable's [String Encode] property, select [Equipment Setting Type] to apply the equipment's string encode setting.
  • The [String Encode] property is displayed only when the driver supports string encoding.

WSTRING

Stores up to 512 words of double-byte text.

You can use the WSTRING data type with external variables only.

String encoding is fixed as UTF16. You cannot change the [String Encode] setting in the variable properties, and the encoding in equipment properties is ignored.

Note:

REAL, LREAL

Data Type Data Length Data Range
REAL

32 bit

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

LREAL

64 bit

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

Note:

TIME, DATE, TIME_OF_DAY, DATE_AND_TIME

Data Type Description Data Range

TIME

Stores the elapsed time in days and time. - 24 d 20 h 31 m 23 s 648 ms ... 24 d 20 h 31 m 23 s 647 ms

Note: When a negative value is set for [Initial value] and [Input range] properties in a TIME variable, the negative sign will display for each time unit. (Example: -24d -20:-31:-23.-648)

DATE Stores the date.

·        When Using SP5000 Series Open Box (Windows 10 IoT Enterprise Model), IPC Series, or PC/AT

1970/01/01 ... 2106/02/07

·        Models other than those above

1970/01/01 ... 2038/01/19

TIME_OF_DAY Stores the time. 00:00:00 ... 23:59:59

DATE_AND_TIME

Combines the DATE and TIME_OF_DAY.

·        When Using SP5000 Series Open Box (Windows 10 IoT Enterprise Model), IPC Series, or PC/AT
1970/01/01 00:00:00 UTC ... 2106/02/07 06:28:15 UTC

·        Models other than those above
1970/01/01 00:00:00 UTC ... 2038/01/19 03:14:07 UTC

Note:

SP5000 Series Open Box (Windows 10 IoT Enterprise Model), IPC Series, or PC/AT

Integer Value Input from External Device UTC+0
(Range: 1970/01/01 00:00:00 ... 2106/02/07 06:28:15)
UTC+9
(Range: 1970/01/01 09:00:00 ... 2106/02/07 15:28:15)
0 1970/01/01 00:00:00 2106/02/07 06:28:16
1 1970/01/01 00:00:01 2106/02/07 06:28:17
: : :
32399 1970/01/01 08:59:59 2106/02/07 15:28:15
32400 1970/01/01 09:00:00 1970/01/01 09:00:00
: : :
4294967295 2106/02/07 06:28:15 2106/02/07 06:28:15


Models other than those above

Integer Value Input from External Device UTC+0
(Range: 1970/01/01 00:00:00 ... 2038/01/19 03:14:07)
UTC+9
(Range: 1970/01/01 09:00:00 ... 2038/01/19 12:14:07)
0 1970/01/01 00:00:00 2038/01/19 03:14:08
1 1970/01/01 00:00:01 2038/01/19 03:14:09
: : :
32399 1970/01/01 08:59:59 2038/01/19 12:14:07
32400 1970/01/01 09:00:00 1970/01/01 09:00:00
: : :
2147483647 2038/01/19 03:14:07 2038/01/19 03:14:07

User Data Type Variables

The following are the types of user data type variables.

 

Note: Array holders and structure holders are also counted as variables.

 

Array Variables

An array is a collection of variables with the same data type. Each variable in an array is called an element.

To understand how an array variable works, think of a variable as a box. As shown in the following diagram, the variable Number is a single box containing one value.

Think of an array as a row of boxes with a number associated with each box. In the following diagram, the array variable Number contains 5 elements 0-4. Variable values are stored in each of the 5 boxes.

To specify each variable in an array, specify the variable name followed by the element number enclosed in square brackets [ ].

(Example) Array with 5 elements

The element number usually starts with 0, but can also start with a positive or negative value.

(Example) Array starting with element number -1 with 5 elements

 

 

A multidimensional array is an array that contains other arrays. For example, an array that contains two DINT arrays is a two-dimensional array.

 

Number of Elements in Each Dimension and Dimension Settings

In the [Project Explorer] window, from [Variables] → [All User Data Types] → [Arrays], in the [Dimension] column, set both array dimension and number of elements.

For the steps in designing an array, refer to the following.

Steps to Design (Variables, Array, Structure)

For a 1-dimensional array, only specify the elements in the array.

(Example) For a 1-dimensional array with number of elements = 3, enter "3".

 

 

For a multidimensional array, in the [Dimension] field, specify the number of elements in each dimension, separated by a comma (,).

(Example) For a two-dimensional array where the first dimension has 3 elements (start number = 0) and the second dimension has 4 elements (start number = 0), enter "3,4".

 

 

This array definition is used to create the array variable Var1, shown below.

 

 

Note: To set the starting number of an element to something other than 0, instead of the number of elements, enter the starting and last element numbers separated by two periods (..) and the [Number of Elements] field calculates the total number of elements.

 

(Example) To set up a two-dimensional array where the first dimension has 3 elements starting from element 0, and the second dimension has 4 elements starting from element 3, enter "3,3..6".

 

After input, "3..6" is converted to 4 elements, and its array dimension starts from element number 3.

 

 

This array creates the array variable Var1, shown below.

 

 

Indirect Addressing of Array

Indirect addressing is the fastest way to access a variable value within a range of consecutive values in an array, to minimize memory consumption, and to update the value within milliseconds.

For indirect addressing of arrays, specify the array element number through a variable value or the property value of an object to specify the element of an array dynamically.

Note:

When specifying an array element number indirectly with the property value of an object, enter "$GraphicalObject" before the object name.
Depending on the input assistance function, after typing "$" in the input or source property field, from the list of options you can select "$GraphicalObject" to enter the string easily.

 

The indirect addressing of an array supports the following:

 

Structure Variables

A structure is a variable that holds a collection of other variables. Each variable in a structure is called an element. An element can be of any data type.

You can create a nested structure by adding another structure or an array as an element.

Think of a structure as a group of boxes with an element associated with each box.

In the following diagram, the structure variable DATA contains 3 elements. Variable values are stored in each of the 3 boxes.

Operation When Input Value is Outside the Input Range

When the value to store in the variable is outside the range (minimum/maximum value), the value is treated as follows.

 

Note:

 

When the value is exceeded on the external device

Data Type Description

STRING, WSTRING

Stores the characters that can fit.
Other than the above

The value of the portion that exceeds the input range is re-counted from the bottom of the input range and stored.

Example) Unsigned 8 bit variable (value range: 0...255)

Example 1: If you try storing 256, 0 is stored in the variable. (As the top limit is exceeded by 1, the bottom limit value of 0 is stored.)

Example 2: If you try storing 257, 1 is stored in the variable. (As the top limit is exceeded by 2, the second value from the bottom limit 1 is stored.)

 

When the value is exceeded with a Value Change operation [Loop]

The value of the portion that exceeds the input range is re-counted from the bottom of the input range and stored.

(Example): Unsigned 8 bit variable (value range: 0...255)

Example 1: If you try storing 256, 0 is stored in the variable. (As the top limit is exceeded by 1, the bottom limit value of 0 is stored.)

Example 2: If you try storing 257, 1 is stored in the variable. (As the top limit is exceeded by 2, the second value from the bottom limit 1 is stored.)

When the value is exceeded with a Value Change operation [Stop]

Data Type Description

STRING, WSTRING

Stores the characters that can fit.
Other than the above

The following are rounded to the top or bottom value.

  • BOOL
    1/0
  • SINT
    127/-128
  • USINT, BYTE
    255/0
  • INT
    32767/-32768
  • UINT, WORD
    65535/0
  • DINT
    2147483647/-2147483648
  • UDINT, DWORD
    4294967295/0
  • LINT
    9223372036854775807/-9223372036854775808
  • ULINT, LWORD
    18446744073709551615/0
  • REAL, LREAL
    Differs depending on the property setting.
  • TIME
    2147483647/-2147483648
  • DATE/TIME_OF_DAY, DATE_AND_TIME
    4294967295/0

 

When the value is exceeded with a Value Change [Set] operation, indirectly specified value, or Expression converter operation

Value is not stored.

When the value is exceeded with a recipe

Data Type Description

BOOL, REAL, LREAL

Value is not stored.

LINT, ULINT, LWORD

The following are rounded to the top or bottom value.

  • LINT
    9223372036854775807/-9223372036854775808
  • ULINT, LWORD
    18446744073709551615/0

STRING, WSTRING

Stores the characters that can fit.
Other than the above

The value of the portion that exceeds the input range is re-counted from the bottom of the input range and stored.

(Example): Unsigned 8 bit variable (value range: 0...255)

Example 1: If you try storing 256, 0 is stored in the variable. (As the top limit is exceeded by 1, the bottom limit value of 0 is stored.)

Example 2: If you try storing 257, 1 is stored in the variable. (As the top limit is exceeded by 2, the second value from the bottom limit 1 is stored.)