Every PLC variable needs a defined representation. The selected data type determines how much memory is reserved, which values are valid, which operations can be applied, and how clearly the variable communicates engineering intent to the next programmer.
- Choose the smallest practical type that still covers the engineering range.
- Use signed or unsigned types deliberately instead of treating every value as a generic integer.
- Group repeated machine objects with STRUCTs and PLC data types / UDTs.
- Confirm support on the target CPU before using newer long, Unicode, reference or generic types.
Siemens PLC Data Types in TIA Portal
This guide is designed for searches around Siemens PLC data types, TIA Portal data types, S7-1200 data types, S7-1500 data types, BOOL INT DINT REAL, Siemens UDT and SCL data type examples.
1. Why Siemens PLC Data Types Matter
Data types are easy to overlook because they sit behind every tag, parameter and data-block member. But the type you choose affects memory usage, usable range, arithmetic behavior, interfaces and code readability. A poor choice can lead to overflow, unnecessary memory allocation or code that is difficult to maintain.
Data type selection influences memory footprint, numerical range, precision and how efficiently values are processed.
A well-chosen type makes intent obvious—for example, a BOOL for a status, DINT for a large total, or a UDT for a complete motor object.
2. Siemens PLC Data Type Families
3. Binary Types: BOOL, BYTE, WORD, DWORD and LWORD
At the lowest level, PLCs process individual bits and groups of bits. BOOL represents one logical state: TRUE or FALSE. It is ideal for switches, permissives, interlocks, alarm states and running feedback.
SCL example – BOOL logic
VAR
pump_enabled : BOOL := FALSE;
pump_fault : BOOL := FALSE;
END_VAR
pump_enabled := start_button AND NOT pump_fault;
For grouped binary data, Siemens provides BYTE (8 bits), WORD (16 bits) and DWORD (32 bits). On newer platforms, LWORD extends the same concept to 64 bits. These types are useful for status words, masks, raw device data and bitwise operations.
VAR
device_status : DWORD := 0;
END_VAR
device_status.0 := 1; // Device ready
device_status.2 := 1; // Communication OK
4. Whole Numbers: Signed and Unsigned Integers
Integer types are the workhorses of counting, indexing and discrete calculations. Signed types allow negative and positive values, while unsigned types use the same bit width entirely for zero and positive values.
| Type | Width | Signed? | Typical use |
|---|---|---|---|
SINT | 8 bit | Yes | Small signed values |
USINT | 8 bit | No | Small positive values, percentage-like raw values |
INT | 16 bit | Yes | Counters, indexes, engineering values |
UINT | 16 bit | No | Positive counts and positions |
DINT | 32 bit | Yes | Large counters and totals |
UDINT | 32 bit | No | Large positive counters and IDs |
LINT | 64 bit | Yes | Very large signed values |
ULINT | 64 bit | No | Very large non-negative values |
SCL example – production totals
VAR
total_parts_produced : DINT := 0;
parts_this_cycle : INT := 50;
daily_target : DINT := 10000;
END_VAR
total_parts_produced := total_parts_produced + parts_this_cycle;
Unsigned types are particularly useful when a value can never be negative. They can represent a larger positive range than a signed type of the same width and also communicate that engineering intent to anyone reading the program.
VAR
led_brightness : USINT := 75;
pwm_value : USINT;
END_VAR
pwm_value := (led_brightness * 255) / 100;
5. Decimal Values: REAL and LREAL
REAL is a 32-bit floating-point type commonly used for analog values, process variables, scaling and engineering calculations. LREAL is a 64-bit floating-point type used where higher precision or a wider numeric range is required and supported by the CPU.
VAR
voltage : REAL := 10.5;
current : REAL := 2.3;
power : REAL;
END_VAR
power := voltage * current;
6. Timer and Duration Types: S5TIME, TIME and LTIME
S5TIME is a legacy Siemens time format retained for compatibility with older projects. TIME is the standard IEC duration type and is widely used for delays, elapsed times and timer parameters. LTIME extends duration handling on supported modern CPUs with much larger range and finer resolution.
VAR
input_signal : BOOL;
timer_value : TIME := T#0s;
max_delay : TIME := T#5s;
output_signal : BOOL := FALSE;
END_VAR
IF timer_value < max_delay THEN
timer_value := timer_value + T#10ms;
ELSE
output_signal := TRUE;
END_IF;
7. Calendar and Clock Types
Automation systems often need both durations and actual timestamps. DATE stores a calendar date, while TIME_OF_DAY (TOD) stores a time of day. Legacy DT (DATE_AND_TIME) combines date and clock information for timestamping and logging.
Newer platforms add types such as DTL, which exposes individual timestamp fields including year, month, day, weekday, hour, minute and second. Higher-resolution long variants include LDT and LTOD on supported CPUs.
VAR
current_dtl : DTL;
END_VAR
IF (current_dtl.weekday = 5) AND (current_dtl.hour = 22) THEN
is_maintenance_day := TRUE;
END_IF;
8. Text Types: CHAR, STRING, WCHAR and WSTRING
CHAR stores a single one-byte character, while STRING stores a sequence of single-byte characters. On S7-1200/1500-class systems, standard STRING is commonly declared with a maximum of up to 254 characters. For Unicode text, newer platforms provide WCHAR and WSTRING.
STRING and Unicode WSTRING have CPU/version-specific storage and declared-length rules. Define only the string length your application actually needs to avoid unnecessary memory use.VAR
device_type : STRING := 'Pump';
device_number : INT := 3;
device_id : STRING;
END_VAR
device_id := CONCAT(device_type, '_', INT_TO_STRING(device_number));
// Result: 'Pump_3'
9. ARRAY, STRUCT and PLC Data Types / UDTs
Complex data types are essential for scalable automation software. A reusable PLC data type / UDT groups related fields into one named engineering object. For example, speed, direction, current, status and enable information for a motor can be defined once and reused consistently across data blocks and block interfaces.
TYPE Motor_Control
STRUCT
speed : INT;
direction : BOOL;
current_draw : REAL;
status : STRING;
enabled : BOOL;
END_STRUCT
END_TYPE
VAR
main_motor : Motor_Control;
END_VAR
main_motor.speed := 1800;
main_motor.enabled := TRUE;
An anonymous STRUCT is useful when the grouped layout is required only locally. An ARRAY creates an indexed collection of elements of the same type and is ideal for sensor banks, recipes, production values and repeated machine data.
VAR
sensor_array : ARRAY[1..16] OF REAL;
max_reading : REAL := 0.0;
END_VAR
FOR sensor_index := 1 TO 16 DO
IF sensor_array[sensor_index] > max_reading THEN
max_reading := sensor_array[sensor_index];
END_IF;
END_FOR;
If a machine object has several related values that repeat across the project, a named PLC data type usually gives cleaner interfaces, consistent structures and easier future changes than many unrelated standalone tags.
10. POINTER, ANY, REFERENCE TO and VARIANT
Advanced Siemens programming includes several forms of indirect or generic data access. Classic POINTER and ANY types are strongly associated with legacy S7 programming and compatibility scenarios. Modern projects increasingly use more type-aware mechanisms where supported.
REFERENCE TO provides typed references on supported newer CPUs, while VARIANT is used in generic block interfaces when the concrete data type can vary at runtime and the called instruction is designed to handle that behavior.
VAR
temperature : REAL := 25.0;
temp_ref : REFERENCE TO REAL;
END_VAR
temp_ref := ADR(temperature);
temp_ref^ := 30.0;
FUNCTION Log_Value
VAR_INPUT
value : VARIANT;
label : STRING;
END_VAR
BEGIN
// Generic processing depends on the supported VARIANT instructions.
END_FUNCTION
11. System and Hardware Types
STEP 7 also provides predefined types for system functions and physical hardware. Examples include standardized timer/counter structures, error-information structures and communication parameter types. Hardware-related types represent configured devices and I/O resources so program blocks can work with engineering objects rather than only raw numeric addresses.
12. Which Siemens CPU Supports Which Data Types?
The following quick-reference table follows the supplied STEP 7 data-type overview. Always check the exact CPU firmware and TIA Portal version before treating the table as a compile-time guarantee.
| Data type / category | S7-300/400 | S7-1200 | S7-1500 | S7-1200 G2 |
|---|---|---|---|---|
| BOOL, BYTE, WORD, DWORD | ✓ | ✓ | ✓ | ✓ |
| LWORD | – | – | ✓ | ✓ |
| INT, DINT | ✓ | ✓ | ✓ | ✓ |
| SINT, USINT, UINT, UDINT | – | ✓ | ✓ | ✓ |
| LINT, ULINT | – | – | ✓ | ✓ |
| REAL | ✓ | ✓ | ✓ | ✓ |
| LREAL | – | ✓ | ✓ | ✓ |
| DATE, TOD | ✓ | ✓ | ✓ | ✓ |
| DTL | – | ✓ | ✓ | ✓ |
| LDT, LTOD | – | – | ✓ | ✓ |
| STRING | ✓ | ✓ | ✓ | ✓ |
| WSTRING, WCHAR | – | ✓ | ✓ | ✓ |
| ARRAY, STRUCT, UDT | ✓ | ✓ | ✓ | ✓ |
| References | – | – | ✓ | ✓ |
| VARIANT | – | ✓ | ✓ | ✓ |
13. Siemens PLC Data Type Best Practices
- Right-size the type. Do not allocate a large numeric type when a smaller range is guaranteed and the smaller type improves clarity.
- Use signed and unsigned values intentionally. Select unsigned types when negative values are impossible and the CPU/platform supports them.
- Build reusable UDTs for complex equipment. Repeated device structures are easier to maintain when their members are centrally defined.
- Check the target CPU. Long, Unicode, reference and generic types are not universal across all S7 generations.
- Keep time-critical logic efficient. Avoid unnecessary floating-point and heavy string manipulation inside tight cyclic loops.
- Declare realistic string lengths. Reserving only the required text length improves memory discipline and documents the intended interface.
Practical Selection Guide
| Requirement | Typical Siemens type |
|---|---|
| On/off status, alarm, permissive | BOOL |
| Raw status bits or bit mask | BYTE, WORD, DWORD |
| Small signed count or index | INT or SINT where supported |
| Large production total | DINT or UDINT |
| Analog/process engineering value | REAL |
| Elapsed duration | TIME |
| Calendar/time logic | DATE, TOD, DTL |
| Short equipment label/message | STRING[n] |
| Unicode text | WSTRING[n] where supported |
| Repeated device object | PLC data type / UDT |
| Repeated same-type values | ARRAY |
| Generic advanced interface | VARIANT or reference mechanisms where supported |
Frequently Asked Questions
What are the main Siemens PLC data type families?
Siemens PLC data types can be grouped into elementary types, complex types such as ARRAY and STRUCT, user-defined PLC data types or UDTs, pointer/reference types, and system or hardware-related types.
What is the difference between INT and DINT in Siemens PLCs?
INT is a 16-bit signed integer, while DINT is a 32-bit signed integer. DINT is suitable when counters, totals, positions or calculations can exceed the INT range.
When should I use REAL or LREAL?
Use REAL for common process values and analog calculations. Use LREAL where the CPU supports it and higher numerical precision or a wider floating-point range is required.
What is a UDT in TIA Portal?
A UDT, commonly implemented as a PLC data type, groups related fields into a reusable named structure. It is useful for motors, valves, machines, recipes and other repeated engineering objects.
Do all Siemens S7 CPUs support the same data types?
No. Legacy S7-300/400 controllers support a smaller set, while S7-1200, S7-1500 and newer S7-1200 G2 platforms support additional integer, long, Unicode, reference and generic data types depending on the CPU and engineering version.
Reference
The supplied source cites STEP 7 V21 – Overview of the Valid Data Types, Siemens TIA Portal Documentation. For production work, always confirm data-type availability and limits in the documentation for the exact CPU firmware and TIA Portal version used in the project.
