Tải bản đầy đủ (.pdf) (85 trang)

Programming language

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (4 MB, 85 trang )

How do you program the
SIMATIC S7 in compliance
with the IEC 61131-3
standard?
Unrestricted © Siemens 2020
Unrestricted © Siemens 2020

siemens.com/controller


S7 Programming language

1

1

Overview S7 Programming language

2

SIMATIC Programming with S7-SCL

3

SIMATIC Programming with S7-Graph

4

Hand-on experience

5



Q&A

2

3

4

5

6

5

6

Unrestricted © Siemens 2020
Page 2

8/12/2020


S7 Programming language

1

1

Overview S7 Programming language


2

SIMATIC Programming with S7-SCL

3

SIMATIC Programming with S7-Graph

4

Hand-on experience

5

Q&A

2

3

4

5

6

5

6


Unrestricted © Siemens 2020
Page 3

8/12/2020


Overview S7 Programming language

Programming language

TIA Portal S7

IEC 61131-3

Ladder Diagram

LAD

LD

Function Block Diagram

FBD

FBD

Structured Text

SCL


ST

Instruction List

STL

IL

S7-GRAPH

SFC

Sequential Function Chart

Unrestricted © Siemens 2020


S7 Programming language

1

1

Overview S7 Programming language

2

SIMATIC Programming with S7-SCL


3

SIMATIC Programming with S7-Graph

4

Hand-on experience

5

Q&A

2

3

4

5

6

5

6

Unrestricted © Siemens 2020
Page 5

8/12/2020



TIA Portal

S7-SCL: Structured Control Language
Programming
Unrestricted / © Siemens VN 2020


S7 - SCL

1.1

What is S7 – SCL ?

1.2

Language description

1.3

Compile and test

1.4

Source code generation

1

2


3

4

5

6

5

6

Unrestricted © Siemens 2020
Page 7

8/12/2020


S7 - SCL

1.1

What is S7 – SCL ?

1.2

Language description

1.3


Compile and test

1.4

Source code generation

1

2

3

4

5

6

5

6

Unrestricted © Siemens 2020
Page 8

8/12/2020


SCL in STEP 7

What is SCL ?
SCL := high-level language programming + extensions typical for PLCs ;

▪ Structured Control Language as text-based
▪ Corresponds to IEC 61131-3 (ST)
▪ Certified according to PLCopen

WinAC
S7-300

▪ Complex calculations & algorithms
S7-400

▪ Data operations, e.g. sort data
▪ Program code exchangeable between S7-1200, S7-300, S7-400
and WinAC

Unrestricted © Siemens 2020

S7-1500
S7-1200


SCL in STEP 7
Usage of SCL: IF data_operation THEN SCL
Example: Storage of Real-values in an array

3630.0
5290.0
6383.0

9215.0
13195.0

Unrestricted © Siemens 2020

3630.0
5290.0
6383.0
9215.0
13195.0


SCL in STEP 7
Usage of SCL: IF data_operation THEN SCL
Code in LAD for S7-1200

Code in STL for
S7-300/400

S7-1200

Solution in SCL for
S7-300/400
AND S7-1200/1500

WinAC
S7-300
S7-1500

S7-400


WinAC

S7-1200

S7-300
S7-400

Unrestricted © Siemens 2020


SIMATIC STEP 7 in TIA Portal – Language Innovations
Efficient high level programming
High level programming with SCL
• Modern, text based SCL-Editor with highlighting, autocompletion, support for passing parameters to a function
call,…
• Optimized for more complex algorithms and data
manipulations
• Access to the command set of the SIMATIC Controllers
• Exchange of ASCII sources by In-/Export

Unrestricted © Siemens 2020


S7 - SCL

1.1

What is S7 – SCL ?


1.2

Language description

1.3

Compile and test

1.4

Source code generation

1

2

3

4

5

6

5

6

Unrestricted © Siemens 2020
Page 13


8/12/2020


SCL in STEP 7
Operators

result := expression ;
Example: switch_on := manual_on OR auto_on;
All assignments, control operations and calls are ended by

;

Combination

Description

Operator

Assignment

Assignment

:=

Parenthesis

(Statement)

(,)


Binary logic

Negation
AND
OR
Exclusive-OR

NOT
AND, &
OR
XOR

Comparison

Less than, less than or equal to, greater than, greater than or
equal to, equal, not equal to

<, <=, >, >=,
=, <>

Arithmetic

Plus, minus (sign)
Addition, Subtraction
Multiplication, Division
Exponentiation

