Siemens SCL Data Types and Value Assignments in TIA Portal

Published on Jun16, 2025 | Category: scl
Share this article:

You can use a value assignment in Siemens SCL to assign the result of an expression to a variable or tag. In every value assignment, the tag on the left side of the assignment operator stores or receives the value from the expression written on the right side.
The data type of this assignment is strictly determined by the data type of the tag on the left. The expression or value on the right must be of the same or a compatible data type; otherwise, the assignment will result in a compile-time error. This ensures data integrity and consistent program execution within the PLC.
In this article, we explore how to properly assign values based on predefined data types in SCL. A tag or variable with a specific data type is designed to store only certain kinds of values. For example, if a tag like switch1 is defined as a BOOL, it can only store logical values such as TRUE or FALSE, or their binary equivalents 1 and 0. You cannot store numeric values like 100 or strings like ON in a BOOL-type tag, as it violates the rules of type consistency.
For handling numeric values, Siemens SCL provides several data types such as INT (integer), DINT (double integer), REAL (floating-point numbers), BYTE, and WORD. Each of these has a defined size and range.
When programming in SCL, it’s critical to understand the context and purpose of your data to select the appropriate data type. For example, use INT for counting pulses, REAL for process values like temperature or pressure with decimals, and TIME for delays and timers using values like T#10s or T#100ms.
Many instructions in SCL require specific data types. For example, the SCALE_X instruction used for analog scaling only supports the INT data type. Trying to use a REAL or DINT with SCALE_X will result in a type mismatch error.
However, other instructions such as arithmetic operations or logical comparisons are more flexible and support multiple data types, provided they are compatible. Understanding this helps you write efficient, type-safe programs that are easy to troubleshoot and maintain.
In summary, correct value assignment in SCL ensures the stability, reliability, and accuracy of your automation logic. Choosing the right data type and matching the value format accordingly is essential for effective PLC programming in Siemens TIA Portal or Step 7 environments.

Siemens SCL Value Assignment Techniques

In Siemens Structured Control Language (SCL), assigning values to tags (variables) is a fundamental programming concept. A value assignment sets the content of a variable on the left side of the assignment operator (:=) to the result of an expression on the right side.
The data type of the left-hand variable defines what type of values it can store — such as BOOL, INT, REAL, etc. The expression on the right must match or be compatible with that type to ensure valid operation and avoid type mismatch errors during compilation.

1. Single Value Assignments

This is the most basic form of value assignment in SCL. A single variable is assigned a value from another tag or constant. It is typically used in calculations, signal transfers, or logical operations.
For example, in the expression a := b;, the value of variable b is assigned directly to variable a. Both a and b must have the same or compatible data types.

2. Multiple Value Assignments

SCL allows assigning values to multiple variables in a single line by chaining the assignment operator. For example: a := b := c;.
This expression is evaluated from right to left, and is equivalent to:
b := c;
a := b;
This technique simplifies the code and is useful when you want to synchronize multiple tags to the same value.

3. Combined Value Assignments

SCL also supports arithmetic operations combined with assignment operators. These include +=, -=, *=, and /=. These operators update the variable on the left by performing the operation with the value on the right.
For example, a += b; is functionally equivalent to a := a + b;. This is helpful in counters, accumulators, and continuous calculations.

4. Nested Combined Assignments

You can chain combined assignments together to perform multi-step calculations in a single expression. For example: a += b += c *= d;
This is evaluated from right to left and is equivalent to:
c := c * d;
b := b + c;
a := a + b;
Such expressions must be written with caution, ensuring proper understanding of operation order and data types.

img/scl-data-type/siemens-scl-value-assignment-types.webp

SCL BOOL Data Type

In Siemens SCL (Structured Control Language), the BOOL data type is used to represent binary values — meaning it can only hold one of two logical states: TRUE or FALSE.
An operand declared as a BOOL is typically used for digital signals such as switch inputs, sensor status, control bits, and logical flags in automation systems. These binary conditions are essential for decision-making processes within PLC programs.

In the following example, two digital switches are assigned values using the BOOL data type:

Both switch_1 and switch_2 are declared as BOOL tags in the program. The TRUE or FALSE values they hold can be evaluated in conditional statements (such as IF statements) to control outputs like motors, lights, or alarms.
For example, you might write a logic condition like IF switch_1 THEN motor := TRUE; to turn on a motor when switch_1 is active.
The BOOL data type plays a critical role in digital automation control by simplifying binary logic and improving the readability of your program.

SCL INT and DINT Data Types in Siemens

In Siemens SCL (Structured Control Language), INT and DINT are commonly used data types for storing numeric values. These types are essential for handling level values, counters, timers, and many other numerical signals in industrial automation.
The INT (Integer) data type represents a 16-bit signed number and can hold values in the range from -32,768 to +32,767. It is suitable for standard-level or counter values that don't require a large range.
The DINT (Double Integer) data type is a 32-bit signed number with a much larger range, from -2,147,483,648 to +2,147,483,647. It is useful for applications that require storing larger values, such as total flow, accumulated runtime, or high-precision sensor readings.

Example: INT and DINT in a Comparison

In the example below:

The logic performs a comparison using the less-than operator (<):

