Data types define the nature of the information that can be processed by the PLC, determining how much memory is allocated and the operations that can be performed. This article dives into the various data types used in Siemens PLCs, particularly in the TIA Portal environment, which is Siemens’ integrated software for programming and configuring automation systems.
1. Boolean (BOOL)
- Size: 1 bit
- Description: The Boolean data type represents a logical state with two possible values:
TRUE
orFALSE
. This is often used to represent discrete on/off conditions, such as the state of a switch or a sensor. - Common Uses: Start/Stop signals, alarms, interlocks, status indicators.
2. Integer Data Types
Siemens PLCs support various integer data types, ranging from small integers to large, signed, and unsigned values.
- BYTE
- Size: 8 bits
- Description: A group of 8 bits, capable of holding values between 0 and 255.
- Common Uses: Low-level digital communication, sensor data, and hardware interfacing.
- WORD
- Size: 16 bits
- Description: Composed of 2 bytes, a WORD can hold values from 0 to 65,535.
- Common Uses: Used in analog values or larger integer operations in hardware control.
- DWORD (Double Word)
- Size: 32 bits
- Description: A DWORD is a 32-bit unsigned integer, providing a value range from 0 to 4,294,967,295.
- Common Uses: Holding large counter values, high-precision timers, or complex process data.
- SINT (Signed Integer)
- Size: 8 bits
- Description: Represents an 8-bit signed integer with values ranging from -128 to +127.
- Common Uses: Situations requiring small negative and positive values.
- INT (Signed Integer)
- Size: 16 bits
- Description: A 16-bit signed integer capable of holding values from -32,768 to +32,767.
- Common Uses: Representing numeric values such as motor speeds or process variables.
- DINT (Double Signed Integer)
- Size: 32 bits
- Description: A 32-bit signed integer with a value range from -2,147,483,648 to +2,147,483,647.
- Common Uses: Control systems that need large ranges of positive and negative values, like position counters or timers.
3. Real Data Types
- REAL
- Size: 32 bits (floating-point number)
- Description: A data type used for representing decimal numbers, capable of storing values between approximately ±3.4E38 (positive and negative), with a precision of 7 digits.
- Common Uses: Used in applications involving analog processing such as temperature control, flow measurement, or other continuous processes requiring precision.
4. Character and String Data Types
- CHAR
- Size: 8 bits
- Description: Stores a single character using the ASCII code.
- Common Uses: Representing textual information, single characters, and communication protocols.
- STRING
- Size: Variable (up to 254 characters)
- Description: A collection of characters that form a string. The size of the STRING data type is variable, with the first byte indicating the maximum length and the second byte specifying the actual length.
- Common Uses: Used in HMI displays, communication with devices, or representing serial data.
5. Time Data Types
- TIME
- Size: 32 bits
- Description: Represents a time duration in milliseconds, ranging from -24 days to +24 days.
- Common Uses: Timer functions, delays, and time tracking in automation processes.
- DATE
- Size: 16 bits
- Description: Represents the current date as a value between 1990-01-01 and 2168-12-31.
- Common Uses: Logging dates of production batches or tracking time-sensitive events.
- TIME_OF_DAY (TOD)
- Size: 32 bits
- Description: Represents the time of day, accurate to milliseconds, with a range from 00:00:00.000 to 23:59:59.999.
- Common Uses: Scheduling events, tracking shifts, or maintaining time-accurate logs.
6. Variant Siemens Data types
The Variant data type in Siemens PLCs, particularly within the TIA Portal environment, is a special data type that can store values of different types dynamically. It allows flexibility by not being strictly bound to a specific data type during compilation. Instead, it can hold a value of several types, such as BOOL, INT, REAL, STRING, or even more complex types like ARRAY or STRUCTURE