Data Types

Data types are defined within the common elements of IECClosed "International Electrotechnical Commission" IEC is a not-for-profit, non-governmental international standards organization that prepares and publishes International Standards for all electrical, electronic and related technologies 61131-3.

Why Data Typing?

Data typing is implemented to define the type of any parameter used. This helps prevent errors early on in the programming phase (e.g., avoids dividing a Date by an Integer).

When you have defined whether the data is a string, a date, an integer or a 16-bit Boolean input, there is no longer any confusion, nor any conflict between different people using the textual representation (i.e., the name of the variable).

Different Kinds of Data Types

  • Common Data Types: Boolean, Integer, Real, Byte, Word, Date, Time_of_Day, and String.
  • Derived Data Types: Define your own personal data types based on the Common data types.
    • Example: Define an analog input channel as a data type and re-use it.

List of Data Types

Available Basic Data Types
Type Prefix Description Values
BOOL   Boolean (bit)
  • FALSE or TRUE
  • Stored in 1 byte
BYTE  

Same as USINT

 
DINT   Signed double precision integer in 32-bits -2147483648 to +2147483647
DWORD  

Same as UDINT

 
INT INT# Signed integer in 16-bits -32768 to +32767
LINT LINT# Long signed integer in 64-bits  
LREAL LREAL# Double precision floating point stored in 64-bits
  • -1.7E308 to +1.7E308
  • -1.7E-308 to +1.7E-308
  • 14 to 15 significant digits of accuracy
LWORD  

Same as ULINT

 
REAL LREAL# ‡‡ Single precision floating point stored in 32-bits
  • -3.4E38 to +3.4E38
  • -3.4E-38 to +3.4E-38
  • 6 to 7 significant digits of accuracy
SINT SINT# Small signed integer in 8-bits -128 to +127
STRING  

Variable length string with declared maximum length.

Each character is store on 1 byte (i.e., on 8-bits)

Maximum length cannot exceed 255 characters
TIME T# or TIME#

Time data type is used to specify a time variable - accuracy is 1ms.

See TIME for more information.

0ms to 24h
UDINT UDINT# Unsigned integer in 32-bits 0 to +4294967295
UINT UINT# Unsigned integer in 16-bits 0 to +65535
ULINT ULINT# Long unsigned integer in 64-bits  
USINT USINT# Small unsigned integer in 8-bits 0 to +255
WORD  

Same as UINT

 

  • ‡ REAL variables are limited to 6 digits of accuracy.
    To achieve greater accuracy, a longer mantissa may be specified by prefixing LREAL with #.

    Example: To achieve an accuracy of 20 digits for the value of Pi, rather than what REAL provides (3.14159), set the type to LREAL#3.141592653589793238.


  • ‡‡ REAL is restrictive, but because it is the default, it is recommended to explicitly declare real constants with the LREAL# prefix.


  • You can use 2#, 8# or 16# prefixes to specify an integer in binary, octal or hexadecimal basis, respectively.