Ilek Technologies

PLC Programming Data Types

Industrial Automation Feb 19, 2026 334 views
PLC Programming Data Types

Introduction: Why Data Types Matter in PLC Programming

Every variable in a PLC program must have a clearly defined Data Type. The data type tells the PLC controller three fundamental things: what kind of data the variable holds (a number, a truth value, a string of text, a time value), how many bytes of memory it occupies, and what operations are legally permitted on it.

Choosing the wrong data type is one of the most common causes of bugs, unexpected behavior, and even dangerous faults in industrial automation systems. For example, storing a temperature value of 1,250°C in a BYTE variable (which can only hold 0-255) will cause an overflow, corrupting your measurement. Treating a 16-bit INTEGER as a 32-bit DWORD when reading from a Modbus register will produce completely wrong values.

Mastering data types is the foundation of professional, reliable PLC programming.

 

Categories of PLC Data Types

PLC data types are organized into several broad categories. Understanding these categories first makes it easier to learn the individual types:

CategoryWhat It RepresentsExamples
Boolean / BitTrue/False values, single binary bitsBOOL, BIT
Integer (Unsigned)Whole numbers - positive onlyBYTE, USINT, UINT, UDINT, ULINT
Integer (Signed)Whole numbers - positive and negativeSINT, INT, DINT, LINT
Floating Point (Real)Decimal / fractional numbersREAL, LREAL
Time & DurationTime spans, durations, datesTIME, DATE, TIME_OF_DAY, DATE_AND_TIME
String / CharacterText, alphanumeric dataSTRING, WSTRING, CHAR
Bit StringGroups of bits treated as a unitBYTE, WORD, DWORD, LWORD
Derived / ComplexUser-defined structures and arraysSTRUCT, ARRAY

1. BOOL - Boolean Data Type

What is BOOL?

The BOOL (Boolean) data type is the simplest and most fundamental data type in PLC programming. It stores exactly one of two possible values:

  • TRUE (also represented as 1, ON, or HIGH)
  • FALSE (also represented as 0, OFF, or LOW)

Even though a BOOL logically represents a single bit, most PLCs allocate at least 1 byte (8 bits) of memory to store a BOOL variable for alignment reasons. Some PLCs pack multiple BOOLs into a single byte when they are declared together in a structure or data block.

Memory Size & Value Range

Data TypeMemory SizePossible ValuesIEC 61131-3 Compliant
BOOL1 bit (typically 1 byte allocated)0 (FALSE) or 1 (TRUE)Yes

Where BOOL is Used

  • Representing the state of digital inputs: Is the pushbutton pressed? Is the sensor detecting an object?
  • Representing the state of digital outputs: Is the motor starter coil energized? Is the warning light ON?
  • Control flags in PLC programs: Has the sequence reached Step 5? Is the machine in Auto mode?
  • Enable/disable bits for timers, counters, and function blocks
  • Alarm and fault bits
  • Safety interlock signals

2. Integer Data Types

Overview of Integer Types

Integer data types store whole numbers without decimal points. They are used when the value you are working with is always a whole number - a counter value, a step number in a sequence, a raw ADC count, or a number of parts produced.

The key distinctions between integer types are: (1) whether they are signed (can hold negative values) or unsigned (positive only), and (2) how many bits they use, which determines their value range.

Type NameSigned?Bit WidthByte SizeMinimum ValueMaximum ValueIEC 61131-3
BOOLNo1 bit1 byte*01Yes
BYTENo8 bits1 byte0255Yes (bit string)
USINTNo (Unsigned)8 bits1 byte0255Yes
SINTYes (Signed)8 bits1 byte-128127Yes
UINTNo (Unsigned)16 bits2 bytes065,535Yes
INTYes (Signed)16 bits2 bytes-32,76832,767Yes
UDINTNo (Unsigned)32 bits4 bytes04,294,967,295Yes
DINTYes (Signed)32 bits4 bytes-2,147,483,6482,147,483,647Yes
ULINTNo (Unsigned)64 bits8 bytes018.4 × 10¹⁸Yes
LINTYes (Signed)64 bits8 bytes-9.2 × 10¹⁸9.2 × 10¹⁸Yes

When to Use Integer

  • Scaled analog input values (e.g., raw counts from 4-20mA inputs: typically 0-27648 in Siemens TIA Portal, 0-32767 in some other systems)
  • Counter values (parts counted, cycles completed)
  • Setpoints that don't need decimal precision
  • Position values in simple motion systems (in steps or encoder counts)
  • Modbus register values (Modbus registers are inherently 16-bit)

3. REAL and LREAL - Floating-Point Data Types

What Are Floating-Point Types?

Floating-point data type store numbers with decimal points. They are essential whenever you need fractional precision - process temperatures like 87.4°C, flow rates like 12.75 litres/minute, PID output values like 63.2%, or calculated results from mathematical operations.

PLC floating-point types follow the IEEE 754 standard for binary floating-point arithmetic - the same standard used by computers and calculators worldwide.

TypeBit WidthBytesPrecision (Decimal Digits)RangeStandard
REAL32 bits4 bytes~7 significant digits±1.18 × 10⁻³⁸ to ±3.4 × 10³⁸IEEE 754 Single
LREAL64 bits8 bytes~15-16 significant digits±2.23 × 10⁻³⁰⁸ to ±1.8 × 10³⁰⁸IEEE 754 Double

When to Use REAL

  • Scaled analog process values: temperature, pressure, flow, level after engineering unit conversion
  • PID controller setpoints, process variables, and outputs
  • Mathematical calculations: square roots, trigonometric functions, exponentials
  • Physical constants: PI, gravitational constant, conversion factors
  • Averaging calculations, RMS computations
  • Any variable that needs to represent values that are not whole numbers

