There are two types of 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. |
These variables store word type values. | |
These variables store text strings. | |
These variables store floating point values. REAL variables can store larger values (such as calculations and constants) than integer type variables. | |
These variables store time and date values. |
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 |
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 |
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.
|
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. |
You can define the number of bytes or words the variable can store in the [Number of Bytes/Words] property.
Recognizes the end of the text string with a NULL (0x00) or [Number of Bytes].
For a selected variable or driver, if you use a text whose character code cannot be converted by the [String Encode], then the end of the string is recognized by character code.
The relationship of high/low order for word data depends on [String Mode] in the selected driver.
Data Type | Data Length | Data Range |
REAL | 32 bit |
+/-3.402823E38 ... +/-1.1754944E-38 |
LREAL | 64 bit |
+/-4.19E-307 ... +/-1.67E308 |
The precision of REAL variables is limited
to seven digits. If data precision is required (such as comparison
operations), use integer variables.
Examples
Example 1: For the value 1.2345678, the resulting value is approximate
as the eighth digit is dropped (after 1.234567).
Example 2: The value 0.1 stored in a REAL variable could result
in 0.1000000014901161.
When using external REAL variables, make sure that the Double Word Order setting in the Device Configuration matches the setting in the equipment. If the settings do not match, the values of the external REAL variables will not be displayed properly.
Use period
(.) for decimal point of the variable value. The comma (,) is
not supported for the decimal points.
Even if comma (,) is used for decimal point of the variable value
in the screen editing software or display unit, unexpected results,
like that error is shown, the comma is ignored, or so on.
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
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 · Models other than those
above |
When using these variables,
match the data types on the external device with the value of
the stored data.
If you have entered the value which is not in range of the external
device address, then the entered value displays on the screen,
but it is not set in the external device address.
When you associate variables with different data types, sometimes the value of the source variable gets overwritten with a common result value.
For example, convert a Real variable to an Integer variable: Set 123.4 to a REAL variable, then write the value to an INT variable and the result is 123. The value of the REAL variable is also updated to 123.
When an integer value is input to the DATE_AND_TIME variable from an External Device, the stored value is offset by the time zone of the display unit. Therefore, for the integer value input, the date and time displayed by a Date/Time Display differ depending on the time zone.
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 |
The following are the types of user data type variables.
Array holders and structure holders are also counted as 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.
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.
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 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.
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:
You can use in [Expression] converter.
(Example: Array11[DINT1.value+2], Array21[Int2[Int3[Int1+1]]], Array31[Int1*4-(Int2+Int4/4)])
A maximum 5 levels of nesting is supported for
all variable data types.
(Example: Array11[Array22[DINT1.value],DINT02.value])
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.
When the value to store in the variable is outside the range (minimum/maximum value), the value is treated as follows.
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.) |
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.)
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.
|
Value is not stored.
Data Type | Description |
BOOL, REAL, LREAL |
Value is not stored. |
LINT, ULINT, LWORD |
The following are rounded to the top or bottom value.
|
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.) |