Logical Expressions in Siemens SCL (Structured Control Language) with Practical Examples

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

Logical expressions in Siemens SCL (Structured Control Language) are used to evaluate conditions based on Boolean logic. These expressions are essential for controlling the program flow in PLC programming, especially in decision-making processes.
Logical expressions typically involve more than two operands combined using logical operators like AND, OR, XOR, and NOT. The result of a logical expression is always a Boolean value — either TRUE or FALSE.
Logical operations are commonly used in conditional statements such as IF...THEN...ELSE, WHILE, or CASE. They help make decisions within the program based on multiple inputs. For example, if you have two switches and want the motor to start when either switch is ON, you would use an OR expression.
Logical expressions evaluate multiple values or conditions and determine a single TRUE or FALSE output based on the logic applied. These expressions are useful in automation scenarios like:

In summary, logical expressions allow your PLC program to make smart decisions, improving its ability to respond dynamically to real-world conditions.

Types of Logical Expressions in SCL

The following logical expressions are available in Siemens SCL (Structured Control Language):


Siemens SCL AND Logical Expression

The AND logical expression is used when you want to check if all conditions are true. If every condition in the expression is true, the result will also be true. If any one condition is false, the final result becomes false.

This logic is commonly used in PLC programs where an action should occur only when multiple input signals are active. For example, you may want to stop a motor only when all level sensors confirm that the tank is full.

Example 1: Two Level Sensors

Example 2: Three Level Sensors

This approach is useful for safety and process control, where multiple conditions must be met before allowing or stopping a machine action.

img/scl-logical-operators/siemens-scl-logical-and-expression.webp

Siemens SCL OR Logical Expression

The OR logical expression in Siemens SCL is used when you want an action to occur if at least one condition is true. The result of an OR operation is TRUE if any of the conditions (operands) are TRUE. It only returns FALSE if all conditions are FALSE.

This is similar to how a logical OR gate works in electronics. The output of an OR gate is high (true) if any of its inputs are high. In PLC programs, OR logic is helpful when you want to trigger an action based on multiple alternative inputs.

Example 1: Two Level Sensors

Example 2: Mixed OR and AND Condition

The OR logical operator is ideal when you have multiple input options for activating a single output. It provides flexibility in control logic, allowing actions to be triggered from any one of several sources.

img/scl-logical-operators/siemens-scl-logical-or-expression.webp

Siemens SCL XOR Logical Expression

The XOR (Exclusive OR) logical expression returns TRUE when an odd number of inputs are TRUE. If an even number (including zero) of inputs are TRUE, the result is FALSE.

This logic is similar to an XOR gate in digital electronics. The XOR gate produces a HIGH output only when the number of HIGH (TRUE) inputs is odd. This makes XOR useful when you want to trigger an action based on exactly one condition being active—or an odd number of conditions.

Example 1: Two Switches

Example 2: Three Inputs – Two Switches and One Level Sensor

XOR logic is useful in control systems where exactly one (or an odd number) of inputs should activate an output. It helps avoid conflicts caused by multiple simultaneous signals.

img/scl-logical-operators/siemens-scl-logical-xor-expression.webp

Siemens SCL NOT Logical Expression

The NOT logical expression is used to invert a Boolean value. It returns TRUE when the input is FALSE, and returns FALSE when the input is TRUE. This is called negation or generating the one's complement of a logical value.

The NOT operator is useful when you want to trigger an action when something is not true. For example, you may want to run a motor when a switch is not pressed or a condition is not active.

Example 1: One Switch Must Be OFF

Example 2: Using NOT with OR Expression

The NOT operator is often used in conditions where you want to reverse the logic or stop a process when a condition becomes active. It is essential for creating fail-safe logic or handling default inactive states.

img/scl-logical-operators/siemens-scl-logical-not-expression.webp