Skip to content
PROCESIAby Aterra Ingeniería

LEARN · PROGRAMMING · SCL 1

SCL from scratch: from ladder to text

Never written code? No problem. If you understand a ladder rung, in 7 short exercises you will write your first SCL program and watch it move a plant.

If you know ladder, you already know SCL

SCL is a way of programming the PLC by writing instead of drawing. The logic is the same as ladder: only how it is written down changes. This table is all you need to get started:

In ladderEn SCL
Normally open contact of XX
Normally closed contact of XNOT X
Contacts in seriesAND
Contacts in parallelOR, in parentheses
Coil YY := ... ;

For example, the rung “if LSH_101 is active, turn on the pilot light XL_101” is written like this:

XL_101 := LSH_101;

It reads “XL_101 takes the value of LSH_101”. The := means “takes the value of” and the ; ends the line, like a period. Whatever comes after // is a comment: the PLC does not read it.

In each exercise you will see the ladder rung next to the code, lighting up while the plant runs. First you read, then you change one word and finally you write it yourself.

See a hint

  1. 1Write or change the code
  2. 2Tap ▶ Run and test it on the plant
  3. 3Tap ✓ Check to review it
Program · OB1 (SCL)

Ctrl + Enter runs. Your code is saved in this browser.

TK-101 tank
FCV-102 45 % TK-101 LSH-101 LSL-101 P-101 XL-101
Level45 %
Watch table

The logical operators

  • NOT a: inverts. TRUE if a is FALSE.
  • a AND b: TRUE only if both are TRUE. It is a contact in series.
  • a OR b: TRUE if at least one is TRUE. It is a contact in parallel.
  • a XOR b: TRUE if they are different.

Order matters: NOT is evaluated first, then AND, then XOR and finally OR, just as multiplication comes before addition. When in doubt, use parentheses.

a OR b AND c // is read as a OR (b AND c)

Latching, in one line

P_101 := (HS_101_MARCHA OR P_101) AND NOT HS_101_PARADA;

It is the same rung from the hysteresis lesson, written as text: the OR P_101 is the pump contact in parallel with the start pushbutton, and the AND NOT is the normally closed stop contact in series. Since the PLC remembers the value of P_101 from the previous cycle, the pump keeps itself on.

In TIA Portal

In a TIA Portal SCL block, global tags go in quotation marks and local variables with #. This simulator accepts both forms, so you can copy your code as is:

"P_101" := ("HS_101_MARCHA" OR "P_101") AND NOT "HS_101_PARADA";
In a real installation, the stop pushbutton is wired normally closed: the input is TRUE when it is not pressed. So you write AND "HS_101_PARADA", without the NOT. That way, if the wire breaks, the pump stops instead of being left with no stop.

What comes next

In lesson 2: IF, ELSIF and ELSE, comparisons with numbers and the scaling of a 4–20 mA signal to meters.

Your program, on a 3D plant

In Procesia you write this same SCL on your real PLC or in PLCSIM and control the TK-101 tank in 3D, with pumps, valves and instruments. Use the full version free for 7 days, no card.