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: Rules for Writing SCL Language in Tia Portal
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 > Rules for Writing SCL Language in Tia Portal

Rules for Writing SCL Language in Tia Portal

Learn the essential rules for writing SCL language and avoid compiling errors in your code. Master syntax with our guide.

Last updated: March 15, 2025 4:30 pm
Viral Nagda
PLC Tutorials
No Comments
Share
6 Min Read
SHARE

In the earlier post, we saw how to use value assignments in SCL language. Be it any statement or condition, there are certain rules to follow when writing this language. It usually applies to all the platforms where ST language is available. If proper syntax and instructions are not followed, then compiling errors will come and you will not be able to solve the issue. In this post, we will thus see some general rules to be followed for writing SCL language in the TIA portal.

Rules for Writing SCL Language

  1. A statement in SCL language must always end with a semicolon. This does not apply to a condition start; like if you use while-do structure, then the semicolon will come inside each statement and not after the while-do line. Then, once the structure is finished, a semicolon too must be used. For example, in our while-do structure, it ends with end_while. So, a semicolon must be used to terminate it. In short, every statement where write instruction is executed and every end of a structure type must be terminated by a semicolon.
  2. It is not necessary to use structures like if-else or while-do compulsory in the program. For example, a simple statement like – tag1:= tag2 AND (NOT tag3); can also work. You could have written it as:

if (tag2 AND (NOT tag3)) then

tag2:=1;

else

tag2:=0;

end_if;

Due to this, your coding size will be reduced. It all depends on how you interpret your conditions well and try to optimize it.

  1. It is also not compulsory to use spaces and tabs. But, using them makes the program look more aesthetic and clean. Just congesting all the words makes no use. A single space is allowed between two variables, but you can use as many spaces and tabs to make an expression look easier. For example, the below construct

            If (tag1 =  tag2)

            Then

            Tag3 := tag4;

            End_if;

It can also be written properly as below, which makes the programmer know that the  below construct is an if-else statement.

            If (tag1 =  tag2)

                        Then

                                    Tag3 := tag4;

            End_if;

  1. You can write as many lines as you require in a single program. It depends on how you need to optimize the code and reduce memory consumption of the PLC.
  2. The SCL language is not case sensitive. So, if you have defined a variable names test and used Test in the code, then too the variable can be compiled without any error.
  3. It is not compulsory to use comments in the program. They are only for understanding purposes. However, it is recommended to use them for easier troubleshooting. Usually, a comment is started with // or starts with (* and ends with *).
  4. All the available data types according to IEC standard can be used in SFC language and there is no limit to it.
  5. The operators inside a condition or statement are executed according to precedence order, also called as order of operations. In mathematics, it is also called as parenthesizes. // or starts with (* and ends with *). A comment can also be used to bypass an expression from the program and not bring it into the execution scan of PLC.
  6. All the available data types in PLC according to the IEC standard can be used in the SLC language code. Just remember to match them properly in an expression. Means, you cannot compare a boolean tag with an integer tag for example. So, the use of correct data types are a must in the program.
  7. Similarly as used in mathematics, an expression executes the operators inside it according to the precedence order. It is also known as order of operations. For example, in (tag1 + tag2 * tag3), multiplication will execute first, and the result will then be added. That means, operators with higher precedence are executed first, and then goes on to lower priorities.
  8. Bracket termination is important to use, otherwise your program will not compile. For example, you have (( brackets in the start, but end with ))) brackets; then your program will not compile. Whatever is the number of brackets in start, the same number of them must be used in the end to terminate an expression or construct.

In this way, we saw some general rules pertaining to writing SCL language in the TIA portal. In the next post, we will see the detailed use of if-else constructs 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

PLC Programming for Sequential Batch Mixing System
PLC Programming Projects for Beginners
OB1 – Main Cyclic Organization Block in TIA Portal
Unknown Do’s Need to Know as a PLC Programmer
Ladder Logic for Flow Meter Totalizer
#18 PLC Best Practices – Store PLC Hard Stop Events from Faults
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

Examples of SCADA and PLC Configuration Systems
PLC Instruction List Example for Level Control of Tank
Doll Claw Machine using Omron PLC Programming
Automatic Motor Forward and Reverse Control using Timer
What are Faceplates? How to Create a Faceplate? HMI Visualization
What is Recipe Management in SCADA?
Example of Controlling the PLC Output using Push Buttons
How to use Sub Routines with Allen Bradley PLC

Keep Learning

How to Program Sequential Outputs in PLC

Timer-Based Sequential PLC Program with One Button

how-a-4-20ma-transmitter-works

How a 4-20mA Transmitter Works?

PLC Based Metro Automation Project

PLC based Metro Automation Project

Contextual HMI

What is Contextual HMI? – HMI Screens on a Mobile or Tablet

PID Block in RSLogix 500

PID Block in RSLogix 500

Preventa XPS MC, XPS MP - Safety controllers

High-end Programmable Logic Controller – Schneider PLC

Industrial motor control using PLC instruction list programming

PLC Instruction List for Motor Reverse and Forward Direction

PLC Demo Software

PLC Trainer Demo Download

Learn More

Magnetic proximity sensors

Magnetic Proximity Detectors – Types, Principle, Advantages

Magnatic Level Indicators Working Animation

Magnetic Level Indicators Working Animation

AND Gate Logic Animation

Digital Building Blocks – GATES

Reduce Control Valve Noise

How to Reduce the Control Valve Noise?

Piping and Instrumentation Diagram

What is Piping and Instrumentation Diagram (P&ID) ?

pn-junction-energy-diagrams

Energy Diagrams of PN Junction & Depletion Region

International Standards - Types and their Details

International Standards – Types and Their Details

Split Phase Motor

Single Phase AC Induction Motors

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?