Inst ToolsInst ToolsInst Tools
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
  • Request
Search
  • Books
  • Software
  • Projects
  • Process
  • Tools
  • Basics
  • Formula
  • Power Plant
  • Root Cause Analysis
  • Electrical Basics
  • Animation
  • Standards
  • 4-20 mA Course
  • Siemens PLC Course
Reading: If Else Statement in SCL Language
Share
Notification Show More
Font ResizerAa
Inst ToolsInst Tools
Font ResizerAa
  • Courses
  • Design
  • PLC
  • Interview
  • Control System
Search
  • Courses
  • Automation
    • PLC
    • Control System
    • Safety System
    • Communication
    • Fire & Gas System
  • Instrumentation
    • Design
    • Pressure
    • Temperature
    • Flow
    • Level
    • Vibration
    • Analyzer
    • Control Valve
    • Switch
    • Calibration
    • Erection & Commissioning
  • Interview
    • Instrumentation
    • Electrical
    • Electronics
    • Practical
  • Q&A
    • Instrumentation
    • Control System
    • Electrical
    • Electronics
    • Analog Electronics
    • Digital Electronics
    • Power Electronics
    • Microprocessor
  • Request
Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Inst Tools > Blog > PLC Tutorials > If Else Statement in SCL Language

If Else Statement in SCL Language

Learn about the If Else Statement in SCL Language and how it simplifies programming with conditional logic.

Last updated: March 25, 2025 2:29 pm
Viral Nagda
PLC Tutorials
No Comments
Share
6 Min Read
SHARE

As seen in earlier posts, one of the most used constructs in SCL language is an if else statement. This is the most used statement in ST language of overall automation platforms. What makes it popular is its relative simplicity in defining them. If a programmer at least learns this construction only, then too he can make a whole program in SCL language. In this post, we will see how we can write different styles in an if else statement.

Contents
What is the if else and if statement?How to write an if statement?How to write an if else statement?

What is the if else and if statement?

As the name describes, an if else statement is a construction which checks the condition first and then executes a statement inside it if true. Or else, it will execute another statement if false. So either way, it will execute something or the other. A simple statement apart from if else is an only if statement. In this case, if the condition is true, then only the statement inside it will execute. Otherwise, it will skip the whole construct and go to the next line after end_if line. So, you can either use if or use if else statements according to your requirement. We will see the use of both cases in the next part.

How to write an if statement?

Let us see the first style on how to write a simple if statement. Refer to the below image. As defined above, if the condition is true, then the statements inside it will execute. Otherwise, it will leave and go to the next case. In our example, we use the same ladder logic of start and stop. The logic written is – if the variable I_Start is on, then the variable Sys_Running turns on. If the variable I_Stop is on, then the variable Sys_Running turns off. So, as in the ladder logic, we need to latch the system running bit, because the start button is momentary. That is why, we write the logic below.

If Else Statement in SCL Language

Now, if we see an if statement written in SCL language, we use two such types. In the first case, if the start variable is on, then we write value “1” to the sys_running bit. If the start variable was not on, then the statement inside it would not execute. But here, we also need to turn it off when the stop button is pressed. So in the second case, if the stop variable is on, then we write value “0” to the sys_running bit. If the stop variable was not on, then the statement inside it would not execute. Due to this, our logic is executed properly according to our requirements. So, the step to write an if statement is – write the condition inside if keyword, use then keyword, write the statements inside it, and use end_if keyword to terminate.

How to write an if else statement?

Let us see the second style on how to write a simple if-else statement. Refer to the below image. As defined above, if the condition is true, then the statements inside it will execute. Otherwise, it will execute the other statements and go to the next case. In our example, we use the same ladder logic of start and stop. The logic written is – if the variable I_Start is on, then the variable Sys_Running turns on. If the variable I_Stop is on, then the variable Sys_Running turns off. So, as in the ladder logic, we need to latch the system running bit, because the start button is momentary. That is why, we write the logic below.

SCL Statements IF ELSE

Now, if we see an if-else statement written in SCL language, we use one such type. If the start variable is on or the sys_running bit is on and the stop variable is off, then we write value “1” to the sys_running bit. Else, we write value “0” to that same bit. So, in either case, the corresponding statements are executed. Due to this, our logic is working properly according to our requirements. So, the step to write an if-else statement is – write the condition inside if keyword, use then keyword, write the statements inside it, then use else keyword, write the statements inside it, and use end_if keyword to terminate.

In both the styles, the work done is the same. Only the way of writing differs. For this purpose, you need to understand the question first in any case, which will help you write the logic in any scenario. In the next post, we will see how to use case statements in SCL language.

Read Next:

  • Types of Expressions in the SCL Language
  • How to Configure IP Address in Rockwell PLC?
  • Complex Car Parking Logic in Electric PLC
  • PLC Bottle’s Capping with a Rotating Mechanism
  • PLC Programming for Sorting Conveyor System
Don't Miss Our Updates
Be the first to get exclusive content straight to your email.
We promise not to spam you. You can unsubscribe at any time.
Invalid email address
You've successfully subscribed !

Continue Reading

Functional Block Diagram in PLC for Oil and Water Process
Explaining Various Types of Analog Instruments
Free Download Programmable Logic Controller (PLC) Book
Top Free PLC Software
Ladder Logic MCQ Questions and Answers
Move Instruction in Tia Portal
Share This Article
Facebook Whatsapp Whatsapp LinkedIn Copy Link
Share
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

128.3kFollowersLike
69.1kFollowersFollow
210kSubscribersSubscribe
38kFollowersFollow

Categories

Explore More

Types of Expressions in the SCL Language of the Tia Portal
Real-Time Clock in Omron PLC? – CX Programmer
Yokogawa DCS and SIS System Architecture
Mixing Program with Timers and Counters in Omron PLC
Difference Between Normal Counters and Fast Counters – Learn PLC
Statement List (STL) to Find Highest Value
Developing PLC Logic for Water Pumping and Chemical Addition
Pause the Timer PLC Ladder Logic

Keep Learning

Retrieve from memory card

How to Retrieve PLC Project From Memory Card?

Sequencer Output in PLC

PLC Sequencer Instruction with Example

4 TO 20 MA ANALOG CURRENT SIGNALS

Basics of 4 to 20 mA analog Signals

Automatic Packing of Bottles

Automatic Packing of Bottles Programming

Automatic Liquid Mixing Application

PLC Program for Automatic Liquid Mixing Application

OMRON PLC program for waste-burning automation

Waste-Burning System OMRON PLC Program Example

Earthing Calculations

Electrical Earthing Calculations

Control 3 Motors with Toggle Switch

PLC Ladder Logic Design: Control 3 Motors with Toggle Switch

Learn More

Calculate the Thermocouple’s Measurement Junction Temperature

Calculate the Thermocouple’s Measurement Junction Temperature

Applications of Tilting Level Switch

How Tilt Level Switch Works ?

Types of Motor Enclosures

Types of Motor Enclosures

Transmission Control Protocol

Difference Between TCP and UDP

Power Electronics Objective Questions

Power Diode Objective Questions

Working Principle of Water Chillers

HVAC Water Chillers Principle

Connect the Differential Pressure Gauge at the Filter

How Do You Connect the Differential Pressure Gauge at the Filter?

Identify Instrumentation Terms in Water Supply System

Identify Instrumentation Terms in Water Supply System

Menu

  • About
  • Privacy Policy
  • Copyright

Quick Links

  • Learn PLC
  • Helping Hand
  • Part Time Job

YouTube Subscribe

Follow US
All rights reserved. Reproduction in whole or in part without written permission is prohibited.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?