Structured Control Language (SCL) Programming Example in Siemens TIA Portal

Published on Jun11, 2025 | Category: tia
Share this article:

Structured Control Language (SCL) is a powerful, high-level, statement-based programming language used in Siemens PLCs such as the S7-300, S7-400, S7-1200, and S7-1500 series. SCL is Siemens’ implementation of the IEC 61131-3 Structured Text (ST) standard and shares similarities with languages like Pascal and C.
Unlike graphical languages like Ladder Logic (LAD), SCL offers a clean and efficient text-based programming interface which is ideal for implementing complex logic, mathematical formulas, and structured algorithms in industrial automation.

Why Use SCL in Siemens PLC Programming?

While Ladder Logic is popular for its intuitive visuals, it becomes less efficient as program complexity grows. SCL allows you to:

Key Concepts in SCL Programming

Before creating a program in SCL, it is important to understand the following elements:

Benefits of Using SCL

SCL simplifies the development and testing of automation programs by enabling engineers to focus on logic rather than visuals. Its similarity to high-level languages makes it easier for developers from software backgrounds to adapt quickly.


Common Use Cases for SCL in TIA Portal


Data Type Declaration in Siemens SCL with Examples

In Siemens Structured Control Language (SCL), declaring variables with the correct data type is crucial for reliable and efficient PLC programming. Each variable must be defined before use, specifying its data type, such as BOOL, INT, REAL, TIME, etc. Below are common data types used in SCL with examples:

1. Boolean (BOOL)

2. Integer (INT, DINT)

3. Real Numbers (REAL, LREAL)

4. Time Data Types

5. String and Character Types

Always ensure data types match when assigning or comparing variables. Mismatched types can cause compile-time or runtime errors in TIA Portal.

img/siemens-tia-scl-example/data-type-declaration-in-siemens-scl.webp

Timer Programming in SCL: IEC Timer and S_PULSE Example

In SCL, a timer is typically declared as a function block with specific parameters such as start input, preset time, and output. To implement a timer, you must first add the appropriate timer block and then declare all related tags with the correct data types.

In this example, we demonstrate two types of timers used in Siemens SCL programming within the TIA Portal: an IEC timer and a SIMATIC-specific S_PULSE timer.

1. IEC Timer

The IEC timer block IEC_Timer_0_DB.TP is used for generating a pulse. It has the following parameters:

Additionally, the preset value is also assigned separately as: "timer_pt" := t#10s, which sets the timer’s duration.

img/siemens-tia-scl-example/iec-timer-example-in-scl.webp

2. S_PULSE Timer (SIMATIC Timer)

The S_PULSE is a standard Siemens pulse timer. It is configured with the following parameters:

The timer number and preset time are also defined:

Both timer types serve different use cases but can be used effectively depending on the requirement for time accuracy, compatibility, or readability.

img/siemens-tia-scl-example/simatic-timer-example-in-scl.webp

Conditional Statement Example in Siemens SCL Programming Language

Conditional statements in SCL are used to control the flow of logic based on conditions such as true or false. One of the most common conditional structures is the IF...THEN...ELSE block.

In this example, we demonstrate how to check whether a given integer value is even or odd. Based on the result, the program sets appropriate boolean tags to indicate the outcome. This is useful for logic decisions in automation processes.

Even-Odd Detection Logic

SCL Logic:

Here, is_even and is_odd are boolean tags used to store the result. You can also link these to physical outputs or HMI indicators.

img/siemens-tia-scl-example/conditional-statement-example-in-siemens-scl-programming-language.webp

Multiple Conditional Statement Example in Siemens SCL Programming Language

In SCL (Structured Control Language), you can use multiple conditions combined with logical operators like AND, OR, and NOT to evaluate complex logic.

In this example, we check whether the value of a variable temperature lies within a defined safe range (between 30 and 50 degrees). If the condition is true, the output tag within_limit is set to TRUE; otherwise, it's set to FALSE.

SCL Logic:

This kind of conditional structure is especially useful in process control applications, where you need to monitor values like temperature, pressure, or flow to maintain safe operating conditions.

img/siemens-tia-scl-example/multiple-conditional-statement-example-in-siemens-scl-programming-language.webp

Arithmetic Operations in Siemens SCL Programming Language

Arithmetic operations are commonly used in SCL (Structured Control Language) for calculations such as addition, subtraction, averaging, and real-world formulas like tank volume or flow calculations. These operations support multiple data types including INT, DINT, REAL, and LREAL.

Example 1: Basic Arithmetic with Variables

In this example, value1 and value2 are of type REAL, while value3 and value4 are of type INT. The result variables (add_value, sub_value, and avg_value) should also be declared as REAL to support mixed-type operations.

img/siemens-tia-scl-example/arithmetic-operations-in-siemens-scl-programming-language-example-1.webp

Example 2: Tank Volume and Flow Calculation

This example calculates the full volume and current volume of a cylindrical tank based on radius and height, and estimates the time to fill it at a given flow rate. All variables should be declared as REAL or LREAL for accurate precision.

img/siemens-tia-scl-example/arithmetic-operations-in-siemens-scl-programming-language.webp