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:
| Category | What It Represents | Examples |
| Boolean / Bit | True/False values, single binary bits | BOOL, BIT |
| Integer (Unsigned) | Whole numbers - positive only | BYTE, USINT, UINT, UDINT, ULINT |
| Integer (Signed) | Whole numbers - positive and negative | SINT, INT, DINT, LINT |
| Floating Point (Real) | Decimal / fractional numbers | REAL, LREAL |
| Time & Duration | Time spans, durations, dates | TIME, DATE, TIME_OF_DAY, DATE_AND_TIME |
| String / Character | Text, alphanumeric data | STRING, WSTRING, CHAR |
| Bit String | Groups of bits treated as a unit | BYTE, WORD, DWORD, LWORD |
| Derived / Complex | User-defined structures and arrays | STRUCT, 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 Type | Memory Size | Possible Values | IEC 61131-3 Compliant |
| BOOL | 1 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 Name | Signed? | Bit Width | Byte Size | Minimum Value | Maximum Value | IEC 61131-3 |
| BOOL | No | 1 bit | 1 byte* | 0 | 1 | Yes |
| BYTE | No | 8 bits | 1 byte | 0 | 255 | Yes (bit string) |
| USINT | No (Unsigned) | 8 bits | 1 byte | 0 | 255 | Yes |
| SINT | Yes (Signed) | 8 bits | 1 byte | -128 | 127 | Yes |
| UINT | No (Unsigned) | 16 bits | 2 bytes | 0 | 65,535 | Yes |
| INT | Yes (Signed) | 16 bits | 2 bytes | -32,768 | 32,767 | Yes |
| UDINT | No (Unsigned) | 32 bits | 4 bytes | 0 | 4,294,967,295 | Yes |
| DINT | Yes (Signed) | 32 bits | 4 bytes | -2,147,483,648 | 2,147,483,647 | Yes |
| ULINT | No (Unsigned) | 64 bits | 8 bytes | 0 | 18.4 × 10¹⁸ | Yes |
| LINT | Yes (Signed) | 64 bits | 8 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.
| Type | Bit Width | Bytes | Precision (Decimal Digits) | Range | Standard |
| REAL | 32 bits | 4 bytes | ~7 significant digits | ±1.18 × 10⁻³⁸ to ±3.4 × 10³⁸ | IEEE 754 Single |
| LREAL | 64 bits | 8 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.
| Type | Bit Width | Bytes | Typical Use |
| BYTE | 8 bits | 1 byte | Status byte, compact flag storage, Modbus coil groups |
| WORD | 16 bits | 2 bytes | Device status words, communication data, register values |
| DWORD | 32 bits | 4 bytes | Extended status, IP addresses, large bit masks |
| LWORD | 64 bits | 8 bytes | Very 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.
| Type | Represents | Format Example | Memory Size | Range |
| TIME | Duration / elapsed time | T#1h30m20s500ms | 32 bits | T#0ms to T#49d17h2m47s295ms |
| LTIME | High-res duration | LT#1000ns | 64 bits | Nanosecond resolution |
| DATE | Calendar date | D#2026-02-18 | 32 bits | D#1970-01-01 to D#2106-02-06 |
| TIME_OF_DAY (TOD) | Time within a day | TOD#14:30:00.000 | 32 bits | TOD#00:00:00 to TOD#23:59:59.999 |
| DATE_AND_TIME (DT) | Date + time combined | DT#2026-02-18-14:30:00 | 64 bits | Full 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).
| Type | Character Set | Max Length Default | Memory Usage | IEC 61131-3 |
| STRING | ASCII (single byte chars) | 80 chars (or defined) | Length + 1 bytes | Yes |
| WSTRING | Unicode (wide chars, 2 bytes each) | 80 chars (or defined) | 2 × Length + 2 bytes | Yes |
| CHAR | Single ASCII character | 1 character | 1 byte | Yes |
| WCHAR | Single Unicode character | 1 wide character | 2 bytes | Yes |
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.