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

Motor Feedback Fail Logic in PLC
PLC Techniques for I/O Mapping
Car Wash Program using Functional Block Diagram (PLC)
Use of Isolators and Barriers in Electrical Panel
PLC based Drink Dispenser System
Advanced Skills Required for a PLC Programmer to Get a Job
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

Siemens PLC Mathematics Instructions
Troubleshoot Allen Bradley PLC Logic
Open User Communication in Siemens Tia Portal – PLC to PLC
Mixing Program with Timers and Counters in Omron PLC
Troubleshooting a 4-20mA Current loop
Face Mask Making Machine using PLC and HMI
Feedback Monitoring in Safety PLC
How to Create Faceplate in FactoryTalk View Studio?

Keep Learning

Single-Acting Cylinder Control Operation using Proximity Sensor

Single-Acting Cylinder Control using Proximity Sensor

What is NEST loading in DCS

What is Nest Loading? – DCS and PLC Control Systems

SCADA in Cloud

Cloud-Based SCADA Projects – Try Free Demo Account

PLC Programming in Hindi - Siemens Tia Portal Full Course

PLC Programming in Hindi – Siemens Tia Portal Full Course Free

What is Multi-touch Technology

What is Multi-touch Technology? – Industrial Automation

Siemens PLC Organization Blocks used For Troubleshooting

Tia Portal – OB121 Programming Errors Interrupt Organization Block

What is Siemens TDC - Siemens Control System

What is Siemens TDC? – Siemens Control System

PLC Program

PLC Program to Heat and Bend Glass Tubes

Learn More

Substation Interview Questions Answers

Substation Interview Questions Answers

Extended Timer Logic in PLC

Extended Timer Logic in PLC

Programmable Logic Controller Quiz

Programmable Logic Controller Quiz

pH Analyzers Questions and Answers

Combination Electrode Questions & Answers

steam heat exchanger

Practical Process Control System Questions & Answers – 9

Orifice Plate Sizing

Orifice Sizing Guidelines and Thumb Rules with Flowchart

Example Ladder Logic Diagram

What is Relay Logic ?

Siemens PLC

#20 PLC Best Practices – Identify Critical Alerts

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?