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: Case Statement in SCL Language
Share
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 > Case Statement in SCL Language

Case Statement in SCL Language

Explore the Case Statement in SCL language and learn how it simplifies coding for selection-based programs.

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

In the previous post, we saw how to write an if else statement in SCL language. The next construct we are going to use is case statement. This Case statement is used widely for selection-based programs, which helps in reducing code size if an if else statement was used. So, studying case statements is a very integral part of learning ST language. In this post, we will see the use of case statements in SCL language.

Contents
What is a case statement?How to write a case statement in SCL language?

What is a case statement?

A case statement is a construct which is used to execute statements inside it based on the various types of cases or values. That means, if there are 10 cases, then when a current case value matches the set case value, the corresponding statements inside that set case are executed. This is useful when you have various criteria and want to execute a criteria depending on the current condition. If case statement is not used, then you can use an if else statement too here, but the program coding will be increased and also the complexity.

The general syntax of case statement is :

Case var of

1: statement;

2: statement;

3: statement;

..

N: statement;

end_case;

Here, the var refers to a variable which takes a value and depending on that value, the statements matching that case value are executed. Means if the current value is 2, then the statements under case-2 will be executed.

How to write a case statement in SCL language?

Now that we have understood the basics, let us write a sample logic using a case statement. Refer to the below image, where we compare it with an if else statement. The logic is – if the value of variable I_Pv is 34, then we add 1 with the value of var_2 and move the answer to var_1; and if the value of variable I_Pv is 35, then we add 1 with the value of var_3 and move the answer to var_1.

Case Statement in SCL Language

In the first scenario, we used an if-else statement. In the first if-else construct, we write the logic for comparing I_Pv with 34. In the second if-else construct, we write the logic for comparing I_Pv with 35. Then, whichever condition is true, the corresponding addition is done inside them. Due to this, our logic is executed.

But if we see the second scenario, we used a case statement. Here, as per the general syntax mentioned earlier, we use the case of I_Pv as reference value. The statement monitors the current value of this variable, and if the value is 34, then the addition written under 34: is executed; and if the value is 35, then the addition written under 35: is executed. Then, we terminate the construct with the end_casekeyword.

If there are a large number of such comparisons, then instead of writing an if or if else multiple times, we can simply use a case statement for solving the issue. Our coding size reduces and the program too looks easier to troubleshoot.

In the next post, we will see how to use a for do statement in SCL language.

Read Next:

  • Types of Expressions in the SCL Language
  • Mail Box Automation: Programming with PLC
  • PLC Hoist Crane Programming Example
  • PLC Mixing Process with Timer and Valve Control
  • PLC Programming for Loss in Weight Liquid Systems
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

OMRON PLC Tutorial: Car Parking System Application
What is Function Module in Siemens PLC?
PLC Math instructions
Interconnection between PLC, MCC, LCP & Pumps – Video
PLC Programming Best Practices and Tips
PLC Programming: Sorting and Distribution of Boxes by Height
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

PLC Energize or De-energize the Outputs based on Events
Pulse Timer Instruction in PLC Programming
Workstation Healthiness Checks
Advanced Skills Required for a PLC Programmer to Get a Job
Safety Considerations in PLC System Design
PLC Digital Input and Digital Output Modules
Turbine-Compressor System Architecture
How to do Scaling for Analog Input in RSLogix 500?

Keep Learning

Download Free HMI software – CODESYS

Basic PLC Alarm Programming Example

Basic PLC Alarm Programming Example

Indusoft SCADA Modbus Communication

Establishing a Modbus Driver for SCADA Indusoft Web Studio

Comparator used in Siemens S7-1200 PLC.

Siemens PLC Comparator Logic

Electrical Cabinet Air Conditioner

Electrical Cabinet Air Conditioner – Enclosure Cooling, Maintenance

PLC Program Upload

How to Upload Siemens PLC Programs?

Motion Detection based Street Light PLC Logic Solution

Motion Detection based Street Light: PLC Logic Solution

PLC Program to Drain Same Products from Two Tanks

PLC Program to Drain Same Products from Two Tanks

Learn More

Digital Electronics Multiple Choice Questions

Compatibility Objective Questions

DC Generators Objective Questions and Answers

DC Generators Objective Questions and Answers

Electrical Machines Questions and Answers

Induction Motor Rotor EMF, Current and Power

Digital Electronics Multiple Choice Questions

Combinational Circuits Objective Questions

Select Security type Intouch

How to Add Security in InTouch SCADA?

Electrical Machines Questions and Answers

Commutator Action Quiz

Measure Frequency using Multimeter

How to measure frequency using Multimeter

State Variable Analysis and Design

State Variables & Linear Discrete Time Systems

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?