TIA Portalsupports multiple programming languages for implementing PLC logic. Each block (OB, FC, FB) can be developed in one of the following formats:
- Ladder Diagram (LAD)
- Graphical, logic-based language resembling electrical relay logic.
- Widely used in industrial automation due to its visual clarity.
- Ideal for simple logic, digital I/Os, and maintenance-friendly programming.
- Structured Control Language (SCL)
- Text-based language similar to Pascal or high-level programming languages.
- Supportsstructured programming: IF, FOR, CASE, mathematical expressions, etc.
- Bestsuited for complex algorithms, scaling, string manipulation, and loops.
- Statement List (STL)
- Low-level, mnemonic-based language.
- Representslogic as assembly-like instructions.
- Rarely used in modern projects — mostly for legacy systems or low-level debugging.
Example: Simple NO / NC Contact Assignment
Let’s look at the same logic written in both LAD and SCL.
Objective:
If a normally open (NO) input is TRUE, turn on an output coil.

Simple NO Contact Assignemt
Notes:
- In LAD, logic is built by connecting graphical elements.
- In SCL, logic is written with structured code and requires strictsyntax (e.g., semicolons).
- Both formats are compiled to the same machine code and executed by the PLC identically.
Structured Control Language (SCL) Basics
Structured Control Language (SCL) is a high-level, text-based programming language used in TIA Portal for developing logic in PLC blocks (OB, FC, FB). It is based on the IEC 61131-3 standard and is very similar to languages like Pascal or ST (Structured Text)
SCL is highly readable, modular, and especially powerful for arithmetic operations, conditional logic, loops, and working with complex data structures
Syntax Basics
- Every instruction ends with a semicolon (;)
- Blocks of logic are enclosed within structured keywords like IF…THEN…END_IF, FOR…DO…END_FOR,etc
- Assignments use the := operator.
Common Opertors
| Opearator | Description | Example |
| := | Assignment | A := B + 5; |
| +-*/ | Arithmetic | Speed := A * 2; |
| AND | Logical AND | A AND B |
| OR | Logical OR | A OR B |
| NOT | Logical NOT | NOT A |
| = | Equality check | IF A = B THEN |
| <> | Not equal | IF A <> B THEN |
| <,>,<=,>= | Comparison | IF A > 10 THEN |
Example
Motor_ON := Start_Button;
This assignsthe value of Start_Button (BOOL) to the variable Motor_ON
IF / THEN / ELSE
The IF structure allows conditional execution of code.
IF Sensor_Value > 100 THEN
Alarm := TRUE;
ELSE
Alarm := FALSE;
END_IF;
You can also use ELSIF for multiple conditions:
IF Temp < 10 THEN
Status := 1;
ELSIF Temp < 20 THEN
Status:= 2;
ELSE
Status:= 3;
END_IF;
FOR Loop
The FOR loop is used to iterate a block of code a specific number of times.
FOR i := 1 TO 10 DO
Sum := Sum + Values[i];
END_FOR;
Arrays must be properly indexed and declared. Example:
Values : ARRAY[1..10] OF INT;
CASE Statement
Alternative to multiple IF-ELSIF conditions.
CASE Mode OF
1: Motor_Speed := 100;
2: Motor_Speed := 200;
3: Motor_Speed := 300;
ELSE
Motor_Speed := 0;
END_CASE;
Commentsin SCL
- Single-line comment:
- // This is a comment
- Multi-line comment:
(* This is a
multi-line comment *)
Practical Example – Basic Control Logi
// Start motor if Start button is pressed and no fault
IF Start_Button AND NOT Fault THEN
Motor := TRUE;
ELSE
Motor := FALSE;
END_IF;
Best Practices
- Use meaningful variable names (e.g. Pump_Start instead of P1).
- Always initialize variables in startup logic or OB100.
- Prefer IF or CASE for readability over nested logic.
- Use FOR loops only with known boundsto avoid infinite loops.
Summary
SCL provides a powerful and clean way to write structured, readable PLC code, especially useful for:
- Complex calculations
- Conditional logic
- Loops and array handling
- Scalable, modular logic design
If you found this helpful, please consider supporting with a small donation. Thank you!