When to Use LREAL

  • High-precision scientific calculations requiring more than 7 significant digits
  • Large accumulator values where REAL precision would cause drift (e.g., totalizing a flow meter over weeks)
  • Financial calculations on high-end automation systems

4. Bit String Data Types - BYTE, WORD, DWORD, LWORD

What Are Bit String Types?

Bit string data type store groups of bits that are treated as a collective unit rather than a numeric value. While they share the same memory sizes as their unsigned integer counterparts, the semantic difference is important: bit string types are for bit-level operations (AND, OR, XOR, bit shift), not arithmetic.

TypeBit WidthBytesTypical Use
BYTE8 bits1 byteStatus byte, compact flag storage, Modbus coil groups
WORD16 bits2 bytesDevice status words, communication data, register values
DWORD32 bits4 bytesExtended status, IP addresses, large bit masks
LWORD64 bits8 bytesVery large bit fields, specialized communication

Practical Uses of Bit String Types

  • Status Words: A single WORD can pack 16 individual status bits from a variable speed drive (fault bits, warning bits, run status, direction, etc.) into one 16-bit register, matching how the drive communicates over PROFIBUS or EtherNet/IP.
  • Modbus Communication: Modbus protocol transmits data as 16-bit registers. Receiving device status packed as bits in a WORD is a standard practice.
  • Compact Flag Storage: Instead of 8 separate BOOL variables, one BYTE can store 8 flags, saving memory in large applications.
  • Bitwise Operations: Masking specific bits, setting or clearing individual bits, checking bit patterns.

5. Time and Date Data Types

Overview

Time-related data types are some of the most unique and powerful features of IEC 61131-3 compliant PLC systems. Industrial automation constantly deals with time: timer durations, timestamps, scheduling, elapsed time measurement, and date-based operations.

TypeRepresentsFormat ExampleMemory SizeRange
TIMEDuration / elapsed timeT#1h30m20s500ms32 bitsT#0ms to T#49d17h2m47s295ms
LTIMEHigh-res durationLT#1000ns64 bitsNanosecond resolution
DATECalendar dateD#2026-02-1832 bitsD#1970-01-01 to D#2106-02-06
TIME_OF_DAY (TOD)Time within a dayTOD#14:30:00.00032 bitsTOD#00:00:00 to TOD#23:59:59.999
DATE_AND_TIME (DT)Date + time combinedDT#2026-02-18-14:30:0064 bitsFull timestamp

TIME - The Most Important Time Type

TIME is used universally with PLC timers (TON, TOF, TP). It represents a duration from 0 to approximately 49 days with millisecond resolution.

DATE and DATE_AND_TIME - For Scheduling and Logging

DATE and DT types are used in applications that need real-time awareness - scheduling maintenance based on calendar dates, logging alarm events with timestamps, enabling/disabling functions based on time of day, or shift-based reporting.

6. STRING and CHAR - Text Data Types

STRING - Variable-Length Text

The STRING data type stores alphanumeric text. In IEC 61131-3, a STRING is defined with a maximum length in square brackets. The actual stored string can be shorter (up to the maximum), and the PLC allocates maximum_length + 1 bytes of memory (the extra byte stores the actual current length).

TypeCharacter SetMax Length DefaultMemory UsageIEC 61131-3
STRINGASCII (single byte chars)80 chars (or defined)Length + 1 bytesYes
WSTRINGUnicode (wide chars, 2 bytes each)80 chars (or defined)2 × Length + 2 bytesYes
CHARSingle ASCII character1 character1 byteYes
WCHARSingle Unicode character1 wide character2 bytesYes

Where STRING is Used

  • HMI display messages: Displaying equipment status, alarm descriptions, or operator instructions on touchscreens
  • Recipe names and product identifiers
  • Serial number and barcode data from scanners
  • Communication with barcode readers, RFID systems, weigh scales, and vision systems via serial protocols
  • Log file entries and event messages
  • Machine/equipment identification tags

7. Derived / Complex Data Types

ARRAY - Indexed Collections

An ARRAY stores multiple values of the same data type in a numbered list (indexed collection). Arrays are essential for handling repetitive data - multiple temperature readings from different zones, recipe step values, production counts for each shift, or historical trend data.

STRUCT - Grouped Related Variables

A STRUCT (Structure) groups multiple variables of potentially different types under a single name. Structures are invaluable for organizing related data that logically belongs together - for example, all the parameters for a pump, all the setpoints for a production recipe, or all the data for one alarm event.

 

Conclusion

Data types are not a bureaucratic formality in PLC programming - they are a fundamental engineering discipline that directly affects the safety, reliability, and maintainability of industrial automation systems. Every variable declaration is a decision that carries real consequences when machines run 24/7 in safety-critical environments.

To summarize the key data type every automation engineer must master:

  • BOOL - The bedrock of digital control logic, representing every ON/OFF state in your system
  • INT / DINT - The workhorses for counters, step numbers, and integer calculations
  • REAL - Essential for all analog process values, PID control, and engineering unit calculations
  • TIME - The proper and readable way to work with all timer durations and time-based logic
  • BYTE / WORD / DWORD - Critical for fieldbus communication, status words, and bit manipulation
  • STRING - For all text data, HMI messages, and communication with identifier-producing devices
  • STRUCT / ARRAY - The advanced types that separate professional, maintainable programs from unscalable spaghetti code

As PLC systems continue to evolve into edge computing platforms supporting OPC UA, MQTT, and cloud connectivity, a deep understanding of data types becomes even more critical - because every data point published to a cloud historian or MES system must be correctly typed, correctly scaled, and correctly interpreted at both ends of the data pipeline.

Master the fundamentals of data types, and you will write PLC programs that are not just functional - but robust, readable, and ready for the demands of Industry 4.0.