0% found this document useful (0 votes)
103 views7 pages

SCL Programming TIA Portal

The document provides an introduction to programming in SCL, a structured text language similar to Pascal or C. It includes examples of SCL code for controlling outputs through inputs, using conditional statements, and implementing various logical operations. Additionally, it outlines the creation of a variable table and the structure of SCL programs using function blocks (FC) called from the main block (OB1).
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views7 pages

SCL Programming TIA Portal

The document provides an introduction to programming in SCL, a structured text language similar to Pascal or C. It includes examples of SCL code for controlling outputs through inputs, using conditional statements, and implementing various logical operations. Additionally, it outlines the creation of a variable table and the structure of SCL programs using function blocks (FC) called from the main block (OB1).
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

(Generalitat of Catalonia

MU Department of Education
Illa dels Banyols Institute

Introduction to programming in SCL

SCL is a structured text language whose syntax is similar to other high-level, general-purpose languages such as
Pascal or C.

1. The first thing to do is to create a table with the input and output variables that will be used in the
programming.

Standard Variables Table


.Create a new group. Name to Data Type Address Row... Visibl... Acces... Comment
• Add device 4 Enter da0 Boolean %10.0 □
0 •
i Devices and networks 2 4 Enter 1 Boolean %IO.1 □
0 0
3 4 Enter da2 Boolean %10.2 □
- Lm PLC_1 [CPU 1214C 0 0
4 4 Enter 3 Boolean %IO.3 □
nT Device 0 0
Online and diagnosis 5 41 Enter da4 Boolean %10.4 □
6
0 0
• Program blocks 4 Tickets Boolean %10.5 □
0 0
► # Technological objects 7 4 ExitO Boolean %Q0.0 □
0 0
► External sources 41 Exit 1 Boolean %Q0.1 □
89 0 0
4 Exit2 Boolean %Q0.2 □
▼ Ca PLC Variables 0 0
- Show all I... 10 4 Exit3 Boolean %Q0.3 □
0 0
• Add table of ... 11 I cAgregan s □
0 0
“4 Table of variables.. ► •i PLC data types

2. A function (FC) is created and the SCL language is chosen.

3. This function is called unconditionally from OB1.

Segment 1
Comment

%FC1
"REE_SCL"

IN EMO

Version: 1.0
Elaborated by: Enrique Ubeda
Printing date: 02/12/2019
ILLA deis Archive: SCL_Programming.doc Page1 6
(Generalitat of Catalonia
MU Department of Education
Illa dels Banyols Institute
4. SCL code must be written in the FC block.

SCL programming examples:

Example 1: Controlling an output through an input.

SCL code:

1 //SCL Examples (C) REEA 2013


2 // Act iva r_De s activate an output with an input
3 EIF "Input0"=1 THEN
4 "Output0":=l;
5 ELSE

"Output0":=0;
7 _END_IF;

Equivalent circuit in KOP:

Example 2: Controlling an output using Set/Reset.

SCL code:
9 //SCL Examples (C) REEA 2013
10 //Activate an output (Set)
11 E1IF "Input"=true THEN
12 "Output":=true;
13 _END_IF;
14 //Disable an output (Reset)
15 IF "Input2"=true THEN
16 "Salidal":=false;
17 END_IF;

Equivalent circuit in KOP:

Segment 2:

■500.1
to ida

Version: 1.0
Elaborated by: Enrique Ubeda
Printing date: 02/12/2019
Archive: SCL_Programming.doc Page2 6
(Generalitat of Catalonia
MU Department of Education
Illa dels Banyols Institute
Example 3: Series association (AND) of two input variables.

SCL code:

19 //SCL Examples (C) REEA 2013


20 //Activation of an output using two serial inputs.
21 E IF "Entry3” AND "Entry4 "=true THEN
22 "Output3":=true;
23 ELSE
24 "Output3":=FALSE;
25 END_IF;
26

Equivalent circuit in KOP:

Example 4: Activating a timer on connection (TON).

SCL code:

27 //SCL Examples (C) REEA 2013


28 //Timer at. connection
29 The "Tmpl" .TON(IN:="Input2", //If the IN signal is true, the timing starts
30 PT:=T#5s,
31 Q=>"Output2") ; //Output Q is set to 1 when PT time has been reached
32

Equivalent circuit in KOP:

Version: 1.0
Elaborated by: Enrique Ubeda
Printing date: 02/12/2019
ILLA deis Archive: SCL_Programming.doc Page3 6
(Generalitat of Catalonia
MU Department of Education
Illa dels Banyols Institute
Previously, some examples of SCL code using the IF- THEN conditional were shown. While its use is suitable
for controlling the value of variables in many programming applications that must be met by establishing logical
conditions, it is not the only way to do so. The following shows how to perform similar operations in S7-1200
programming without resorting to the use of IF-THEN.
The examples show the SCL code and the LAD program of the equivalent "electrical" circuit.

Example 1: Controlling an output through an input.

SCL code:

The value of the output is equal to the logical value of the input.

//SCL Examples (C) REEA 2013 //Switch mode


"Output0" :="Input0";

Equivalent in KOP:

#0.0 #0.0
'■■■■!.' 5nlidno"

Example 2: Serial association (AND) of two inputs

SCL code:

The output is only activated if the AND condition is met on the inputs.

//SCL Examples (C) REEA 2013


//Serial inputs
"Output":= "Input" AND "Input2";

Equivalent in KOP:

Version: 1.0
Elaborated by: Enrique Ubeda
Printing date: 02/12/2019
ILLA deis Archive: SCL_Programming.doc Page4 6
(Generalitat of Catalonia
MU Department of Education
Illa dels Banyols Institute

Example 3: Parallel association (OR) of two inputs

SCL code:

The output is activated by two inputs connected in parallel (OR) //SCL Examples (C) REEA 2013 //Inputs in parallel
"Output2":= ”Input3” OR "Input4";

Equivalent in KOP:

"40 2 Sd Idtp'

Example 4: Use of negations.

SCL code:

The value of the output is the opposite of the input. //SCL Examples (C) REEA 2013
//Deny the value of a variable (closed contact) "Output3" := NOT ”Input5”;

Equivalent in KOP:
*0.3 0.5
"Input3" "Output5"
--------1 |--------------1 NOT |--------------------------------------------------( }-------।

Example 5: Feedback (Start-Stop).

SCL code:

Input 4 functions as a start button. Input 7 as a stop button. Thus, when Input 4 is activated, the output is set to
1 and is maintained by the feedback contact connected in parallel with said input. If in this situation, Input 7
is activated, the output value is 0 and therefore it stops providing feedback.

//Examples 3CL (C) REEA 2013


//Output feedback (Start-Stop)
"Output4":= ("InputO” OR "Output4" AND NOT "Input?”;

Version:
Elaborated by:
Printing date:
Archive:

1.0
Enrique Ubeda
02/12/2019
SCL_Programming.doc Page5 6
(Generalitat of Catalonia
MU Department of Education
Illa dels Banyols Institute

Equivalent in KOP:

The variable table used in the examples is as follows:

• Entry0 Boolean WO

2 • Exit0 Boolean %Q0.0

3 4 Entry 1 Boolean %l0 1


4 • Entry2 Boolean 910.2

4 Exit 1 Boolean %Q0.1

6 • Exit2 Boolean %00.2


eithe
7 r Exit3 Boolean %Q0.3

8 • Entry3 Boolean %10.3

9 • Entry4 Beam! % 0.4

1□ • Entry 5 Boolean %[□ 5

11 • Entrance Boolean %10.6

12 • Entry 7 BOOl %10.7

13 Exit4 Boolean 900.4


14 4 Departures Boolean %Q0.5

The program in SCL has been written in an FC, which is called unconditionally from OB1 or main block.

Version:
Elaborated by:
Printing date: 1.0
Enrique Ubeda
02/12/2019
SCL_Programming.doc Page6 6
(Generalitat of Catalonia
MU Department of Education
Illa dels Banyols Institute

Archive:

1.0
Enrique Ubeda
02/12/2019
SCL_Programming.doc Page7 6

You might also like