If either level_1_sts < 30 or level_2_sts < 45 is TRUE, then motor_1 is turned ON and motor_2 is turned OFF.
If both conditions are FALSE, then motor_1 and motor_2 remain OFF.

This example shows that different integer types like INT and DINT can be used together in logical expressions, as long as they are numerically compatible. The system automatically handles internal conversions if needed. However, it's good practice to keep data types consistent to avoid unexpected behavior.

Using the correct data type ensures optimized memory usage and accurate data processing. INT is best when you only need small numeric values, while DINT is recommended for high-range operations.

img/scl-data-type/scl-int-dint-comparison.webp

SCL REAL Data Type in Siemens Programming

In Siemens SCL (Structured Control Language), the REAL data type is used to represent floating-point numbers. These are numbers with decimal points, such as temperatures, flow rates, or analog sensor values.
Operands of the REAL type are stored using 32 bits and are designed according to the IEEE 754 floating-point standard. This data type is essential when high precision and decimal representation are needed in your logic or calculations.

Structure of REAL Data Type

A REAL value in memory consists of three main components:

REAL Type Example in Comparison

Consider the following logic example using the REAL data type:

This example highlights the practical use of the REAL data type where precision is required. Integer types (like INT or DINT) cannot represent decimal points, making REAL essential for analog sensor data, temperature control, and PID logic.

img/scl-data-type/scl-real-data-type.webp

SCL S5TIME Data Type in Siemens

The S5TIME data type in Siemens SCL is used to represent time durations for timers and delay operations. It is a 16-bit data type and stores time values in BCD (Binary Coded Decimal) format. S5TIME is designed for compatibility with legacy S5 PLC systems and is still supported in S7 for certain timer functions.

Structure and Behavior of S5TIME

An S5TIME value is made up of two components:

This means the actual time duration is calculated as:
Time Duration = Time Value × Time Base

Range of Values

The valid range for S5TIME is from S5T#0MS to S5T#2H_46M_30S. The format used for value entry includes keywords like S5T#10s or S5TIME#10s.

Example: Using S5TIME in Value Assignment

In the example below:

This kind of assignment is useful when you need to reuse or pass timer durations between function blocks or logic sequences. Since S5TIME uses a defined format, it ensures consistency and readability when setting delays or timeouts.

The S5TIME format is most commonly used with standard siemens timers like pulse timer, PEXT_timer etc. or simens non IEC Timer.

img/scl-data-type/scl-s5time-data-type.webp

SCL TIME Data Type in Siemens Programming

The TIME data type in Siemens SCL represents a duration in milliseconds and is primarily used in timer instructions such as TON, TOF, and TP. It supports a wide range of time values with high precision, making it ideal for automation tasks that require accurate timing.

Format and Structure of TIME

The TIME data type uses a 32-bit signed format to store time durations. The internal representation is in milliseconds, but users can input time values using a human-readable format that includes multiple time units:

The total range of values spans from:
T#-24d_20h_31m_23s_648ms to T#+24d_20h_31m_23s_647ms

Examples of Valid TIME Format

You can enter a TIME value in several combinations of units. All of the following examples are valid:

It is not required to specify every time unit. You may define just one or more units depending on your need. However, when multiple units are used, the total duration must remain within the supported range.

Usage Example of TIME Data Type

In the following SCL example, the TIME data type is used to define the preset time of a pulse timer (TP instruction):

This example demonstrates that the TIME data type is highly readable and flexible for both configuration and logic control in Siemens automation projects.

img/scl-data-type/scl-time-data-type.webp

Siemens SCL CHAR Data Type

In Siemens Structured Control Language (SCL), the CHAR data type is used to store a single character. A tag of type CHAR occupies 8 bits (1 byte) of memory and stores a character using the standard ASCII encoding system. Each character is enclosed in single quotes and is case-sensitive.

Properties of the CHAR Data Type

Example Usage of CHAR in SCL

The following SCL instructions show how to assign characters to variables using the CHAR data type:

In this example, three variables of type CHAR are defined to hold the characters 'p', 'l', and 'c'. These characters can later be combined into a STRING, used in comparison operations, or displayed in an HMI interface. It's important to remember that each CHAR variable holds only a single character. If you need to store multiple characters or a word, consider using the STRING data type instead.

img/scl-data-type/scl-char-data-type.webp

Siemens SCL WORD and DWORD Data Types

In Siemens SCL (Structured Control Language), WORD and DWORD are used to handle groups of bits as a single unit. These data types are essential when dealing with digital signals, hardware registers, status words, and bitwise operations in automation systems.

siemens scl WORD Data Type

An operand of data type WORD is a bit string of 16 bits. It is primarily used to represent 16 digital states or flags in one variable. Each bit can be independently read or manipulated using bitwise operations.

Example:

Properties of WORD

siemens scl DWORD Data Type

An operand of data type DWORD is a bit string of 32 bits. It is used when a larger number of digital flags or a higher value range is required. Like WORD, each bit can be individually accessed.

Example:

Properties of DWORD

These data types are commonly used in industrial control systems for efficient binary data processing, especially where space optimization or fast digital status evaluation is needed.

img/scl-data-type/scl-word-dword-data-type.webp