Schneider PLC Structured Text Programming Examples

Published on Sep 01, 2025 | Category: oper-block

Share this Page:

Arithmetic operators are the foundation of any Structured Text (ST) program in a Schneider PLC. Using operators like +, -, *, and /, engineers perform real-time calculations for process values such as flow rate, temperature, or motor speed. Within EcoStruxure Control Expert, arithmetic logic lets you scale analog inputs, create set-point adjustments, and implement energy-saving formulas directly in code.

Once raw values are calculated, conditional operators and IF…THEN…ELSE statements decide how the PLC should react. For example, you can instruct the controller to open a valve if pressure exceeds a threshold, or stop a motor when a limit switch is active. Conditional logic turns numeric data into clear yes/no actions, ensuring that your automation sequence behaves predictably and safely.

Combining arithmetic and conditional statements builds the core of most real-world programs. In Schneider EcoStruxure, you can layer loops, timers, and counters on top of this logic to manage batching, machine cycles, or safety interlocks. Mastering these building blocks early makes future tasks—like advanced PID control, data logging, or diagnostics—much easier, while keeping your PLC code clean, readable, and efficient.

Arithmetic Operators in Structured Text (ST)

In Structured Text (ST) for PLCs, an arithmetic operator is a symbol used to perform mathematical calculations on numeric variables or constants. ST behaves much like a high-level language, so the math symbols are simple and familiar.

Operations follow normal precedence (exponent → multiply/divide/mod → add/subtract). Use parentheses () to control the calculation order, for example Avg := (A + B) / 2;. These operators make it easy to handle scaling, set-point math, and real-time process calculations inside the PLC.

Arithmetic Operator Examples in Structured Text (ST)

Structured Text in Schneider PLCs allows engineers to perform clear and readable calculations directly inside the controller. Arithmetic operators form the backbone of scaling analog inputs, calculating machine efficiency, or preparing set-points for downstream logic. Below are practical examples showing how each operator is applied.

Always use parentheses () to control the order of operations. Structured Text follows normal precedence (exponent → multiply/divide/mod → add/subtract), so explicit grouping ensures the PLC performs calculations exactly as intended. This disciplined approach keeps your math routines predictable, easier to review, and ready for expansion when the process grows more complex.

Practical Arithmetic Example in Structured Text (ST)

Let’s consider a scenario in a water treatment plant where you need to calculate the adjusted flow rate of a pump based on measured flow, temperature compensation, and a scaling factor. This shows how arithmetic operators are used in a real PLC program.

This simple arithmetic chain demonstrates how addition, division, and multiplication operators can be combined in a practical, real-world PLC application. Engineers can extend this logic further by adding safety checks, conditional limits, or integrating it into alarms and data logging routines.

Conditional Operators in Schneider PLC Structured Text (IF…THEN…ELSE)

Conditional operators in Structured Text (ST) allow a PLC program to make decisions based on process values. Using IF…THEN…ELSE statements, you can compare variables and execute specific code blocks only when certain conditions are met. This is essential for automation tasks such as controlling motors, valves, alarms, or any equipment that needs to react to changing process conditions.

Conditional operators are essential for process control and safety logic. They allow your Schneider PLC program to react dynamically to changing inputs, implement alarms, control actuators, or manage machine cycles effectively. Combining conditional logic with arithmetic operations enables advanced automation strategies.

Practical Conditional Example in Schneider PLC Structured Text

Building on our previous example of calculating AdjustedFlow, we can use conditional operators to make decisions. For instance, we may want the PLC to start or stop a pump depending on the flow, or trigger an alarm if the flow is too high or too low. This demonstrates how arithmetic results feed directly into process control.

This example shows how conditional operators in Structured Text can control real-world processes safely and efficiently. Combining arithmetic calculations with IF…THEN…ELSE logic allows the PLC to react dynamically to changing conditions, ensuring reliable and automated operation of industrial equipment.

Combined Arithmetic and Conditional Example in Schneider PLC Structured Text

In real-world industrial automation, arithmetic operations are often followed by conditional checks. For example, after calculating an adjusted flow rate, a PLC can decide whether to start or stop a pump and trigger alarms if necessary. This example shows how both arithmetic and conditional operators work together in Schneider PLC Structured Text.

Combining arithmetic and conditional logic in this way allows Schneider PLC programs to perform real-time calculations and make decisions automatically. This pattern is widely used in industrial automation for process control, safety, and efficiency improvements.