In the previous post, we had a brief introduction to the SCL language and saw how to start writing the language. Once we have gone through this, we must first learn what are the valid types of expressions which this language accepts with proper syntax. If you are not able to write them properly, then you will not be able to use this language. In this post, we will see some general types of expressions which are used in the SCL language of the TIA portal (mostly, it is uniform in other automation platforms too).
Arithmetic expressions
As the name implies, you can use mathematical operators for creating calculations and also for assigning values. They work on numerical values and can be used either as conditions or statements. The data types must be used properly in the code before doing any mathematical operation. You can use all the data types using arithmetic expressions, except strings. The various types of arithmetic operators are – power(**), plus(+), minus(-), multiplication (*), division (/), and modulo function (MOD).
Relational expressions
Relational expressions compare values and give you a result based on those comparisons. The final answer will always be true or false. They work on numerical or string values and can be used only as conditions. The data types must be used properly in the code before doing any relational operation. You can use all the data types using relational expressions.
The various types of relational operators are – equal(=), not equal(<>), less than(<), less than or equal to(<=), more than(>), and more than or equal to (>=).
Logical expressions
Logical expressions refer to the gate logic we use in digital circuits. They work on numerical and string values and can be used either as conditions or statements. The data types must be used properly in the code before doing any logical operation. You can use all the data types using logical expressions. The various types of arithmetic operators are – AND, OR, NOT, and XOR.
Types of Expressions in the SCL Language
Let us now write a logic using all these expressions. We will again convert the ladder logic into SCL logic, and see how to write using proper syntax. The logic is – if the variable I_Start is on or the variable Sys_Running is on and the variable I_Stop is off and the variable I_Sensor is more than 30, then the variable Sys_Running turns on and a variable Add_Tag is added with itself and 1. If any of the conditions goes false, then the output too will turn off and the addition will pause. Refer to the below image for ladder logic.

Now, we write the following logic in SCL code as below:

Let us understand how it is written by referring to the below image. You get a direct view with the ladder logic. Continuing from our earlier post, we just added a sensor value comparison and added a tag when the system is running. As the sensor comparison is required in series, we add an AND syntax before that, and compare the tag by putting > syntax. Once the condition is true, we also add a tag as required. As discussed before, the write tag comes in the left hand side of :=; so add_tag comes before :=. The values to write comes in the right hand side of :=; so we write as add_tag+1.
Note that we are not asked to reset the value of addition in the question anytime; so we are just not writing anything in the false condition, where we turn off the running bit. So, it all depends on how you read and understand the question first. The same was written in ladder logic.

In this way, we saw some general types of expressions in the SCL language of TIA Portal. Next, we will see some different types of value assignments in the SCL language.
Read Next:
- PLC Instruction List Program for Basic Instructions
- How to do Scaling for Analog Input in RSLogix 500?
- PLC Light Sequence Control using Bit Shift Registers
- PLC Instruction List for Motor Reverse and Forward
- Timer-Based Sequential PLC Program with One Button