Unrestricted © Siemens 2020


+,+,*, /, DIV,
MOD
**


SCL in STEP 7
Direct addressing (Example)
Direct Addressing : symbolic and absolute!
Area

Notation example

Examples

Bit

%DBz.DBXy.x, %Ex,y

%DB1.DBX0.0, %E0.0

Byte

%DBz.DBBy, %ABy

%DB5.DBB2 , %MB2

Word

%DBz.DBWy, %MWy


%DB5.DBW4, %MW3

Dword

%DBz.DBDy

%DB5.DBD8

„<DB-Symbol>“.<Variable-Name>

„Motor“.Sollwert

Absolut addressing

Symbolic
addressing

Unrestricted © Siemens 2020


SCL in STEP 7
Direct addressing (Example)
In the SCL-Editor, inputs, outputs and Bit memory are always Symbolic

: Tags symbols and addresses in table form

Unrestricted © Siemens 2020


SCL in STEP 7

Indirect addressing
Indirect addressing, with symbolic address access of Arrays

Syntax:

„<DB-Symbol>“.<Array-Symbol> [Index]

Example:

Unrestricted © Siemens 2020


SCL in STEP 7
Overview: Functions for Data handling

Controler

S7-300

S7-1200

WinAC

S7-1500

S7-400

Possibilities

System functions


Unrestricted © Siemens 2020




ANY – Pointer
Absolute und symbolic
Addressing
BLKMOV

FILL




VARIANT
Symbolic Addressing




ANY - Pointer und VARIANT
Symbolic Addressing

MOVE_BLK

FILL_BLK

BLKMOV


FILL

PEEK

POKE

MOVE_BLK

FILL_BLK

PEEK

POKE


SCL in STEP 7
New Functions: Rising and falling edge
When a Rising edge is detected on the input CLK , the output Q returns signal status 1
Rising edge:

Example
CLK

R_TRIG

Q

Local


When a falling edge is detected on the input CLK , the output Q returns signal status 1
Falling edge
F_TRIG
Local

Unrestricted © Siemens 2020

Example
CLK
Q


SCL in STEP 7
Control operations – Overview
Control operations can be programmed easily using the code snippet!

Program branching

Program loop
(Abort possible)

Loop aborts

Block abort

Unrestricted © Siemens 2020

Keyword

Functionality


IF

Program branching with Boolean Value

CASE

Program branching with INT Value

FOR

Program loop with run variable

WHILE

Program loop with execution condition

REPEAT

Program loop with abort condition

CONTINUE

Abort current loop pass

EXIT

Exit program loop

RETURN


Exit the block


SCL in STEP 7
Program Branching - Syntax
IF Instruction

Example of use

IF Condition_1 THEN
Statements_1;
ELSIF CONDITION_2 THEN
Statements_2;
ELSE
Last_Statements;
END_IF;

STL

SCL

Unrestricted © Siemens 2020


SCL in STEP 7
Program Branching - Syntax
CASE- Instruction:
CASE Selection_Variable OF
CONST_1: Statements;

…..
CONST_n: Statements;
…..
ELSE
Statements;
END_CASE;

Selection_Variable has data type
INT
Unrestricted © Siemens 2020

Example of use
STL

SCL


SCL in STEP 7
Program loops- Syntax
FOR Loop
For START_VAR TO END_VAR BY STEP_WIDTH DO
Statements;
END_FOR;

WHILE Loop
WHILE Condition DO
Statements;
END_WHILE;

START_VAR, END_VAR

und
STEP_WIDTH can have
either Data type INT or
DINT

REPEAT Loop
REPEAT
Statements;
UNTIL Condition;
END_REPEAT;

Condition has data type
BOOL

For a better performance, Loop index should be from a 32 Bits data type.
Unrestricted © Siemens 2020


SCL in STEP 7
Program loops- Syntax
Example of use
SCL

STL

SCL

Symbolic Programming possible

Unrestricted © Siemens 2020



SCL in STEP 7
Loops abort- Syntax
CONTINUE Instruction:
For i:= 0 TO 10 DO
IF #Request THEN Continue;
END_IF;
Buffer[#i] := #Value+#i;
END_FOR;

After Continue, the control variable is
incremented by the specified increment
immediately.

EXIT Instruction:
For i:= 0 TO 10 DO
Buffer[#i] := #Value+#i;
IF #Error THEN EXIT;
END_IF;
Further Statements…
END_FOR;
Unrestricted © Siemens 2020

Execution of the program is continued after the
end of the loop (FOR Loop).


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×