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: Repeat Until 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 > Repeat Until Statement in SCL Language

Repeat Until Statement in SCL Language

Learn how to use the repeat until statement in SCL language for effective coding practices in the Siemens TIA Portal.

Last updated: April 1, 2025 10:09 am
Viral Nagda
PLC Tutorials
No Comments
Share
6 Min Read
SHARE

In the earlier post, we saw how to write regions in the SCL language. Now, in our last post related to a series of different types of constructs or statements, one type to check more is repeat-until statement. Repeat until is a very powerful tool used to execute statements which require repetitive loops. It is similar to while-do loop, but has some slight differences. It is thus necessary to understand the differences between various types, so that a programmer can use them accordingly. In this post, we will see how to use repeat until statement in SCL language of TIA Portal.

Contents
What is a repeat-until statement?How to write a repeat-until statement in SCL language?

What is a repeat-until statement?

Repeat until the statement will be easier to understand if related with the while-do statement. As opposed to a while-do statement which executes statements as long as the condition is true, a repeat-until statement executes lines as long as the condition is false. A single condition is checked, and if this condition is not satisfying, then the statements will be executed in a continuous loop. When the condition goes true, it goes out of the loop and exits. So the general meaning is that – while the condition is false, execute the statements in a loop until the condition goes true, and then come out of the loop.

The general syntax for this construction is

Repeat

Statement;

Until condition

End_repeat;

The meaning is – execute the statement, check for the condition, and again repeat the loop. Then again execute the statement, check the condition, and repeat the loop. This loop will continue until the condition goes true. Once true, the loop is exited and the PLC executes other logic written. So, you can see that it is completely opposite of the while-do statement. Also, the condition is checked in the last, as compared to the start which is done in a while-do statement.

If it is required to exit the loop in between, then mention a keyword named exit; in between. Due to this, the loop terminates without executing fully. You can also write this under an if-else condition, to come out forcefully from the loop. One thing to remember is to not execute a loop under an already existing loop; otherwise it will become infinite and the PLC will go into fault mode.

How to write a repeat-until statement in SCL language?

Refer to the below image. The logic is – while the value of seconds is more than 0, decrement it’s value every 1 second by 1. The initial value of this tag will be 10. Once this value becomes less than 0, then the decrement will be stopped. For your understanding, I will also use the exit keyword to understand more better.

Repeat Until Statement in SCL Language

The execution flow is as follows –

  1. We have fixed or initialised the value of the secs as 10.
  2. First, the secs is initiated to 10, so that abrupt addition does not execute.
  3. So, with the PLC encountering a repeat keyword first, the statements inside this construct will be executed. A timer instruction is first written for executing every 1 second. After every 1 second, we decrement the value by itself to 1, as shown in the 66th line.
  4. The condition to exit the loop is then checked as Secs <=0. If this condition is not yet achieved, then the loop is again executed from the start. As the value has now become 9 and still more than 0, the loop is executed once again.This goes on till the value becomes 1. The loop is executed one last time and when it becomes 0, the execution stops and the loop is exited finally.

You could have written this statement in an if-else style too. Simply replace the repeat statement as – if secs>0 then, remove the exit and until keywords and replace end_repeat with end_if. But, this is good for our example of simple decrement. If complex statements are required to be executed continuously in a loop, then you would have to write an if-else statement, which would make the program bulkier. In that case, a repeat loop statement makes a task much easier to work.

In the next post, we will see how to insert block calls in SCL language.

Read Next:

  • Flip-Flop PLC Programming Examples
  • Example of PLC based on Logic Circuit
  • PLC Example Program for Star-Delta System
  • Siemens PLC Program Course for Beginners
  • Analog Alarms using Functional Block Diagram
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

200+ Quiz on Electrical Meters, Measurement, and Troubleshooting
Basic Conveyor System for Product Handling in Omron PLC
HMI Handbook
PLC based Automatic Packaging System
Free Mitsubishi PLC Online Training Course and Tutorials
Control Speed of Induction Motor using Analog Output of PLC
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

Series Tanks Level Control using PLC Ladder Programming
Top Free PLC Software
FactoryTalk View Studio – Import and Export Tutorial
4-20 mA Transmitter Wiring Types : 2-Wire, 3-Wire, 4-Wire
Implement UDT in PLC Programming: User-Defined Data Type
Free Download Programmable Logic Controller (PLC) Book
Free Siemens PLC Training Course
PLC Programming for Fan Control Unit System for Industry

Keep Learning

Overview of Industrial Control Systems

Overview of Industrial Control Systems

Types of Digital Outputs in PLC

Types of Digital Outputs in PLC

Electrical Ground Loop

How to Solve Electrical Ground Loop Problems?

Indusoft SCADA Modbus Communication

Establishing a Modbus Driver for SCADA Indusoft Web Studio

Why Use Normally-Closed Contact for Stop Buttons

Why Use Normally-Closed Contact for Stop Buttons?

Complementary Split Range Control

What is Complementary Split Range Control (CSRC)?

Wiring in PLC System

Wiring in a PLC Control Panel

Difference between Analog Signal and Digital Signal

What are Analog and Digital Signals? Differences, Examples

Learn More

Diaphragm seal for pressure measurement device

When to use a Diaphragm Seal?

Software Troubleshooting Errors and Faults in Siemens PLC

Software Troubleshooting Errors and Faults in Siemens PLC

Feedback Accelerometer System Objective Questions

Feedback Accelerometer System Objective Questions

Rotary Granulator Drive

Rotary Granulator Drive Root Cause Analysis (RCA)

Latching and Unlatching in PLC Programming for Beginners

Latching and Unlatching in PLC Programming Example

How to Prevent Ground Loops in Analog Circuits?

How to Prevent Ground Loops in Analog Circuits?

PLC Program to control level of parallel tanks

Parallel Tanks Level Control using PLC Ladder Diagram Tutorial

Why Using VoIP Systems

Why Using VoIP Systems Can Save You and Your Business Money?

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?