Вы находитесь на странице: 1из 776

STEP

7:


STEP 7 STL
SCL
SIMATIC S7300/400

2001




SCL


STEP 7


,
,
. ,
:

!
!
!

, ,
, .

,
, .

,
.

, ,
.

,
.



. , ,
,
.

,
,
,
Siemens.
,
, , ,
.


SIMATIC, SIMATIC HMI SIMATIC NET - SIEMENS AG.
, ,
; ,
.
Copyright Siemens AG 2001
,

.
.
, ,
,
.
Siemens AG


\ 4848, D- 90327,

Siemens Aktiengesellschaft



.
,
. ,
, ,

.
.
Siemens AG 2001
Technical data subject to change.

SIMATIC

""
.
,

(SIMATIC S7), (SIMATIC
M7) (SIMATIC C7).


. S7-200
("-PLC"), S7300 S7-400

.
STEP 7, STEP 5,

SIMATIC. Windows 95/98 Microsoft Windows NT Microsoft
, STEP 7

( , "").

STEP
7

, DIN EN
6.1131-3: STL ("statement list" - , Assembler- ),
LAD ("ladder diagram" - " ",
), FBD ("function block diagram" - " ",
-) SCL
("Structured Control Language" " ", Pascal ).
,
: S7-GRAPH (

SIMATIC

), S7-HiGraph (
SIMATIC
) CFC ("continuous
function chart" - ;
CFC FBD).

.
II

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

,
, STEP 7.
STL S7-300/400.
S7-300/400
STEP 7.
STEP 7 ,
STEP 7 .

STL ,
.
, , .
STL, (
) .
,
,
, ,
.
SCL.
SCL
, SCL
. STEP 7
SIMATIC S7- ,
.

STEP 5 STEP 7,
STL SCL.
STEP 7
5.1, S7-SCL 5.1.
Erlangen, 2001

Automating with STEP 7 in STL and SCL


STEP
STL SCL


(Hans Berger)

III




S7-300/400

PLC



1 SIMATIC S7-300/400

PLC
(

S7-300/400);
;

(PROFIBUS
DP);

();
;

AND (), OR
(), Exclusive OR
( );

5

,


15



INT, DINT
REAL

"" ,
"" ;
EN/ENO

10

16

,
;

;


INT, DINT
REAL;
;
/

2 STEP 7

11

; ;

; Symbol Editor
( );
STL/ SCL;
;

Load
Transfer;



7

;
Arc-;
;

MCR,
MCR-,
MCR-

12

18


SIMATIC
; IEC-

3 S7-

13

; ;
STL/ SCL;
DB;
; ;
()

SIMATIC-;
/ ;
/;
IEC-



14
Word

IV

AND (), OR
(), Exclusive OR
( )

,
,
RLO,
BR, ""
;


17
(MCR)

, ;

19

;

;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20

;

; (
,
;
);
;

; SFC SFB
21

24

;

UDT

25

;

;

;

;
,

22
STL

;
DB;
ANY;

(
);

"", ""
;
STOP, HOLD,
;

23

;


;
""
ANY;

;
;

26

Automating with STEP 7 in STL and SCL


STEP
STL SCL


SCL
SCL
27 ,

S5/S7
,

32 S5/S7

, ,
, ;

S5-;
28

IF, CASE, FOR, WHILE,


REPEAT, CONTINUE,
EXIT, GOTO, RETURN

29 SCL

SCL;
;
;
EN/ENO

30 SCL-
;
;

;

;

28

;
STRING-;
Date/TOD-;

33

;
IEC-
; S5-S7
;
TI-S7 ;

-;

34
STL
;

;

35 SCL
;
;
;



,
STL SCL.
, .
STL_BOOK SCL_BOOK.

2,7 1,6 (
PG).
STL_BOOK ,
STL- .
,
(: [Conveyor Example]),
( [Message Frame
Example]).
.
STL_BOOK

STL-
FB 104 4:
FB 105 5:
FB 106 6:
FB 107 7:
FB 108 8:
(Digital)
STL-
FB 109 9:
FB 110 10:
FB 111 11:
FB 112 12:
FB 113 13:
FB 114 14: Word

STL-
FB 115 15:
FB 116 16:
FB 117 17:
FB 118 18:
FB 119 19:

( 3)


UDT 51 ,
UDT 52 ,
FB 51
FB 52
FC 61
FC 62
FC 63

VI


SFC
FB 120 20:
FB 121 21:
FB 122 22:
FB 123 23:


FB 124 24:
FB 125 25:
FB 126 26:
FB 101
FB 102
FB 103


FC 11
FC 12
FB 20
FB 21
FB 22

FC 41
FC 42
FC 43
FC 44 DOUBLE
WORD
FC 45
S5 REAL S7
FC 46 REAL S7
S5
FC 47
( ANY)
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

SCL_BOOK SCL
SCL-. ,
STL- :

" " [Conveyor Example]


[Message Frame Example], SCL_BOOK
SCL-.
"General Examples" (" ")
SCL-
,
SCL STL SCL-.
SCL_BOOK

SL- ( 27)
FC 271
OB 1

FB 271 , ,
FB 272

SL- ( 28)
FB 281 IF
FB 282 CASE
FB 283 FOR
FB 284 WHILE
FB 285 REPEAT
SCL-
SL- ( 29)
F 291 FC
F 292 FC
FB 291 FB
FB 292 FC FB
F 293 FC EN/ENO
FB 293 FB EN/ENO
FB 294 EN/ENO


FC 11
FC 12
FB 20
FB 21
FB 22

SCL-
SL- ( 30)
FB 301
FB 302
FB 303
FB 304
FB 305

SL- ( 31)
FB 311
FB 312
FB 313 String
FB 314 Date/TOD
FB 315

FC 61 DT_TO_STRING
FC 62 DT_TO_DATE
FC 63 DT_TO_TOD
FB 61
FB 62
FB 63
FB 64 FIFO
STL SCL


UDT 51 ,
UDT 52 ,
FB 51
FB 52
FC 61

, ,
,
, , .
-,
.
STEP 7 STEP 7Mini,
-,
- STEP 7 (.
).

Automating with STEP 7 in STL and SCL


STEP
STL SCL

VII

STEP 7:

, ,
()
STEP 7.
SIMATIC Manager,
.
. , (
Windows)
, CPU.
.
.
,
, .
.

. :
(), ;
() ,
( ) .

, SIMATIC Manager.

VIII

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

SIMATIC Manager



Hardware

(,CPU)


Proect

CPU c DP Master
(CPU with DP Master):
PROFIBUS,
DP-

Hardware


(
)

CPU


(Master) DP ,
,

(Slave) DP-

Automating with STEP 7 in STL and SCL


STEP
STL SCL



System Data
[ ]

IX


CP

""






(UDT) DB


" "

FC FB,
DB
OB


System Data
[ ]


Blocks
[]

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL



(online)


CPU PG

Automating with STEP 7 in STL and SCL


STEP
STL SCL

XI

1-1

SIMATIC S7-300/400

1-3

1.1

1-3

1.1.1

1-3

1.1.2

S7-300

1-4

1.1.3

S7-400

1-6

1.1.4

CPU

1-8

1.1.5

1-10

1.1.6

1-10

1.2

I/O (/)

1-11

1.2.1

DP-

1-12

1.2.2

DP- (DP Master)

1-13

1.2.3

DP- (DP Slaves)

1-13

1.2.4

PROFIBUS-PA

1-15

1.2.5

AS-

1-16

1.2.6

1-18

1.3

(communications)

1-18

1.3.1

1-18

1.3.2

1-20

1.3.3

(communications services)

1-24

1.3.4

(connections)

1-25

1.4

1-26

1.4.1

1-26

1.4.2

1-27

1.4.3

1-27

1.4.4

1-28

1.4.5

1-29

1.5

1-29

1.5.1

1-29

1.5.2

( )

1-31

1.5.3

1-32

XII

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

STEP 7

2-1

2.1

STEP 7 (STEP 7 Basic Package)

2-1

2.1.1

2-1

2.1.2

2-2

2.1.3

SIMATIC Manager

2-2

2.1.4

(Project(s) Library(ies))

2-6

2.1.5

(Online Help )

2-7

2.2

2-8

2.2.1

2-8

2.2.2

2-10

2.2.3

(Project Versions)

2-11

2.3

2-13

2.3.1

2-15

2.3.2

2-15

2.3.3

2-16

2.3.4

MPI

2-17

2.3.5

Monitor () Modify ()

2-18

2.4

(Network)

2-18

2.4.1

(Network View)

2-20

2.4.2

DP-
Network Configuration

2-21

2.4.3

(Connections)

2-22

2.4.4

(Network Transitions)

2-27

2.4.5

(Loading the Connection Data)

2-28

2.5

S7-

2-29

2.5.1

2-29

2.5.2

(Symbol Table)

2-30

2.5.3

STL- (STL Program Editor)

2-32

2.5.4

SCL- (SCL Program Editor)

2-37

2.5.5

(Rewiring)

2-40

2.5.6

(Address Priority)

2-41

2.5.7

(Reference Data)

2-42

2.5.8

2-44

2.6

(Online Mode)

2-46

2.6.1

PLC

2-46

2.6.2

2-47

2.6.3

CPU (CPU Information)

2-49

2.6.4

CPU

2-49

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

XIII

2.6.5

(Block Handling)

2-50

2.7

2-52

2.7.1

2-53

2.7.2

STOP

2-53

2.7.3


(Monitoring and Modifying Variables)

2-54

2.7.4

(Forcing Variables)

2-56

2.7.5


( Enable peripheral outputs)

2-59

2.7.6

"Program Status" (" ") STL

2-60

2.7.7

SCL-

2-62

SIMATIC S7-

3-1

3.1

3-1

3.1.1

3-1

3.1.2

3-3

3.1.3

3-4

3.2

3-5

3.2.1

(Block Types)

3-6

3.2.2

(Block Structure)

3-8

3.2.3

(Block Properties)

3-8

3.2.4

(Block Interface)

3-13

3.3

(Addressing Variables)

3-15

3.3.1

3-16

3.3.2

3-18

3.3.3

3-18

3.4

STL

3-20

3.4.1

STL-

3-20

3.4.2

STL

3-21

3.4.3

STL,

3-24

3.5

SCL

3-28

3.5.1

SCL-

3-28

3.5.2

SCL-

3-30

3.6

3-35

3.6.1

3-35

3.6.2

3-37

XIV

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3.7

3-39

3.7.1

3-39

3.7.2

3-41

3.7.3

3-41

3.7.4

3-42

3.7.5

3-45

4-1

4-3

4.1

4-3

4.2

4-7

4.2.1

AND ()

4-8

4.2.2

OR ()

4-10

4.2.3

Exclusive OR ( )

4-10

4.2.4

4-11

4.3

4-13

4.4

4-14

4.4.1

( )

4-14

4.4.2

AND- () OR ()

4-16

4.4.3

OR () Exclusive OR ( )
AND ()

4-17

AND ()
Exclusive OR ( )

4-18

OR ()
Exclusive OR ( )

4-18

4.4.6

4-19

(memory functions)

5-1

5.1

Assign ()

5-1

5.2

Set ( ) Reset ( )

5-3

5.3

RS Flipflop (RS-)

5-4

5.3.1

Reset
( )

5-4

Set
( )

5-5

5-5

5.4

Edge Evaluation ( )

5-7

5.4.1

5-8

4.4.4
4.4.5

5.3.2
5.3.3

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

XV

5.4.2

5-10

5.4.3

5-10

5.4.4

5-12

5.4.5

(Binary Scaler)

5-12

5.5

5-14

(move functions)

6-1

6.1

6-1

6.2

Load ( )

6-4

6.2.1

Load

6-4

6.2.2

6-6

6.2.3

6-7

6.3

Transfer ( )

6-7

6.3.1

Transfer

6-7

6.3.2

6-8

6.4

(Accumulator Functions)

6-9

6.4.1

6-10

6.5

accumulator 1

6-12

6.6

6-12

6.6.1

6-13

6.6.2

6-14

6.6.3

6-15

6.6.4

STRING

6-16

(timer functions)

7-1

7.1

7-2

7.1.1

7-2

7.1.2

7-2

7.1.3

(Resetting a timer)

7-4

7.1.4

(Enabling a timer)

7-5

7.1.5

() (Checking a timer)

7-5

7.1.6

7-7

7.1.7

( )

7-8

7.2

(Pulse timer)

7-8

7.3

(Extended pulse timer)

7-12

7.4

(On-delay timer)

7-15

7.5

(Retentive On-delay timer)

7-19

7.6

(Off-delay timer)

7-23

XVI

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.7

IEC- (IEC Timer Functions)

7-26

7.7.1

SFB 3 TP

7-28

7.7.2

SFB 4 TON

7-28

7.7.3

SFB 5 TOF

7-29

(ounter functions)

8-1

8.1

8-2

8.2

(Counting)

8-3

8.3

() (Checking a Counter)

8-4

8.4

(Enabling a counter)

8-5

8.5

8-8

8.6

IEC- (IEC Counter Functions)

8-9

8.6.1

SFB 0 CTU

8-10

8.6.2

SFB 1 CTD

8-11

8.6.3

SFB 2 CTUD

8-11

8.7

8-12

9-1

9-3

9.1

9-4

9.2

9-5

9.3

9-8

10

10-1

10.1

10-2

10.2

INT

10-3

10.3

DINT

10-5

10.4

REAL

10-6

10.5

10-8

10.6

Accumulator 1

10-10

10.7

10-11

11

11-1

11.1

11-1

11.2

11-2

11.3

(Arc-)

11-3

11.4

11-4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

XVII

12

12-1

12.1

12-2

12.2

INT DINT

12-3

12.3

BCD

12-4

12.4

REAL

12-5

12.5

12-7

13

13-1

13.1

13-2

13.2

13-4

13.3

13-7

14

(Word Logic)

14-1

14.1

14-1

14.2

14-4

15-1

15

(Status Bits)

15-3

15.1

15-3

15.2

15-7

15.3

15-10

15.4

( BR)

15-12

16

16-1

16.1

16-2

16.2

16-3

16.3

RLO BR

16-3

16.4

CC0 CC1

16-5

16.5

OV OS

16-8

16.6

(Jump Distributor)

16-9

16.7

(Loop Jump)

16-10

17

MCR

17-1

17.1

MCR- (MCR Dependency)

17-2

17.2

MCR- (MCR Area)

17-3

17.3

MCR- (MCR Zone)

17-4

17.4

(I/O )

17-6

XVIII

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18

(Block Functions)

18-1

18.1

18-1

18.1.1 :

18-2

18.1.2 CALL

18-3

18.1.3 UC CC

18-4

18.1.4 (Block End Functions)

18-6

18.1.5

18-6

18.1.6

18-10

18.2

18-14

18.2.1

18-15

18.2.2

18-16

18.2.3

18-19

18.2.4

18-20

18.2.5

18-21

18.2.6 ,

18-21

18.3

18-24

18.3.1

18-25

18.3.2

18-25

18.3.3

18-25

18.4

18-26

Null- (-)

18.4.1 NOP

18-26

18.4.2 BLD

18-26

19

19-1

19-1

19-1

19-1.1

19-1

19-1.2

19-1

19-1.3 (declaration)

19-2

19-1.4 (declaration)

19-5

19-1.5 (Initialization)

19-6

19-2

19-6

19-3

19-11

19-4

("Pass On")

19-16

19-5

19-17

19.5.1 :

19-17

19.5.2 :

19-19

19.5.3 :

19-20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

XIX

20-1

20

(main program)

20-3

20.1

20-3

20.1.1

20-3

20.1.2

20-5

20.2

20-8

20.2.1

20-8

20.2.2

20-10

20.2.3
("background scanning")

20-12

20.2.4 ("Response Time")

20-14

20.2.5 ("Start Information")

20-15

20.3

20-17

(Program Functions)

20.3.1 (Real-Time Clock)

20-17

20.3.2 (System Clock)

20-18

20.3.3 (Run-Time Meter)

20-19

20.3.4 CPU (Compressing CPU Memory)

20-20

20.3.5

20-21

20.3.6

20-21

20.4

(ommunications) I/O 20-22

20.4.1 (I/O)

20-24

20.4.2 (I/O)

20-30

20.4.3 (I/O)

20-45

20.5

20-49

20.5.1

20-49

20.5.2 GD-

20-53

20.5.3 GD-

20-56

20.6

20-57

SFC-

20.6.1 (Station-Internal) SFC-

20-57

20.6.2

20-59

20.6.3 (Station-External) SFC-

20-61

20.6.4
("" SFC)

20-63

20.7

20-67

SFB-

20.7.1

20-67

20.7.2 (Two-way Data Exchange)

20-70

20.7.3 (One-way Data Exchange)

20-73

XX

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.7.4 (Print Data)

20-74

20.7.5 (Control Functions)

20-75

20.7.6 (Monitoring Functions)

20-77

21

21-1

21.1

21-1

21.2

(Hardware Interrupts)

21-4

21.2.1

21-4

21.2.2

21-5

21.2.3 STEP 7

21-6

21.3

21-6

(watchdog Interrupts)

21.3.1 (watchdog Interrupts)

21-7

21.3.2
(watchdog Interrupts) STEP 7

21-9

21.4.

(time-of-day interrupts)

21-10

21.4.1 (time-of-day interrupts)

21-10

21.4.2
(time-of-day interrupts) STEP 7

21-12

21.4.3
(time-of-day interrupts)

21-13

21.5.

21-15

c (time-delay interrupts)

21.5.1 c (time-delay interrupts)

21-15

21.5.2 c
(time-delay interrupts) STEP 7

21-17

21.5.3 c
(time-delay interrupts)

21-17

21.6

21-19

21.7

21-21

22

22-1

22.1

22-1

22.1.1

22-1

22.1.2 HOLD ()

22-2

22.1.3 (disable)

22-3

22.1.4

22-4

22.2

22-5

(Power-Up)

22.2.1 STOP ()

22-5

22.2.2 (Memory Reset)

22-6

22.2.3 (Retentivity)

22-6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

XXI

22.2.4

22-7

22.3

22-8

22.3.1 (START-UP)

22-8

22.3.2 "" (Cold Restart)

22-9

22.3.3 "" (Complete Restart)

22-11

22.3.4 "" (Warm Restart)

22-12

22.4

22-13

22.5

22-15

23

23-1

23.1

23-2

23.2

23-3

23.2.1

23-3

23.2.2

23-6

23.2.3

23-6

23.2.4

23-7

23.2.5 "" ( - Substitute Value)

23-7

23.3

23-8

23.4

23-12

23.4.1

23-12

23.4.2

23-13

23.4.3

23-14

23.4.4

23-15

24-1

24

24-3

24.1

24-3

24.1.1

24-3

24.1.2 BOOL, BYTE, WORD, DWORD, CHAR

24-4

24.1.3

24-6

24.1.4

24-9

24.2

24-11

24.2.1 DATA_AND_TIME

24-12

24.2.2 STRING

24-13

24.2.3 ARRAY

24-15

24.2.4 STRUCT

24-17

24.3

24-20

XXII

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24.3.1 ,
(UDT)

24-20

24.3.2 UDT 24-21


25

25-1

25.1

25-1

25.1.1 (area pointers)

25-2

25.1.2 DB (DB pointers)

25-2

25.1.3 ANY- (ANY pointer)

25-4

25.2

25-5

STL

25.2.1

25-6

25.2.2 (Indirect Addresses)

25-7

25.2.3
(memory-indirect addressing)

25-8

25.2.4
(Register-Indirect Area-Internal Addressing)

25-10

25.2.5
(Register-Indirect Area-Crossing Addressing)

25-11

25.2.6

25-12

25.3

25-13

25.3.1

25-14

25.3.2

25-15

25.3.3

25-15

25.3.4

25-16

25.4

25-18

25.4.1 AR1

25-18

25.4.2 AR2

25-18

25.4.3

25-20

26

26-1

26.1

26-1

26.2

26-4

26.2.1

26-4

26.2.2

26-6

26.2.3

26-6

26.3

26-8

26.3.1

26-8

26.3.2

26-11

26.3.3 "" ANY- (ANY-pointer)

26-13

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

XXIII

26.4

"Message Frame Example"


( )

SCL

26-16

27-1

27

27-3

27.1

SIMATIC

27-3

27.1.1 ()

27-3

27.1.2

27-4

27.1.3 SCL-

27-4

27.1.4 (Symbol Table)

27-5

27.1.5 SCL-

27-7

27.1.6 SCL-

27-7

27.1.7 SCL-

27-7

27.1.8

27-8

27.1.9 (Data Type Veiws)

27-10

27.2

27-12

27.2.1

27-12

27.2.2

27-13

27.2.3 SCL

27-13

27.3

27-15

27.4

27-16

27.4.1

27-17

27.4.2

27-17

27.4.3

27-19

27.5

27-20

27.5.1

27-20

27.5.2 DT STRING

27-20

27.5.3

27-21

27.5.4

27-21

28

(Control Statements)

28.1

28.1

IF

28.1

28.2

CASE

28.3

28.3

FOR

28.4

28.4

WHILE

28.5

28.5

REPEAT

28.6

28.6

CONTINUE

28.7

28.7

EXIT

28.8

XXIV

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

28.8

RETURN

28.8

28.9

GOTO

28.9

29

SCL-

29-1

29.1

SCL-:

29-1

29.2

SCL-

29-2

29.2.1 FC

29-3

29.2.2 FC

29-3

29.2.3 FB

29-4

29.2.4

29-5

29.2.5

29-7

29.2.6

29-8

29.2.7

29-9

29.3

SCL-

29-10

29.3.1 FC

29-11

29.3.2 FC

29-11

29.3.3

29-12

29.3.4

29-13

29.3.5

29-14

29.4

29-15

EN/ENO

29.4.1 -

29-15

29.4.2 ENO (ENO output)

29-16

29.4.3 EN (EN input)

29-17

30.

SCL-

30-1

30.1

30-1

30.2

30-2

30.3

30-4

30.4

(Shifting) (Rotating)

30-5

30.5

(Conversion Functions)

30-6

30.5.1 (Implicit Conversion Functions)

30-7

30.5.2 (Explicit Conversion Functions)

30-8

30.6

SCL

30-8

30.7

STL

30-13

30.8

SCL

30-15

30.8.1 "Conveyor" ("")

30-15

30.8.2

30-16

30.8.3

30-16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

XXV

31

IEC-

31-1

31.1

(Conversion Functions)

31-2

31.2

(Comparison Functions)

31-4

31.3

STRING (STRING Functions)

31-8

31.4

Date/Time-of-Day
(Date/Time-of-Day Functions)

31-11


(Numerical Functions)

31-14

31.5

32-1

32

S5/S7-

32-3

32.1

32-3

32.2

32-5

32.2.1 (PLC)

32-5

32.2.2

32-6

32.2.3

32-8

32.2.4

32-10

32.3

32-11

32.3.1

32-11

32.3.2

32-13

32.3.3

32-13

32.3.4

32-14

32.4

32-17

32.4.1 STEP 7

32-17

32.4.2

32-18

32.4.3

32-19

32.4.4

32-19

32.4.5 " "

32-21

32.4.6

32-21

32.4.7

32-23

32.4.8

32-23

32.4.9

32-23

33

33-1

33.1

()

33-1

33.2

(SFB)

33-3

33.3

IEC-

33-9

33.4

S5-S7-

33-11

33.5

TI-S7-

33-15

XXVI

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33.6

33-16

33.7

33-16

34

STL-

34-1

34.1

34-2

34.1.1

34-2

34.1.2

34-3

34.1.3

34-3

34.1.4

34-4

34.1.5

34-5

34.2

34-5

34.2.1

34-5

34.2.2

34-5

34.2.3

34-6

34.2.4

34-6

34.2.5

34-7

34.2.6

34-7

34.3

34-8

34.3.1

34-8

34.3.2 MCR

34-9

34.3.3

34-9

34.4

34-10

35

SCL-

35-1

35.1

35-1

35.2

35-2

35.3

35-2

35.4

CSL

35-3

35.4.1

35-3

35.4.2

35-4

35.4.3

35-5

35.4.4

35-6

35.4.5

35-7

36-1

37-1

STEP 7

38-1

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

XXVII

SIMATIC S7300/400.
SIMATIC S7-300/400
. ,
, ( CPU)
. SIMATIC S7
/ (I/O) . CPU,
,
. (load memory)
: ,
( ),
(work memory),
,
.
STEP 7 S7-300/400.
,

SIMATIC Manager. SIMATIC Manager
, Windows 95/98/NT
, .
SIMATIC Manager , ,
,
.

, STEP 7.
SIMATIC S7 ,
, ,
,
.
.
STEP 7 ,
(BOOL), (INT REAL)
,
( ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1- 1


S7-300/400.
STEP 7 .
STEP 7 5.1.
3 " SIMATIC S7"
S7-

STL SCL. STL SCL


.
.

1- 2

SIMATIC S7-300/400
;
(I/O);
;
;
.

STEP 7
SIMATIC Manager;
;
;
;
( , );
;
.

SIMATIC S7
;
;
;
STL SCL;
;
( ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

1 SIMATIC S7-300/400

1.1
1.1.1
SIMATIC S7-300/400
:

(Rack):

.
(PS "power supply"):
.
(CPU "central processing unit"):

.
(IM "interface module"):
.
(SM "signal module"):
,
,

.
(FM "function module"):
CPU,
.

(CP "communication processor"):


.
:

.
( )
, .
, CPU I/O ( SM, FM CP)
. I/O
I/O ,
,

(. . 1).
/ (. 1.2, " I/O").

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1- 3

1. SIMATIC S7-300/400

:
/ (I/O P-) ( K-).
I/O-
,
.
CPU (MPI)
.

1.1.2 S7-300

S7-300
8 / .
,
CPU 314
:
,
( IM
365 );
, 4 , ..
, 3 (
IM 360 IM 361
).
.

, 1.2 ( CPU 312 IFM
0.8 ).
,
P- K-.


FM 356
M7-300. FM-356 ""
, "
" .
,
.
SIMATIC
SIMATIC S7-300
. :
(-25+60),

,
IEC 68 2-6;
, IEC
721-3-3 Class 3 K5, /
EN 50155 ( ). .
1- 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

S7-300


:
IM 460-1
IM 460-0
IM 460-3
IM 463-2

S7-400


5 ;
:
1.5
(IM 461-1)


5 ;
:
3
(IM 461-0)


5 ;
:
100
(IM 461-3)

S5;
:
600
(IM 314)

. 1.1 S7-300/400
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

1- 5

1. SIMATIC S7-300/400

1.1.3 S7-400

S7-400

:
18 9 ( UR1
UR2), CPU,
( ).
IM 460-1 IM 461-1
5-
1.5 .
, IM 460-0 IM 461-0
4
3 . ,
IM 460-3 IM 461-3
4
100 .

21 .

.
P- K-.
ER1 ER2 ( 18 9 )
"" ,
, 24-
P-, K. K- UR1, UR2 CR2
,
1
6.


CR2.
CR2
. CPU
, P-
,
K-.

S7-400
( )
CPU.
CPU ( ).
20.3.6
" " 21.6 "
".

1- 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

SIMATIC S5
IM 463-2
S7-400 SIMATIC S5 (EG 183U, EG 185U,
EG 186U, ER 701-2 ER 701-3),
. IM 314
SIMATIC S5
. ,
. S7-400
IM 463-2;
IM 463-2, ,
S5
.

SIMATIC S7-300/400,

,
.

"
",
,
. , ,
"" .
,
, .
/
(I/O) (ET 200M IM 1533 PROFIBUS-DP).
()
("Software Redundancy").
SIMATIC S7-400H
SIMATIC S7-400H
, ,
H CPU . "
";

.
/

(, )
( ET 200M).
.
,
;
.
() "S7-400H".
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

1- 7

1. SIMATIC S7-300/400

1.1.4 CPU

1.2 CPU,
.
, (load memory)
(work memory).
(load memory) CPU
.

,
(load memory) .
(work memory) CPU
RAM-.
:
. "" ,
, ,

.

(CPU)

(offline)

(offline)

()


I/O

CPU
S7-400



()

. 1.2 CPU
1- 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

,
, (load memory).
CPU "" (. )
(work memory).
CPU,
(load memory)
(work memory) (
. 2.6.4 " CPU" 2.6.5
" ").
(load memory) RAM-,

,
CPU. (load
memory) EEPROM-
EPROM -, CPU
.
(load memory) CPU 3xxIFM RAM EEPROM
. RAM-
,
EEPROM-,
.
(load memory) CPU S7-300 ( CPU
318) RAM-,
. EPROM -

, .
CPU S7-300
( ) (, , )
.

.
RAM- CPU S7-400
.
,
(load memory), RAM-
. EPROM -

.
CPU S7-400 (work memory)
.
STEP 7 V5.1, CPU S7-400,

(load memory) CPU (. 2.2.2
", ").

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1- 9

1. SIMATIC S7-300/400

1.1.5
: RAM- EPROM
-.
(load memory),
RAM- (, CPU S7-400).
RAM-
. ,
RAM-
.
-
,
, EPROM -.

, EPROM -
. CPU

, EPROM -
CPU.

1.1.6
(),
.
( ), ,
CPU, . , ,
,
, ,
() .
CPU :
(I):
" "
.
(Q):
" "
.
(M):
, .
():
,
.
():
.
1- 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

(L)

.
L-,
CPU .
,
, ,
.

.

( ).
,
, S7-400
.

1.2 I/O (/)


PROFIBUS-DP
"
"
. " " " DP" (DP-master), "
DP-" (DP-slave). / (I/O)
, PROFIBUS-DP
PROFIBUS. PROFIBUS-DP EN 50170

DP-.
1.3.2 "".
DP- DP-
" DP-" (DP-master system).
32 127
. DP-
, DP-.
PROFIBUS-DP , ,
, - ,
ET 200 DP- SIMATIC S5.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1- 11

1. SIMATIC S7-300/400

1.2.1 DP-
DP- (mono master system)
PROFIBUS-DP DP ("mono master system"); DP DP-.
DP-
, ,

. DP- DP " DP-" ("DP-master system")
(. . 1.3).
S7-
DP-, ,
CPU 318-2DP


, ,
ET 200B

PROFIBUS-DP
DP/PA
(DP/PA link)

PROFIBUS-PA
DP/RS232C (link)


, ,
ET 200M

,
, CPU 315-2DP

DP/PA
(DP/PA coupler)

PROFIBUS-PA

DP/AS-
(DP/AS-Interface link)

AS-

. 1.3 DP- (DP-master system)

1- 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

DP- (multi master system)


PROFIBUS-DP
DP- ("multi master system"). ,

DP-; , , DP "" DP-,
DP- "" DP-
. .
DP-
, DP DP-.
S7- DP-,
DP-
. CPU
" DP-".

1.2.2 DP- (DP Master)


DP- (DP Master)
PROFIBUS.
"" DP-. DP- :
CPU DP-
(, CPU 315-2DP, CPU 417).

CPU (, IM 467).

CP CPU (, CP 3425, CP 443-5).

" DP- 1 ",


, " DP- 2
", (,
).

1.2.3 DP- (DP Slaves)


DP- (DP Slaves)
PROFIBUS. SIMATIC S7 DP-:
,
DP-.

, ().

,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1- 13

1. SIMATIC S7-300/400

PROFIBUS DP-
DP-
:
ET 200B ( /
/ , IP 20
, 12 /);
ET 200C ( ,
IP 66/67,
/ / ,
, 1,5 /
12 /);
ET 200L-SC (-
/
/ , IP 20
, 1,5 /);
, DP/AS-I (DP/AS-I Link),
DP- PROFIBUS-DP.
PROFIBUS DP-
DP- ET
200M. S7-300,
DIN, , IM 153
CPU 8 (SM)
(FM). 9,6 / 12 /).
ET 200M ,
DP- S7-400. ,
/ S7-300
, .
.

, ..
.
ET 200M IM 153-3
DP- . IM 1533 : - DP-
() - DP .
PROFIBUS DP-
() DP-
S7-300, CPU DP, (slave)
( , CPU 315-2DP), S7-300
CP 342-5 (slave)
.

1- 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

DP- ET 200X
BM 147/CPU. 7
.
""
"" BM 147/CPU,
S7- .
/
/ ,
(load feeders),
400 5,5 .
9,6 /
12 /.

1.2.4 PROFIBUS-PA
PROFIBUS-PA
PROFIBUS-PA ("Process Automation" [ ])
(
Ex-, , ,
), (,
).
PROFIBUS-PA EN 50170, 2
(PROFIBUS-DPA); IEC 1158-2.

PROFIBUS-PA:

PROFIBUS-DP

DP/PA (DP/PA coupler), ,


PROFIBUS-DP ,
45,45 /.

DP/PA (DP/PA link),


PROFIBUS-DP PROFIBUS-PA.

DP/PA (DP/PA coupler)


DP/PA (DP/PA coupler) PA-
PROFIBUS-DP. PROFIBUS-DP DP/PA
DP-
, 45,45 /. DP/PA
31 PA- .
"" PROFIBUS-PA
, 31,25 /. PROFIBUS-PA
PROFIBUS-PA (shared).
DP/PA :
DP/PA -Ex 400

DP/PA Ex 100 .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1- 15

1. SIMATIC S7-300/400

DP/PA (DP/PA link)


DP/PA (DP/PA link) PA-
PROFIBUS-DP 9,6
/ 12 /. DP/PA
IM 157 5 DP/-,
() SIMATIC S7.
, PROFIBUS-PA,
PROFIBUS-PD . DP/PA
31 PA- .
SIMATIC DPM
SIMATIC DPM (Process Device Manager [
], : "SIPROM") ,
, ,

PROFIBUS-PA HART (Highway Addressable Remote
Transducers [ ]). -
DDL (Device Description Language [
]).
SIMATIC DPM "" ,
Windows 9x/NT,
STEP 7.

1.2.5 AS-
AS-
AS- ("Actuator-Sensor Interface" ("AS-i") [ -])

. AS-i
, 31 AS-i.
AS-i-,
, .
AS-i
AS-i , 8
("normal" - "") .
AS-i 100 ,
(
AS-i )
( AS-i
,
AS-i).

1- 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

AS-i (AS-i master)


AS-i (AS-i master)
AS-i ,
5 . AS-i
SIMATIC S7 CP 342-2
PROFIBUS-DP DP/AS-
(. . 1.4).
P 342-2
S7-300

DP/AS-i

PROFIBUS-DP
DP/AS-

(DP/AS-Interface link)

AS-

DP/AS-i

DP/AS-i


AS-i ASIC

DP/AS-i

DP/AS-i

DP/AS-i

(DP/AS-i distributor)


AS-i ASIC

DP/AS-i

. 1.4 SIMATIC S7 AS-i


CP 342-2 AS-i
S7-300 ET 200M.
:
CP 342-2 / .
16 16
( 256). AS-i
CP, .

AS-i. FC,

(
, / ,
).
DP/AS- (DP/AS-Interface link)
AS-i AS-i PROFIBUS-DP.
PROFIBUS-DP DP, AS- AS-i
, 31 AS-i .
AS-i DP/AS-
16 16 .
- 12 /.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

1- 17

1. SIMATIC S7-300/400

DP/AS- :
( 65) IP 66/67
( 20) IP 20
,
20 .

1.2.6
PROFIBUS-DP/RS 232C (PROFIBUS-DP/RS 232C link)
RS 232C (V.24) PROFIBUS-DP.
DP/RS 232C RS 232C
PROFIBUS-DP. DP/RS 232C
3964R ASCII.
DP/RS 232C
" ".
. 224 .
PROFIBUS-DP 12 /; RS 232C
38,4 /
, , 8 1
-.

1.3

(ommunications)

- SIMATIC S7.
.
-

CPU. CP
( SIEMENS)
.
SIMATIC NET - ,
SIMATIC. SIMATIC NET
,
HMI (-
). SIMATIC
.

1.3.1
1.5 .
SIMATIC
( SIEMENS) .
. SIMATIC S7
CPU MPI ,
. ,
(CP),
.

1- 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

. -
( ).
""
(" "),
(""). , S7 S7- .

SIMATIC S7
CPU

ID -

DB

ID

SIMATIC S7
CPU

ID -

SFB

DB

SD

ID

SFB

RD

(Subnet)

. 1.5 SIMATIC S7

-
.
, .


,
, ; ,

. SIMATIC
: MPI, PROFIBUS, Industrial Ethernet PTP ("point-to-point"
[ " "]).
(communications service)
(communications service) ,
,
. ,

.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

1- 19

1. SIMATIC S7-300/400

SIMATIC
: S7, PROFIBUS-DP, PROFIBUS-FMS, PROFIBUS-FDL
(SDA), ISO transport, ISO-on-TSP .
(connection)

( ).
(
) , , ,

(,
)

.
SIMATIC : S7, S7- (), "point-to-point" [
" "], FMS- FDL-, "ISO transport"-, "ISO-onTSP"- TSP-, UDP- E-mail-.
(communications functions)

.
SIMATIC S7
CPU .

( Siemens)
.

1.1 ,
.

1.3.2
-
.
SIMATIC
Manager.
:
MPI

SIMATIC .
PROFIBUS
;

/.
Industrial Ethernet
PLC
.
PTP (" ")

.

1- 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

1.1

MPI

CPU

(GD)

CPU
DP-


SFC
SFB
( S7-400)
PROFIBUS-DP
( )

PROFIBUS

SFC
IM 467

CP 342-5
CP 443-5
Extended
()

CP 343-5
CP 443-5
Basic
()

Industrial
Ethernet

CP 343-1
CP 443-1

CP 343-1 IT
CP 443-1 IT

PROFIBUS-DP
( )

GD-
SFC
,
SFB

, /
, SFC
SFC

SFC

, /
, SFC
SFC

PROFIBUS-FDL,
PROFIBUS-DP
( )
SFC

NCM,
,
SEND / RECEIVE
SFC

SFB
( S7-400)
PROFIBUS-FMS,
PROFIBUS-FDL

,
SFB
NCM, FMS-
,
SEND / RECEIVE
SFC

SFC
SFB
( S7-400)
ISO
TCP / IP
SFB
( S7-400)
ISO
TCP / IP
IT-
SFB
( S7-400)

,
SFB
NCM,
,
SEND / RECEIVE
,
SFB
NCM,
,
SEND / RECEIVE
,
SFB

NCM - CP; NCM


PROFIBUS Industrial Ethernet.

STEP 7 V.5
SIMATIC S7 , ,
, . ()
S7
.
MPI
CPU ("multipoint
interface", MPI [" "]).
CPU, PG, HMI ( ) Siemens.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

1- 21

1. SIMATIC S7-300/400

MPI :
" " - .
50 .
1100
RS485 100
(optical link modul).
187,5 /.
32 .

.
( "token
passing" [ ""]).
MPI CPU
:
, SFC
SFB.
.
PROFIBUS
PROFIBUS ("PROcess FIeldBUS") "
". PROFIBUS ,
EN 50170, .
PROFIBUS :
" "
- .
; 100
(12 /) 1000
(9,6 /).
(optical link
modul).
127 .
.

.
( "token passing"
[ ""]). (slaves)
(master),
, .
.

PROFIBUS;
PROFIBUS-DP. CPU
DP-
. PROFIBUS
SFC SFB.
CP
PROFIBUS-FMS PROFIBUS-FDL.
(FMS-
SEND/RESEIVE-).
1- 22

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

Industrial Ethernet
Industrial Ethernet -

IEEE 802.3.
Industrial Ethernet
, " " ("industrial")
- .
1,5 ,
4,5 . 10 /.
Industrial Ethernet 1000
. , , ,
.
, , ,
,
(
"CSMA/CD"). .
Industrial Ethernet
:
S7- SFB.
Industrial Ethernet CP,
ISO transport ISO-on-TCP,
SEND/RESEIVE.
Point-to-point
" " ("Point-to-point", PTP)
.
"point-to-point"
SIMATIC Manager.
.
RS 232C (V.24), 20 (TTY) RS
422/485. 20 300
/ 19,2 /, RS 232C RS 422/485 - 76,8 /.

; 10 RS 232C, 1000
20 9,6 / 1200
RS 422/485 19,2 /.
3964 (R), RK 512, ASCII
(),
.
.
AS-
AS- ("AS-Interface", AS-i)
IEC TG 178 AS- c

. AS- SIMATIC
Manager; AS-i (AS-I master)
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1- 23

1. SIMATIC S7-300/400

AS-Interface
" ",
(
).
300 .
167 /.
AS-I (master) 31
(slave)
.

1.3.3 (communications services)


,
.
, :
S7- - SIMATIC. S7-
CPU,
() , HMI
.
:
(PG):
, ; PG ,
, "monitor
variables"
.
- (HMI):
(OP), ,
/ .
SFB- (SFB-communications):

; SFB
; ,
.
SFC- (SFC-communications):
76
; SFC
; ,
.
S7- MPI, PROFIBUS Industrial
Ethernet.
(Global data communications)
CPU
.
.
""
( ); .
.
MPI- -.

1- 24

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

PROFIBUS-DP
.
" " EN 50170 2.

, SIMATIC S7
PROFIBUS.
PROFIBUS-FMS (Fieldbus Message Specification ["
"])
(FMS-) EN 50170
2.
PROFIBUS.
PROFIBUS-FDL (Fieldbus Data Link ["
"]) SDA (Send Data with
Acknowledge [" "])
EN 50170 2.
. PROFIBUS
, , SIMATIC S5.
ISO transport
ISO 8073 Class 4.
. ISO transport ,
, SIMATIC S5 Industrial
Ethernet.
ISO-on-TSP TCP/IP
RFC 1006.
Industrial Ethernet.

1.3.4 (connections)
-
.
;
("Communications via non-configured connections" - "
").
.

(connection table).
("Communications via configured
connections"- " ").

.
"Connection type" (" ")
(. 2.4 " ").


(GD) PROFIBUS-DP SFC- (SFC-communications)
S7-. GD
GD;
PROFIBUS-DP SFC-
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

1- 25

1. SIMATIC S7-300/400

(Connection resources)
-
""
CP. , , S7
MPI- CPU, CPU;
MPI- CP ()
CP CPU.
CPU .
PG (
).
"
" (SFC-).

1.4

1.4.1
PLC (. . 1.6).

+HP01
-S10

I/O
n

0 4

0 1 2 3 4 5 6 7
4
5

0 5

n+1

DI 16

A
A

1- 26

I
4

"Switch
motor on"


BOOL

I 5.2

"Switch motor on" /


I 5.2
/

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

, , +HP01-S10,
("Switch motor on" - " "), ,
. "",
I/O- (, 5, 2).
CPU
"
", ("input")
(, I 5.2). "I 5.2"
.
,
(, "Switch motor on"). "Switch
motor on" .

1.4.2

( S7-).
.
(" ").
,
. ,

.
, I/O "
", DP .

"Hardware Configuration" ,
S7-, .

(. 2.3 " ").

1.4.3
, ,
,
( I/O-).
/ 0
, ,
CPU.
, /
(S7-).
.

(" ").
() 8 (.. ).
0, 1, 2 3;
. ,
8 8,
9, 10 11 .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

1- 27

1. SIMATIC S7-300/400

(
), "" ("channel"), 2 .
, 2, 4, 8 16
, 4, 8, 16 32
.
( ) CPU
, ,
. ( ) 0.
.
S7-3xx DP-, S7-318 S7-400
.

.

.
,
() I/O. I/O
.
DP-
,
( ) .
DP- I/O ,
SFC 14 DPRD_DAT
SFC 15 DPWR_DAT.

,
"Input" ("") "Output"
(""). , FM CP
.

1.4.4

,
.
( ),
. ,
, , ,
, ,
.
I/O
.
0; (
), CPU
.
STEP 7 ,
I/O.

1- 28

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

.

;
(. 20.4.1
" ").

1.4.5
,
DP- (, DP-
) PROFIBUS ,

.
MPI-
, MPI- (, CPU, FM CP),
MPI-. PG, HMI .
, S7-300 FM CP,
, MPI-, MPI-
CPU.
CPU 318 MPI-
, MPI-.
.

1.5



:
;

(. 7 " " 8
" ");

L- ( 18.1.5 " ").


( ) ,
.

1.5.1
SIMATIC S7 :
,
LOAD TRANSFER
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1- 29

1. SIMATIC S7-300/400

,
,
I/O. ()
.
.

/ .
, , ().
. ,
1, 2, 4 .
0. 0
; .
I/O ,
PI- ("peripheral
inputs") ( ) PQ- ("peripheral outputs")
( ).
,
CPU .


. PI-
.
0- I/O,
CPU.
(Direct I/O Read)
,
(, ).
, ,
.
. ,

,
.
,
.


. PQ-
.
0- I/O,
CPU.
(Direct I/O Write)
,
(, ).

1- 30

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400

, ,
.
. ,

(!),


,
.

1.5.2 ( )
( )
, ,
.

(I),
(Q). ,
.
,
,
.
20.2.1 " ".
S7-300 CPU , 1998 ., S7-400 CPU
,
, ,
. ,
.
CPU, , CPU 417,
.
, , ,
(work) .
CPU (work) ,
.

-
. - ,
.
CPU
.
:

(I/O ).
,
(,
- I/O , ,
, ). ,
.
(

).

.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

1- 31

1. SIMATIC S7-300/400

, , ,
RAM-. ,
.
,
.
.
(.
20.2.4 " ").

-
. - ,
. CPU
.
:
(
I/O ).
,
(,
- I/O , ,
, ). ,
.


.
.
, , ,
RAM-,
, .
.
.
20.2.4 " " ,
.

1.5.3
" "
.
. .
CPU, , ,
.
CPU.
,
,
.
:
, ,
.
,
, .

1- 32

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1. SIMATIC S7-300/400


,
,
. 0-
.
CPU.
22.2.3 "".

.
(
), (watchdog) (
) .
- ,
/, 1:1. ,
,
(. .1.7).
CPU.
,
.

10
5 ( [flickering light])
2,5 ( [fast flashing light])
2
1,25 ( [flashing light])
1
0,625 ( [slow flashing light])
0,5

.1.7

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

1- 33

1. SIMATIC S7-300/400

1- 34

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2 STEP 7
2.1 STEP 7 (STEP 7 Basic Package)
STEP 7 (STEP 7 Basic Package)
5.1.
, ,
.
STEP 7 (STEP 7 Basic Package)
: STL ("statement list" - ), LAD ("ladder
diagram" - ), FBD ("function block diagram" -
).
S7-SCL ("Structured Control Language"
), S7-GRAPH (
SIMATIC
), S7-HiGraph (
SIMATIC
).

2.1.1
STEP 7 V 5 32- ,
: Microsoft Windows 95
( Service Pack 1, 4.00.950), Windows 98
Windows NT ( Service Pack 2,
4.00.1381).
STEP 7 Windows 95/98
(PG) ()
80486 32 ( :
Pentium 64 ).
Windows NT Pentium 32 ;
STEP 7
Windows NT.
STEP 7, ,
, , 100 ,
PG .
STEP 7 V 5 200 380
(, )
.
(
128 256 ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 1

2. STEP 7

,
. ,
,


.

Windows.
STEP 7 SETUP Windows 9x/NT,
-. PG STEP 7
.
STEP 7 - (.
), NCM
STEP 7 Acrobat
Reader V3.01.
MPI-.
PG MPI-,
MPI-.
,
.
STEP 7 V 5
, , , ,
.
Windows
SIMATIC Workstation.

.

2.1.2
STEP 7
( ).
. STEP 7
, .
, .
,
- .
, , -
, (
) " " (emergency license),
- ( ).

2.1.3 SIMATIC Manager


SIMATIC Manager STEP 7.
Windows:
SIMATIC Manager .

2- 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

" " (Project


Wizard).
. ,
Check box "Display Wizard on starting the
SIMATIC Manager" (" - SIMATIC
Manager"). -
: File () -> "New Project" Wizard.

("project").
.
ZEn01_09_S7_ZEBRA
: File () -> Open (), :
(), (.2.1).

.2.1 SIMATIC Manager


"+"
;
.
SIMATIC Manager STEP 7.
"" , SIMATIC Manager,
"" ().
() , (station)
(PLC).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 3

2. STEP 7

Project

MPI
[PTP, PROFIBUS, Ethernet]
SIMATIC 300/400 station

Subnet
()

Configuration table

Hardware

(
)
( )
CPU xxx

CPU

Connections
()
S7 program
Symbols
()
Sources

Connection table
( )


Symbol table
( )

S7 program

(
) GD

Source programs
Source files
( ) ( )
Blocks


(STL-, SCL-)

OB n
FB n
FC n
DB n

SFC n
SFB n



. , CPU

System data
(
)
UDT n

Data types ( )

VAT n

Variable table
( )

,
CPU ( , S 7-,
CPU)

.2.2 STEP 7
, ,
, MPI. CPU, CPU
S7-.
, Blocks (),
.
2- 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

STEP 7 . . 2.2
("main
branch" - " "),
S7 (offline view). ,
, . (offline
view) .
PG. PG
(online) CPU (
PLC), (online view),
: View -> Online ( -> ).
,
; , ,
.
,
(online) (offline) .

. :
Options -> Customize ( -> )
"View" ("").
: Options -> Customize ( ->
), SIMATIC Manager,
session language (),
, .

:
-
, .
-
(. ) ,
, , , : Edit ->
Object Properties ( -> ),
. ,
CPU,
(),
(Hardware Configuration).
- ,
, , SIMATIC Manager
,
, SIMATIC Manager
(,

).

. ,

.
.
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 5

2. STEP 7

2.1.4 (Project(s) Library(ies))


STEP 7 " ",
, (project) (library).
(projects)
. :
;
;
;
( , , ).
.

.
.
(library)
.
. STEP 7 ,
( ),
.
(online) ( ),

.
STEP 7 V5 Standard
Library, :
System Function Blocks ( ),

, CPU;
S5-S7 Converting Blocks ( S5-S7 ),
S5-S7 (
S5
);
T1-S7 Converting Blocks ( TI-S7 ),
TIS7 ;
IEC Function Blocks ( IEC),

DATE_AND_TIME STRING;
Communication
Blocks
(
),
CP;

PID Control Blocks ( -),


;

Organization Blocks ( ),
(
).
33 "
".
2- 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

S7- ,

.
.
: File -> Open ( -> ),
.
.
: File -> New ( -> )
(
). (
)
: Options -> Customize ( -> )
New ().
Insert ()
(,
). ,
, SIMATIC
Manager.
: Edit -> Copy ( > ) Edit -> Paste ( -> ) ,
Windows, "drag-n-drop",

. , ,
SIMATIC Manager.

2.1.5 (Online Help )


(Online Help) SIMATIC Manager
,
.
, Help
(). Getting Started (),
, SIMATIC
Manager.
: Help -> Contents ( -> )
STEP 7 .
.
: Help -> Context-Sensitive Help F1 ( ->
) ,
F1, ,
"" , ,
.
,
.
(, ),
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 7

2. STEP 7

2.2
"" ("")
,
. , ,
( , CPU)
. , S7 -
. , (
, CPU, )
Hardware Configuration
tool.
,
SIMATIC Manager. ,
, (!)
Windows Explorer ()
SIMATIC
Manager.

2.2.1
Project Wizard ( )
STEP 7 V3.2 STEP 7 Wizard
.
CPU, - S7-
CPU, S7-,
.
S7-
"",
,
. 2.1.3 "SIMATIC Manager"
.

: File -> New ( -> ),
, , ,
""
"Enter".

: Insert -> Station
-> Simatic 300 Station ( -> -> S7-300) (
S7-300).

2- 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7


,
project ; SIMATIC Manager
Hardware () .
Hardware
Hardware Configuration,
.
,
: View -> Catalog ( -> ).
(rail), ,
"SIMATIC 300" "RACK 300" "drag-n-drop"
(station window).
, .

, "drag-n-drop",
.
CPU, , CPU 314
2. .

2.3 " ".
,
SIMATIC Manager.
CPU.
CPU SIMATIC Manager S7 .
.
S7-
CPU;
S7- (S7-program) (connection table).
S7-program; SIMATIC Manager
(Blocks - ),
.
(Blocks - ); SIMATIC Manager
(System
data - )
(main) (OB1) .

.
1
.

: Insert -> S7 Block -> (Blocks )
.
System data ( )
.
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 9

2. STEP 7


Hardware () Station ().
System data ( ) CPU, : PLC -> Download
(PLC -> ), CPU.
Source Files ( ) .
Source Files : Insert -> S7 Software ->
STL Source File ( -> S7 -> STL- )
Source Files , ASCII
( STEP) , : Insert
-> External Source File ( -> ).
S7-
,
. .
S7-, : Insert
-> Program -> S7 Program ( -> -> S7- ).
S7- SIMATIC Manager Symbols ()
Sources ( ) Blocks ().
Blocks () OB 1.

library (),
, .
,
. ,
(online) ,
S7- .

2.2.2 ,
SIMATIC Manager "
" ("main objects"),
, () .
()
STEP 7 .
File -> Rearrange ( ->
) SIMATIC Manager ,
,

. ,
.
: File
-> Archive ( -> ). SIMATIC Manager
(
) .
,
. STEP 7 ARJ PKZIP
2.50, (,
winzip, 6.0, pkzip, 2.04g, JAR,
1.02 LHARC, 2.13).
2- 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

,
() .
"" : File ->
Retrieve ( -> ),
.
.

"Archive" (""),
: Options -> Customize ( ->
).

"Generate archive name automatically" ("
"),
/,
.
CPU
STEP 7 V 5.1, S7400 CPU ()
CPU, . ,
,
,
, ,
.
, ,

CPU.
, CPU,
, CPU PLC -> Save Project on Memory Card (PLC ->
).
: PLC -> Retrieve Project from
Memory Card (PLC -> ).
, , CPU,
,
.
, CPU,
, CPU PLC ->
Display Accessible Nodes (PLC -> ).
PG, : File -> S7 Memory
Card -> Open ( -> S7 -> )
.

2.2.3 (Project Versions)


SIMATIC. STEP 7 V1
1, STEP 7 V2
2, STEP 7 V3/ V4/ V5.0
- 2 3. STEP 7 V5.1
3 3.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 11

2. STEP 7

1
2, : File -> Open Version 1 Project ( ->
1). ,
1, STL-,
.
2 STEP 7
V2, V3, V4 V5.0 (. .2.3).
STEP 7 V1
1 (V1)

STEP 7 V5.1

: File -> Open


Version 1 Project ( ->
1)

V1 V2

File -> Open


( ->
)

V2

V3

File -> New ->


project
( ->
->
)

V3

3 (V3)

3 (V3)

2 (V2)
2 (V2)

File -> New ->


project 2. ( -> )
V2
File -> Save as
( -> )
V2 V3

V2 V3

STEP 7 V2

STEP 7 V3/ V4/ V5.0

.2.3 STEP
STEP 7 V5.1 3. ,
V1 V2,
: File -> Open Version 1 Project ( ->
1). 2, : File ->
Open ( -> ). ,
V2.
2- 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

2.3

Hardware
Configuration.

(offline), ..
CPU.
.

.

: Edit -> Open Object ( ->
)
(Hardware object) SIMATIC 300/400 Station.
(basic settings) ,
: Options -> Customize ( -> ).

: Station ->
Consistency Check ( -> ).
: Station -> Save ( -> )

.
: Station -> Save and Compile ( ->
)

System data ( )
"" (offline) Blocks ().
CPU, :
PLC -> Download (PLC -> ). System data (
) "" (online) Blocks ()
CPU. ""
, : PLC -> Upload (PLC -> ).
,
: Station -> Export ( -> ).
STEP 7 ASCII ,
.
,
, ()
.
ASCII .
(Checksum)
Hardware Configuration

.
,
"" (offline) "" (online) .
(Checksum)
System data ( ).
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 13

2. STEP 7

Blocks () S7, System data ( )


: Edit -> Open Object ( -> ).

.
Blocks (): Blocks (),
: Edit -> Object Properties ( -> )
"Checksums" ( ).
(Station)
Hardware
Configuration (.
. 2.4).

. 2.4 ,
Hardware Configuration
()
.
DP- . ,
,
PROFIBUS, DP. ,
DP, .
2- 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

(Hardware)
:
View -> Catalog ( -> ).
, , , STEP 7.
: Options -> Edit Catalog Profile ( ->
)
, ,
.
""
.
(Configuration table)
Hardware Configuration
, ,
DP-.
, ,
.
(properties),
.

2.3.1

"" "drag-n-drop"
, , "SIMATIC 300" "RACK 300"
.
.
. ,
"No Parking" ("
") ,
.
S7-300 3 :
.


. S7-400 ( :
)
"Link" ()
("Properties") ("Send") IM. ,
: Edit -> Object Properties ( -> ).
I/O
20.4.2 " I/O".

2.3.2

Hardware Configuration .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 15

2. STEP 7


. S7-400 CPU S7-300 CPU
DP- .
S7-400 S7-300,
.
, ,
() .
,
;

.
S7-400,
.
,
,
CPU.
: View -> Address Overview ( -> )

CPU.
MPI MPI-.
. , ,
MPI- ,
CPU.
,

Hardware Configuration () ,
(Symbol Table).

.
( ) : Edit -> Symbols ( -> )
, ,
(
).
"Add Symbol" (" ")
.
"Apply" ("")
(Symbol Table). "OK" .

2.3.3
.
, ,
. ,
.

,
2- 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

: Edit -> Object Properties ( ->


).
.
CPU
.


SFC 55 WR_PARM, SFC 56 WR_DPARM SFC 57
PARM_MOD.

2.3.4 MPI
MPI- (Module
Properties). CPU
MPI, ,
, : Edit -> Object Properties ( ->
). "General"
("") "Properties" () "Interface"
(). ,
"Parameter" (), .
MPI-,
CPU. , S7-300 CPU,
FM CP MPI- MPI- ,
CPU.
MPI- MPI-,
(
FM CP!).
.
: CPU ,
CPU ().
"CPUxxx(1)",
MPI-.
CPU, , ..
"CPUxxx(1)" "CPUxxx(n)", "n" MPI-.
MPI-
MPI- PG ()
.
PG ()
MPI-;
(spur-line) - MPI-
.
: 0 , 1 3 - CPU (
, ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 17

2. STEP 7

2.3.5 Monitor () Modify ()


Hardware
Configuration
. ,
(online) ,
CPU.
.
, : PLC -> Monitor/Modify (PLC ->
/)
.
"Status Value" ( )
Hardware Configuration
. "Modify Value"
( ) ,
"Modify Value".
checkbox "I/O Display" ( I/O),
/
/ ( ).
checkbox "Enable Periph Outputs" (
), , CPU
STOP (. 2.7.5 " ").

2.7.3 " " 2.7.4
" ".

2.4 (Network)
SIMATIC S7-.

.

SIMATIC Manager.
( CPU CP),
Hardware Configuration;
.
-
(connection)
Network Configuration (connection table).
Network Configuration
.
Network Configuration
;
("node properties")
.

2- 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

(connections)
Network Configuration
:
MPI-,
. ,
: Insert -> Subnet ( -> ).
Network Configuration
, , .
station ()
.

.
, .
(communication connections)
(connection table), .

Network Configuration:
MPI : Options -> Define Global Data ( ->
) (. 20.5 "
").
: Network -> Save ( -> )
.
: Network ->
Consistency Check ( -> ).

: Network -> Save and Compile ( ->
).
Network ()
Network Configuration
. SIMATIC Manager
MPI-.

Network Configuration.
, Connections ()
CPU.
. 2.5 Network
Configuration, ()
(connections).
(connection table) .
, ,
, , S7-400 CPU.
SIMATIC
, DP-.
: View -> Catalog ( -> ).
""
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 19

2. STEP 7

. 2.5 Network Configuration


: View -> Zoom In ( -> ), View ->
Zoom Out ( -> ) View -> Zoom Factor ( ->
)
.

2.4.1 (Network
View)


"" .
.
.
2- 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

,
. "".
Hardware configuration,
, ,
() .
(Network Configuration).
, ,
,
. ,
"" .
.
.
.

.

,
.
: Edit -> Object Properties ( -> )
. "General" () S7 (ID). ID -
. ID S7-
(online)
, .
(network properties) "Network
Settings" (" "), , (data
transfer rate) (highest node address).
(network connection),
: Edit -> Object Properties
( -> ), , (node address)
(subnet), ,
.
"Interfaces" ("")

.

(
Hardware Configuration).

2.4.2 DP-
Network
Configuration
Network
Configuration I/O.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 21

2. STEP 7

: View -> with DP Slaves ( -> DP-),


(slave) DP (Network View).
DP- :

PROFIBUS ( , ""
PROFIBUS ).

DP- (master) ( ,
"" ,
DP-
Hardware Configuration
CPU , ).
(connection) DP- PROFIBUS (

Hardware Configuration,
DP- (master)
Network Configuration ""
PROFIBUS).
DP- (master),
DP- (slave). DP (slave) "PROFIBUS"
, ""
.
DP- (slave)
: Edit -> Open Object ( ->
).
Hardware Configuration.
,
(slave), I/O (. 2.3
" ").
DP- ,
(. 20.4.2
" I/O").
DP- (slave) "Already created
stations" (" "). DP-
(master) ""
(
Hardware Configuration).
: View -> Highlight -> Master System ( ->
-> DP-)
DP- (DP-master system).
() (master)
(slave) .

2.4.3 (Connections)
(Connection)
.

2- 22

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

SFB- SIMATIC S7 ("Communications via configured connections" - "


")
SIMATIC S7-.
:
(online) MPI-
.
,
, .
(Network
Object Catalog) PG/PC Stations (), PG/PC
(network),
.
Connection table ( )

(Connection table).
: ,
,
.
Connections () CPU
(Connection table). Connections
()

Network
Configuration, .
S7-400 CPU
Network Configuration.
(Connection table) (. :
2.1). ,
, , .
2.1 (Connection table)
Send Operating
State Message
(

Local ID
( ID)

Partner ID
(ID )

Partner
()

Type
()

Active Connection
Buildup
(
)

Station 416/CPU416(5)

S7 connection

Yes ()

No ()

Station 416/CPU416(5)

S7 connection

Yes ()

No ()

Station 315/CPU315(7)

S7 connection

Yes ()

No ()

Station 417/CPU414(4)

S7 connection

Yes ()

No ()

3
4

:
Insert -> New Connections ( -> )
.
(connection)
("active") CPU. , S7-300 CPU
; S7-300 CPU "" ("passive")
S7-.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 23

2. STEP 7

"New Connection" (" ")


"Station" ("")
"Module" ("") (. . 2.6);
. .

. 2.6
,
check box "Show Properties Dialog"
(" ").
.
: View ->
Display Columns ( -> ),
.
Connection ID ( )
CPU. STEP 7
ID .

.
Local ID ( ID)
ID ( local ID - ID
).
,
ID .
2- 24

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

ID (local ID)
.
, ,
:
S7-:
0001 16 0FFF16
PtP-:
1000 16 140016
Partner ID (ID )
ID ( partner ID),
CPU
ID (local ID);
: Edit -> Object Properties
( -> ). STEP 7 ID
(partner ID), ,
() (. ).
Partner ()
.

, "Station" ("")
"unspecified" (" ").

(one-way
connection)

; :
SFB- S7-400 S7-300 CPU.
SFB- S7-300,
S7-400 CPU SFB 14 GET SFB 15 PUT.
S7300,
.
(one-way connection)
(connection table) "" ("active") CPU.
STEP 7 ID ("Local ID").
.
(two-way connection)
; , , S7-400 CPU.
, ,
SFB 8 BSEND SFB 9 BRCV.
(two-way connection)
. STEP 7
ID ("Local ID"), ID ("Partner ID")
.
.
Type ()
.
STEP 7
(connection type):
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 25

2. STEP 7

PtP connection ("Point-to-point", " ")


PTP ( 3964 (R) RK 512) SFB-.
PtP
. SIMATIC S7
CP SIMATIC S7
( SIMATIC),
, -.
S7 connection MPI, PROFIBUS
Industrial Ethernet SFB-. S7
SIMATIC S7,
PG HMI ( -
). S7
.
Fault-tolerant S7 connection ( S7)

PROFIBUS
Industrial
Ethernet

SFB-. S7
SIMATIC S7

.
"NCM S7 for PROFIBUS" "NCM S7 for Industrial Ethernet"
.
NCM
: FMS-, FDL-,
ISO transport-, TCP-, ISO-on-TCP-, UDP E-mail-.
(Active Connection Buildup)
, ,
().
, .
check box "Active connection
buildup" (" ") :
, : Edit -> Object Properties
( -> ).
(Sending operating state messages)

.
,
check box .
CPU
SFB 23 USTATUS.
(Connection Path)

, , ()
(Connection Path).
, STEP 7
: Industrial Ethernet, Industrial Ethernet/TCPIP, MPI , , PROFIBUS.

2- 26

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

CPU, ,
.
"Interface" ("")
. CPU
(, S7-400 CPU ),
"PLC-internal" (" PLC").
"Type" ("") ,
. ,
, MPI- PROFIBUS-,
"MPI".
"PROFIBUS", STEP 7 .
MPI PROFIBUS "Address"
("").
(Connections between projects)
S7 ,
SIMATIC-, "unspecified" ("
") (
).
, , STEP 7
.

.
S7- (Connection to non-S7 station)
, S7, :

( [ Siemens] ,
S7- )

PG / ()

SIMATIC S5-

,
( S7) ,

(,
Network Configuration, :
Edit -> Object Properties [ -> ]
"Interfaces" [""]).

2.4.4 (Network Transitions)


,
.
S7-,
MPI-. - S7-
, PROFIBUS,
.
,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 27

2. STEP 7

,
(routing
table), .

S7- "",

.
, ,
,
( ).
"placeholder" (""), PG/
(Network Object Catalog)
. PG/
,
PG.
PG
: PLC -> Assign PG/PC (PLC -> PG/).
.
PG : PLC ->
Undo PG/PC Assignment (PLC -> PG/).
(online) ,
, ID S7-
. ID S7- :
. ID .
, - : Edit -> Object Properties
( -> ) "General" ("").

2.4.5 (Loading the Connection Data)


,
("connection table") PLC (
"" CPU).
: (network window),
. ,

.
. ,
, STOP.
: PLC -> Download -> (PLC -> -> )

. ,
, :
-> Selected Stations ( )
-> Selected and Partner Stations ( )
-> Selected Connections ( )
-> Stations on Subnet ( )
-> Connections and Gateways ( )
2- 28

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7


(connection table).

(System data) Blocks.
CPU
.
(online) MPI
.
PG Ethernet PROFIBUS,
.
"Set PG/PC Interface"
Windows.

2.5 S7-
2.5.1
( ) S7 Program.
CPU
, CPU. S7 Program
Symbols () Source Files (
) Blocks () (. . 2.7).

. 2.7 , .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 29

2. STEP 7

("sourceoriented")
Source Files ( ).
- ASCII,
,
.
;
Blocks (). MC7
S7 CPU.
"" ("incremental"), - .
.
,
Blocks ().
(online)
CPU, .
.
- , , I1.0 ( ).
Symbol Table Symbols,
, , "Switch motor on" (" ")
,
( ). Blocks ()
,
(Symbol Table) -
,
(address priority).


SIMATIC Manager ,
: Edit -> Object Properties ( -> ),
"General-Part 2" (" - 2").
,
SIMATIC Manager Blocks ()
: Edit -> Object Properties ( -> ).
Blocks ()
(load memory) (work memory),
.
;
.

2.5.2 (Symbol Table)


, .. ,
, .
(, I1.0) (, Start signal [
]). .
, ,
.
2- 30

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

(local)
(global) ( ). (local)
, .

.

.
( Symbols S7 Program).

24 . ,
, , .
00 hex, FF hex (").
.

.
80 .

:
I, Q, PI PQ
M, T C
OB, FB, FC, SFC, SFB DB
, , UDT
VAT
;
(declaration section)

(declaration section)
.
S7- SIMATIC Manager
Symbols.
(. 2.8).

. 2.8 Symbol Table

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 31

2. STEP 7

S7- Symbols.
.
, .
, BOOL ,
INT ,
16- .
3.7 " "
24 " ",
STEP 7.
""
;
.
,
.
,
.
"" ,
. ,
.
: ASCII ( *.asc),
sequential assignment list ( -
*.seq), System Data Format ( -
*.sdf Microsoft Access) Data Interchange Format (
- *.dif Microsoft Excel).
.

.

: Edit -> Special Object Properties ( ->
),
.
:
HMI WinCC


S7-PDIAG
: View -> Columns O, M, C, R ( -> O, M, C, R),
. : Options ->
Customize ( -> ) ,
,
.

2.5.3 STL- (STL Program Editor)


STEP 7 (STEP 7
Basic Package) LAD, FBD
STL. STL-
"" ()
2- 32

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

. . 2.9
, STL-.

Symbols

(Symbol
table)

Sources

(Source
programs)

Blocks
(off-line)

PG

off-line
( )

PLC
(PLC
download)

on-line
( )

( )

( )

Blocks
(on-line)

PLC
(PLC
upload)

CPU

. 2.9 STL Editor.



,
. ,

. ,
,
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 33

2. STEP 7

STL- "" ("decompiled"), .. MC7



(offline database) ( CPU,
PG ). ,
STL-
.
STL-

SIMATIC Manager, ,
OB1
Windows: Start -> Simatic -> STEP 7 -> LAD, STL, FBD Program S7 Blocks.
:
Options -> Customize ( -> ). "Editor"
("") ,
, , , ,
.
Blocks () (,
) .
,
,
Source files ( ).
,
, , ..
, .
,
, LAD FBD.

MC7
.
,
,
. ,
-
.

, ,
" " .
,
, ,
(block protection KNOW_HOW_PROTECT).
, ,
CPU.
,
. ,

ACSII-
.


, (online)
, ( ) .
2- 34

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

,
"Source-oriented" (
)
STL- Source Files ( ). STL-
ACSII- .
,
.
SIMATIC Manager Source Files ( )
: Insert -> S7 Software
-> STL Source File ( -> S7 -> STL-).
,
: Insert -> Block Template -> ( ->
-> ) ( ). -
\Step7\S7ska, S7kafnnx.txt.
, .

STL-
: File -> Generate Source File ( -> ).

, SIMATIC Manager: Insert > External Source File ( -> )
Source Files ( ).
:
Edit -> Export Source File ( -> ).
,
,
, .
3.4.3 " ,
STL" 3.6.2 " ,
"
STL-.
STL-

, .

Blocks ().

STL-,


.
"Source Files" (" ") ,
: Options -> Customize ( ->
) ,
, ,
,
, .
"Generate Block" (" ")
.
: File -> Consistency Check ( ->
)
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 35

2. STEP 7

.
,
: File -> Compile ( -> ).
.
, .
,
, , , CPU, ,
.

,
(
3.4.3 "
, STL").
STL-
"Source Files" (" ") ,
: Options -> Customize ( ->
) "Generate source files automatically"
(" "),


( ).
.

.
"Execute" ("")
,
.


(offline), (online) Blocks ().


. , ,
, .
"Create Block" (" "),
: Options -> Customize ( -> ),
(reference data)
.
(offline)
(online) CPU (,
, ["programmable controller"]
PLC). SIMATIC Manager ("offline"
"online"); .
"" ("offline")
PG.
("offline")
: File -> Save ( -> ) CPU
: PLC -> Download (PLC -> ).
2- 36

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

,
CPU,
: File -> Save as ( -> ).
CPU "" ("online")
. CPU
. CPU
: PLC -> Download (PLC -> ). CPU
(RUN) ,
.
, "" ("online")
("offline") ,
: File -> Save ( -> ).
2.6.4 " CPU" 2.6.5
"
"

(online) . 3.4.2 "


STL" 3.6.1 "
STL" , STL-.

2.5.4 SCL- (SCL Program Editor)

S7-SCL

SCL.
S7-SCL SIMATIC Manager.

. SCL,
,
(. . 2.10).
,
. ,
Blocks (), .

, , STL.

,
.
SCL-
, ,
. (: CPU,
).
STL-
SCL- SIMATIC Manager
SCL- SCL-
Windows: Start -> Simatic -> STEP 7 -> S7-SCL -> Program
S7 Blocks.
SCL-
, ,
,
STL-.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 37

2. STEP 7

Symbols

(Symbol
table)

Sources

(Source
programs)

( )

Blocks
(off-line)

PG

PLC

( )

Blocks
(on-line)

(PLC
download)

CPU

. 2.10 SL Program
Editor.
SL-
: Options -> Customize ( -> ).
"Editor" ("") ,
, , ,
.
SCL-
Source files ( ) SIMATIC Manager
: Insert -> S7 Software -> SCL Source File ( -> S7 ->
SCL-), .
.
: Insert
-> Block Template -> ( -> -> ),
2- 38

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7


.
SCL-
, SIMATIC Manager: Insert > External Source File ( -> )
Source Files ( ).
:
Edit -> Export Source File ( -> ).
,

"Window" ("").
,
,
, .
3.5.2 " SCL" 3.6.2 "
, "
SL-.
SCL-

, .

Blocks ().


SCL-,

.
"Compiler"
("") , :
Options -> Customize ( -> ).
Create object code ( ):
, ,
, ;

.
Optimize object code ( ):
,
.
Monitor array limits ( ):
,
, , ,
.
Create debug info ( ):

Program Status, . (
- )
Set OK flag ( OK):
,
OK EN/ENO.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 39

2. STEP 7

,
: File -> Compile ( -> ).
.
, .
,
, , , CPU, ,
.
, : File -> Partial Compile ( ->
).

,
(
3.5.2 "
SCL"). SCL-
DB, .
DB (Symbol Table)
.
, , , IEC-,
Blocks ()
.
: PLC -> Download (PLC -> )
CPU ,
Blocks ()
.

SCL
, ,
.
: Insert -> SCL Compilation Control File ( ->
) Source Files (
).

,
.
: File -> Compile ( -> )
.

2.5.5 (Rewiring)
Rewiring

. , I 0.0 I 0.7
I 16.0 I 16.7. , ,
, , FC
FB.
SIMATIC Manager ,
; , ,
Ctrl,
- Blocks ().
2- 40

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

,
, : Options -> Rewire ( ->
). , O,
, SIMATIC Manager .
,
.
:

Address priority ( ).
,

,
, (rewire)
.

2.5.6 (Address Priority)


("offline") Blocks ()
"Blocks" ("")
( ) ,
.
.
: "Absolute address has priority" (
) ( ,
STEP 7). ,
, ,
.
: "Symbol has priority" (
), , ,
.
:
:
I 1.0 "Limit_switch_up"

(" ")

I 1.1 "Limit_switch_down" (" "),


I 1.0:
A I 1.0 "Limit_switch_up"
: "Symbol has priority" (
),
:
I 1.0 "Limit_switch_down" (" ")
I 1.1 "Limit_switch_up"

(" "),

:
A I 1.1 "Limit_switch_up"

(" "),

: "Absolute address has priority" (


), :
A I 1.0 "Limit_switch_down" (" ")
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 41

2. STEP 7


,
"Absolute address has priority" ( ),
(
),
. : "Symbol has priority"
( ),
(
).
: "Symbol has priority" (
),
.

(rewired) .
: (rewiring)
,
MC7- .
,
.

2.5.7 (Reference Data)


SIMATIC Manager
(Reference Data),
.
:
Cross references ( )
Reserved locations ( : I, Q, M, T, C)
Program structure ( )
Unused symbols ( )
Addresses without symbols ( )
Blocks ()
: Options -> Reference Data -> Display ( ->
-> ).
: View -> Filter
( -> );
: Save as Standard (
). .
C : Options -> Customize ( ->
) "Create Blocks" ("
")

.
: (offline)
; "" (offline) ,
, (online).

2- 42

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

(Cross references)

. ,
( ), ,
( )
. STL- ,
, ,
; SCL- - .

.
, : Edit -> Go To -> Line
( -> -> ) ,
.

(: View -> Filter ( -> )
(,
). ,
, . STEP 7
(
"Standard") .
: ,
. ,
(, ).
(Assignments)
I/Q/M , I, Q M
.
. (,
). T/C ,
.
.
: ,
()
.
(Program structure)

. ("starting blocks")
.
:
"" (tree structure)
.
, -
"+" "-". ,
("temporary local data"), ("path")
.
,
.
"-" (Parent-child structure) 2
, , .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 43

2. STEP 7

: ,
, ,
,

( ).
(Unused symbols)
,
, . ,
, .
: ,
, ,
, .
(Addresses without symbols)
,
. , .
: ,
, ( ).

2.5.8

SIMATIC Manager
.

, . , , ,
, , STEP 7
SIMATIC Manager : Options ->
Customize ( -> ) "Language"
(""). , ..
, STEP 7.
.

, , (,
),
. , .
, *.csy ,
Microsoft Excel.
(translation)
(translation table) .
() .
.
(Exporting and importing texts)
SIMATIC Manager ,
, (), ,
, (block container),
. : Options -> Manage Multilingual Text ->
Export ( -> -> ).
2- 44

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7


(storage location) ,
(target language). (Text type),
( 2.2).
2.2
(Text type) ()
Text type ( )

Meaning ()

BlockTitle

Block title

BlockComment

Block comment

NetworkTitle

Network Title

NetworkComment

Network Comment

LineComment

Line Comment

InterfaceComment

SymbolComment

( )
( )
( )
( )

( )

Comment in
declaration table of
code blocks
data blocks
user data type UDT
Symbol Comment

(
-

-
-
)

( )

, ,
SymbolComment.csv.
.
() () Microsoft Excel
: File -> Open ( -> ) (
).
,
() .

: Options -> Manage Multilingual Text -> Import ( ->
-> ). (log-)
,
.
: ,
(Text type),
.


SIMATIC Manager : Options ->
Manage Multilingual Text -> Change Language ( ->
-> ).
(, ),
.
( log-).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 45

2. STEP 7


SIMATIC Manager : Options -> Manage
Multilingual Text -> Delete Language ( ->
-> ).

2.6

(Online Mode)

, engineering
system (ES). S7- (offline)
, .
CPU PG
CPU, - ("online") .
CPU
(assigned) , ..
.

2.6.1 PLC (Connection a PLC)


MPI- PG MPI- CPU
(online) .
, CPU
.
CPU MPI-, CPU
(MPI-). MPI-
CPU. CPU
CPU
System Data ( ) Blocks ()
Hardware Configuration
: PLC -> Download (PLC -> ). CPU
MPI- ("naming" - )
.
MPI- CPU MPI-
, MPI CPU.
: MPI- .
,
, , ,
MPI-.
MPI- CPU . ,
CPU .

(online) CPU, ,
, PG .

2- 46

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

PG ,
CPU : PLC -> Display
Accessible Nodes (PLC -> ).
(project) :
"Accessible Nodes" - "Module (MPI=n)" - "Online User Program (Blocks)"
[" " - " (MPI=n)" - "
()"].
Module (online)
, (operational status)
(module status). Blocks
(), ,
CPU. (, ,
) .
CPU ,
,
PG (data
management system).
SIMATIC Manager, ,
- : PLC -> Upload Station (PLC ->
). CPU
(online) .
CPU,
(online) . MPI- CPU
, (online) S7-
: Edit -> Object Properties ( -> ),
CPU
"Addresses Module".
S7- (online)
, (online)
CPU. Blocks () ,
CPU. (offline)
(online) ,
,
PG ( ,
).
, CPU,
(online) ,
, CPU . ,
SIMATIC-, ..
CPU, .

2.6.2
CPU
. , ,
. ,
, () .
"Protection" ("")

Hardware Configuration CPU.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 47

2. STEP 7

1:
(Protection level 1: keylock switch position)
(
).
CPU.
RUN-P STOP ;
RUN " "
PG. ,

.
RUN,
, "Can be revoked with password" ("
"), , CPU
.
2:
(Protection level 2: write protection)


.
3:
(Protection level 3: read/write protection)

.
(Password protection)
2 3 1
"Can be revoked with password" (" "),
. 8
.
,
, .
CPU,
: PLC -> Access Rights (PLC ->
). CPU S7-.
"Enter Password" (" ")
"Use password for other protected modules" ("
")
.
("Password access autorization")
, S7
.
, ,
CPU
.

2- 48

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

2.6.3 CPU (CPU Information)


(online)
, CPU. ,
- ( [online]
) S7- ( [online] ).
PLC -> Diagnose Hardware (PLC -> )
(. 2.7.1 " " )
PLC -> Module Information (PLC -> )
(, , ), ,
( [map] [work memory]
[load memory], [compression]),
[cycle time] ( ,
), (
CPU, , ),
( , ,
, SFC SFB), (
), STOP (B-, I- L) "Addresses Module".
PLC -> Operating Mode (PLC -> )
(, RUN STOP),
.
PLC -> Clear/Reset (PLC -> /)
CPU STOP-.
PLC -> Set Date and Time (PLC -> )
CPU.
PLC -> CPU Messages (PLC -> CPU)
,
, SFC 52
WR_USMSG, SFC 18 ALARM_S SFC 17 ALARM_SQ.
PLC -> Display Force Values, (PLC ->
),
PLC -> Monitor/Modify Variables, (PLC -> /
)
(. 2.7.3 "/ " 2.7.4
" ").

2.6.4 CPU
CPU ( ,
)
(load) CPU. (load)
RAM EPROM,
CPU .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 49

2. STEP 7

EPROM,
:
PG,
CPU, .

(work) CPU. CPU
EPROM-,
.
(load) RAM,
CPU : CPU
STOP,

. RAM-
(backup battery).
( CPU,
, GD-,
..), CPU System data (
).
: PLC -> Download (PLC -> ). CPU
;
(startup).
, PLC
System data ( ). : PLC ->
Download (PLC -> ) , , GD-,
PLC.
: :
PLC -> Save Project on Memory Card (PLC ->
) (. 2.2.2 ", ").
, ,
PG,
CPU.

2.6.5 (Block Handling)



(load) RAM,
(online),
, .
CPU, ""
(offline) : PLC -> Download
(PLC -> ). "" (online)
"" (offline) , ""
( "drag-n-drop").

. , CPU,
, "
". ,
. " " .
, ,
.

2- 50

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

SIMATIC Manager
"" (offline) "Blocks" ("")
CPU SCL. CPU
,
SCL-.
SCL-
.
(online)
STL
(online) ( CPU),
, (offline) . ,
"" ""
, ,
"" ;
( , , ,
) .
, ,
(offline) ,
(, "
" ["time stamp conflict"],
).

(load) RAM , .

EPROM, ,
RAM- .
EPROM "invalid" ("").
,
(load)
EPROM (work) .

PG.

EPROM

(compressing)
CPU, CPU
(load)
(work) . (work)
, " " (invalid)
( ),
"" ( ).
, (invalid),
.
(gap)
.
Compress.
RUN ,
, ; STOP

.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 51

2. STEP 7


: PLC -> Module Information (PLC ->
) "Memory" ("").
.
SFC 25 COMPRESS
, .
(online) (offline)

(initial value) (actual value) (. 3.6
" "). CPU,
(initial) (load) ,
(actual) (work) .


.
CPU,
(work) , (actual)
. (actual)
: View -> Data View ( ->
). (actual)
, CPU,
(work) .
(load)
EPROM, (work)
CPU.
.
. S7-300
,
(retentive)
, "UNLINKED"
(""), (work) ;
(load) .
"UNLINKED" ("")
SFC 20 BLKMOV.

2.7


CPU
()
, .
, , , ,
,
. CPU STOP,
, , CPU.
. , ,
, CPU
OB1. OB1 ,

,
, , ,

2- 52

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

.
( )
PLCSIM, CPU PG

.

2.7.1


"Diagnose Hardware".
PG MPI- SIMATIC Manager.
, ,
PG, (online)
: View -> Online ( - ).
: PLC -> Display Accessible Nodes (PLC ) CPU.

: PLC -> Diagnose Hardware (PLC - ) (
). Hardware Configuration

; SIMATIC
Manager "View" ("") : Options ->
Customize ( -> ).
(status)
(operating state) , ,
(project view - ,
), (station view , )
(module view -
).

2.7.2 STOP
CPU STOP - , ,
, -
. CPU
, ,
STOP ,
.

PG (online) , S7-
Diagnostics Buffer ( )
: PLC -> Module Information (PLC -> ).
( 1)
CPU STOP, , "STOP because
programming error OB not loaded" (" STOP - ").
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 53

2. STEP 7

, CPU STOP,
, : "FC not loaded" ("FC ").

.
,
, "Open Block" (" ").
, , CPU STOP
, " "
, , "Stacks"
(""). "Stacks" (""), B-
(block stack - ),
,
. "I stack",
(interrupt stack), CPU
(, , ,
) , .
"L stack" (local data stack - ),
,
B-. B-
"" .

2.7.3 (Monitoring and


Modifying Variables)
(Monitoring and
Modifying of Variables), VAT- (
).
.

, ..
.
:
, !

,
(Monitoring and Modifying of Variables), VAT ( ),
. 255
(VAT1 VAT255)
(Symbol Table). VAT- 1024
255 (. . 2.11).

VAT-

(offline),

Blocks (), : PLC ->


Monitor/Modify Variables (PLC -> / ).

( ).

2- 54

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

, : View -> Display Format ( ->


),
"Display Format" (" ").

. 2.11 (Variable Table)



.
, , .

, .
Blocks () :
Table -> Save ( -> ).
(online)
VAT-, (offline),
: PLC ->
Connect To (PLC -> ).
, : PLC -> Disconnect (PLC ->
) .
(Trigger conditions)
: Variable -> Trigger (
-> ) (trigger point) (trigger
conditions) .
(trigger point) - , CPU
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 55

2. STEP 7

,
.

,
.
"Start of cycle" (" "),
OB
1. "End of cycle"
(" "),
OB1
.
(Monitoring of Variables)
: Variable ->
Monitor ( -> ). VAT-
.

. ,
Display Format ( ).
Esc.
: Variable -> Update Monitor Values ( ->
)
,
.
(Modifying of Variables)
( CPU
)
: Variable -> Modify ( ->
).
VAT-, , .
(""
) "//" :
Variable -> Modify Value Valid ( ->
);
. ,
Display Format ( ).
Esc.
: Variable -> Activate Modify Values ( ->

,
.

2.7.4 (Forcing Variables)


CPU (Forcing Variables), ,

.
2- 56

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

.
CPU
.
:
, !
VAT-.
VAT-, - ,
.
CPU. ,
, : Variable -> Display Force Values ( > ).
CPU,
(force window) .

.

: Table ->
Save As ( -> ).

:
I ( )
[S7-300 S7-400]
Q ( )
[S7-300 S7-400]
PI
[ S7-400]
PQ
[S7-300 S7-400]

[ S7-400]
:
Variable -> Force ( -> ).
CPU
.
:


(, load [])
(, )

S7-400
(, transfer [])
(, SFC)
: . S7-300

.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

2- 57

2. STEP 7

S7-300
:
CPU ;

CPU .
:
, CPU!
,
: Variable -> Delete Force ( ->
).
,
() , , CPU
.
,
,
, .
I/O
CPU. PI PQ
(, ), PI PQ
.

, " " (access width)
, (,
[byte] [word]),
. (
[access or area length error]),
CPU " "
["error substitute value"] CPU STOP.
, " " (access width) ,
(, [byte]
[word]), .

, (write protection)
(synchronization error).
(loading)
. " " (access width)
, ,
,
.
I ,
PI, ;
.
.
PQ Q
(
"" ["externally"] ).
;
( ). ,
2- 58

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

,
,
.
"0"
(substitute value) OD (
STOP [], HOLD [] RESTART []) -
(
OD,
). OD ,
.
STOP Enable PQ (
PQ), STOP
( OD-). Enable PQ
( PQ) ,
("safe") ( "0"
[substitute value]);
RUN.

2.7.5 ( Enable
peripheral outputs)
STOP OD-.
"Enable peripheral outputs" ("
") OD-, ,
, CPU
STOP.
. CPU
. :
STOP- .
:
.
(PQ),
.
(online) : PLC ->
Connect To (, CPU, , ,
: PLC -> Operating Mode, "STOP".
OD- : Variable ->
Enable Peripheral Outputs ( ->
);

"0",
(substitute value),
(force value).
: Variable -> Activate Modify Values ( ->
).

.

: Variable -> Enable Peripheral Outputs ( ->
) ESC.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 59

2. STEP 7

OD-,
"0", (substitute value),
(force value) .
STOP , "Enable
peripheral outputs" (" "),
, OD-
(RESTART),
RUN.

2.7.6 "Program Status" (" ") STL


"Program Status" (" ")

.

.
"STL" : Options -> Customize ( ->

)
("Standard"
[""]

1 ).
(user
memory) CPU, .
, , ""
(online) SIMATIC Manager.
, .
, . :
Debug -> Monitor ( -> ) Program
Status ( ).
, .
: Debug -> Monitor ( -> )
Program Status ( ).
: Debug -> Call Environment ( ->
" ") .
, , ,
.
(status recording),
, .
, "No Condition" (" ").
, Program Status
( ). ,
, : Debug -> Modify Address (
-> ).
Program Status ( )
.
:
"debug mode" ( ) "process mode" ( ).
( "debug mode" [ ])
.
, , ,

.
2- 60

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

"process mode" ( )
-
, ,
, (
). CPU
"Protection" (" ") CPU.
CPU "debug mode" ( ),

. ,
. : Debug ->
Operation ( -> ).
Breakpoints ( ),
Single-step Mode ( )
, STL, CPU
"Single-step
mode". CPU HOLD;
. (breakpoints),

(step-by-step).
"debug mode" ( ).
CPU "debug mode" ( ),

. ,
.
(breakpoint)
: Debug -> Set Breakpoint ( ->
). : Debug ->
Breakpoints Active ( -> );
CPU . CPU
, CPU
HOLD.
.
(
) , : Debug -> Execute Next Statement
( -> ).
,
.
,
, : Debug -> Execute Call
( -> ).
: Debug -> Resume ( -> )
,
.
, ,
(online).
.
.
: Debug -> Resume ( -> ) CPU
RUN.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 61

2. STEP 7

2.7.7 SCL-
SCL-,
"Create debug info" (" ").
"Compiler" ("")
: Options -> Customize ( -> )
SCL Editor.
"Create object code" (" "),
CPU : PLC -> Download (PLC -> ).
SCL-
SCL Editor.
"Program Status" (" ") SCL
,
" " ("monitor area") .
" "
.
.
,
,
.
, ,
() , ,
, - .
SCL-, CPU RUN RUNP . :
Debug -> Operation -> Debug Operation ( -> -> ).
, .
: Debug -> Monitor ( > ).
.
, : Debug ->
Monitor ( -> ); : Debug -> End
Debug ( -> ) .
Breakpoints ( ),
Single-step Mode ( )
"Single-step mode"

. (breakpoints),

(single-step) .
(single-step)
:
, (online)
.

2- 62

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2. STEP 7

(single-step) CPU,
.
"debug mode" ( ), Program
Status ( ) . CPU
HOLD (breakpoint),
(step-by-step) HOLD.

(breakpoints)
: Debug -> Set Breakpoint ( ->
).
.
: Debug -> Breakpoints Active
( -> ). CPU
,
CPU HOLD (. . 2.12).

. 2.12 SCL-
(
) , : Debug -> Execute Next Statement
( -> ).
,
.

: View -> Symbolic Representation ( ->
).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2- 63

2. STEP 7

: Debug -> Resume ( -> )


,
. : Debug -> Execute to
Selection ( -> )
, .

: Debug -> Edit Breakpoints ( ->
).
: Debug -> Breakpoints Active
( -> ).
: Debug -> End Debug ( -> )
.
: : Debug -> Execute Next Statement
( -> ) Debug -> Execute to
Selection ( -> )
. ,

, CPU.

2- 64

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 SIMATIC S7-

CPU SIMATIC S7-300/400,
( )
() .

STL SCL. 24 "
".

,
; ,
.
.

3.1
CPU
(operating system) (user program).
- ,

,
.
,
.. -
CPU, , ,
. ,
, , .
(user program) -
( - ),
, ()
.

3.1.1
,
CPU .
, ,
,
(. . 3.1). , ,
(priority class),
("mutual
interruptibility" - ) ,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3- 1

3. SIMATIC S7-

<>

<>

. 3.1
(main)
, CPU.
(main) , CPU


.
()
.
. , CPU

.
() - ,
.
, CPU ,
(startup routine).
,
CPU PG.
, ,
S7-300
("complete restart" - " "), S7-400
,
, ("warm restart" - " ").

3-2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

(main) 1,
.

1. 1,
, CPU

, ,
1.
, , -
.
( ), CPU ( ["watchdog",
], ["time-of-day"] ..)
,
. - ,
, ,
,
.
- ,
, ,

.

CPU; CPU ,
STEP 7.

3.1.2
3.1 SIMATIC S7
( ).
3.1 SIMATIC S7

OB
OB 1
TOD
OB 10 OB 17

OB 20 OB 23
Watchdog
OB 30 OB 38

OB 40 OB 47

OB 60

OB 70
OB 72
OB 73

OB 80
OB 81 OB 84, 86, 87
OB 85

OB 90


(, )
;


(, 100 )
I/O

;

- I/O
CPU

,
(, [time
error], ,
/ , /
)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

2 24

36

2 24

7 15

2 24

16 23

2 24

25

25
28
25

2 26
2 28
24 26

2)

26
2 26
24 26

1)

26
2)
26
2)
26
29

3-3

3. SIMATIC S7-

3.1 SIMATIC S7 ()


OB 100, 101, 102

OB 121, OB 122


PLC

27

,
(, I/O )

1)

2)

: 28

,
.


CPU. 3.1
.
CPU
.
CPU.
OB 90 ( )
OB 1 , OB 1,
.
OB 100 (
) OB 101 ( );
27. ,
, 28.
.
,
CPU.
( ) 0.

;
CPU OB 85 ("Program Processing Error" - "
") STOP.

(L-) (
18.1.5 "
").

3.1.3
CPU ,
. CPU
Hardware
Configuration ,
. .
CPU .
STEP 7
.
Sturtup ( )
("cold restart" [" "] /
("warm restart" [" "]); "Ready"
; ,
" ".

3-4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

Cycle/clock memory (/ )
/

;
;
;
; .
Retentive memory ( )
, ;
.
Memory ()

( );
L- .
Interrupts ()
,
(time-delay interrupts), (
) .
Time-of-day Interrupts ( )
,
.
Cyclic Interrupts ( )
,
.
Diagnostics/Clock ( / )
STOP;
; .
Protection ( )
, .
Multicomputing ( )
CPU.
Integrated I/O ( I/O)
I/O.
CPU
, . ,
, .

3.2
,
, .
STEP 7
, .
(self-contained)
.
"" ("block").
- ,
, .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3-5

3. SIMATIC S7-

3.2.1 (Block Types)


: STL
:
User blocks ( )
- ,
.
System blocks ( )
- ,
.
Standard blocks ( )
- , ,
, FM
CP.
(User blocks)
"" -
.
,
.
OB (Organization blocks)

. CPU
,
, .
OB 1.
,
, .
FB (Function blocks)
,
.
(variable memory),
.
, , , .
( ,
)
.
(instance data block),

(call instance) , , ""
("instance").
;
"
" ("local instance").
FC (Functions)

(automation functions).
.

( ) .
- .
.
.
3-6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

DB (Data blocks)
.
, , (
, ).
:
(global data blocks) (instance data
blocks).
, , "" ("free")
. , ,

.

CPU.
; CPU.

.
() , ,
.
(System blocks)
(System blocks)
. ( SFC
SFB) (
SDB).
, , , ,
CPU
.
SFC SFB,
, .
(user
memory); SFB
.
SDB ,
.
STEP 7 .
, , ,
. , SDB
(load) .
.
(Standard blocks)
,
,
, " " ("Standard
blocks").
,
STEP 7 (,
IEC- S5/S7 ).
33 " "
" " Standard Library.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3-7

3. SIMATIC S7-

3.2.2 (Block Structure)



"" ,
:
(logic block) ("" )
Block header ( )

Declaration ( )
Address
Declaration
()
()

Name
()

Type
()

Program ()
A Input1

//Limit switch responded

( )

A Input2

//Manual operation

( )

= Output1

//Message to operator panel ( )

(data block) ("" )

Block header ( )
Declaration ( )
Address
()

Name
()

Type
()

Initial Value
( )

. 3.2 ("" )

3-8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

(logic block) (,
)
Block type Address ( )
Block header ( )
VAR_xxx
name : Data type := Initialization;
name : Data type := Initialization;

END_VAR

BEGIN
Program

()

END_Block Type

(data block) (,
)
DATA_BLOCK Address ( )
Block header ( )
STRUCT
name : Data type := Initialization;
name : Data type := Initialization;

END_ STRUCT

BEGIN
name := Initialization;
END_DATA_BLOCK

. 3.2 (,
)
:

Block header ( ),
() , .

Declaration section ( ), (..


) ("block-local" - "")
.
Program section ( ),
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

3-9

3. SIMATIC S7-

Block header ( ),
() .

Declaration section ( ),
("") ;
.
Initialization section ( ),
.
""
.
, "declaration view" ( "")

"data view" ( "") (. ).

3.2.3 (Block Properties)


.
:
File -> Properties ( -> ) (. . 3.3).

. 3.3 ("Properties - Type block")

3 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

"General - Part 2" (" - 2")


:
Local Data ( -
).
MC 7: ( ).
Load memory requirement ( ).
Work memory requirement ( ).
"Know-how protection" (" ")
. ,
,
.
(declaration table) .

KNOW_HOW_PROTECT.
, ( )
(
!).
(standard block),
Siemens, "Standard Block".
"DB is write-protected in the PLC" ("DB PLC
") .
,
.
. (
) .
,
PG,
.
"Unlinked" ("")
(load) ;
("non execution-relevant").
, ,

SFC 20 BLKMOV.
"General - Part 2" (" - 2")
:
Name () ; ,
: .
Family ( - - )
.
Name () Family ( - )

(program elements catalog).
Author () .
Name (), Family ( - ), Author ()
8 ( :
, ).
Version () : 0 15.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 11

3. SIMATIC S7-

"General - Part 1" (" - 1")


:
, ..
.
: ,
,
. ,

"time stamp conflict" (" ").
1
2.
. "multi-instance
capability" (" DB "), ,
, , 2.
"multi-instance capability" ,
,

. 1 ,

( STL).
"Calls" ("") ,

.
"Attributes" ("") .

, ,
SIMATIC PCS7.
Program length ( )
(Properties)
Blocks ().
Blocks () : Edit -> Object Properties
( -> ). "Blocks" ("")
"Size in work memory" ( )
"Size in load memory" ( ).
: ,
( )
(load) . Blocks (),
(load)
( ).
SIMATIC Manager
, Ctrl.
PG, (online),
SIMATIC Manager
CPU "Memory" (""),
: PLC -> Module Information (PLC -> ).
(Checksum)
Program Editor
(Checksum)
Blocks ().
,
.
3 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

.
SIMATIC Manager
Blocks () : Edit -> Object
Properties ( -> ).

3.2.4 (Block Interface)



. (,
), (
).
.
, (.
19. " ").
Program Editor ,

. :

, , ,

. Program Editor
,
, ,
.
(Time stamp conflict)

, , "
" ("Time stamp conflict"). , "
" ("Time stamp conflict"),
. Program Editor
. ,
, , ,
,
,
.
, ,
" " ("Time stamp conflict"),
. ,
(referenced) (younger),
.
" " ("Time stamp conflict"):

(younger), .


(younger), ( DB

, , ,
, ).


, ( ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 13

3. SIMATIC S7-

UDT
(younger), , UDT;
, UDT.

Program Editor
UDT-
: Edit -> Block Call -> Update ( -> > ). ,

. ,
.
.
Check Block Consistency ( )
Program Editor
" " ("Time stamp conflict"),
, " ".
,
"Check Block Consistency".

, .

Blocks () : Edit -> Check Block Consistency
( -> ).
Program Editor , ,
STEP 7 V5.0 SP3.
STEP 7
, STEP 7
( ,
"Check
Block Consistency"), : Program -> Compile ( > ).
Program Editor
("1:Compile").

, .

(. 3.4).
, .
" " (reference tree)
:
, . :
DB 20 / FB 20 OB 1, FB 21 FB 22
FB 20.
" " (dependency tree) ,
.
, . : FB 22
DB 20 / FB 20,
OB 1. DB 29,
FB 20.
(!)

.
3 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

. 3.4

Check
Block Consistency
,
, : Edit
-> Open Block ( -> ), ..
.

3.3 (Addressing Variables)



: (absolute addressing)
(symbol addressing).
, (0)
.
( ) ,
(Symbol Table)
(declaration section)
.
(indirect addressing),
()
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 15

3. SIMATIC S7-

3.3.1

(absolute addressing).
,
,
(configuration table), ,
. ,
.
QD24
QW24
7

QW26

0 7
QB24

0 7
QB25

0 7
QB26

0
QB27

QW25

. 3.5
(binary)
.

, ..,
, , , ..,
.

16 .
"" ("channel"),
(word), .. 2 (. ).
(, )
,
16-
(16 ). , 16-

(, ).

("information
width"
" ")
("information width") ,
.
(,
), , (data
tape) .
BOOL (
), - INT (
).
,

.
3 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

STEP 7 4 :
1

BOOL,

BYTE 8- ,

16

WORD 16- ,

32
.

DWORD 32-

BOOL
,
. (0)
.
CPU. 0 7.
:
I 1.0

0 1

Q 16.4

4 16

BYTE
,
. B.
:
IB 2

QB 18

18

WORD ().

,
. W.
:
IW 4

4; 4 5

QW 20

20; 20 21

DWORD ( ).

,
. D.
:
ID 8

8; 8, 9, 10 11

QD 24

24; 24, 25, 26


27

.
:
DB 10.DBX 2.0

2.0 DB 10

DB 11.DBB 14

14 DB 11

DB 20.DBW 20

20 DB 20

DB 22.DBD 10

10 DB 22


18.2.2 " ".

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 17

3. SIMATIC S7-

3.3.2
(indirect addressing)
.
STL SCL
. STL :

("Memory-indirect-addressing")
, IW [MD 200]
, .

("Register-indirect area-internal addressing")
, IW [AR1, P#2,0]
, , AR1,
(offset) P#2,0
.

("Register-indirect area-crossing addressing")
, W [AR1, P#0,0]
, ( ),
AR1,
(offset) P#0,0 .
(DBD DID), (MD)
(LD)
.

: AR1 AR2.

".

25

"

SCL
, .
, MW[index] - ,
index. index
.
SCL 27.2.3 "
SCL".

3.3.3
(symbolic addressing) ()
. .
24 . STL
().
,
() SCL, "#" .

( , : ).
( ),
(declaration) .

().

3 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

:
,
,
.

(symbol table)
:

, ,
,


,
, .
00 hex, FF hex (").

.
.
;
(
) .
,
2.5.2 " ".



.
, .
,
. ( )
(
) .
() "#".

"#".
PG (
[offline] Blocks []).
,
(substitute symbol).


,
.

.
,


.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 19

3. SIMATIC S7-


,
, MSERIES[1]
MSERIES. STL
(INT). SCL
(INT), (INT).
("subname")
, , FRAME.HEADER.CNUM.

.
24 " ".


. . ,
MVALUES MVALUE1, MVALUE2 MTIME.
:
"MVALUES". MVALUE1
"MVALUES". MVALUE2
"MVALUES". MTIME

18.2.2 "
" (STL) 27.2.2 " " (SL).

3.4 STL
3.4.1 STL-
STL- (statement).

.
CPU. 3.6 STL-.

STL-

M001:

/
IW

12

//

ANALOGVALUE_1

. 3.6 STL-

3 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

STL-:

( ) 4 ,
":" (. " ").

CPU ( , , load
[], scan [], compare [] ..).

- ,
(, IW12,
ANALOGVALUE_1 W#16#F001
. .). .

( )
"//" .

( , ) " (";").
STL 200 ,
160 .

3.4.2 STL
2.5 " S7-"
S7-
.


: SIMATIC
Manager, : File -> Open
( -> ). ,
:

SIMATIC Manager
Blocks (), : Insert->S7
Block-> ( -> S7 Block -> ). (Properties)
"General - Part 1" (" - 1")
"STL".

, : File -> New ( ->


) ( ,
, ).
.

, , ,
: File -> Properties ( -> ).

"Create Block" (" ") ,
: Options -> Customize ( ->
).

STL (. . 3.7).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 21

3. SIMATIC S7-

.3.7 STL-
, ,
:

.
() .
.
.

. STL ,
(offline) Blocks (),
FB
.

.
,
, ,
, "" .
,
(. 3.2).
,
. ,
.

3 - 22

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

3.2
Variable type
( )
Input parameters
( )
Output parameters
( )
In-out parameters
(/ )
Static local data
( )
Temporary local data
( )

Declaration
()

in

FC

FB

out

FC

FB

in_out

FC

FB

stat

FB

OB

FC

FB

temp

, ,
( ) ( ).

(,
). ,
, 19
" ".
(
), .
,
8 16 , BYTE
- . BOOL BYTE,
.
1 (
).

( ,
) ,
, ,
.
()
: View -> Comment ( -> ), View ->
Symbolic Representation ( -> ), View -> Symbol
Information ( -> ).
: View -> Zoom In ( ->
), View -> Zoom Out ( -> )
View -> Zoom Factor ( -> ).
STL- .
, 1.
(network title) (network
comment).
: Edit -> Go To -> ...( ->
->). .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 23

3. SIMATIC S7-


,
"Display with Comments" (" "),

. .
.
3.4.1 " STL-"
STL-.
(OP-code [operator]) ( [operand])
.
,
. ,
<Enter>. ,
"//".
, : Insert ->
Network ( -> ).
.

,
.

: Insert -> Symbol ( -> ).

.

,
.
: Option -> Symbol Table ( ->
),
: Edit -> Symbol ( ->
).
, .
.
, ""
"Block End" (" "),
(
).
,
"", .. STL-.

PG, ,
, , .
PG
,
(substitute symbols).


SIMATIC Manager.

,
: View -> Catalog ( -> ).

3 - 24

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-


. ,
""
.

LAD FBD, .
STL ,
(offline) Blocks (),
FB
.

3.4.3

STL,

2.5 " S7-"


S7-
. ,
,
SIMATIC Manager (. 2.5.3 " STL [STL Program Editor] ",
").
, ,
, ,
.
3.3 ,
, .



.
(optional);
,
.
3.2.3 " ".
"TITLE ="
64 .

, .
18 .

, .. ,
.
(. 3.3).
- , ,
.
, ,
( ) (
).
:
Quantity : INT := +500; //Units per batch ( )

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 25

3. SIMATIC S7-

3.3 STL

ORGANIZATION_BLOCK

FUNCTION_BLOCK

FUNCTION :

TITLE =
//

[Header]

KNOW_HOW_PROTECT
NAME :
FAMILY :
AUTHOR :
VERSION :

[Declaration]

TITLE =

//
CODE_VERSION1
KNOW_HOW_PROTECT
NAME :
FAMILY :
AUTHOR :
VERSION :
VAR_INPUT

END_VAR
VAR_OUTPUT

END_VAR
VAR_IN_OUT
/
END_VAR

TITLE =

//
KNOW_HOW_PROTEC
T
NAME :
FAMILY :
AUTHOR :
VERSION :
VAR_INPUT

END_VAR
VAR_OUTPUT

END_VAR
VAR_IN_OUT
/
END_VAR

VAR

END_VAR

[Program]


[Block end]

VAR_TEMP

END_VAR
BEGIN
NETWORK
TITLE =

//
//
STL-
//
NETWORK
..
END_ORGANIZATION_
BLOCK

VAR_TEMP

END_VAR
BEGIN
NETWORK
TITLE =

//
//
STL-
//
NETWORK
..

VAR_TEMP

END_VAR
BEGIN
NETWORK
TITLE =

//
//
STL-
//
NETWORK
..

END_FUNCTION_BLOCK

END_FUNCTION

(
, ,
).
19 "
".
(.
3.3),
,
( )
. 24 " " ,
,
.

3 - 26

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-


BEGIN
END_xxx, xxx ,

ORGANIZATION_BLOCK,
FUNCTION_BLOCK FUNCTION. END_xxx
Block End BE.
, ,
( ).
3.4.1 " STL". OP- () ()
.

(/ ) .
";".
,
"//".
. ,
";".
,
"//". 160 ;
.

(network). (
) , STL
- . STL ;

,

.
, ,
,
: Edit -> Go
To -> ... ( -> ->). ,
, .
NETWORK;
"TITLE="
64 . ,
, , 18
. STL ,
1. 999 .
64
.
,

,
, ,

,
"
" (
).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 27

3. SIMATIC S7-

,
( ["interface description"]),
.
"" ,
!
.
, ,

, , " ",
, -
- (main
program), , , .
,
, ,
. :

UDT

,

(
)


3.8
, ,
.

3.5 SCL
3.5.1 SCL-
SCL- (statement).
-
. CPU.
3.9 SCL-.
SCL- :

( ), 24
":".
.

, CPU (,
, ..)

( ),
"//",
( ).
SCL- ";" (
). SCL- 126 .

3 - 28

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

FUNCTION_BLOCK V_Memory
TITLE = Intermediate buffer for 4 values
// : 4
// FB STL
AUTHOR
: Berger
FAMILY
: STL_Book
NAME
: Memory
VERSION : 01.00
VAR_INPUT
Transfer
: BOOL := FALSE;//
Input_value : REAL := 0.0; // REAL ( )
END_VAR
VAR_OUTPUT
Output_value : REAL := 0.0; // REAL ( )
END_VAR
VAR
Valuel : REAL := 0.0; // REAL
Value2 : REAL := 0.0; //
Value3 : REAL := 0.0; //
Value4 : REAL := 0.0; //
Edge_memory_bit : BOOL := FALSE;//
END_VAR
BEGIN
NETWORK
TITLE = Program for transfer and output
// , Transfer
A
Transfer;
// Transfer "l"
FP
Edge_memory_bit; // RLO "1" FP
JCN
End;
// ,
// ,
L
Value4;
T
Output_value;
//
L
Value3;
T
Value4;
L
Value2;
T
Value3;
L
Value1;
T
Value2;
L
Input_value;
//
T
Value1;
End: BE;
END FUNCTION BLOCK

DATA_BLOCK Values1
TITLE = Instance data block for "V_Memory"
// FB "V_Memory"
AUTHOR
: Berger
FAMILY
: STL_Book
NAME
: V_MEM_DB1
VERSION
: 01.00
V_Memory
// FB "V_Memory"
BEGIN
Valuel := 1.0;
//
Value2 := 1.3;
//
END_DATA_BLOCK

. 3.8 STL-

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 29

3. SIMATIC S7-

Value Assignments
Power
TooLarge
Switch_on

( )

:= Voltage * Current;
:= Volt_Act > Volt_Set;
:= Manual_on OR Auto_on;

Control Statements

( )

IF Input_value > Maximum


THEN Delimiter
:= Maximum;
ELSIF Input_value < Minimum
THEN Delimiter := Minimum;
ELSE Delimiter
:= Input_value;
END_IF;
FOR i := 1 TO 32 DO
Measure_value[i] := 0;
END_FOR;
Function Calls

( )

Result := Delimiter(
Input_value:= Actual_value,
Minimum
:= Lower_limit,
Maximum
:= Upper_limit)
. 3.9 STL-

3.5.2 SCL-
2.5 " S7-"
S7-
.

SIMATIC Manager (. 2.5.4 " SCL [SCL Program Editor] "
SCL-").
, ,
, ,
.
3.4 ,
, .



.
(optional);
,
.
3.2.3 " ".
"TITLE ="
64 .

, "//".
18 .
3 - 30

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

3.4 SCL

ORGANIZATION_BLOCK

FUNCTION_BLOCK
PROGRAM3)

FUNCTION :

TITLE =
//

[Header]

KNOW_HOW_PROTECT
NAME :
FAMILY :
AUTHOR :
VERSION :

[Declaration]

[Program]

TITLE =

//
CODE_VERSION1
KNOW_HOW_PROTECT
NAME :
FAMILY :
AUTHOR :
VERSION :

TITLE =
//
KNOW_HOW_PROTECT
NAME :
FAMILY :
AUTHOR :
VERSION :

VAR_INPUT

END_VAR
VAR_OUTPUT

END_VAR

VAR_INPUT

END_VAR
VAR_OUTPUT

END_VAR

VAR_IN_OUT
/
END_VAR

VAR_IN_OUT
/
END_VAR

VAR

END_VAR

VAR1)

END_VAR

VAR_TEMP

END_VAR

VAR_TEMP

END_VAR

VAR_TEMP

END_VAR

CONST

END_CONST

CONST

END_CONST

CONST

END_CONST

LABEL

END_LABEL

LABEL

END_LABEL

LABEL

END_LABEL

BEGIN2)

BEGIN2)

BEGIN2)

SCL-

SCL-

SCL-

//

//

//

(*

(*

(*

*)

*)

*)

..
..
..
END_ORGANIZATION_
END_FUNCTION_BLOCK
END_FUNCTION
[Block end]
BLOCK
END_PROGRAM3)
1)
VAR SCL- FC
(VAR_TEMP).
2)
SCL.
3)
: FUNCTION_BLOCK
END_FUNCTION_BLOCK.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 31

3. SIMATIC S7-

, .. ,
.
(. 3.4).
- , ,
.
, ,
( ) (
).
:
Quantity : INT := +500; //Units per batch ( )

, :
Value1, Value2, Value3, Value4 : INT;
(
, ,
).
19 "
".
(.
3.4),
,
( )
. 24 " " ,
,
.
SCL ,
.
SCL- ,
.

SCL-
BEGIN () END_xxx,
xxx , ,
ORGANIZATION_BLOCK, FUNCTION_BLOCK FUNCTION.
END_xxx Block End (BE).
, ,
( ).
3.5.1 " SCL". OP- () ()
.

(/ ) .
";".
,
"//".
.
, ";".

3 - 32

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

SCL- SCL- (
";"). SCL-
STL-.
,
"//".
160 ;
.
SCL ,
. "(*"
"*)".
SCL-;
"" (:
).
,

,
, ,

,
"
" (
).
,
( ["interface description"]),
.
"" ,
!
.
, ,

, , " ",
, -
- (main
program), , , .
,
, ,
.
:

UDT

,

(
)


3.10
, ,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 33

3. SIMATIC S7-

FUNCTION_BLOCK V_Memory
TITLE = 'Intermediate buffer for 4 values'
// : 4
// FB SCL
AUTHOR
: Berger
FAMILY
: SCL_Book
NAME
: Memory
VERSION : 01.00
VAR_INPUT
Transfer
: BOOL := FALSE;//
Input_value : REAL := 0.0; // REAL ( )
END_VAR
VAR_OUTPUT
Output_value : REAL := 0.0; // REAL
END_VAR

( )

VAR
Valuel : REAL := 0.0; // REAL
Value2 : REAL := 0.0; //
Value3 : REAL := 0.0; //
Value4 : REAL := 0.0; //
Edge_memory_bit : BOOL := FALSE;//
END_VAR
BEGIN
// , Transfer
IF Transfer = 1 AND Edge_memory_bit = 0
THEN Output_value := Value4;
//
Value4 := Value3;
Value3 := Value2;
Value2 := Valuel;
Valuel := Input_value;
Edge_memory_bit := Transfer;
// ,
ELSE Edge_memory_bit := Transfer;
//
END_IF;
END FUNCTION BLOCK

DATA_BLOCK Values1
TITLE = 'Instance data block for "V_Memory"
// FB "V_Memory"
AUTHOR
: Berger
FAMILY
: SCL_Book
NAME
: V_MEM_DB1
VERSION
: 01.00
V_Memory
// FB "V_Memory"
BEGIN
Valuel := 1.0;
//
Value2 := 1.3;
//
END_DATA_BLOCK

. 3.10 SCL-

3 - 34

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

3.6
2.5 " S7-"
S7-
.
STL SCL
, .
STL-.
,
STL-,
SCL-.

3.6.1


: SIMATIC
Manager, STL- :
File -> Open ( -> ). ,
:

SIMATIC Manager
Blocks (), :
Insert -> S7 Block -> Data Block ( -> S7 Block -> ).
(Properties) "General - Part 1" (" 1") . (creation
language) "DB".
.

, : File -> New ( ->


) ,
"Object name" (" ").
.

, , ,
: File -> Properties ( -> ).

, "New
Data Block" (" "); ,
.
,
"" :

"Data Block" (" ")


;

.

"Data block with assigned user-defined data type" ("


")

;
UDT.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 35

3. SIMATIC S7-

"Data block with assigned function block" ("


")
;

.


(. . 3.11).

.3.11 (Declaration View [


])
:

Declaration View ( )
,
.

Data View ( )

, .


.
, , (0),
(blank), .
,
, ,
, FB.
, UDT,
, ,
UDT.

3 - 36

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

:
Declaration View ( : View -> Declaration View [ ->
])
,
,
, ,
.
Data View ( : View -> Data View [ ->
])

.
"Actual
value" (" "). ,
(main) CPU.
.

.
:
. ,
( FB/DB)
.
, : View ->
Data View ( -> )
, ,
"Actual value" (" "). : Edit ->
Initialize Data Block ( -> )
.

3.6.2 ,


, 3.5.

.
STL-, SCL-.


.
(optional);
,
.
3.2.3 " ".
"TITLE ="
64 .

, .
18 .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 37

3. SIMATIC S7-

3.5


[Global Data Block]


UDT
[Global Data Block from
UDT]

[Instance Data Block]

DATA_BLOCK

DATA_BLOCK

DATA_BLOCK

TITLE =
//

TITLE =
//

KNOW_HOW_PROTECT
NAME :
FAMILY :
AUTHOR :
VERSION :
READ_ONLY
UNLINKED

KNOW_HOW_PROTECT
NAME :
FAMILY :
AUTHOR :
VERSION :
READ_ONLY
UNLINKED

KNOW_HOW_PROTECT
NAME :
FAMILY :
AUTHOR :
VERSION :

UDTname ( UDT)

FBname ( FB)

BEGIN

BEGIN

BEGIN

Name := Default
( :=
)

KOMPname := Default
( :=
)

KOMPname := Default
( :=
)

..

..

..

END_DATA_BLOCK

END_DATA_BLOCK

END_DATA_BLOCK

[Header]

TITLE =
//

STRUCT

[Declaration]

Name : Type := Default


( : :=
)
END_STRUCT

[Initialization]


[Block end]

, .. ,
.
("individual") ,
UDT .
,
, ( )
( ).
:
Quantity : INT := +500; //Units per batch ( )
.

, (
) . 24 " "
.
26.2 " "
, .
,
.

3 - 38

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

,
(0),
(blank), .
, UDT,
UDT. (,
UDT 51) (, "Frame header").
,
,
FB ,
.


BEGIN END_DATA_BLOCK.

, .
,
(actual)
. ,
(default)
, (initial)
, (actual)
. CPU, (initial)
(load) ,
(actual) (work) CPU (.
2.6.5 " " " (offline)/
(online) ").
,
.

,
, ,
( - "overwrite") ,
, .
,
( ,
) .
(actual)
( ).

3.7
3.7.1
- (. . 3.12).
(, input 5.2)
(, BOOL [] ). ,
, ( I
input) (, ,
5.2, 2- 5- ).
,
() (Symbol Table).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 39

3. SIMATIC S7-


.

.

. 3.12
BOOL (binary address)
(binary operand). , ,

(digital operand).
, , (local
- ) . ,

.
,
(, - DI ,
- L ,
- DB ).
,
(, ).
, 32 ,
, , .
("normal")
STL-.
, IEC-,
STEP 7 (
).
,
,
(,
, 30 (INT) ,
).

.
, .

3 - 40

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

3.7.2
,

. STEP 7 .
,
(User Data Type - UDT).
(Global Basis) .
.
.
PLC.
3.6 STEP 7.
3.6
Elementary Data Types
(
)

Complex Data Types


(
)

User Data Types


(
)

Parametr Data Types


(
)

BOOL, BYTE, CHAR,


WORD, INT, DATE,
DWORD, DINT, REAL,
S5TIME, TIME, TOD

DT,
STRING,
ARRAY,
STRUCT

UDT,

,

(Instances)

TIMER, COUNTER,
BLOCK_DB,
BLOCK_SDB,
BLOCK_FC,
BLOCK_FB,
POINTER, ANY




(32 )

,



(DT, STRING)



(
)

(
),

3.7.3

STL-,
32 .

SCL-.

() .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

3 - 41

3. SIMATIC S7-

STL- (. . 3.7) SCL-


(. . 3.8) .

(,
TIME# T#).
STL
STL ( )
( [binary]
[digital] ). , ,
, ,
.
SCL
SCL
. SCL
, .
: SCL 12345 ANY_NUM,
INT DINT,
REAL. " " ("type-defined")
, ,
DINT#12345 DINT.

3.7.4
(. 3.9)
L-,
.
("complex") ,
, ("complete")
;
("normal") .
("direct variable access")
STL
, .
IEC-,
DT STRING (,
). IEC-
STEP 7; "Standard
Library" "IEC Function Blocks".
IEC-
. DT
;
STRING, ARRAY STRUCT .
STRING 254
2 , .
65536 (..
-32768 32767).

3 - 42

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3.7 STL
Data Type (width)
Description
( ,
()
)
BOOL (1 )
Bit ( )
BYTE (8 ) 8-bit hexadecimal
number (8-

)
CHAR (8 ) One character (ASCII)
( ASCII)
16-bit hexadecimal
WORD
number (16-
(16 )

)
16-bit binary number
(16-
)
Count value, 3 decades
BCD
( , 3
BCD)
Two 8-bit unsigned
decimal numbers
( 8-

)
32-bit hexadecimal
DWORD
number (32-
(32 )

)
32-bit binary number
(32-
)
Four 8-bit unsigned
decimal numbers
( 8-

)
INT (16 )
Fixed-point number
( )
DINT
Fixed-point number
(32 )
( )
REAL
Floating-point number
(32 )
(
)
Time value in SIMATIC
S5TIME
format (
(16 )
SIMATIC )
Time value in IEC
TIME
format
(32 )
(
IEC-)
DATE
Date
(16 )
()
TIME_OF_DAY
Time of day
(32 )
( )
1)
2)

STL-

B#16#00,
16#00


TRUE ()
B#16#FF,
16#FF

,
, 'A'
W#16#0000,
16#0000

,
, 'A'
W#16#FFFF,
16#FFFF

2#0000_0000_0000_0000

2#1111_1111_1111_1111

C#000

C#999

B(0,0)

B(255,255)

DW#16#0000_0000,
16#0000_0000

DW#16#FFFF_FFFF,
16#FFFF_FFFF

2#0000_0000...0000_0000

2#1111_1111...1111_1111

B(0,0,0,0)

B(255,255,255,255)

-32 768

+32 767

L# -2 147 483 648 1)

L#+2 147 483 647 1)


FALSE ()

: +1.234567E+02

2)

: 123.4567 2)
S5T#0ms,
S5TIME#0ms

S5T#2h46m30s,
S5TIME#2h46m30s

T#-24d20h31m23s647ms,
TIME#-24d20h31m23s647ms
T#-24.855134d,
TIME#-24.855134d
D#1990-01-01,
DATE# 1990-01-01

T#24d20h31m23s647ms,
TIME#24d20h31m23s647ms
T#24.855134d,
TIME#24.855134d
D#2168-12-31,
DATE#2168-12-31

TOD#00:00:00,
TIME_OF_DAY#00:00:00

TOD#23:59:59.999,
TIME_OF_DAY#23:59:59.999

"L#" , INT
24.1.3, " "

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3- 43

3. SIMATIC S7-

3.8 SCL
Description
Data Type (width)
()
( ,
)
BOOL
Bit (, )
(1 )
BYTE
8-bit decimal number
(8 )
8-bit hexadecimal number
8-bit octal number
8-bit binary number
, 8-: , ,

One printable character
CHAR
(ASCII)
(8 )
( ASCII)
WORD
16-bit decimal number
(16 )
16-bit hexadecimal number
16-bit octal number
16-bit binary number
, 16-: , ,

DWORD
32-bit decimal number
(32 )
32-bit hexadecimal number
32-bit octal number
32-bit binary number
, 32-: , ,

INT
16-bit decimal number
(16 )
16-bit hexadecimal number
16-bit octal number
16-bit binary number
, 16-: , ,

DINT
32-bit decimal number
(32 )
32-bit hexadecimal number
32-bit octal number
32-bit binary number
, 32-: , ,

REAL
Floating-point number
(
(32 )
)
Time value for SIMATIC timer
S5TIME
functions ( (16 )
SIMATIC -)
TIME
Time value in IEC format
(32 )
( IEC)
DATE
Date
(16 )
()
Time of day
TIME_OF_DAY
(32 )
( )
1)

SCL-
FALSE (), TRUE (), BOOL#FALSE,
BOOL'TRUE, 2#0, 2#1, BOOL#0, BOOL#1
0, B#127, BYTE#255
16#0, B#16#7F, BYTE#16#FF
8#0, B#8#177, BYTE#8#377
2#0, B#2#0111_1111, BYTE#2#0111_1111

' ', CHAR#' ', CHAR#20


'z', CHAR#'z', CHAR#122
0, W#32767, WORD#65535
16#0, W# 16#7FFF, WORD#16#FFFF
8#0, W#8#7J7777, WORD#8#17_7777
2#0, W#2#0111_1111_ , WORD#2#1111_1111_

0, DW#2147483647, DWORD#4294967295
16#0, DW#16#7FFF_FFFF, DWORD#16#FFFF_FFFF
8#0, DW#8#177_7777_7777, DWORD#8#377_7777_ ...
2#0, DW#2#0111_1111_... , DWORD#2#1111_1111_...

-32_768, 0, +32_767
INT#16#0, INT#16#7FFF, INT#16#FFFF
INT#8#0, INT#8#7_7777, INT#8#17_7777
INT#2#0, INT#2#0111_1111_ ..., INT#2#1111_1111_...

-2_147_483_648, 0, +2_147_483_647
DINT#16#0, DINT#16#7FFF_FFFF, DINT#16#FFFF_...
DINT#8#0, DINT#8#177_7777_7777, DINT#8#377_...
DINT#2#0, DINT#2#0111_1111_... , DINT#2#1111_...

: +1.234567E+02 1)
: -123.4567 1)
: +1234567 1)
T#0ms, TIME#2h46m30s
T#0.0s, TIME#24.855134d
T#-24d20h31m23s647ms, T#0ms,
TIME#24d20h31m23s647ms
T#-24.855134d, T#0.0ms, TIME#24.855134d
D# 1990-01-01, D#2168-12-31
DATE# 1990-01-01, DATE#2168-12-31
TOD#00:00:00, TOD#23:59:59:999
TIME_OF_DAY#00:00:00, TIME_OF_DAY#23:59:59:999

24.1.3, " "

3 - 44

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3. SIMATIC S7-

3.9

DATE_AND_TIME
STRING

64

DT#1990-01-01-00:00:00.000
DATE_AND_TIME#2168-12-31:23:59:59.999

ASCII , , "String 1"

ARRAY

STRUCT

;
6
;
6

3.7.5
- (.
. 3.10). ,
( ).
TIMER COUNTER
.
3.10

TIMER

16

T 15

COUNTER

16

C 16

BLOCK_FC

16

FC 17

BLOCK_FB

16

FB 18

BLOCK_DB

16

DB 19

BLOCK_SDB

16

( )

POINTER

DB

48

: P#M10.0 P#DB20.DBX22.2
:
MW 20 I 1.0

ANY

ANY

80

: P#DB10.DBX0.0 WORD 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

3 - 45

3. SIMATIC S7-

3 - 46

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

STL,
" " ("basic functionality") STEP 7.
PLC ,
.
(binary logic operations)

AND () OR ()
. ("")
.
(memory functions)
(RLO - result of logic operation).
,
.
(transfer functions)
. , ,
.
(timer) PLC
/, ,

"electronic switching systems". , CPU,

(monitoring time).
(counter) - -
0 999.
,
, .
. ,
.
,
.
,
.
5 " " (memory functions)

(memory functions); 8 " "
.
FC .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

4-1

(binary logic operations)


AND (), OR (), Exclusive OR ( );
"1" "0";
; () .

(memory functions)
Assign (), Set () Reset (); RS-;
;
.

(transfer functions)
Load () Transfer (); .

(timer)
5 ; ,
; .

(counter)
; ;
; ;
.

4 -2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4.

AND (), OR (), Exclusive OR


( ),
STL. AND (), OR (), Exclusive OR
( )
.
()
"1" "0".


.
, , ,
, "STL_Book" "Basic
Functions" FB 104 Chap_4.

4.1
. 4.1
. , ,
I 1.2. CPU ("status" - )

,
. (RLO)
" ".
CPU , ,

.
()
() ()
"0" "1". SIMATIC S7
"1" , , ~ 230 = 24
( ); ,
, "0".
, (check statement),
.
- ,

. :
A

I 17.1

I 17.1 "1" RLO AND ().


Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

4-3

4.

()

CPU



(RLO memory)

(RLO)

Set/Reset
(/)

. 4.1

4 -4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4.

:
ON

M 20.5

M 20.5 "0" (links) RLO


OR ().

, CPU (link) ,
:
"1"
; "0"
.

(RLO) - CPU,
CPU .

(check statement). RLO "1", ,
, RLO
"0", ,
.
.
(logic step)

(sequential control system),
(logic control system) (logic step).
(..
) .
(
- "scan statements")
. ,
, " " ("first check").

:

Q 4.0

(conditional statement)

I 2.0

(first check)

I 2.1

(check statement)

I 1.7

(check statement)

Q 5.1

(conditional statement)

Q 4.3

(conditional statement)

I 2.6

(first check)

I 2.5

(check statement)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4-5

4.

(First check)
, ,
" " ("first check"). ,
CPU ,
. " " ("old")
RLO .
. () (AND
(), OR (), Exclusive OR ( ))
.
(Check statement)
RLO
. "1" "0"
(link) AND (), OR (), Exclusive
OR ( ). CPU
RLO.
. 4.2 ,
"1" "0". "1"
.
"0"
.

S1

S2

S1

"0"
I 1.1

"1"

"1"

I 1.2
"0"

S2
I 1.1

"1"

"0"
I 1.2

"1"

"0"

(Status)

A I 1.1

AN I 1.2

A I 1.1

AN I 1.2

(Instruction)

"0"

"0"

"1"

"1"

(Check)

. 4.2 "1" "0"


(Condition statement)
(condition statement) - ,
RLO.
( [assign]), (set)
(reset) , ..

4 -6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4.

( ) ,
RLO "1", , RLO
"0". ( )
RLO, , , RLO

.

() ,
.
()
. ,

Q 15.3

I 18.5

I 21.7

Q 15.4

I 18.4

I 21.6

Q 15.5

AND

AND

AND-, (
AND)
.
, ,
:

Q 10.0

I 20.1

Q 10.1

I 20.1 -> Q 10.1

AND .

4.2
STL
AND (), OR (), Exclusive OR ( ).
"1" "0".

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4-7

4.


"1"
AND ()

AN
"0"
AND ()
O


"1"
OR ()

ON
"0"
OR ()
X


"1"
Exclusive OR ( )

XN
"0"
Exclusive OR ( )
"1" "1",
"1". "0"
"1", "0".
CPU
RLO
RLO.
,
RLO- .
.
, ,
- CPU.

4.2.1 AND ()
AND ()
RLO, "1", ( ) "1".
AND () , ,
RLO "1", , RLO
"1", "0". . 4.3

4 -8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4.

AND ()
Network 1 ( 1)

Input1

A Input1;
A Input2;
A Input3;
= Output1;

Input2
Input3
Output1

Network 2 ( 2)

Input4

A Input4;
AN Input5;
= Output2;

Input5
Output2

OR ()
Network 3 ( 3)

Input1

O Input1;
O Input2;
O Input3;
= Output3;

Input2
Input3
Output3

Network 4 ( 4)

Input4

O Input4;
ON Input5;
= Output4;

Input5
Output4

Exclusive OR ( )
Network 5 ( 5)

Input1

X Input1;
X Input2;
= Output5;

Input2

Network 6 ( 6)

Input4

X Input4;
XN Input5;
= Output6;

Input5

Output5

Output6

. 4.3

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4-9

4.

AND (). 1 AND ()


(Input1 ... Input3) (Output1);
.
"1",
AND ().
, "1",
Output1 "1".
AND () , Output1 "0".
2 AND () , (Input5)
, (Output2).
Input5 ,
"0", .. "1" , "0".
AND () , Input4 "1",
Input5 "0".

4.2.2 OR ()
OR ()
RLO, "1", (
) "1". OR ()
, , RLO "1", ,
RLO "1". RLO
"0", "0". . 4.3
OR (). 3 OR ()
(Input1 ... Input3) (Output3);
.
"1",
OR ().
, "1",
Output3 "1".
RLO "0", OR () ,
Output3 "0".
4 OR () , (Input5)
, (Output4).
Input5 ,
"0", .. "1" , "0".
OR () , Input4 "1",
Input5 "0".

4.2.3 Exclusive OR ( )
Exclusive OR ( )
RLO, "1", (
) ; , RLO
"0", .
. 4.3 Exclusive OR (
). 5 Exclusive OR ( )
(Input1 Input2) (Output5);
4 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4.

.
"1",
Exclusive OR ( ).
, "1", Output5
"1".
, "1", , "0",
Output5 "0".
6 Exclusive OR ( ) ,
(Input5) , (Output6).
Input5 ,
"0", .. "1"
, "0". Exclusive OR ( )
, , ..
.
Exclusive OR ( )
, , RLO "1", ,
,
"1".

4.2.4 ,
AND (), OR (), Exclusive OR
( ), ,

(.. ,
,
, "1"). , ,
,
. , , ""
( ),
(
, "0", ).
, ,
, ,
"1". , ,
,
, "1". CPU " "
( ).
"1" "0".
, ,
.

( ).
,
("Sensor activated" [ ], "Sensor not
activated" [ ]), , ,
"1" "0",
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

4 - 11

4.

. 4.4 .
1: :

S1

S2

S1

S2

"0"

"0"
I 1.1

A
A
=

"1"

"1"

I 1.2

I 1.1

I 1.1
I 1.2
Q 4.1

I 1.2

A
A
=

Q 4.1

I 1.1
I 1.2
Q 4.1

Q 4.1
"0"

"1"

K1

K2

2: :

S1

S2

S1

"0"
I 1.1

"1"
I 1.2

A
AN
=

S2
"1"
I 1.1

A
AN
=

I 1.1
I 1.2
Q 4.1

"0"
I 1.2

Q 4.1

I 1.1
I 1.2
Q 4.1

Q 4.1
"0"

"1"

K1

K2

. 4.4
4 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4.

, ,
, ( PLC
), (
PLC )
, ,
.

, "1".
AND () "1",
"1".
, "0".
AND ()
"1", "0".

4.3
NOT () .
NOT (), ,
AND () (. .4.5. 7. NAND [-]).
8 OR
(), NOR (-).
NOT
() 4.4.6 " ".

NAND (-)
Network 7 ( 7)

Input1

A Input1;
A Input2;
A Input3;
NOT;
= Output3;

Input2
Input3
Output7

NOR (-)
Network 8 ( 8)

Input4

O Input4;
O Input5;
O Input6;
NOT;
= Output0;

Input5
Input6
Output0

. 4.5 NOT ()

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4 - 13

4.

4.4
, ,
AND () OR () .
,
CPU.
, , , STL.
STL
OR () Exclusive OR (
) . AND ()
"" OR ()
Exclusive OR ( ).
CPU
( RLO,
). (
)
( ).

. ()
OR ().
STL
( ):
O

OR () AND ()

A(

AND ()

O(

OR ()

X(

Exclusive OR ( )

AN(

NOT-AND (-)

ON(

NOT-OR (-)

XN(

NOT-Exclusive

OR

(-

,

RLO .
,
.

4.4.1 ( )
STL

. CPU
, , ,
.
4 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4.

CPU ,
RLO ( ),
CPU , RLO
RLO
, (. 4.6).
1
RLO 1

2
RLO 2
)

:
RLO 3 = RLO 1 ( ) RLO 2

. 4.6
, ,
, .. CPU
RLO . ,
, , ..
. CPU
RLO .

(. . 4.7). 7, , 7
,
, .
, .
(nesting stack)
CPU " "
("nesting stack") .
:
(RLO) ;
(BR "binary result") ;
(OR) (,
OR []);
( ,
).
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

4 - 15

4.

X(

// XOR (6)

A(

// AND (4)

O Input0;

// OR (1)

O Input1;
)

A(

O Input2;

// OR (2)

Input2

>=1

&

(4)

(2)

XOR (6)

Input4

X( ;
A Input5;
A(

(1)

Input3

A Input4;
)

>=1

Input1

O Input3;
)

Input0

// XOR (6)
// AND (5)

Input5

// OR (3)

Input6

&

(5)

O Input6;
O Input7;
)

Output20;

>=1

(3)

Input7

Output20

. 4.7 ()
CPU (BR)
, .

,
STL. ,
. ,
, ,
, ,
.

4.4.2 AND- () OR ()
, OR
() AND (),
. , AND ()
. , OR
(), (link - ) .
4 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4.

:
A

Input0;

Input1;

Input2;

Input3;

Output8;

O ( OR
()) AND ().
Output8 , { Input0 Input1} { Input2
Input3} ( "1").

4.4.3 OR () Exclusive OR ( )
AND ()
, OR
() AND (),
, , OR
() , AND ().
:
A(

Input0;

Input1;

A(

Input2;

Input3;

Output10;

AND ().
OR () .
(link) OR () (
, )
, , AND ().
Output10 , { Input0 Input1} { Input2
Input3} ( "1").
Exclusive OR ( ) AND ()
.
OR () Exclusive OR
( ), .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4 - 17

4.

4.4.4 AND () Exclusive OR


( )
AND (), Exclusive OR
( ), .
CPU AND ()
, ,
Exclusive OR ( ).
:
X(

Input0;

Input1;

X(

Input2;

Input3;

Output12;

AND () ,
AND () , Exclusive OR
( ). ,
.
Output12 , {Input0
Input1} { Input2 Input3} AND ().

4.4.5 OR () Exclusive OR
( )
OR (), Exclusive OR
( ), .
CPU OR ()
, ,
Exclusive OR ( ).
:

4 - 18

X(

Input0;

Input1;

X(

Input2;

Input3;

Output14;
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

4.

Output14 , {Input0
Input1} { Input2 Input3} OR ().
Exclusive OR ( ) OR ()
.
OR ()
Exclusive OR ( ) ,
.

4.4.6
"0" (
),
( - ).
, CPU ""
.

N
.
:
AN(

Input0;

Input1;

AN(

Input2;

Input3;

Output16;

Output16 , -
{Input0 Input1}, { Input2 Input3} -
.

() NOT. NOT,
,
.
:
A(

Input0;

Input1;

NOT ;
)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

4 - 19

4.

A(

Input2;

Input3;

NOT ;
)

Output17;

() NOT
.

4 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

5 (memory functions)
,
STL. Assign
() "" , Set
( ) Reset ( ) "" .

.

, ()
" " RLO,
CPU.

: /
, , ,
.
, , ,
STL_Book "Basic
functions" (" ") FB 105
Chap_5.

5.1 Assign ()
:
=

Bit


, "=",
RLO, CPU, ,
. "1",
; "0",
(. . 5.1. 1).
, RLO "0",
RLO
NOT (. . 5.1. 2).

4 " ".


,
(. . 5.1. 3).
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

5-1

5.

Assign ( )
Network 1 ( 1)
A Input1;
= Output1;

Input1
Output1

Network 2 ( 2)
A Input1;
NOT;
= Output2;

Input1

Network 3 ( 3)

Input2

A Input2;
= Output3;
= Output4;

Output3

Network 4 ( 4)
A Input3;
= Output5;
A Output5;
A Input4;
= Output6;

Output2

Output4
Input3
Input4
Output5
Output6

Set Reset ( )
Network 5 ( 5)
A Input1;
S Output7;

Input1

Network 6 ( 6)
A Input2;
R Output7;

Input2

Network 7 ( 7)
A Input3;
A Input4;
S Output8;
R Output9;
S Output10;
= Output11;

Output7

Output7
Input3
Input4
Output8
Output9
Output10
Output11

. 5.1 Assign (), Set () Reset ()


5-2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

5.

Set Reset ( )
Network 8 ( 8)
A Input1;
S Output12;
A Input2;
R Output12;
Network 9 ( 9)
A Input3;
R Output13;
A Input4;
S Output13;

Input1
Input2
Output12
Input3
Input4
Output13

. 5.1 () Set () Reset ()


, Assign,
, ,
, RLO. CPU
RLO .


(. . 5.1. 4).

5.2 Set ( ) Reset ( )


:
S

Bit

,
"1".
R

Bit

,
"1".
Set ( ) , Reset (
) ,
RLO "1".
"0", Set Reset ,
(. . 5.1. 5 6).


,
Assign
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

5-3

5.

.
(Set/Reset) (. . 5.1.
7). Assign, Set
Reset .
CPU RLO
.
NOT () RLO
.

Set ( ) Reset ( )
.

5.3 RS Flipflop (RS-)


RS Flipflop (RS-)
Set ( ) , Reset
( );
STL. RS Flipflop (RS-)
Set ( )
Reset ( )
- .
,
.
, , ,
( ).
, ,
; (, ""
), (,
) CPU (
).

5.3.1
Reset ( )
Reset ( ) ,
Set (
) Reset ( )
"1",
( "0"). ,
, Reset ( )
Set ( ) (. . 5.1. 8).
, CPU
, Set ( ),
, Reset ( ).

.
,
5-4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

5.


,
()
. CPU
.
Reset ( ) ""
, (
"0") , , .

5.3.2
Set ( )
Set ( ) ,
Set (
) Reset ( )
"1",
( "1"). ,
, Set ( )
Reset ( ) (. . 5.1. 9).
, CPU
, Reset ( ),
Set ( ), .

.
,

,
()
. CPU
.
Set ( )
, , .
Set ( ) , ,
,
Reset (),

.

5.3.3

STL
.
RLO ,
.
. 5.2 ,
RLO.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

5-5

5.

Input1;

Input2;

Input1

&
>=1

Input2

NOT;
O( ;
A

Input3;

Input4;

Memory1;

Input5;

Input6;

Memory1;

Input3
Input4

Input5

AN Memory1;
)

Input7;

Output14;

&

Input6

Memory1
S

>=1
R

Input7

Output14

. 5.2 :
RS-.
.
RS-
RS-
. ,

.
STL-; ,
,

RLO.


, :

5-6

,
,
.
.

,

.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

5.

, .
CPU.
"" (..
).
,
. , ,
(
).
:
" " ("scratch-pad memory"),
STEP 5, ,
.

5.4 Edge Evaluation ( )


:
FP

Bit

()
FN

Bit

()



( ).
"0" "1". ,
"1"
"0".

" "
("pulse contact element").
,
.
, .
, ,
" " ("edge memory bit") (
). ,
,
,
- .
,

. (
" ").
, "" RLO,
CPU .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

5-7

5.

CPU
RLO .
, .
CPU ,
RLO,
RLO "1"
,
. , CPU
, RLO "0".
, , "1",
. ,
, .
- , CPU
(
). CPU RLO "0"
.
RLO
,
" " ("pulse memory bit"). RLO
, RLO
; .
" "
, ,
.

RLO
AND (), OR () Exclusive OR ( ).

CPU. , RLO

.
(
, ).
,
. ,

("pulse memory bit"). ,
,
.

5.4.1
CPU () ,

"0" "1".
. 5.3.
5.3 PulseMerkerX,
, , FrontMerkerX.
5-8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

5.

Network 1 ( 1)

Input0
(RLO FP)

A Input0;
FP FrontMerker0;
= PulseMerker0;

FrontMerker0
( FP)

PulseMerker0
(RLO FP)

Network 2 ( 2)

Input1
(RLO FP)

A Input1;
FN FrontMerker1;
= PulseMerker1;

FrontMerker1
( FP)

PulseMerker1
(RLO FP)

. 5.3
. 5.3 :
1

Input0, FrontMerker0
"0". PulseMerker0 , ..
"0".

2- Input0 "0" "1".


CPU RLO
FrontMerker0. Input0 "1",
FrontMerker0 "0",
( "1"). PulseMerker0 "1".

3- RLO
FrontMerker0 CPU ,
. PulseMerker0 "0".

4-
RLO FrontMerker0 CPU
PulseMerker0 "0", FrontMerker0 "1".

5- Input0 "1" "0".


CPU
FrontMerker0 "1" "0". PulseMerker0
(PulseMerker0 "0"). ,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

5-9

5.

5.4.2
CPU () ,

"1" "0".
. 5.3.
. 5.3
:
1

Input1 FrontMerker1
"0". PulseMerker1 , ..
"0".

2- Input1 "0" "1".


CPU RLO
FrontMerker1. Input1 "1",
"0", (
"1"). PulseMerker1 "0".

3-
Input1 FrontMerker1, PulseMerker1 "0",
FrontMerker1 "1".

4- Input1 "1" "0". ,


CPU FrontMerker1 "1" "0"
PulseMerker1 "1".

5- Input1 FrontMerker1.
CPU "0" PulseMerker1. ,
.

5.4.3
(pulse memory bits)
(-) PG
,
( "1")
.
,

.
" " ("flying restart circuit"),
,
, RS-.
RS-, , .. RS " ".
"" .

5 - 10

Pmembit0;

Pmembit1;

Flipflop2;
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

5.

Input2;

Flipflop2;

, " "
"" .

5.4.4

, ,
("") ,
.
.
O

Input3;

Input4;

FP EMembit2;
A

Input5;

Output15;

Input6;

FN EMembit3;
R

Output15;

Output15 , OR(-) ( OR- [-]


"0" "1") Input5 ( "1"). Output15
, Input6.
" "
("first check"), RLO,
,
. ,

""
("completed")
( OR- [-] ).
.

5.4.5 (Binary Scaler)


(Binary Scaler) .
, ,
"0" "1",
. 5.4.
Input ()
Output ()

. 5.4 ,
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

5 - 11

5.


.
. ,

.
,
.
,
( "1"), ( "0"),
( "0"), (
"1").
,
(
).
:
Input - , Output - ,
EMembit - , PMembit - .
A

Input_1;

FP EMembit_1;
=

PMembit_1;

PMembit_1;

AN Output_1;
S

Output_1;

PMembit_1;

PMembit_1;

Output_1;

Output_1;

JCN
. CPU , RLO "0"
.
CPU
, . ,
( "0"), (
"1"), ( "1"),
( "0). ,
" ",
.

M1:
5 - 12

Input_2;

FP

EMembit_2;

JCN

M1

AN

Output_2;

Output_2;

... ;
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

5.

5.5


, .

; .
:
,
"readyload" (" ").
"Start" ("")
.

"end-of-belt" ("
"), , , ,
"ready_rem" (" ")
.

"Continue" ("")
, "end-of-belt" (" ")
.

-
. 5.5. ,
. .
.
19 " "
;
( ).


:

Basic_st
.

Man_on
, .

/Stop
,
"0" ( , "zero active"
[" "]).

Light_barrier1
.

/Mfault
(,
); "zero
active" (" ")
, , , ().

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

5 - 13

5.

Load
(
)

Start
Light_barrier1

>=1

Basic_st
/Mfault1

Continue
Light_barrier1

Remove
(
)

Basic_st

/Mfault1

>=1

Ready_rem

>=1

Basic_st
/Mfault1

>=1

Basic_st
P

>=1

/Mfault1

Positive edge
(
)
Negative edge
(
)

Readyload

>=1

Man_on

&

/Stop

Belt_mot1_on

/Mfault1

. 5.5
, ..
(),
Symbol Table (. . 5.1)
.
, , .

5 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

5.

5.1 Symbol Table



Symbol ()

Address ()

Data Type ()

Comment ()

Belt_control

FC11

FC11

Basic_st

I 0.0

BOOL

Man_on

I 0.1

BOOL

/Stop

I 0.2

BOOL

Start

I 0.3

BOOL

Continue

I 0.4

BOOL

Light_barrier1

I 1.0

BOOL

/Mfault1

I 2.0

BOOL

Readyload

Q 4.0

BOOL

Ready_rem

Q 4.1

BOOL


(" ")

Belt_mot1_on

Q 5.0

BOOL

Load

M 2.0

BOOL

Remove

M 2.1

BOOL

EM_Rem_N

M 2.2

BOOL

()
"remove" (" ")

EM_Rem_P

M 2.3

BOOL

()
"remove" (" ")

EM_Loa_N

M 2.4

BOOL

()
"load" (" ")

EM_Loa_P

M 2.5

BOOL

()
"load" (" ")


("zero-active" ["
"])

, "End of belt"
(" ") 1

("zero-active"
[" "]) 1

(" ")


. ,
, OB1 :
CALL Belt_control;
. 5.6
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

5 - 15

5.

FUNCTION Belt_control : VOID


TITLE = Control of a conveyor belt
// ( )
NAME
:
Belt1
AUTHOR :
Berger
FAMILY :
STL_Book
VERSION :
01.00
BEGIN
NETWORK
TITLE = Load parts
// "Load",
//
A
Start;
//
S
Load;
O
Light_barrier1;
//
O
Basic_st;
ON
"/Mfault1";
//
R
Load;
NETWORK
TITLE = Parts ready for removal
// ,
A
Load;
//
FN
EM_Loa_N;
//"Load"
S
Ready_rem;
//
A
Remove;
FP
EM_Rem_P;
//
O
Basic_st;
ON
"/Mfault1";
R
Ready_rem;
NETWORK
TITLE = Remove parts
// "Remove"
A
Continue;
//
S
Remove;
ON
Light_barrier1;
//
O
Basic_st;
ON
"/Mfault1";
//
R
Remove;
NETWORK
TITLE = Belt ready for loading
// ,
A
Remove;
FN
EM_Rem_N;
//
O
Basic_st;
S
Readyload;
//
A
Load;
FP
EM_Loa_P;
//
ON
"/Mfault1";
R
Readyload;
NETWORK
TITLE = Control belt motor
//
A(;
O
Load;
//
O
Remove;
//
O
Man_on;
// "Man_on" ( )
);

(. )
5 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

5.

A
"/Stop";
ON
"/Mfault1";
=
Belt_motor1;
NETWORK
TITLE = Block end
BE
END_FUNCTION

//
//

. 5.6
(
), .
( ) (, [space]),
.
STL .

. , BLOCK END
( ), ,
. ,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

5 - 17

5.

5 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6 (move functions)
STL,

(). :
Load ( )

( - "digital
functions" - , ..)
Transfer ( )

accumulator1 CPU, , .
Accumulator functions ( )


accumulator1.
Load ( )

.
SFC 20 BLKMOV, SFC 81 UBLKMOV SFC 21 FILL

.
Load ( ) Transfer
( )
;
,
.

.

STL_Book "Basic Functions" FB 106
Chap_6.

6.1

Load ( ) Transfer
( )
.
,
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

6-1

6.

accumulator 1. - ,
.
,
, . ,
accumulator 1,
(loading), ,
, (transferring) (
"" ["transferred"] ).


(digital functions),
(digital value) (,
) (,
).
.
accumulator 1 accumulator 2.
CPU . , S7-400 CPU
- accumulator 3
accumulator 4,
.
, (accumulator
functions),
.
. 6.1
.
(load)
(system memory), (work memory) (I/O)
accumulator 1, "" ( ,
"") accumulator 1 accumulator 2.
(digital functions)
accumulator 1 ,
accumulator 1 accumulator 2,
accumulator 1.
(accumulator functions)
. (transfer)
(system memory), (work
memory) (I/O)
accumulator 1.
32 ,
(byte-oriented).
accumulator 1
, 1 1 .
Load ( )
Transfer ( )
, , ,
(I/O) .

6-2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6.


(System memory)


(Work memory)

L-


(Load functions)


(Accumulator functions)

1
(Accumulator 1)


(Transfer functions)

(Modules)

2
(Accumulator 2)

3
(Accumulator 3)

4
(Accumulator 4)


(Digital functions)

L-


(System memory)


(Work memory)

(Modules)

. 6.1

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6-3

6.

Load ( ) Transfer
( )
:

( 7 " ", 8 " ")

( 15 " ")

(L-, 18.1.5 " ")
,
( 18.2 " ")

( 25 " ")

( 26 " ")

6.2 Load ( )
6.2.1 Load

L ( )
, ,
accumulator 1.
L

+1200

( )

IW 16


( )

ActValue

( )

CPU
RLO .
.
accumulator 2
Load ( )
accumulator 2. ,
,
accumulator 1, accumulator
1 accumulator 2. Load
accumulator 1
accumulator 2.
accumulator 2 .
S7-400 CPU
accumulator 3 accumulator 4.
6-4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6.


, Load,
(byte), (word) (duoble word) (. . 6.2).
() Load
7

(n)

0 7

(n+1)

0 7

(n+2)

0 7

(n+3)

(n)

0 7

(n+1)

(n)

Accumulator 1

(n)

31

24 23

16 15

8 7

(n)

0 7

(n+1)

0 7

(n)

0 7

(n+1)

(n+2)

0 7

(n+3)

() Transfer

. 6.2 , ,

accumulator 1
. .

accumulator 1
. (n+1)
, (n)
(n+1).
.


accumulator 1 .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

6-5

6.

(n) ,
( n+3) .

6.2.2

L

IB n

IW n

ID n

CPU ,
(. . 1.5.2
" ").

L

QB n

QW n

QD n

CPU ,
(. . 1.5.2
" ").
(I/O)
L

PIB n

PIW n

PID n

I/O
(PI).
.
, I/O
,
,
( CPU
).
I/O ""
.

L

MB n

MW n

MD n

,
CPU. , ,
CPU .

6-6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6.

6.2.3

.
,
. 3 "SIMATIC S7-"
. ,

.
L

B#16#F1

-1000

(INT)

5.0

(REAL)

S5T#2s

S5

C#250

BCD ( )

TOD#8:30:00

24 " " (
).

- ,
.
:
L

P#1.0

P#M2.1

P#name

DB (DB pointer) ANY (ANY


pointer) , 32 .
25 " " 26 "
" .

6.3 Transfer ( )
6.3.1 Transfer
T ( )
,
accumulator 1.
T

MW120


( )

Setpoint


( )

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6-7

6.

CPU
RLO .
.
accumulator 1
, ,
. accumulator 1
,
accumulator 1.
accumulator 1.
,
accumulator 1,
,
Transfer .

, Transfer,
(byte), (word) (duoble word) (. .
6.2).


accumulator 1 .


accumulator 1 .
(n+1)
, (n+1),
(n) ,
(n).


accumulator 1
. (n)
(n) ,
(n+3)
(n+3).

6.3.2

T

IB n

IW n

ID n

CPU ,
(. . 1.5.2
" ").
6-8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6.

,
( "inputs").


:
,
, ,
.

T

QB n

QW n

QD n

CPU ,
(. . 1.5.2
" ").

T

PQB n

PQW n

PQD n

I/O
(PQ).
.
, I/O
, ,
, (
) ( )
.

T

MB n

MW n

MD n

,
CPU. , ,
CPU .

6.4 (Accumulator Functions)


(Accumulator Functions)

accumulator 1.
RLO .
RLO,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6-9

6.

6.4.1
PUSH

""

POP

""

TAK

accumulator 1
accumulator 2

ENT

""
( accumulator 1)

LEAVE

""
( accumulator 1)

PUSH, POP TAK CPU,


(S7-300 CPU).
CPU, (S7-400 CPU).
. 6.3.
:
TAK
PUSH
POP

ENT

LEAVE

Accumulator 4 Accumulator 4

Accumulator 3

Accumulator 4

Accumulator 3

Accumulator 4

Accumulator 3 Accumulator 3

Accumulator 2

Accumulator 4

Accumulator 2

Accumulator 4

Accumulator 2 Accumulator 1

Accumulator 1

Accumulator 3

Accumulator 2

Accumulator 3

Accumulator 1 Accumulator 2

Accumulator 1

Accumulator 2

Accumulator 1

Accumulator 1

, S7-300 ( CPU 318)

. 6.3 CPU S7-300 S7-400


PUSH
PUSH
accumulator 1, accumulator 2, accumulator 3 accumulator 4.
accumulator 3
accumulator 4, accumulator 2 accumulator 3
accumulator 1 accumulator 2
( accumulator 1 ).

6 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6.

, PUSH
.
POP
POP
accumulator 4, accumulator 3, accumulator 2 accumulator 1.
accumulator 4
accumulator 3, accumulator 3 accumulator 2
accumulator 2 accumulator 1 (
accumulator 4 ).
, POP
accumulator 4, accumulator 3 accumulator 2
accumulator 1,
.
TAK
TAK
accumulator 1 accumulator 2.
accumulator 3 accumulator 4 .
ENT
ENT
accumulator 2, accumulator 3 accumulator 4.
accumulator 3 accumulator 4
accumulator 2 accumulator 3.
accumulator 1 accumulator 2
.
ENT Load,

accumulator 1, accumulator 2, accumulator 3 accumulator 4 (
PUSH);
accumulator 1.
LEAVE
LEAVE
accumulator 4, accumulator 3 accumulator 2.
accumulator 3 accumulator 2
accumulator 4 accumulator 3.
accumulator 4 accumulator 1
.
LEAVE.

(,
[Word]).
(digital logic
operation), LEAVE accumulator
4 accumulator 3 accumulator 3 accumulator
2. (digital logic operation)
accumulator 1.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6 - 11

6.

6.5 accumulator 1
CAW


accumulator 1

CAD


accumulator 1

CAW
accumulator 1.
.
CAD accumulator 1.
,
.

. 6.4.

1
n

n+1

n+2

n+3

CAW
1
n

n+1

n+3

n+2

1
n

n+1

n+2

n+3

CAD
1
n+3

n+2

n+1

. 6.4. accumulator 1

6.6
SFC 20 BLKMOV

SFC 21 FILL

SFC 81 UBLKMOV

6 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6.

ANY (. .
6.1).
, .
6.1 SFC 20, 21 81
SFC

SFC 20

SFC 21

SFC 81

SRCBLK

INPUT

ANY

-,

RET_VAL

OUTPUT

INT

DSTBLK

OUTPUT

ANY

-,

BVAL

INPUT

ANY

-,

RET_VAL

OUTPUT

INT

BLK

OUTPUT

ANY

-,
( )

SRCBLK

INPUT

ANY

-,

RET_VAL

OUTPUT

INT

DSTBLK

OUTPUT

ANY

-,

,
("complete variable");
(, )
( ).
ANY; 25.1 "".

STRING. , STL SCL- - (. . 6.6.4
" STRING").

ANY, ,
ANY.
ANY ,
, ,
" " ("variable area"). 26 "
" , " ANY ".

6.6.1
SFC 20 BLKMOV
()
( SRCBLK) ( DSTBLK).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6 - 13

6.

:
(I), (Q),
(M) (
),
(
ANY),
ANY.
SFC 20 BLKMOV
,
( I/O),
/ (SDB).
( ),
,
.
(load) (
UNLINKED []).
SFC 20 BLKMOV - . - ,
, -.
: Frame (,
) "Rec_mailb"
Frame1 ( Frame)
"Buffer".
Copyerror "Evaluation".
CALL BLKMOV
SRCBLK

:= Rec_mailb.Frame,

RET_VAL := Evaluation.Copyerror,
DSTBLK

:= Buffer.Frame1);

6.6.2
SFC 81 UBLKMOV
( SRCBLK)
( DSTBLK) ()
. ,

. 512 .

:

(I), (Q),
(M) (
),
6 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6.

(
ANY),
ANY.
SFC 81 BLKMOV
,
( I/O).
/ (SDB) /
(load) ( UNLINKED
[]).
( ),
,
.
SFC 81 BLKMOV - . - ,
, -.
: "Buffer" Data
Frame "Send_mailb".
Copyerror
"Evaluation".
CALL UBLKMOV
SRCBLK

:= Buffer.Data[1],

RET_VAL := Evaluation.Copyerror,
DSTBLK

:= Send_mailb.Frame1);

6.6.3
SFC 21 FILL
( BVAL) (
BLK) () .
(
-
).

:

(I), (Q),
(M) (
),
(
ANY),
ANY.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

6 - 15

6.

SFC 21 FILL
,
( I/O).
/ (SDB).
( ),
,
.
SFC 21 FILL - . - , , -
; -
-, - (
) (,
).
: DB 13 128 .
MB 80.
CALL SFC 21
BVAL

:= MB 80,

RET_VAL := MW 32,
BLK

:= P#DB13.DBX0.0 BYTE 128);

6.6.4 STRING
STRING
SFC 20 BLKMOV SFC 81 UBLKMOV.
STL- SCL- - .
STL- STRING
, SFC (
). , ,
STRING,
STRING- ("length bytes")
.
SCL- STRING
ANY. SFC
STRING-. STRING-
, .
, , STRING-
CHAR .
, - STL-, SCL- STRING- STRING-
.

6 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 (Timer Functions)

, ,
(waiting)
(monitoring time),

,
STL. SCL
(. . 30.1 "
" ["Timer Functions"]).
:
(Pulse timer)
(Extended pulse timer)
(On-delay timer)
(Retentive On-delay timer)
(Off-delay timer)

(dynamic response), (duration),
/ .
("retrigger") .
. (Load)

BCD- accumulator 1.
, , IEC-
STL_Book library
"Basic Functions" FB 107
Chap_7.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7-1

7.

7.1
7.1.1
(.. ),
CPU
RLO.
("Off-delay timer") RLO
"1" "0", RLO
"0" "1".
(.
. 7.1).

:

STL

SCL

SP
() (Pulse timer)

S_PULSE

(Extended pulse timer)

SE

S_PEXT

(On-delay timer)

SD S_ODT



(Retentive on-delay timer)

SS

S_ODTS

(Off-delay timer)

SF

S_OFFDT

t
t
t
t
t

. 7.1

7.1.2
accumulator 1
(running time) (duration).
accumulator 1 .
,
accumulator 1

( ), (,
, ).
7-2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

:
accumulator 1 ,
.
()
L

S5TIME#10s;

// 10

S5T#1m10ms;

// 1 + 10

STL, LAD FBD " " (running time)


" ()" (duration) ,
, .
S5TIME#10ms S5TIME#2h46m30s (
, 9990 ).
S5TIME#, S5T#
.
()
L

S5T#10m;

// (duration) = 10

MW20;

// " "

MW20;

// " "

" () " (duration)


"
()" ("duration") " " ("time value")
" " ("time base"). ()
:
" ()" = " " " ".
() - ,
("timer running").
("time value")
,
("timer running").
" " ("time base")
,
CPU "" (. 7.2).
15

12 11

" "
("time base") BCD
0 = 0.01 c
1 = 0.1 c
2 = 1c
3 = 10 c

8 7
10

4
10

0
10

("time value") BCD

7.2 " " ("duration")

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7-3

7.

" "
("duration") .
" " ("time base")
. ,
, 1 ,
" " ("time base") ,
,
(,
):
" " ("time base") = 1 ;

" " ("duration") = 2001hex

" " ("time base") = 100 ; " " ("duration") = 1010 hex
" " ("time base") = 10 ;

" " ("duration") = 0100 hex


.
CPU ("time
value") ,
("timer running").

. , CPU

" " ("time base").
"0", ,
. CPU
() ( "0" "1",
),
.
("time value"),
(0), ,
CPU , "".

. , ,
.

, .

7.1.3 (Resetting a timer)



R

Tn

, RLO, "1",
. RLO "1",
"1" "0";
"0" "1".
7-4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

("time value")
" " ("time base") (0).
:

. CPU
RLO, "0",

.

7.1.4 (Enabling a timer)



FR

Tn

FR ,
(..,
).
, FR
() .

. RLO
"1" ,
, .
("time value")
" " ("time base") (0).
:

, ..,
.

7.1.5 () (Checking a timer)


()
A

Tn

"1" RLO
AND ().

Tn

"1" RLO
OR ().

Tn

"1" RLO
Exclusive OR ( ).

AN

Tn

"0" RLO
AND ().

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7-5

7.

ON

Tn

"0" RLO
OR ().

XN

Tn

"0" RLO
Exclusive OR ( ).

, , , (input),
.
() "1"
() (.
).
(input) ()
"0"
"1" - .
() (time value)

Tn

("time value") ,

LC

Tn

("time value") (BCD).

L T LC T
("time value") accumulator 1.
L ("time value") ,
LC -
. ("time value") ,
accumulator 1, ,
, (
, ,
, ,
CPU
).
(time value)
("time value"),
, ,
accumulator 1 () . " "
("time base") accumulator 1
"0".
, ,
(INT)
, , .
:
" " ("duration").
7-6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

:
L

T 15;

// ("time value")
//

MW 34;

// ("time value")

( BCD ["coded load"])


.. ""
("coded load") ("time
value") . ("time value")
" " ("time base") BCD ().
accumulator 1 ( )
"0".
:
LC

T 16;

// ("time value")
// BCD-

MW 122;

// ("time value")

7.1.6


.
, .

.


.
7.1
.
7.1
:
:
A
I 16.5
(Enable timer)
FR T 5
A
I 17.5
L
S5T#1s
(Start timer)
SP T 5
A
I 18.0
(Reset timer)
R
T 5
L
T 5
T
MW20

LC T 5
(Digital timer check)
T
MW22
A
T 5

=
Q 2.0
(Binary timer check)
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

7-7

7.

, ,
.
"" (
),
,
. , (),
.

7.1.7 ( )
,
/ .
Start_Input .
,
(extended pulse).
Output
(duration).
AN
R

Start_input;
Timer;

Output;

JC

M1;

Timer;

JC

M1;

AN

Output;

Output;

Pulse_duration;

JC

M2;

Pulse_duration;

M2:

SE

Timer;

M1:

//

7.2 (Pulse timer)


STL
" " (Pulse timer):

7-8

Enable_input;

FR

Timer;

Start_input;

Duration;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

SP

Timer;

Reset_input;

Timer;

Timer;

Binary_time_value;

LD

Timer;

BCD_time_value;

Timer;

Timer_status;

SCL " "


(Pulse timer):
BCD_time_value
:= S_PULSE (
T_NO

:= Timer,

:= Start_input,

TV

:= Duration,

:= Reset_input,

:= Timer_status,

BI

:= Binary_time_value);

(Starting a pulse timer)


7.3 ,
(Pulse), .
1


Start_input

5
t


Reset_input


Enable_input


(internal)
C
()
c
( "1")
t - (duration)

. 7.3
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

7-9

7.

. 7.3
,
STL ( , ,
). (Enabling a timer)
, SCL .
1

, Start_input
"0" "1" ( ).
, Start_input "1".
() "1" (timer status)
"1", .
( )
(initial) ,
" " (time base).

,
Start_input "1" "0" (
),
( - "duration"). ()
"1" (timer status) "0".
( ) ,
( - "duration"),
,
.

(Resetting a pulse timer)


(Resetting a pulse timer)
(. . 7.3).
3

Reset_input, "1",
, . ()
"1" (timer status) "0".
(time value) " " (time base)
"0". (..
"1" "0") Reset_input ,
Start_input "1",
.

, "1"
Reset_input .

Start_input "0" "1"


( ), ,
Reset_input "1", ,
( . 7.3
). ()
"1" (timer status) ,

- "0".

(Enabling a pulse timer)


7.4 ,
(Pulse).
7 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

(Enabling a pulse timer)


( )
Enabling_input (
"0" "1").
(Enabling a pulse timer)
STL.
1


Start_input

2
t

3
t


Reset_input


Enable_input


(internal)
C
()
c
( "1")
t - (duration)

. 7.4 (Enabling)

Enable_input
"0" "1" ( ),
, Start_input
"1". ("duration")
.
Enable_input "1"
"0" ( ) .

Start_input "1",
,
Enable_input "0" "1" ( )
(pulse timer).
("duration")
.

Start_input "0",
Enable_input "0" "1" (
) .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 - 11

7.

7.3 (Extended pulse timer)


STL
" " (Extended pulse timer):
A

Enable_input;

FR

Timer;

Start_input;

Duration;

SE

Timer;

Reset_input;

Timer;

Timer;

Binary_time_value;

LD

Timer;

BCD_time_value;

Timer;

Timer_status;

SCL " "


(Extended pulse timer):
BCD_time_value
:= S_PEXT (
T_NO

:= Timer,

:= Start_input,

TV

:= Duration,

:= Reset_input,

:= Timer_status,

BI

:= Binary_time_value);

(Starting an extended pulse timer)


7.5 ,
" " (Extended pulse timer),
.
. 7.5
,
STL ( , ,
). (Enabling a timer)
STL, SCL
.

7 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.


Start_input

2
t

3
t

4
t

7
t


Reset_input


Enable_input


(internal)
C
()
c
( "1")
t - (duration)

. 7.5 " " (Extended


pulse timer)
1

, Start_input
"0" "1" ( ).
( "duration"),
Start_input "1" "0".
() "1" (timer status)
"1", .
( )
(initial) ,
" " (time base).

Start_input "0"
"1" ( ), ,
, .
("duration")
.
,
, ,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 - 13

7.

" " (Extended pulse timer)


" " (Extended
pulse timer)
(. . 7.5).
4

Reset_input, "1",
, . ()
"1" (timer status) "0".
(time value) " " (time base)
"0". (..
"1" "0") Reset_input ,
Start_input "1",
.

, "1"
Reset_input .

Start_input "0" "1"


( ), ,
Reset_input "1", ,
( . 7.5
). ()
"1" (timer status) ,

- "0".

" " (Extended pulse timer)


(Anabling extended pulse timer)
( )
Enabling_input
( "0" "1").
(Anabling a pulse timer)
STL.

7 - 14

Enable_input
"0" "1" ( ),
, Start_input
"1". ("duration")
.
Enable_input "1"
"0" ( ) .

Start_input "1",
,
Enable_input "0" "1" ( )
" " (extended pulse
timer). ("duration")
.

Start_input "0",
Enable_input "0" "1" (
) .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

7.6 ,
" " (Extended pulse timer).
1

2
t


Start_input

3
t

4
t


Reset_input


Enable_input


(internal)
C
()
c
( "1")
t - (duration)

. 7.6 (Enabling)
" " (Extended pulse timer).

7.4 (On-delay timer)


STL
(On-delay timer):
A

Enable_input;

FR

Timer;

Start_input;

Duration;

SD

Timer;

Reset_input;

Timer;

Timer;

Binary_time_value;

LD

Timer;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 - 15

7.

BCD_time_value;

Timer;

Timer_status;

SCL (On-delay
timer):
BCD_time_value
:= S_ODT (
T_NO

:= Timer,

:= Start_input,

TV

:= Duration,

:= Reset_input,

:= Timer_status,

BI

:= Binary_time_value);

(On-delay timer)
7.7 ,
(On-delay timer),
.
. 7.7
,
STL ( , ,
). (Enabling a timer)
STL,
SCL.
1


Start_input

5
t


Reset_input


Enable_input


(internal)
C
()
c
( "1")
t - (duration)

. 7.7 (On-delay timer)



7 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

, Start_input
"0" "1" ( ).
, ( "duration"). () "1" (timer status)
"1",
( - "duration")
"0" Start_input,
Start_input "1", , "1",
Reset_input, .
( )
(initial) ,
" " (time base).

,
Start_input "1" "0" (
),
( - "duration"). ()
"1" (timer status) "0".
( ) ,
( - "duration"),
,
.
(Resetting an on-delay timer)
(Resetting an on-delay
timer)
(. . 7.7).

Reset_input, "1",
, .
() "1" (timer status)
"0",
Start_input "1".
(time value) " " (time base)
"0".
(.. "1" "0")
Reset_input , Start_input
"1", .
RLO, "1", Reset_input
,
. () "1" (timer
status) "0"

Start_input "0" "1"


( ), , Reset_input
"1", ,
( . 7.7
). ()
"1" (timer status) ,

- "0".

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 - 17

7.

(Anabling an on-delay timer)


(Anabling an on-delay timer)
(
) Enabling_input
( "0"
"1").
(Anabling an on-delay timer)
STL.
7.8 ,
(On-delay timer).
1


Start_input

4
t


Reset_input


Enable_input


(internal)
C
()
c
( "1")
t - (duration)

. 7.8 (Enabling) (On-delay


timer)

7 - 18

( )
Enable_input "0" "1"
( ),
, Start_input "1".
("duration")
.
Enable_input "1" "0"
( ) .

Enable_input "0"
"1" ( ) ,
,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

Start_input "1",

Reset_input, Enable_input
"0" "1" ( )
(On-delay timer).
("duration")
.
Start_input "0",
Enable_input "0" "1" (
) .

7.5 (Retentive On-delay


timer)
STL
(Retentive On-delay timer):
A

Enable_input;

FR

Timer;

Start_input;

Duration;

SS

Timer;

Reset_input;

Timer;

Timer;

Binary_time_value;

LD

Timer;

BCD_time_value;

Timer;

Timer_status;

SCL
(Retentive On-delay timer):
BCD_time_value
:= S_ODTS (
T_NO

:= Timer,

:= Start_input,

TV

:= Duration,

:= Reset_input,

:= Timer_status,

BI

:= Binary_time_value);

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 - 19

7.

(Retentive On-delay timer)


7.9 ,
(Retentive On-delay
timer), .
. 7.9
,
STL ( , ,
). (Enabling a timer)
STL, SCL
.
1

2
t


Start_input

3
t


Reset_input


Enable_input


(internal)
C
()
c
( "1")
t - (duration)

. 7.9 (Retentive Ondelay timer)


1

, Start_input
"0" "1" ( ).

( - "duration"),
Start_input "1"
"0". ,
() "1" (timer status)
"1"
Start_input. () "1" (timer
status) "1"
Start_input.
( )
(initial) ,
" " (time base).

7 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

Start_input "0"
"1" ( ), ,
, .
("duration")
.
,
, ,
.

(Retentive On-delay timer)


(Retentive Ondelay timer)
(. . 7.9).
4

Reset_input, "1",
,
Start_input. ()
"1" (timer status) "0".
(time value) " " (time base)
"0".

Start_input "0" "1"


( ), , Reset_input
"1", ,
( . 7.9
). ()
"1" (timer status) ,

- "0".

(Anabling a retentive ondelay timer)


(Anabling a retentive on-delay timer)
(
) Enabling_input
( "0"
"1").
(Anabling a retentive on-delay timer)
STL.
7.10 ,
(Retentive On-delay timer).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 - 21

7.

2
t


Start_input

3
t

5
t


Reset_input


Enable_input


(internal)
C
()
c
( "1")
t - (duration)

. 7.10 (Enabling)
(Retentive On-delay timer)

7 - 22

( )
Enable_input "0" "1"
( ),
, Start_input "1".
("duration")
.
Enable_input "1" "0"
( ) .

Enable_input "0"
"1" ( ) ,
,
.

Start_input "0",
Enable_input "0" "1" (
) .

Start_input "1",

Reset_input, Enable_input
"0" "1" ( )
(Retentive on-delay
timer). ("duration")
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

7.6 (Off-delay timer)


STL
(Off-delay timer):
A

Enable_input;

FR

Timer;

Start_input;

Duration;

SF

Timer;

Reset_input;

Timer;

Timer;

Binary_time_value;

LD

Timer;

BCD_time_value;

Timer;

Timer_status;

SCL (Off-delay
timer):
BCD_time_value
:= S_OFFDT (
T_NO

:= Timer,

:= Start_input,

TV

:= Duration,

:= Reset_input,

:= Timer_status,

BI

:= Binary_time_value);

(Off-delay timer)
7.11 ,
(Off-delay timer),
.
. 7.11
,
STL ( , ,
). (Enabling a timer)
STL, SCL
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 - 23

7.

2
t


Start_input

4
t


Reset_input


Enable_input


(internal)
C
()
c
( "1")
t - (duration)

. 7.11 (Off-delay timer)



1

, Start_input
"1" "0" ( ).
, ( "duration"). () "1" (timer status)
"1",
( - "duration") Reset_input
"1", ,
Start_input "1".
( )
(initial) ,
" " (time base).

,
Start_input "0" "1" (
),
( - "duration"). ,
() "1" (timer status)
"0".
Start_input.

(Resetting an off-delay timer)


(Resetting an off-delay
timer)
(. . 7.11).

7 - 24

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

Reset_input, "1",
. () "1"
(timer status) "0". (time
value) " " (time base)
"0".

Reset_input "0" "1"


( ), , Start_input
"1", (
[] "1" [timer status]
, , "0").
(.. "1" "0")
Reset_input , Start_input
"1", "1".
Start_input "1" "0"
( ), , Reset_input
"1", ,
( . 7.11
). ()
"1" (timer status) ,

- "0".

(Anabling an off-delay timer)


(Anabling an off-delay timer)
(
) Enabling_input
( "0"
"1").
(Anabling an off-delay timer)
STL.
7.12 ,
(Off-delay timer).
1

( ),
Start_input "1",
Enable_input "0" "1"
( ),
, Enable_input
.

Enable_input "0"
"1" ( ) ,
( ),
.
("duration")
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 - 25

7.

Enable_input "0"
"1" ( ) "1" "0"
( ) , (
),
.
1

3
t


Start_input


Reset_input


Enable_input


(internal)
C
()
c
( "1")
t - (duration)

. 7.12

(Enabling)
(Off-delay timer)

7.7 IEC- (IEC Timer Functions)


IEC- (IEC Timer Functions)
CPU SFB.
CPU
:
SFB 3 TP

SFB 4 TON

SFB 5 TOF

. 7.13 .
SFB
SFB .
7 - 26

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.


IN

C ()
Q
SFB 3 TP

C ()
Q
SFB 4 TON

C ()
Q
SFB 5 TOF

t - (duration)

. 7.13 IEC-

(offline) " " Standard Library
System Function Blocks.

STL_Book "Basic Functions"
FB 107 Chap_7 SCL_Book
"30 SCL Functions".
7.2 IEC-
(Name)

(Declaration)

(Data type)

(Description)

IN

INPUT

BOOL

PT

INPUT

TIME

INPUT

BOOL

ET

INPUT

TIME

(Start input)
(Pulse length)


(Delay duration)

(Timer status)

(Elapsed time)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 - 27

7.

7.7.1 SFB 3 TP
IEC- SFB 3 TP 7.2.
RLO IN "0" "1",
, ..
(duration),
RLO . Q
"1" , .
ET (duration),
Q .
(duration) T#0s
PT. PT , ET
, IN "0".
IN "0" ,
PT (duration), ET
T#0s , PT.
,
PT = T#0s.
IEC- SFB 3 TP RESTART RUN. IEC SFB 3 TP ()
.

7.7.2 SFB 4 TON


IEC- SFB 4 TON
7.2
RLO IN "0" "1",
, ..
(duration). Q
"1" ,
. (duration) RLO
"1" "0",
. ,
.
ET (duration),
. (duration)
T#0s PT.
PT , ET ,
IN "0". IN
"0" , PT
(duration), ET T#0s .
,
PT = T#0s.
IEC- SFB 4 TON RESTART RUN. IEC SFB 4 TON ()
.
7 - 28

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7.

7.7.3 SFB 5 TOF


IEC- SFB 5 TOF
7.2
RLO IN "0"
"1", Q "1".
RLO "1" "0",
, ..
(duration). Q ,
"1", .
(duration) RLO
"0" "1", ,
Q , "1".
,
.
ET (duration),
. (duration)
T#0s PT.
PT , ET ,
IN "1". IN
"1" , PT
(duration), ET T#0s .
,
PT = T#0s.
IEC- SFB 5 TOF RESTART RUN. IEC SFB 5 TOF ()
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

7 - 29

7.

7 - 30

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8 (Counter Functions)
CPU.

"" 000
999.
,
STL. SCL
(. . 30.2
" " ["Counter Functions"]).

! CPU
, ,
( )
.
, .
:
S7-300 CPU (CPU 3xxIFM)
,
10 .
, ,
CPU. (initial
value). ,
.
( ).
(load)
BCD- accumulator 1.
, , IEC-
STL_Book library
"Basic Functions" FB 108
Chap_8.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8-1

8.

8.1
(Setting a counter)
S

Cn

, RLO "0" "1"


S (Set). ..
.
- .
, ,
accumulator 1 (. ). 0
999.

15

12 11

0000 hex

8 7
10

4
10

0
10

("counter value") BCD

. 8.1 ("counter value")

(Specifying a counter)
("set counter")
accumulator 1 " " ("count value").
accumulator 1 .
,
accumulator 1

(.., ),
(, , ).
:
accumulator 1 ,
.
()

8-2

C#100;

// 100

W#16#0100;

// 100
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

8.

000 999.
. BCD.
.
C# W#16# (
).
()
L

C#200;

// 200

MW 56;

//

MW 56;

//

Set
accumulator 1,
. ( C#)
24 " ".
(Resetting a counter)
R

Cn

, RLO "1" ,
R (Reset). RLO
"1", "1" "0";
"0" "1".
("count value")
(0).
:

,
. CPU
RLO,
"0",

.
.

8.2 (Counting)
(Counting up)

CU

Cn

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8-3

8.

(""), CU
() RLO
(RLO "0" "1").
, CU,
("count value") ,
, 999.
RLO CU .
(Counting Down)

CD

Cn

(""), CD
() RLO
(RLO "0" "1").
, CD,
("count value") ,
, 0.
RLO CD .
.

8.3 () (Checking a Counter)


() (binary counter check)
A

"1" RLO
AND ().

"1" RLO
OR ().

"1" RLO
Exclusive OR ( ).

AN

"0" RLO
AND ().

ON

"0" RLO
OR ().

XN

"0" RLO
Exclusive OR ( ).

, , , (input),
. ()
"1" "1",
0 , "0", 0.

8-4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8.

(direct loading of a count value)

Cn

("count value").

L C ("count value")
, , accumulator 1
. ,
accumulator 1, ,
, .
accumulator 1
(INT) , ,
.
:
L

C 99;

//

MW 76;

//

BCD- ("coded loading")

LD

Cn

-
("count value").

("")

.. ""
("coded load") accumulator 1 , .
, accumulator 1,
, ,
. accumulator 1
BCD-, .
.
:
LD

99;

// BCD-

MW 50;

//

8.4 (Enabling a counter)

FR

Cn

() .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8-5

8.

FR (Set)

RLO. ,
, RLO "1".
, , , RLO
"0" "1".
RLO -
.

, (..,
).
:

, !
RLO
(S, CU CD), "1".
,
( . 8.2):
A
FR

"Enable";
"Counter";

"Count up";

CU

"Counter";

"Count down";

CD

"Counter";

"Set";

C#020;

"Counter";

"Reset";

"Counter";

"Counter";

"Counter status";

, . 8.2:

8-6


20.

(Set)

CU (
1).

Set "1",
- 1.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

8.

(Reset)
( 1).


: "1" .


20.

Reset, "1", .
"1" "0".

Set "1",
20.
"1" "1".

(Set)

Enable


Count up


Count down

Set


Reset

Counter status

. 8.2 Enable

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8-7

8.

8.5


.
, .
,
(initial value),
"0".


.
8.1
.
, ,
, ,
Enable.
8.1
:
(Enable counter)
(Count up)
(Count down)
(Set counter)
(Reset counter)

(Digital counter check)

(Binary counter check)

:
A
I 22.0
FR 17
A
I 22.1
CU 17
A
I 22.2
CD 17
A
I 22.3
L
C#500
S
17
A
I 22.4
R
17
L
17
T
MW 30
LC 17
T
MW 32
A
17
=
Q 13.0

Reset ("static")
CU, CD S
(RLO),
Reset ,
.
(set) (reset)
"", ,
Reset. ,
,
.
8-8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8.

Set ("static")

(RLO), Set
.
(set) (reset)
"",
, Set
,
.
,
.

8.6 IEC- (IEC Counter Functions)


IEC- (IEC Counter Functions)
CPU SFB.
CPU
:
SFB 0 CTU

SFB 1 CTD

SFB 2 CTUD

SFB
SFB .

(offline) " " Standard Library
System Function Blocks.

STL_Book "Basic Functions"
FB 108 Chap_8 SCL_Book
"30 SCL Functions".
IEC-
8.2.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8-9

8.

8.2 IEC-

(Name)

SFB

(Declaration)

(Data type)

CU

INPUT

BOOL

CD

INPUT

BOOL

INPUT

BOOL

LOAD

INPUT

BOOL

PV

INPUT

INT

OUTPUT

BOOL

QU

OUTPUT

BOOL

QD

OUTPUT

BOOL

CV

OUTPUT

INT

(Description)

(Up count input)

(Down count input)

(Reset input)

(Load input)

(Preset value)

(Counter status)


(Count counter status
up)


(Count counter
status down)

(Current counter value)

8.6.1 SFB 0 CTU


IEC- SFB 0 CTU 8.2.
(up counter input) CU
"0" "1" (" "),
( )
CV. ( "0"
R)
PV (Preset value).
, 32767,
. CU
.
R "1",
0. CU
, R "1".
Q "1", CV
PV.

8 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8.

IEC- SFB 0 CTU RESTART RUN. IEC SFB 0 CTU .

8.6.2 SFB 1 CTD


IEC- SFB 1 CTD 8.2.
(down counter input) CD
"0" "1" (" "),
( )
CV. ( "0"
LOAD)
PV (Preset value).
, -32768,
. CD .
LOAD "1",
( PV).
CD ,
LOAD "1". Q
"1", CV .
IEC- SFB 1 CTD RESTART RUN. IEC SFB 1 CTD .

8.6.3 SFB 2 CTUD


IEC- SFB 2 CTUD 8.2.
(up counter input) CU
"0" "1" (" "),
( )
CV. (down counter
input) CD "0" "1" (" "),
( )
CV. CU CD
"0" "1" (" "),
.
, 32767,
.
CU .
, -32768,
. CD
.
LOAD "1",
( PV).
,
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

8 - 11

8.

LOAD "1".
R "1",
0.
"1" LOAD ,
R "1". QU
"1", CV
PV. QD
"1", CV .
IEC- SFB 2 CTUD RESTART RUN. IEC SFB 2 CTUD .

8.7
,
.
, ,
. .

.
. ,
,
"Finished".
.
,
.
"Set" (
, ).
.
0,
"Finished". ,
(
).
"Set" "Active".
, ,
"Active". "Active"
, .

"Dura1"
. Start "0"
.
.
, ,
,
. "Dura2".

8 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8.

,
"Dura1" ("free") ,
, "Dura2",
- "Fault".
"Active" "Dura2".
"Set" .
, ,
,
() (watchdog timer).

, , , " "

. - ""
(, , ).
("pulse
memory bits") .
("edge memory bits")
,
.
- .
(, OB 1) :
Call "Counter_control";

-
, .
(
), .
( ) (,
[space]), .
STL
.

. , BLOCK END
( ), ,
. ,
.
(symbol table)
STL_Book "Conveyor Example"
Symbol, "Conveyor"
Source Files Blocks,
FC 12.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8 - 13

8.

Counter
CD

Light_barrier1
P

Positive edge
(
)
Negative edge
(
)

Set

PV

Quantity

Acknowledge

Finished

Finished
Light_barrier1

Set

&
>=1

Acknowledge

Light_barrier1

Light_barrier1

Active

Active

>=1

Timer
SE

Light_barrier1
Dura1
Dura2
Active

TV
Q

&
Fault

. 8.3

8 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8.

FUNCTION "Counter_control" : VOID


//TITLE =
//
NAME
: Count
AUTHOR : Berger
FAMILY : STL_Book
Version : 01.00
VAR_TEMP
PM_LB_P : BOOL;
//
PM_LB_N : BOOL;
//
END_VAR
BEGIN
NETWORK
TITLE = Counter_Control
A
Light_barnerl;
//
CD Count;
// 1
A
Set;
L
Quantity;
//
//
"Quantity"
S
Count;
A
Acknowledge;
R
Count;
AN Count;
// 0,
=
Finished;
//
NETWORK
TITLE = Activate monitor
A
Light_barrierl;
FP EM_LB_P;
//
=
PM_LB_P;
//
A
Light_barrierl;
FN EM_LB_N;
//
=
PM_LB_N;
//
A
Set;
FP EM_ST_P;
S
Active;
//
A
Finished;
A
PM_LB_N;
0
Acknowledge;
R
Active;
//
NETWORK
TITLE = Monitoring circuit
L
Dura1;
// "1",
A
Light_barrierl;
// JC Dl
JC D1;
// "Dura1",
L
Dura2;
// - "Dura2"
Dl: A
Active;
FP EM_AC_P;
// "Active",
0
PM_LB_P;
// ,
0
PM_LB_N;
// ,
SE Monitor;
//
AN Monitor;
A
Active;
//
//
"Active",
=
Fault;
// "Fault"
NETWORK
TITLE = Block End
BE;
END_FUNCTION

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

8 - 15

8.

8 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL


INT, DINT REAL,
PLC.
, STL-.
SCL ,
Word
(. 27.4 "");
SCL (.
30.3 " ", 30.4 " ",
30.5 " ").

. INT, DINT
REAL.
.

INT, DINT REAL.

.
.

.

. ,
.
Word

"0" "1".
, ,
.
, .
18.2 " "
.

.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

9-1

9
, ;
: , , ,
; .
10
; ;
; .
11
; ;
; ;
.
12
INT/DINT BCD ;
DINT REAL
;
, .
13
, , ,
; 1
; ,
2.
14 Word
AND (), OR (), Exclusive OR ( );
, ,
2.

9 -2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL


, accumulator
1, accumulator 2.
RLO (
) CC0 CC1.
,
. 9.1
.
9.1


INT

DINT

REAL

==I

==D

==R

<>I

<>D

<>R

>I

>D

>R

>=I

>=D

>=R

<I

<D

<R

<=I

<=D

<=R

15 " " ,
CC0 CC1.
,
STL.
SCL
(. 27.4.2 "
").
, ,
STL_Book library "Digital
Functions" (" ") FB 109
Chap_9.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

9-3

9.

9.1

Address1;
Address2;
;
Result;
Load
accumulator 1.
accumulator 1
accumulator 2 (. 6.2 " ").

.
( BOOL),
().
.
- .
9.2 .

.
9.2



INT



DINT



REAL

9 -4

99.0 ,
MW
92 120,

"CompResult"
"Global_DB"
,
"CompVal1"
"CompVal2",

#Actval

#Calibra,
#Recali
, -
.

L MW 92;
L 120;
==I;
R M 99.0;
L "Global_DB"."CompVal1";
L "Global_DB"."CompVal2";
<D;
= "Global_DB"."CompResult";

L #Actval;
L #Calibra;
>=R;
S #Recali;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

9.

, INT, CPU
( ) ;
, ( ), .
, REAL,
( )
. , CPU
RLO "0", CC0, CC1, OV OS
"1".

9.2


,
.
. RLO
"1", :
INT
accumulator 2
accumulator 1,
DINT
accumulator 2
accumulator 1,
REAL
accumulator 2
accumulator 1 ,
(REAL) .
REAL , ,
("equal to") (RLO = "0").


,
.
. RLO
"1", :
INT
accumulator 2
accumulator 1,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

9-5

9.

DINT
accumulator 2
accumulator 1,
REAL
accumulator 2
accumulator 1 ,
(REAL) .
REAL ,
, ("not equal to") (RLO =
"0").
""

""
, . ,
, accumulator 2, ,
accumulator 1.
RLO "1", :
INT
accumulator 2
accumulator 1,
DINT
accumulator 2
accumulator 1,
REAL
accumulator 2
accumulator 1 ,
(REAL) .
" "

" "
, .
, , accumulator 2,
, accumulator 1.
RLO "1",
:
INT
accumulator 2
accumulator 1,
DINT
9 -6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

9.

accumulator 2
accumulator 1,

REAL
accumulator 2
accumulator 1 ,
(REAL) .
""

""
, . ,
, accumulator 2, ,
accumulator 1.
RLO "1", :
INT
accumulator 2
accumulator 1,
DINT
accumulator 2
accumulator 1,
REAL
accumulator 2
accumulator 1 ,
(REAL) .
" "

" "
, .
, , accumulator 2,
, accumulator 1.
RLO "1",
:
INT
accumulator 2
accumulator 1,
DINT
accumulator 2
accumulator 1,

REAL
accumulator 2
accumulator 1 ,
(REAL) .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

9-7

9.

9.3

RLO , ,
. FC,
,
("first check").


("first check"). RLO,
(
).
L

MW 120;

512;

>I;
A

Input1;

Output1;

Output1 ,
, Input1 "1".


,
( ["first check"]).
O

Input2;

O( ;
L

MW 122;

200;

<=I;
);
O

Input3;

Output2;

Output2 , Input2 Input3


"1"
.

,

STL.

9 -8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

9.

MW 124;

1200;

>I;
JC GREA;
==I;
JC EQUA;


. RLO =
"1", MW 124 1200,
GREA.
RLO.
,
, ..
. ,
.

:
L

MW 124;

1200;

>I;
JP GREA;
JZ EQUA;


CC0 CC1.
(" ") ;
, , "
". JP
, . JZ ,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

9-9

9.

9 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

10

,
accumulator 1,
accumulator 2.
accumulator 1. CC0, CC1, OV OS
, (.
15 " "). 10.1
.
10.1


INT

DINT

REAL

(Addition)

+I

+D

+R

(Subtraction)

-I

-D

-R

(Multiplication)

*I

*D

*R

(Division with quotient


as result)

/I

/D

/R


(Division with remainder
as result)

MOD

,
accumulator 2,
accumulator 1
.
,
STL. SCL

(. 27.4.1 " ").
, ,
STL_Book library "Digital
Functions" (" ") FB 110
Chap_10.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

10 - 1

10.

10.1


:
(load) Address1;
(load) Address2;
;
(transfer) Result;
Load
accumulator 1.
accumulator 1
accumulator 2 (. 6.2 " ").

.
accumulator 1.

. -
.
10.2 .
10.2


INT

W 100
250;

W 102.

L MW 100;
L 250;
/I;
T MW 102;


DINT


"ArithVal1" "ArithVal2"
,

"ArithResult".
"Global_DB".

L "Global_DB"."ArithVal1";
L "Global_DB"."ArithVal2";
+D;
T "Global_DB"."ArithResult";


REAL

#Actval #Factor
;

#Display.

L #Actval;
L #Factor;
*R;
T #Display;

, INT,
( )
; , (), .
10 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

10.

, REAL,
( )
.
S7-300 CPU ( CPU 318)
accumulator 2; S7-400 CPU
CPU 318 accumulator 2
accumulator 3.
accumulator 4 (
) accumulator 3 (. . 10.1).
S7-300 CPU ( CPU 318)

S7-400 CPU CPU 318

Accumulator 4

<Accumulator 4>

<Accumulator 4>

Accumulator 3

<Accumulator 3>

<Accumulator 4>

Accumulator 2

Address () 1

Address () 1

+
Accumulator 1

Address () 2

<Accumulator 3>

+
result ()

Address () 2

result ()

. 10.1

10.2 INT
INT
+I
1 2 (INT).

accumulator 1.
CC0 CC1 ,
: , .
OV OS
.
INT
- I
1 2 (INT).
, accumulator 1,
, accumulator 2
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

10 - 3

10.

accumulator 1.
CC0 CC1 ,
: , .
OV OS
.
INT
*I
1 2 (INT).

DINT accumulator 1.
CC0 CC1 ,
: , .
OV OS
.
,
accumulator 1, DINT.
INT
/I
1 2 (INT).
, accumulator 2
(), ,

accumulator 1
(), : ,
INT (. . 10.2).
31

16

( )

Accumulator 2

( )

Accumulator 1

/I

Accumulator 1

15

. 10.2 , / I.
accumulator 1
.
. :
, ,
. ,
.
10 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

10.

accumulator 1
(
!). ,
.
CC0 CC1 ,
: , .
OV OS
.

, CC0, CC1, OV OS
"1".

10.3 DINT
DINT
+D 1
2 (DINT).

accumulator 1.
CC0 CC1 ,
: , .
OV OS
.
DINT
-D 1
2 (DINT).
, accumulator 1, ,
accumulator 2 ()
accumulator 1.
CC0 CC1 ,
: , .
OV OS
.
DINT

*D

1 2 (DINT).

accumulator 1.
CC0 CC1 ,
: , .
OV OS
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

10 - 5

10.

DINT
/D 1 2
(DINT).
, accumulator 2 (), ,
accumulator 1 (),
accumulator 1.
.
: ,
, .
, .
CC0 CC1 ,
: , .
OV OS
.

, CC0, CC1, OV OS
"1".
DINT
MOD
1 2 (DINT).
,
accumulator 2 (), , accumulator 1
(), accumulator 1.
- , .
.
, .
CC0 CC1 ,
: , .
OV OS
.

, CC0, CC1, OV OS
"1".

10.4 REAL

REAL
+R 1
2 (REAL).

accumulator 1.

10 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

10.

CC0 CC1 ,
: , .
OV OS
.
,

(invalid REAL number)


[- ] [+ ]), +R
accumulator 1
CC0, CC1, OV OS "1".
REAL
-R 1
2 (REAL). ,
accumulator 1, ,
accumulator 2 ()
accumulator 1.
CC0 CC1 ,
: , .
OV OS
.
,

(invalid REAL number)


[+ ] [+ ]), -R

accumulator 1 CC0, CC1, OV OS
"1".
REAL

*R

1 2 (REAL).

accumulator 1.
CC0 CC1 ,
: , .
OV OS
.
,

(invalid REAL number)


0), *R
accumulator 1
CC0, CC1, OV OS "1".

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

10 - 7

10.

REAL
/R 1 2
(REAL). ,
accumulator 2 (), ,
accumulator 1 (),
accumulator 1.
CC0 CC1 ,
: , .
OV OS
.

, CC0, CC1, OV OS
"1".
,

(invalid REAL number)


0 0),
/R
accumulator 1 CC0, CC1, OV
OS "1".

10.5


;
.
.
:
,
S7-300 CPU S7-400 CPU - (S7-300 CPU
2 , S7-400 CPU 4).
S7-300 CPU ( CPU 318)
:
,

.
:
Result1 := Value1 + Value2 - Value3
L

Value1;

Value2;

+I;
10 - 8

//Value1 + Value2
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

10.

Value3;

-I;
T

// - Value3

Result1;

CPU
accumulator 2

.
:
Result2 := Value5 + 2 Value6
L

Value6;

Value5;

+R;

//Value5 + Value6

+R;

// + Value6

Result2;

:
2

Result3 := Value7 (Value8)


L

Value8;

Value7;

*D;

//Value7 Value8

*D;

// Value8

Result3;

S7-400 CPU CPU 318


:
,

. CPU, 4 ,
accumulator 3
accumulator 2 .
ENT
accumulator 3 (,
) (. 6.4 " ").
:
Result4 := (Value1 + Value2) (Value3 - Value4)
L

Value1;

Value2;

+I ;
L

Value3;

ENT;
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

10 - 9

10.

Value4;

-I ;
*I ;
T

Result4;

Value1 Value2.
accumulator 1 Value3
accumulator 2. ENT
accumulator 3. Value4, Value3
accumulator 2.
"" accumulator 3 accumulator
2. .

10.6 Accumulator 1

+ B#16#bb

(byte)

+ w

(word)

+ L#d

(duobleword)


:
Address;
Const;
Result;

,
,
.

accumulator 1.

byte word
duobleword.
word, DINT,
L#.
INT, ( )
DINT.
-

.

10 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

10.

INT .
, INT
word
accumulator 1
.
INT , 15 ( )
. word
32 ,
DINT.

- .
:
L

AddValue1;

B#16#21;

AddResult1;

AddValue1 33
AddResult1.
L

AddValue2;

-33;

AddResult2;

AddValue2
AddResult2.
L

AddValue3;

L#-1;

AddResult3;

33

AddValue3 1
AddResult3.
DINT.

10.7

DEC

INC

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

10 - 11

10.

Address;
;
Result;

Address;
;
Result;

accumulator 1.
() () ,
.
0 255.
.
.
,
255,
( 0), ,
0,
( 255).

RLO.
RLO, .
:
L

IncValue;

INC 5;
T

IncResult;

IncValue 5
IncResult.
L

DecValue;

DEC 7;
T

DecResult;

DecValue 7
DecResult.

10 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

11
:
(SIN), (COS), (TAN)
(ASIN), (ACOS), (ATAN)
(SQR), (SQRT)
(EXP), (LN)
REAL.

CC0, CC1, OV OS (. 15 " ").
,
STL. SCL

SCL (. 30.3
" ").
, ,
STL_Book library "Digital
Functions" (" ") FB
111 Chap_11.

11.1

, accumulator 1,

accumulator 1.

:
(load) Address;
;
(transfer) Result;

accumulator 1;
.
- .

11 - 1

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

11.

11.1
.
11.1

SIN


D 110
.


D 104.

L MD 110;
SIN;
T MD 104;

SQRT




"MathValue1"

"MathRoot".
"Global_DB".

L "Global_DB".MathValue1;
SQRT;
T "Global_DB".MathRoot;

EXP

#Result

#Exponent.

L #Exponent;
EXP;
T #Result;


REAL,
.
, accumulator 1
(invalid REAL number)
,
(REAL) accumulator 1
CC0, CC1, OV OS "1".

11.2

SIN

COS

TAN

(REAL) accumulator
1 , .
:
0 360
0 2 ( = +3.141593+00).
.
, 90 / 2 +1.570796+00.
, , , , ,
2 +6.283185+00, 2
2, , 2.

11 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

11.

:
: Ps = U I Sin ()
L
PHI;
//
SIN

Current;

*R

Voltage;

*R

I_Power;

//
//
//
//

, .
,

/ 180 = +1.745329-02
,
.

11.3 (Arc-)
Arc-
ASIN

ACOS
ATAN

, .
(REAL),
accumulator 1, , (.
. 11.2).
,

CC0, CC1, OV OS
"1".
11.2 Arc-

ASIN

-1 +1

-/2 +/2

ACOS

-1 +1

0 +

ATAN

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

-/2

+ /2

11 - 3

11.

:

0,343.
?
Arcsin(0.343) , ;
360/2 (= 57.2958)
( 20).
:
L
0.343;
ASIN

57.2958;

*R

Angle_Degree;

11.4
:
SQR

SQRT
EXP

LN

(
)


SQR
accumulator 1.
:
: V = r2 H
L
Radius;
//
//
SQR

Height;

*R

3.141592;

*R

Volume;

//
//
//


SQRT
accumulator 1.
,
CC0, CC1, OV OS
"1". "-0" ( 0), "-0".
11 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

11.

:
c = SQRT(a2 + b2)
L
#a;
SQR

#b;

SQR

+R

SQRT
T

;
#c;

( b c ,
#,
; b c ,
).
( )
EXP
( accumulator 1
Accu1
); = 2.718282+00).
(
:

a b = e b ln a
L

Value_a;

LN

Value_b;

*R

EXP

Power;

//

( )
LN
( accumulator 1
; = 2.718282+00).
,

CC0, CC1, OV OS "1".

:

y = e , x = ln (y).

:

:
:
log n a
log b a =
log n b
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

11 - 5

11.

b n .
n = e,
, :
ln a
log b a =

ln b

,
( ) :

10

ln a
lg a =

= 0.4342945 ln a
ln 10

11 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

12
() ,
accumulator 1. .12.1
, .

BCD
3

BTI
INT

INVI
NEGI

ITB
ITD

BCD
7

BTD
DINT

INVD
NEGD

DTB
DTR

RND+, RND-,
RND, TRUNC

REAL

ABS
NEGR

.12.1
,
STL. SCL

SCL (. 30.5 "
").

24 " ",
,
15 " ".
, ,
STL_Book library "Digital
Functions" (" ") FB
112 Chap_12.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

12 - 1

12.

12.1
,

accumulator
1.


accumulator 1 ( 0 15),
.

:
(load) Address;
;
(transfer) Result;
12.1
.
,
.
.
12.1


INT


DINT


REAL


W 120
INT.

W 122
BCD-.

"ConvertDINT"

DINT.

"ConvertREAL"
REAL.
"Global_DB".


#Display.

L MW 120;
ITB;
T MW 122;

L "Global_DB".ConvertDINT;
DTR;
T "Global_DB".ConvertREAL;

L #Display;
ABS;
T #Display;


accumulator 1
,


.

12 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

12.

:
L

BCD_Number;

BTI

//BCD

->

INT

ITD

//INT

->

DINT

DTR

//DINT ->

REAL

REAL_Number;

BCD-
REAL.

12.2 INT DINT



INT DINT:
ITD

INT DINT

ITB

INT BCD

DTB

DINT BCD

DTR

DINT REAL

INT DINT
ITD
accumulator 1 ( 0 15) INT
15 ( ) , .. 16 31.
INT DINT .
INT BCD
ITB
accumulator 1 ( 0 15) INT
BCD-. BCD-
accumulator 1
. 12 15.
"0", ,
"1", .
( 16 31) .
INT- , ,
BCD- (>999), ITB
OV OS.
.
DINT BCD
DTB accumulator 1
DINT BCD-.
BCD- accumulator 1

Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

12 - 3

12.

. 28 31.
"0", , "1",
.
DINT- , ,
BCD- (> 9 999 999), DTB
OV OS
.
DINT REAL
DTR accumulator 1
DINT REAL.
DINT REAL,

, (
RND). "0",
, "1",
.
DTR .

12.3 BCD

BCD:
BTI

BCD INT

BTD

BCD DINT

BCD INT
BTI
accumulator 1 ( 0 15) BCD-
INT.
accumulator 1
. 12 15.
"0", ,
"1", .
15.
( 16 31) .
"" BCD- (
10 15 A F ), CPU
("a parameter assignment
error") OB 121 (
). OB 121 , CPU
STOP.
BTI .

12 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

12.

BCD DINT
BTD accumulator 1
BCD- DINT.
accumulator 1

. 28 31 .
"0", , "1",
.
31.
"" BCD- (
10 15 A F ), CPU
("a parameter assignment
error") OB 121 (
). OB 121 , CPU
STOP.
BTD .

12.4 REAL
,
REAL DINT
( ).
.
RND+

""

RND-

""

RND

TRUNC ()
12.2
REAL DINT.
-1 +1 .
""
RND+ accumulator 1
REAL DINT.
RND+ ,
.

DINT ,
REAL, RND+
OV OS.
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

12 - 5

12.

12.2 REAL

REAL

DW#16#

RND

RND+

RND-

TRUNC

1.00000001

3F80 0001

1.00000000

3F80 0000

0.99999995

3F7F FFFF

0.50000005

3F00 0001

0.50000000

3F00 0000

0.49999996

3EFF FFFF

5.877476e-39

0080 0000

0.0

0000 0000

-5.877476e-39

8080 0000

-1

-0.49999996

BEFF FFFF

-1

-0.50000000

BF00 0000

-1

-0.50000005

BF00 0001

-1

-1

-0.99999995

BF7F FFFF

-1

-1

-1.00000000

BF80 0000

-1

-1

-1

-1

-1.00000001

BF80 0001

-1

-1

-2

-1

""
RND- accumulator 1
REAL DINT.
RND- ,
.

DINT ,
REAL, RND-
OV OS. .

RND accumulator 1
REAL DINT.
RND ,
, .
RND ,
.
,
, .. .

DINT ,
REAL, RND OV
OS. .
12 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

12.


TRUNC accumulator 1
REAL DINT.
TRUNC ,
, ("").
DINT
, REAL,
TRUNC OV OS.
.

12.5
,
:
INVI

INT

INVD

DINT

NEGI

INT

NEGD DINT
NEGD REAL
ABS

REAL

INT
INVI
accumulator 1 ( 0 15) .
,
. ( 16 31)
.
INVI .
DINT
INVD accumulator 1
.
, .
INVD .
INT
NEGI
accumulator 1 ( 0 15) INT
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

12 - 7

12.

-1.
accumulator 1 ( 16 31)
.
NEGI
: CC0, CC1, OV OS.

DINT
NEGD accumulator 1
DINT .
-1.
accumulator 1 ( 16 31)
.
NEGD
: CC0, CC1, OV OS.

REAL
NEGR accumulator 1
REAL -1 (
,
).
NEGR .
REAL
ABS accumulator 1
REAL ,
"0" (
"0",
).
ABS .

12 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

13

accumulator 1 .
13.1
.
13.1
Word ()

Duobleword ( )

.
Accum2

.
Accum2

SLW n

SLW

SLD n

SLD

SRW n

SRW

SRD n

SRD

SSI n

SSI

SSD n

SSD

RLD n

RLD

RRD n

RRD


CC1
(Rotate left through
CC1)

RLDA

1)


CC1
(Rotate right through
CC1)

RRDA

1)


(Shift left)

(Shift right)

(Shift with sign)

(Rotate left)

(Rotate right)

1)

,
STL. SCL

SCL (. 30.4 " ").
, ,
STL_Book library "Digital
Functions" (" ") FB
113 Chap_13.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

13 - 1

13.

13.1
,
accumulator 1.
(word),
(duobleword). , ( ),
( [shift operations]),
(
[rotate operations]).
.
-
.
accumulator 1.
(RLO).

:
, 2
,

:
(load) Number_of_positions;
(load) Address;
;
(transfer) Result;
(load) Address;
" " (Number_of_positions);
(transfer) Result;
CC0 "0", CC1
,
(. . 13.1).

15 " " 16 " ".
13.2
Word Duobleword.
Word
accumulator 1 ( 0
15). .
CC1
accumulator 1

13 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

13.

SLW

SLW

"0"

"0"

CC1

Accumulator1

Accumulator1

CC1

SRW

SRW

"0"

CC1

CC1

Accumulator1

Accumulator1

"0"
SSI
S

SSD
CC1

Accumulator1

CC1
Accumulator1

RLD

. CC1 RLDA

CC1

CC1
Accumulator1

Accumulator1

RRD

. CC1 RRDA
CC1

CC1

Accumulator1

Accumulator1

.13.1
13.2


Word
()

Duobleword
( )

W 130
4

W 132.

.

"ShiftOn"
"ShiftPos"

"ShiftOff".

accumulator 2.
#Actval
2

#Display.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

L
MW 130;
SLW 4;
T
MW 132;

L
L
SRD
T

"Global_DB".ShiftPos;
"Global_DB".ShiftOn;
;
"Global_DB".ShiftOff;

L
#Actval;
SSI 2;
T
#Display;

13 - 3

13.



accumulator 1 .
:
L

Value1;

SSD

4;

SLD

2;

Result1;


2
"0".

13.2

SLW

SLW

n
,
accumulator 2

SLW ,
accumulator 1 (..
0 15). ,
. ,
;
16.
, ,
SLW
accumulator 2 INT,
. ,
( , .. NOP);
15, SLW
"0".
accumulator 1 ( )
INT,
,
2 , ,
.

SLD
SLD

n

, accumulator 2

SLD ,
accumulator 1.
,
13 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

13.

.
, ,
SLD
accumulator 2, INT,
. ,
( , .. NOP);
31, SLD
accumulator 1 "0".
accumulator 1
DINT, ,
2 ,
, .

SRW

SRW

n
,
accumulator 2

SRW ,
accumulator 1 (..
0 15). ,
. ,
( 16 31) .
, ,
SRW
accumulator 2 INT,
. ,
( , .. NOP);
15, SRW
"0".
accumulator 1 ( )
INT,
,
2 , ,
.
, ,
.
.

SRD
SRD

n

, accumulator 2

SRD ,
accumulator 1.
,
.
, ,
SRD
accumulator 2, INT,
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

13 - 5

13.

. ,
( , .. NOP);
31, SRD
accumulator 1 "0".
accumulator 1
DINT, ,
2 ,
, .
,
,
.
.

SSI

SSI

n
,
accumulator 2

SSI ,
accumulator 1 (..
0 15). ,
15 (,
INT). ,
"0", "1",
.
SSI 16 31.
, ,
SSI
accumulator 2 INT,
. ,
( , .. NOP);
15, SSI
,
.
accumulator 1 ( )
INT,
,
2 , ,
.
.
SSD
SSD
SSD

n
,
accumulator 2

SSD ,
accumulator 1.
,
31 (,
DINT). , "0",
"1", .
13 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

13.

, ,
SSD
accumulator 2, INT,
. ,
( , .. NOP);
31, SSD
accumulator 1 ,
.
accumulator 1
DINT, ,
2 ,
, .
.

13.3

RLD n

RLD

,
accumulator 2

RLD
, accumulator 1.

, ""
.
, ,
RLD
accumulator 2,
INT, . ,
( , .. NOP);
32, accumulator 1
, CC1 ,
( 0).
33, accumulator 1 1 ,
34, 2
.

RRD n

RRD

,
accumulator 2

RRD
, accumulator 1.

, ""
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

13 - 7

13.

, ,
RRD
accumulator 2,
INT, . ,
( , .. NOP);
32, accumulator 1
, CC1 ,
( 31).
33, accumulator 1 1 ,
34, 2
.
CC1
RLDA

CC1 1

RLDA 1
, accumulator 1.
( 0)
CC1, CC1,
, ""
( 31). CC0
"0".
CC1
RRDA

CC1 1

RRDA 1
, accumulator 1.
( 31)
CC1, CC1,
, ""
( 0). CC0
"0".

13 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

14
(Word Logic)
(Word Logic)
, accumulator 1,
accumulator 2.
accumulator 1.
Word
(), Duobleword ( ).

:
AND

"",

OR

"",

Exclusive OR

" ".


(Word Logic), STL.
SCL

(. 27.4.3 " ").
,
15 " ".
, ,
STL_Book library "Digital
Functions" (" ") FB
114 Chap_14.

14.1

:
(load) Address1;
(load) Address2;
;
(transfer) Result;
(load) Address;
c ;
(transfer) Result;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

14 - 1

14. Word


- .
(RLO).


, ,
4 " " (.14.1).
14.1

2
0
0
1
1

1

AW, AD

OW, OD

XOW, XOD

0 accumulator 1
0 accumulator 2 ,
. 0 accumulator 1.
2,
3 ( 15
31 ).
accumulator 2 .
accumulator 2

, ,
.
accumulator 1.
:
L

MW 142;

// 1

MW 144;

// 2

AW

//

MW 146;

//


(Word).


, ,
,
.
accumulator 1.

14 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

14. Word

:
L

MW 148;

AW

W#16#807F;

MW 150;

MD 152;

OD

DW#16#8000_F000;

MD 156;


(Duobleword).
c (Word)
, (Word),
,
accumulator 1 (.. 0 15). ,
( 16 31),
(. . 14.1).
accumulator 1
31

16

15

L MD 160

<MW 160>

<MW 162>

L MD 164

<MW 164>

<MW 166>

AW

<MW 164>

<MW 162> AW <MW 166>

MW 170

MW 172

T MD 170

.14.1 c (Word)



( load
)
(,
).
.
:
L

Value1;

Value2;

AW

Value3;

OW

Result1;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

14 - 3

14. Word

AW
accumulator 1.
Value3 accumulator 2.
OW.
:
L

Value4;

Value5;

XOW

AW

W#16#FFF0;

Result2;

XOW
accumulator 1. 0 3
"0" AW.
14.2
.
14.2

AND
( )


W 138
"0";

W 140.

L
AW
T

OR
(
)

"WlogicVal1"
"WlogicVal1"

OR ();

"WlogicReslt".

L
"Global_DB".WlogicVal1;
L
"Global_DB".WlogicVal2;
OD ;
T
"Global_DB".WlogicReslt;

Exclusive OR
(
)

#Input
#Mask
Exclusive OR
( );

#Buffer.

L
L
XOW
T

MW 138;
W#16#0FFF;
MW 140;

#Input;
#Mask;
;
#Buffer;

14.2
AND ()
AW
AW

AND ()
Word () accum1 accum2
W#16#

AD
AD
14 - 4

AND ()
Word () accum1
AND ()
Duobleword ( ) accum1 accum2

DW#16#

AND ()
Duobleword ( ) accum1
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

14. Word


AND () ,
accumulator 1,
accumulator 2 ,
. , ,
"1" ,
"1".
accumulator 2 ,
"0", "0"

accumulator 1, , ""
("masked"). , ,
AND () .
OR ()
OW
OW

OR ()
Word () accum1 accum2
W#16#

OD
OD

OR ()
Word () accum1
OR ()
Duobleword ( ) accum1 accum2

DW#16#

OR ()
Duobleword ( ) accum1


OR ()
, accumulator 1,
accumulator 2
, . ,
, "0" ,
"0".
accumulator 2 ,
"1", "1"

accumulator 1, , ""
("masked"). , ,
OR () .
Exclusive OR ( )
XOW

Exclusive OR ( )
Word () accum1 accum2

XOW W#16#

Exclusive OR ( )
Word () accum1

XOD

Exclusive OR ( )
Duobleword ( ) accum1 accum2

XOD

DW#16#

Exclusive OR ( )
Duobleword ( ) accum1

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

14 - 5

14. Word


Exclusive OR ( )
, accumulator 1,
accumulator 2
, .
, , "1"
,
"1".
accumulator 2 , "1",


accumulator 1.
accumulator 2 ,
"1", "1"

accumulator 1, , ""
("masked"). , ,
Exclusive OR ( )
.

14 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

STEP 7
.
,

.
, ,
,
.
(status bits) ,

, (, -
).

, .
(jump functions)
.
, , (
,
RLO ). STL


( )
( ).
(Master Control Relay - MCR)
.
, STL
()
.

(block
functions)

.
, .
STL
3.4 " STL".
18 " " 19 " "
. , SCL,
3.5 "
SCL" 29 "SCL ". 26 " "
, ,
,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15 - 1

15 (Status bits)
RLO, BR, CC0, CC1 (overflow);
; (status word); EN/ENO.
16 (Jump functions)
; RLO, BR, CC0, CC1
(overflow); ("jump distributor");
(loop jump).
17 (Master Control Relay - MCR)
MCR; MCR-; MCR-.
18
, , ;
; , ,
.
19
;
; ; :
, .

15 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15 (Status Bits)
- ( ). CPU
. CPU

. (,
);
. , "
" ("status word").
, ,
STL_Book library "Program
Flow Control" (" ")
FB 115 Chap_15.

15.1
15.1 , STL.
15.1

(binary flags)

/FC

(first check)

RLO

STA

c ( - "status")

OR

OR (OR status bit)

BR

(binary result)

(digital flags)
OS


(stored overflow)

OV

(overflow)

CC0

(condition code)

CC1

(condition code)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15 - 3

15.

. CPU
" " ("binary flags")
; " " ("digital flags")
.
(first check)
/FC
( ).
(
) /FC = "0",
. /FC "1" (/FC = "1").
,
, .
: /FC = "0". ()
.
(RLO)
RLO
. CPU
RLO, RLO

RLO ( 4 " ").
,
RLO BR. ,
RLO,
.
(status)
STA
( ) " "
(A, AN, O, ON, X, XN).
(S, R, =) STA
(
, , RLO = "0"
MCR ) STA
( ) .
FP FN RLO
STA.
STA (STA = "1"),
, : JC, JCN, JBI, JNBI
(: CLR STA: STA = "0").
STA STL-.

PG ( , ,
"program status"). ,

.
OR (OR status bit)
OR status ( ,
) AND () ("1")

15 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15.

OR (),
( OR ()
AND () OR ()).
OR status.
15.2 " (Binary flags)"

.

.
15.2
STL-


(binary flags)
/FC
RLO STA
OR

...
=

M 10.0

I 4.0

I 4.0 . "1"

I 4.1

I 4.1 . "0"

I 4.2

I 4.2 . "0"

ON

I 4.3

I 4.3 . "1"

Q 8.0

Q 8.0 --> "1"

Q 8.1

Q 8.1 --> "0"

Q 8.2

Q 8.2 --> "1"

I 5.0

...

STL-


(digital flags)
CC0 CC1
OV
OS

...
T

MW 10

+12

+15

-I
L

+20000

*I
L

+20

+I
T

MW 30

MW 40


: OV OS -> "1"
OV --> "0"

OS .="1"

...

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15 - 5

15.

(Overflow)
OV

()
(REAL) . OV
: , ,
,
(REAL) .
OV
JO.
(Stored overflow)
OS (
OV). CPU
OV, OS. ,
OV
, OS , ..
.
,
( ),

(REAL)
.
OS
() JOS.
JOS OS.
CC0, CC1 ( " ") (condition codes)
CC0, CC1 ( )

,
,
""
.

() (.
). 15.2
(digital flags).
(binary result)
BR ( )
EN/ENO ( ).
15.4 " " , STEP 7
.
BR
() . ).
(status word)
(status word) .
accumulator 1,
.

15 - 6

STW;

//

STW;

//
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

15.

. 6 " " ,
(load) (transfer). 15.1

.

.
,

.
, S7-300 CPU ( CPU 318)
/FC, STA OR ;
"0".

15.2
CC0, CC1, OV OS,
15.3. STL
RLO BR.
INT- DINT-
INT
DINT ("digital flags" -
). , , CC0 CC1
"0". CC0 = "0", CC1 = "1"
. CC0 = "1", CC1 = "0"
. (overflow)
OV OS
(: CC0 CC1).
"1" "
" ("digital status bits").
REAL-
REAL
" " ("digital status bits").
, , CC0 CC1 "0".
CC0 = "0", CC1 = "1" .
CC0 = "1", CC1 = "0" .
(overflow)
OV OS (:
CC0 CC1).
(REAL) "1"
.
(REAL) "" (
"" - "denormalized"),
. ""
-38
("denormalized") REAL 1.175494 10 (.
24 " "). S7-300
REAL , .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

15 - 7

15.

15.3
INT-

DINT-

CC0

CC1

OV

OS

CC0

CC1

OV

OS

<-2147483648
(+D, -D)

<-2147483648 (*D)

-32768 ... -1

-2147483648 ... -1

+1 ... +32767

+1... +2147483647

>+2147483647
(+D, -D)

<-32768
(+I, -I)
<-32768

(*I)

>+32767
(+I, -I)
>+32767

(*I)

>+2147483647 (*D)

32768

(/I)

2147483648

(-)4294967296

0
(/D, MOD)

CC0

CC1

OV

OS

(-)65536
0

REAL-

(/D)

CC0

CC1

OV

OS

. REAL

+
( 0)
-
( 0)
. REAL

NEG_I

NEG_D

CC0

CC1

OV

OS

CC0

CC1

OV

OS

+1 ... +32767

+1... +2147483647

-32768 ... -1

-2147483648 ... -1

(-) 32768

(-) 2147483648


CC0

CC1

OV

OS

"0"

"1"

. 0

15 - 8

CC0

CC1

OV

OS

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15.



" " ("digital status bits"). ,
OV OS
: (
REAL):
ITB DTB: INT BCD
RND+, RND-, RND, TRUNK: REAL
DINT

CC0 CC1.
;
,
. REAL
REAL.


CC0 CC1. OV ("0").
RLO
SET RLO "1", CLR
RLO "0".
"1" "0" STA.
.
SET CLR OR /FC,
, SET CLR
().
(
) SET:
SET
;
S

M 8.0;

//

M 8.1;

//

CLR

C 1;

//
// "Set counter"

RLO
.
RLO "0" "1" (
,
). ,
, RLO , ,
" " (
-"digital flags").
SET CLR RLO
RLO.
RLO NOT . . 4 " ".
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

15 - 9

15.

BR
SAVE
" " (BR - "binary result"). SAVE
RLO BR. SAVE
; .
SET

SAVE

// BR "1"

...
AN

OV;

SAVE

// BR "0"

...

15.3
RLO BR (digital flags)
.

.

(),
4 " ",
(digital flags) BR (. ).
A

() AND ()

() OR ()

() Exclusive OR
( )

AN

() AND ()

ON

() OR ()

XN

() Exclusive OR
( )

>0

[(CC0=0) & (CC1=1)]

>=0 0

[(CC0=0)]

<0

[(CC0=1) & (CC1=0)]

<=0 0

[(CC1=0)]

<>0 0 [(CC0=1) & (CC1=0)] v [(CC0=0) & (CC1=1)]

15 - 10

==0 0

[(CC0=0) & (CC1=0)]

UO

[(CC0=0) & (CC1=1)]

OV

(overflow)

[(OV=1)]

OS

[(OS=1)]

BR


Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

15.

()
, , , .

RLO BR, CC0
CC1, OV OS
(. 15.4). 16 " "
.
15.4
RLO

BR

CC0

CC1

OV

OS

JC, JCB

JCN, JNB

JBI

JNBI

JZ, JMZ, JPZ

JN, JP, JPZ

JN, JM, JMZ

JUO

JO

JOS

OV OS

, OV
"1"; "1"
OS ( ,
).
(,
) , OV
. , OS ,
,
, ,
() .
OS ,
JOS (..,
).

,
-
() , .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15 - 11

15.

Value1;

Value2;

+I

OV;

Status1;

Value3;

+I

OV;

Status2;

Value4;

+I

OS;

Status_overall;

Result;

//

//

//

Value1;

Value2;

+I

JO

ST1;

Value3;

+I

JO

ST2;

Value4;

+I

JOS

STOV;

Result;

//

//

//

, ()
(
OV), (
OS).

15.4 ( BR)
STEP 7 BR ( )
EN/ENO LAD
(" " - ["ladder diagram"]) FBD (" " - ["functional block diagram"]).
,
STL;
BR RLO.
15 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15.

, (
SFB SFC
) BR ,
STL.
EN/ENO
LAD FBD
EN
ENO. EN
"1",
( ). ,
ENO "1".
(,
), ENO
"0". EN
"0", ENO
"0".
/
(EN/ENO)
; ENO

EN

(. . 15.1).
, ("switch off")
( ,
I 1.0 "0")

.
EN ENO , ,
, LAD/FBD

( ).
LAD/FBD
EN

.
, . 15.1, Network 8
FB 115 "Program Flow Control" (
STL_Book). FB 115
, LAD-,
: View -> LAD.
LAD-.

, , LAD- FBD-,
BR, "0"
(. ).


.
, BR "1", - BR
"0".

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15 - 13

15.

DIV_R

Input1

EN

ENO

Numb1

IN1

OUT

Numb2

IN2

Input2

ROUND

#tmp1 #tmp1

EN

ENO

IN1

OUT

#tmp2 #tmp2

MOVE
EN

ENO

IN1

OUT

Output1

Numb3

A(
A(
A(
A

Input1

JNB

M001

Numb1

Numb2

// EN
//

/R
T

tmp1

AN

OV

SAVE

//
// BR

CLR
M001:

BR

// BR ENO

JNB

M002

// EN

tmp1

RND
T

tmp2

AN

OV

SAVE
CLR
M002:

BR

)
A

Input2

JNB

M003

tmp2

Numb3

// EN

SET
SAVE
CLR
M003:

BR

)
=

Output1

15.1 EN/ENO
15 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15.

: BR "1".
,
, ,
( )
BR "0" JNB
, , (
"0").
SET

SAVE

//BR = "1"

...
L

10000;

Result;

// Result > 10000,

<=I

// BR = "0"

JNB

ERR;

// ERR

...
"Clock entry" 26.4 "
" BR
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

15 - 15

15.

15 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

16
(jump functions)

.
, ( - ,
).
(
)
.

JU

JC

, RLO = "1"

JCN

, RLO = "0"

JCB

, RLO = "1", RLO

JNB

, RLO = "0", RLO

JBI

, BR = "1"

JBI

, BR = "0"

JZ

, "0"

JN

, "0"

JP

, "0"

JPZ

, "0"

JM

, "0"

JMZ

, "0"

JUO

JO

( OV)

JOS

( OS)

JL

LOOP

,
STL. SCL

, , IF (. 28
" ").
, ,
STL_Book "Program Flow
Control" (" ")
FB 116 Chap_16.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

16 - 1

16.

16.1
,
, ,
,
, .
4 ,
.
. .
(),
.
. 16.1 .
L

C 10;

50;

>I

JC GR50;

, ,

JU SHAR;

GR50:

, ,

SHAR:

.16.1 .

;
RLO. RLO
JC.
( ) RLO =
"1", GR50.
.
( ) RLO = "0"
GR50 ,
.
(
, .., ), .
; ,
,
.
.
, ,
,
.
16 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

16.

()
. MCR,
MCR- MCR, .
STL

PG. (work)
CPU ( ).
, CPU,
PG
.
CPU PG,
.
(M001, M002
..) .

16.2
JU , ..
. JU

- , .
JU .
(), , , A I, O I
..,
,
.

16.3 RLO BR

RLO BR (. . 16.1). ,
RLO BR.
16.1 RLO BR
RLO

BR

"1"

"1"


JC

, RLO = "1"

--> "1"

JCB

, RLO = "1" RLO

"0"

JCN

, RLO = "0"

"0"

--> "0"

JNB

, RLO = "0" RLO

"1"

JBI

, BR = "1"

"0"

JNBI

, BR = "0"

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

16 - 3

16.


, RLO,
STA RLO "1", OR /FC "0",
, .

: RLO "1".
, RLO,
, ,
. (),
, , A I, O I ..,
, ()
, ,
( ).
, BR, STA
"1", OR /FC "0", ,
. BR RLO
.
:
;

. RLO

.
RLO = "1"
JC , RLO = "1"
. RLO = "0",
.
RLO = "0"
JCN , RLO = "0"
. RLO = "1",
.
RLO = "1" RLO
JCB , RLO = "1"
. JCB
BR "1". RLO = "0",

. JCB
BR "0" (.., RLO
BR).
RLO = "0" RLO
JNB , RLO = "0"
. JNB
BR "0". RLO = "1",

. JNB
BR "1" (.., RLO
BR).

16 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

16.

BR = "1"
JBI ,
BR = "1" .
BR = "0",
.
BR = "0"
JBIN ,
BR = "0" .
BR = "1",
.

16.4 CC0 CC1



CC0 CC1 (. . 16.2). , ,
, ,
( ). ,
CC0 CC1,
15 " ".
16.2 CC0 CC1
CC0

CC1


JZ

, = 0

JMZ

, = 0 < 0

JPZ

, = 0 > 0

JM

, < 0

JMZ

, = 0 < 0

JN

, <> 0

JP

, > 0

JPZ

, = 0 > 0

JN

, <> 0

JUO


, CC0 CC1,
. , RLO

( /FC).
(.
15 " ").
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

16 - 5

16.

,
JZ , CC0 = "0"
CC1 = "0". ,

accumulator 1
;

accumulator 2 ,
accumulator 1, ;

accumulator 1
;

.
JZ

.
,
JN ,
CC0 CC1 . ,

accumulator 1
;

accumulator 2 ,
accumulator 1, ;

accumulator 1
;

"1"
.

JN

.
,
JP , CC0 = "0"
CC1 = "1". ,

16 - 6

accumulator 1

(
JO JOS);

accumulator 2 ,
accumulator 1,
;

accumulator 1
;

"1"
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

16.

JP

.
,
JPZ , CC0 = "0".
,

accumulator 1

(
JO JOS);

accumulator 2 ,
accumulator 1,
;

JPZ

.
,
JM , CC0 = "1"
CC1 = "0". ,

accumulator 1

(
JO JOS);

accumulator 2 ,
accumulator 1,
.

JM

.
,
JMZ , CC1 = "0".
,

accumulator 1

(
JO JOS);

accumulator 2 ,
accumulator 1,
;

JMZ

.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

16 - 7

16.

,
JUO , CC0 = "1"
CC1 = "1". ,

(REAL)
.

JUO

.

16.5 OV OS

OV OS. ,
.
, OV OS,
15 " ".
,
() ( OV)

JO , OV = "1".
,
. OV
, :
;
;
;
REAL;
INT/DINT BCD
REAL DINT.
OV = "0", JO

.
,
OV ,
OV
,
.
OS
,

.

16 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

16.

,
() ( OS)

JOS , OS = "1".
,
,
OV (. ). OV, OS ,

. OS
:
;
JOS.
OS = "0", JOS

.

16.6 (Jump Distributor)


(Jump Distributor) JL
() ,
.
JL JU.
JU
JL 255 ().
JL ,
JU ( ,
JU).

Distributor) JL :
L
Number_of_positions; //
JL

End;

JU

M0;

JU

M1;

JU

M2;

(Jump

...
JU
End:

Mx;

...

Number_of_positions ,
accumulator 1.
JL ,
JU.
, ,
accumulator 1. 0,
.
1, .
,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

16 - 9

16.

( ,
JU).
JL .
JU,
, JL.
,
.

16.7 (Loop Jump)


(Loop Jump) LOOP
.
LOOP (word)
accumulator 1 16- 0
65535.
LOOP ()
accumulator 1 1.
, .
,
.
accumulator 1, ,
, .
. ()
.

:
L
Number;
Next:

LOOP

Counter;

...
...
...
L

Counter;

LOOP

Next;

...
Number ,
. Counter
, .
Counter ,
.
Counter
LOOP.
, Next.
Counter.
LOOP .
16 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

17 MCR
, (Master
Control Relay - MCR)
,
. :

.
,
MCR .
MCR
LAD-.
,
MCR
STL.
MCR STL.

MCR,
,
STL_Book "Program Flow Control"
(" ") FB 117
Chap_17.
,
(Master Control Relay - MCR)
.

MCR, (memory
functions)!
STL
MCR:

MCRA

MCR

MCR(

MCR

)MCR

MCR

MCRD

MCR

MCRA MCRD ,
MCR.
MCR( )MCR
MCR, MCR
.
MCR .
RLO,
MCR MCR- .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

17 - 1

17. MCR

17.1 MCR- (MCR Dependency)


(MCR) ,
() . ,
MCR, MCR-,

, :

(=):
"0"

Set (S) Reset (R):


Transfer (T):
"0"

STL (
) , ,
.
"0", MCR- ,
( )
.
, CPU
STOP ,
MCR ,
:

,
(, BLOCK_DB)

,
,
UDT.

MCR- , , MCR,
"" ,
.
MCR- , RLO "0"
(
MCR). MCR-
RLO, "1" ( MCR ),
MCR- MCR.
:
MCRA

17 - 2

Input0;

MCR(

Input1;

Input2;

Output0;

)MCR

// MCR
// MCR-

// MCR-
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

17. MCR

MCRD

// MCR

Input0 = "0"
Output0 "0". Input0 "1",
Output0 Input1 Input2.

17.2 MCR- (MCR Area)


,
(MCR), - MCR- (MCR
Area) MCRA MCRD. MCR-
MCR- ( )
MCRA
;
// MCR
...
...

//MCR-

...
MCRD

// MCR

MCRA MCR-, MCRD


. MCR-,
MCR- (.
. 17.1). MCR-
MCRA.
, MCR-
,
, MCR-
.

Block 1

Block 2

Block 3

MCRA
MCRA
MCRA

MCRD

MCRD

. 17.1 MCR-
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

17 - 3

17. MCR

17.3 MCR- (MCR Zone)


MCR- (MCR Zone)
MCR( )MCR. MCR- MCR-
RLO = "0" RLO = "1".
...
// MCR
...

// "0"

Input3;

MCR(

// MCR-

...
...

//MCR-

...
)MCR

// MCR-

...
MCR( )MCR
().
MCR- MCR-.
MCR- 8, ,
8 , .
MCR- , MCR-
MCR- RLO. , MCR-
MCR- , MCR MCR- .
(MCR) MCR- MCR-
(. . 17.2).

MCRA
A Input3
MCR(
[MCR zone 1]
A Input4
MCR(
[MCR zone 2]

MCR-
MCR- 1 MCR- 2

MCR-
,
MCR-
MCR- 1

)MCR
)MCR
MCRD
. 17.2 MCR- MCR-

17 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

17. MCR

MCR- MCR-.
MCR-,
, (
). , MCR-
MCR- MCRA
(. . 17.3).
Block 1

Block 2

MCRA

A Input5
MCR(
[MCR zone 1]

MCRA
[MCR zone 1]
A Input6
MCR(
[MCR zone 2]

)MCR
)MCR
MCRD

MCRD

. 17.3 MCR-
. 17.3 Input5 Input6 MCR-.
Input5 MCR-
( "0"), Input6.
MCR- 1 Input5 = "1",
MCR- 2 Input6
(. . 17.1).
17.1 MCR-
MCR-

Input5

Input6

"1"

"1"

"1"

"0"

"0"

"1" "0"

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

Zone 1

Zone 2

MCR-
MCR

MCR-

MCR-

17 - 5

17. MCR

17.4 (I/O )
MCR- (Set)
(Reset) I/O .
, , ,
.
SFC 79 SET I/O ,
SFC 80 RSET (.
. 17.2). MCR-.
, MCR-
; MCR- ,
.
17.2 SFC I/O-
SFC

79

INPUT

INT

RET_VAL

OUTPUT

INT

SA

OUTPUT

POINTER

INPUT

INT

RET_VAL

OUTPUT

INT

SA

OUTPUT

POINTER

80

I/O-
.
/ (I/O) (
). , SFC-, (
) ,
.
:
CALL SFC 79 (
N

:= 8,

RET_VAL

:= MW 10,

SA

:= P#12.0);

CALL SFC 80 (
N

:= 16,

RET_VAL

:= MW 12,

SA

:= P#13.5);

SFC 79 SET I/O-,


Q 12.0 ... Q 12.7; SFC 80 RSET
I/O-, Q 13.5 ... Q 15.5.
17 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

17. MCR

N , ,
SF ( "" - POINTER)
, . SFC
RET_VAL,
, .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

17 - 7

17. MCR

17 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18 (Block Functions)
,
, ,
STL.
.
3.4 "
STL" 3.6 "
".
SCL,
29 "SCL ".
, ,
STL_Book "Program Flow
Control" (" ")
FB 118 Chap_18.

18.1

(. . 18.1).
18.1


CALL
In1
In2
Out

CALL name (
In1 := Number1;
In2 := Number2;
Out := Number3);

FB
:=
:=
:=

10, DB 10 (
Number1;
Number2;
Number3);




UC FB 11;
CC FB 11;

CALL FB 10 (
In1 := Number1;
In2 := Number2;
Ret_Val := Number3);

CALL FB 10 (
In1 := Number1;
In2 := Number2;
Out := Number3);






BEC

BEU

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL




UC FB 11;
CC FB 11;


BE

18 - 1

18.

CALL.

.
. CALL
,
.
,
UC CC.
.

18.1.1 :
, "".
. 18.1 FC 10
OB 1.


,
,
OB 1

,
,
FC 10

CALL
IN1
IN2
OUT

FC
:=
:=
:=

10
I 1.0
I 1.1
Q 4.0

...
A IN1
A IN2
= OUT
...

...
A I 1.0
A I 1.1
= Q 4.0
...

BE

. 18.1
( : CALL FC 10)
. ,
.
CPU
( : FC 10). ,
.
CPU
( : OB 1);
.
, CPU
18 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.

.
, CPU ,
(B- [B stack]).
B- ,
,
. CPU STOP
, ,
B- ,
.

.
(, , ,
RLO),
( "" ,
).

18.1.2 CALL
CALL
FB, FC,
SFB, SFC. CALL
, ,
, . (
;
, ).

FB,
CALL,
, .
, .

(Symbol Table) ,
.
.

;
.

.

. ,
.

"" ("multi-instance-capable"),
,
"" . ,


.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

18 - 3

18.


,
(
).

" ". 18.1.6
" ".

FC,
CALL, , .
.

; .
;
, .
,
.
, ,
RET_VAL.

CPU SFC
SFB, .
CPU.
CALL.

, , ;

(user memory) SFB.
, ,
.
CPU.

(offline) ,
, .
Standard library
System Function Blocks.
()
"Blocks", .

"" .

18.1.3 UC CC

UC CC. ,

, ,
. ,
, .
18 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.

UC CC,
.
,
. UC CC
FC FB.
.
UC , ,
UC .
CC , ,
CC ,
(RLO) "1". RLO "0", ,
RLO "1".
.
( "condition code"):
OS ;
CC0, CC1 OV ,
/FC , ,

.
" " ("binary nesting stack"):
" ".
.
,
(binary nest), ,

.
MCR:
MCR- . MCR
, ,
MCR .
MCR- ,
.
:

UC CC.
:
B-;
.
,
.
(,
OB 1),
, ,
.
:

FB FC
UC CC;


UC;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18 - 5

18.


CC .

18.1.4 (Block End Functions)


BEC ,
RLO, BEU BE
.
BEC
BEC,
, RLO.
RLO = "1" BEC,
.
,
.
RLO = "0" BEC,
. CPU RLO "1"
BEC .
()
.
BEU
BEU ;
BEU .
,
.
BE BEU
. ,
BEU,
.
BE
BE ; BE
.
,
.
BE .
BE .
""
, ; ,
, ,
, END_FUNCTION_BLOCK BE.

18.1.5

18 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.

, .

; .
,
( L-)
CPU. CPU
.
L-
"" . ,
, , , .
, L-
.
, ,
.
, L-
. ,
( ,
: File -> Properties ( -> ),
SIMATIC Manager :
Edit -> Object Properties ( -> ),
"General - Part 2" (" 2")).


:


"Declaration" ("") "temp"
();

,
,
: VAR_TEMP END_VAR.

. 18.2
. temp1,
INT, temp2
REAL.
L-
.
L-
26.2 " ".


.
,
() .
, ,
. , ,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18 - 7

18.

,
.
,


Address
()

Declaration
()

Name
()

Type
()

0.0

in

In

INT

Initial value
(
)
0

out

VAR_INPUT
In
: INT := 0;
END_VAR
VAR_OUTPUT ... END_VAR

inout

VAR_IN_OUT ... END_VAR

2.0

stat

Total

INT

0.0
2.0

temp
temp

temp1
temp2

INT
REAL

VAR
Total : INT := 0;
END_VAR
VAR_TEMP
Temp1 : INT;
Temp2 : REAL;
END_VAR

. 18.2 .

. (:

.)
L-
L- CPU.
,
,
. S7-300 L- , , 256
CPU 314. S7-400 L-
.
CPU.
,
,
, , .
,
, ,
.
.
(Start information)
CPU (start
information)

.
20
. 20 " ",
21 " ", 22 " " 23
18 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.

" "
.
20
.

(
),
20 , ,
, OB
.
,
. .
Standard Library
Organization Blocks ( ).
,
20 , , ( . 18.3).


Address
()

Declaration
()

Name
()

Type
()

0.0

temp

SINFO

INT

*1.0
20.0
*1.0

temp
temp
temp

Initial value
(
)
ARRAY
[1..20]

VAR_TEMP
SINFO : ARRAY[1..20]
OF BYTE;
Lbyte : ARRAY[1..16]
OF BYTE;

BYTE
Lbyte

INT

ARRAY
[1..16]

BYTE

BYTE

END_VAR

. 18.3 .


,
. ,
L-,
.
.
L;
L, -
LB, - LW,
- LD.
:
16
,
,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18 - 9

18.

, 0.

,
, 20.
:

STL, LAD FBD.
SCL
.
26 " " ,

.
ANY
,
, ANY.
STL
ANY,
.
26.3.3 """ ANY".
SCL
ANY ()
.
29.2.4 " ".

18.1.6
- ,
.
- "" .
, ,
.
,
,
,
CPU.


:

18 - 10


"Declaration" ("") "stat"
();

,
,
: VAR END_VAR.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.

. 18.2 18.1.5 " "


.
,
, , .


.

26.2 " ".


.
,
() .

,
.
:
"Totalizer" (input
value) , , (stored
value)
.

, , (.
. 18.4. ()).
Total - "TotalizerData",
"Totalizer" (

Symbol Table ).
.
INT
In Total.


. , .
.
,

: ""."".
"TotalizerData",
Total.
:
L

"TotalizerData".Total;

MW 20;

0;

"TotalizerData".Total;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18 - 11

18.

FB "Totalizer" ("")

DB "TotalizerData"

Address

Declaration

+0.0

in

In

INT

+0.0

in

In

INT

+2.0

stat

Total

INT

+2.0

stat

Total

INT

Type

Add

BOOL

#In;

#Total;

+I

#Total;

Name

Type

Address

Declaration

Name

Type

FB "Evaluation" ("")
DeclaAddress
ration
Name

0.0
in
Add

BOOL

DB "EvaluationData"
DeclaAddress
ration

0.0
in

0.1

in

Delete

BOOL

0.1

in

Delete

BOOL

2.0

stat

EM_Add

BOOL

2.0

stat

EM_Add

BOOL

2.1

stat

EM_Del

BOOL

2.1

stat

EM_Del

BOOL

4.0

stat

Memory

Totalizer

4.0

stat:in

INT

6.0

stat

Memory.In
Memory.
total

#Add;

FP

#EM_Add;

JCN

M1;

CALL #Memory
(In := "Value2");
M1:

#Delete;

FP

#EM_Del;

JCN

End;

#Memory.Total;

"Result";

0;

#Memory.Total;

Name

Type

INT

: Data view
( ) ,

.


.

. 18.4 .

18 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.



.

.
STEP 7 V2, "",
,
. (
)
. ,

2, "".

8 .
(. 18.4 ()):
"Evaluation" Memory,
"Totalizer"
.
"Totalizer" Memory,
, Memory ("blocklocal") (Memory "
" "Totalizer").
Memory
"Evaluation" ,
(Memory)
(Total).
"EvaluationData", ,
Memory.In Memory.Total,
, ,
: "EvaluationData".Memory.Total.

FB 6, 7 8 "Program Flow Control"
. 19.5.3 " "
.


,
.
DI.
,
DI.
DIX, - DIB, -
DIW, -
DID.
, ,
.

. !
. ,
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

18 - 13

18.

,

.
, ,
,
.
: Select View -> Data View ( ->
).
. "Totalizer"
Total DIW 2, FB
"Totalizer" (. DB
"TotalizerData"), DIW 6, FB "Totalizer"
FB "Evaluation" (.
DB "EvaluationData").
, ,
,
, :
?
,
AR2. (.
25 " " 26 " "
).
:

STL, LAD FBD.
SCL
.

18.2
.
,
(bit memory area). , ,
, ,
.

,
.

:
(global data blocks),
, (instance data blocks),
.
, , "" ,
. ,
,
.
18 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.

,
;
""
.
CPU.
1;
DB 0.
.
,
,
, SFC 22 CREAT_DB
.
(work) ,
/
. (load)
, "Unlinked" ( UNLINKED

).
(work) .
, (load)
SFC 20 BLCMOV.

(recipe) ,
.
"The data block is writeprotected in the
programmable controller" (" PLC")
(
READ_ONLY
),
DB.

18.2.1
CPU " " (data block register)
.
; ,
.
, , ,
.
(
. ),
.
.

,
.
,
: DB ("Global data block register")
DI- ("Instance data block register").
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

18 - 15

18.

CPU .

( ).
, ,
.
DB-,
DBW;
DI-, DIW.

(. . 18.2).
18.2


DB-

DI-

DBX y.x

DIX y.x

DBB y

DIB y

DBW y

DIW y

DBD y

DID y

x = ,
y =

18.2.2

:


25 " ".

.

, ,
.


, .

(
),

18 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.

( ,
; "
", , DBB 156 DBB 165,
,
),
(
, CPU
).
(
, ),
.
:
.
,
.
(, Motor1)
(, DB 51).
.

)
("associated")
"" - "block-local").
.

(
.
(



.
,
.
L
MOTOR1.ACTVAL;
L

DB 51.DBW 20;

MOTOR1 c ,
. ACTVAL - ,
.
MOTOR1.ACTVAL -
, DB 51.DBW 20.

( DB).
: DB, .

.
,
, (load)
(transfer) .
(
19 " ").

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18 - 17

18.



,
, (setting up). ,
.
,
.
- ,
, ,
.
,
( ).
,
26.2 " ".
, ,
, , ; ,
(. . 18.3),
.
18.3

A
O
X
AN
ON
XN
=
S
R
FP
FN

DBXy.x
DIXy.x
DBz.DBXy.x

"1", AND () .
"1", OR () .
"1", Excl.OR (.) .
"0", AND () .
"0", OR () .
"0", Excl.OR (.) .
.
.
.
() .
() .
DB-
DI-

L
T

DBBy
DBWy
DBDy
DIBy
DIWy
DIDy
DBz.DBBy
DBz.DBWy
DBz.DBDy

.
.
DB-
DB-
DB-
DI-
DI-
DI-


x = , y = , z =
18 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.


,
.

18.2.3
OPN DBx

DB-
;

OPN DBname

DB-
;

OPN DIx

DI-
;

OPN DIname

DI-
;

.
RLO, ;
.
(work) .
:
DBW 10 DB 12
DBW 12 DB 13 (. 18.5).
DBW 14 DB 12 DB 13
; DBW 14
DB 14.

:
(. . 18.5).
DB 13

DB 12

DB 14

DBW 10
DBW 12
DBW 14

DBW 14

DBW 14

. 18.5

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18 - 19

18.

. 18.5


OPN
L
OPN
T

DB 12;
DBW 10;
DB 13;
DBW 12;

OPN
L
OPN
L
+I
OPN
T

DB 12;
DBW 14;
DB 13;
DBW 14;
;
DB 14;
DBW 14;

DB 12.DBW 10;

DB 13.DBW 12;

DB 12.DBW 14;

L
+I

DB 13.DBW 14;
;

DB 14.DBW 14;

, "" ("valid"), ,
.
(.
", "). ,
CALL
.
UC CC
.

.

18.2.4
CDB

CDB
.
,
.
:
CDB "" DB
DI;
( ).
CDB ;
OPN

#Data2;

CDB

CDB DB-
DI-. #Data2
18 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.

, ; ..,
DB-.
, DB-, DI .

18.2.5
L

DBLG

(Load) ,
DB-;

DBNO

(Load) ,
DB-;

DILG

(Load) ,
DB-;

DINO

(Load) ,
DB-;

L DBLG (load) ,
DB- accumulator 1.
. L DILG
, ,
DI-.
L DBNO (load) ,
DB- accumulator 1. L DINO
, ,
DI-.

accumulator 1,
accumulator 2, ""
(load).
(load)
, accumulator 1
(0)
.

;
OPN DB, OPN DI CDB
( ).

18.2.6 ,
DB-

,
:

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18 - 21

18.


,
,
OPN DB, .
()
DB-.
.

DB-
: ,
, /
.
CALL FB
, CALL FB
DB-
( )
.
,
.
CALL FB DB-
,
. CALL FB
DB-.
DI-
DI-
.

DI- AR2
"" .
:
DI-, DI-
CDB OPN DI.
, ,
,
, .
, . 18.6,
.

"Blocks" ("")
Blocks ,
: -

.
"Absolute address has priority"
(" ") ( ,
STEP 7). , ,
, ,
,

18 - 22

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.

. "Symbol has priority" ("


") ,
, ,
.
Var_Temp
ZW_DB : WORD;

// //

ZW_DI : WORD;

//
//

END_VAR
//
L

DBNO;

ZW_DB;

DINO;

ZW_DI;

//
// .

//
//
OPN

DB 12;

// DB 12 DB-

OPN

DI 13;

// DB 13 DI-

DBW 16;

//#########

DIW 28;

//# .

DID 30;

//# , .

DBD 30;

//# ,

+R

//# ""
//#

DID 26;

//#########

//
OPN

DB[ZW_DB];//
//

OPN

DI[ZW_DI];//

. 18.6

:
DB 1 DBW 10
Actual_value. "Data"
DB 1, ,
, :
L

"Data".Actual_value

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

DB1.DBW 10

18 - 23

18.


MaxCurrent DBW 10,

( ) :
"Absolute address has priority" ("
"):
L

"Data".MaxCurrent

DB1.DBW 10

"Symbol has priority" (" "):


L

"Data".Actual_value

DB1.DBW 12


(, ),
.

2.5.6 " ".

18.3
.
18.4.

SFC 22 CREAT_DB

SFC 23 DEL_DB

SFC 24 TEST_DB

18.4
SFC
22

23
24

18 - 24

LOW_LIMIT

INPUT

WORD

. DB

UP_LIMIT

INPUT

WORD

. DB

COUNT

INPUT

WORD

DB ( )

RET_VAL

OUTPUT

INT

DB_NUMBER

OUTPUT

WORD

DB_NUMBER

INPUT

WORD

RET_VAL

OUTPUT

INT

DB_NUMBER

INPUT

WORD

RET_VAL

OUTPUT

INT

DB_LENGTH

OUTPUT

WORD

DB

WRITE_PROT

OUTPUT

BOOL

= "1", DB

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18.

18.3.1
SFC 22 CREAT_DB
(work) .

, LOW_LIMIT ( )
UP_LIMIT ( ).
.
, .
DB_NUMBER
. COUNT
() .

.
.
( ) ("valid") .
, ,
. ,
, ,
.
.
,
, DB_NUMBER
, .

18.3.2
SFC 23 DEL_DB
RAM ( [work] [load] ).

DB_NUMBER.
, CPU
STOP.
, UNLINKED (),
, FEPROM
SFC 23.
,
, .

18.3.3
SFC 24 TEST_DB
(work)
DB_LENGTH, ID

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

18 - 25

18.

WRITE_PROT.
DB_NUMBER.

,
, ,
.

18.4 Null- (-)


Null- (-)
. STL
NOP 0, NOP 1 BLD, Null- ().

18.4.1 NOP
NOP 0 ( 16 "0") NOP 1
( 16 "1") ,
.
:
, Null- (-)
(2 )
.
:
,
. ,
,
NOP 0.
A
I 1.0
JC

MXX1

...
MXX1:

NOP 0


( ) (

, ).

18.4.2 BLD
BLD nnn
.
BLD .

18 - 26

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19
, ;
, ,
() ,
,
,
("pass on") .

. , ,
.

19.1 :
19.1.1

.
: (adder),

.
;
(. . 19.1).
,
.
"" (input
parameter), (Check - .., )
(Load) .
( Set, Reset, Assign, Transfer),
"" (output parameter).
, ,
"/" (in/out parameter).
.

19.1.2

"" ,
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

19 - 1

19.

Block header ( )
Adder
Numb_1

Block type, Name


,

+INT

Numb_2

FC 12
STL
Name :Adder
Author:Berger
Family:STL_Book
Ver: 01.00
Declaration table ( ')

Numb_3

Result
parameter

Input parameter
(
)
INT

Output parameter
(
)
INT
program

Declaration
'
in
in
in
out

Name

Numb_1
Numb_2
Numb_3
Result

Type

INT
INT
INT
INT

Program ()
L
L
+I
L
+I
T

Numb_1;
Numb_2;
;
Numb_3;
;
Result;

. 19.1
,
;
(Formal parameters).
"Adder" .

(. . 19.2).
, ;
(Actual parameters).
CPU
. (. 19.2)
MW 30, MW 32 MW 34,
MW 40.
"Adder" ,
,
DBW 30, DBW 32 DBW 34 DB 10,
DBW 40 DB 10.

19.1.3 (declaration)
,
.

19 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.

//First call ( )
Call "Adder"
Numb_1 := MW
Numb_2 := MW
Numb_3 := MW
Result := MW

//

30
32
34
40

10.DBW
10.DBW
10.DBW
10.DBW

Numb_1

Numb_2

+I
L

//Second call ( )
Call "Adder"
Numb_1 := DB
Numb_2 := DB
Numb_3 := DB
Result := DB

30
32
34
40

Numb_3

+I
T

Result

L
L
+I
L
+I
T

MW 30
MW 32
MW 34
MW 40

//
L
L
+I
L
+I
T

DB 10.DBW 30
DB 10.DBW 32
DB 10.DBW 34
DB 10.DBW 40

. 19.2

. ,
,
(. 19.3). :
VAR_INPUT - , VAR_OUTPUT -
VAR_IN_OUT - / .
()

,
. ,
.

.
(Block parameter name) 24 .
-
( , )
.
. .

.
, .
Data type :
(elementary), (complex) (userdefined).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19 - 3

19.


Address
()

Declaration
()

Name
()

Initial value
(
)

Type
()

0.0

in

Manual

BOOL

TRUE

2.0

in

Setpoint

INT

10000

4.0

in

Characteristic

ANY

14.0

out

Actual_value

INT

16.0

out

Temperature

REAL

0.000000e+00

20.0

out

Message

WORD

W#16#0

22.0

in_out

EM

ARRAY[1..16]

*0.1

in_out

*28.0

in_out

Comment
()


Motor 1
Point

Motor 1

Motor 1

BOOL
Interface

DWORD

DW#16#0


Motor 2

,
VAR_INPUT
Manual
: BOOL
Setpoint
: INT
Characteristic : ANY;
END_VAR

:= TRUE;
:= 10000;

//
// Motor 1
//

:= 0;
:= 0.0;
:= 16#0000;

// Motor 1
// Motor 1
//

VAR_OUTPUT
Actual_value
Temperature
Message
END_VAR

: INT
: REAL
: WORD

VAR_IN_OUT
EM
Interface
END_VAR

: ARRAY[1..8] OF BOOL; //
: DWORD := 16#00000000; // . Motor 2

. 19.3

19 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.

,
.
STEP 7
PG. (work)
CPU ( )
( Declaration) (
Type). ,
(online) CPU,

PG, .
PG CPU
PG,
, .
, ,
( INn,
OUTn /
INOUTn, n ,
1).

19.1.4 (declaration)
( ) .
RET_VAL ( ret_val) .

. ,
: DATE_AND_TIME, STRING, POINTER, ANY
UDT. ,
, ARRAY STRUCT.
"Adder"
Result
.
,

,
, (
),
:
FUNCTION FC 12 : INT
VAR_INPUT
Numb_1 : INT;
Numb_2 : INT;
Numb_3 : INT;
END_VAR
BEGIN
L
Numb_1;
L
Numb_2;
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

19 - 5

19.

+I ;
L
Numb_3;
+I ;
T
RET_VAL;
END_FUNCTION
RET_VAL INT.
"T RET_VAL"
Numb_1, Numb_2 Numb_3.


RET_VAL
.
FC.

. "T RET_VAL"
Numb_1,
Numb_2 Numb_3.

19.1.5 (Initialization)

. ,
,
.
, (. . 19.3
" ").
STEP 7 V5.1
,
.
.

(.., )
.

19.2
,
. . 19.1 ,
, ,
.
POINTER
ANY STL
. ,
,
, .

19 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.

, 26 " " ,
,
.
19.1 ( )

IN

I_O

OUT

BOOL

BYTE, WORD,
DWORD, CHAR, INT,
DINT, REAL, S5TIME,
TIME, DOT, DATE

STL

(load)
(transfer)

STL

TIMER

COUNTER

BLOCK_FC, BLOCK_FB

UC CC2)

BLOCK_DB

OPN DB

BLOCK_SDB

3)

POINTER, ANY

x1)

STL

:
,

(load)
(transfer)

:
DT, STRING
ARRAY, STRUCT

1)

2)

CC

3)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19 - 7

19.

BOOL
BOOL
.
() /
(with contacts)
/
.
FC -

() .
. 19.2 BOOL.

, xxxx.
, CPU ,
,
(. . 19.2) 4
" " 5 " ".
19.2 BOOL
A
AN
O
ON
X

XN

xxxx
xxxx
xxxx

Exclusive OR ( )
"1"
Exclusive OR ( )
"0"
/ BOOL
TIMER
COUNTER

S
R
=
-

xxxx

SET ()
RESET ()

/ BOOL

FP
FN
-

xxxx



/ BOOL

AND () "1"
AND () "0"
OR () "1"
OR () "0"


8, 16 32 (
, BOOL).

.
/ (load)
,
/ (transfer).
19 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.

FC (transfer)
.
.
L
T

xxxx
xxxx

/
/


, xxxx.
, CPU ,
,
6 "
".
DT STRING
DT STRING
. ,
DT STRING
.
26 " " ,

.
ARRAY STRUCT
ARRAY STRUCT
"" , ..,

(
, , [load]
[transfer]).
( )
,
. ,

("pass on") ARRAY STRUCT
.
26 " " ,

.


, STRUCT.

UDT
( ,
, [load] [transfer]).


.
("pass on")
UDT .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

19 - 9

19.

26 " " ,

.
TIMER
(), . 19.2,
TIMER
:
SP

"" ("pulse")

SD

" " ("ON


delay")

SE

" "
("extended pulse")

SS

"
" ("retentive ON delay")

SF

" " ("OFF


delay")

("reset")

FR

("enable")

xxxx

TIMER


, xxxx.
, CPU ,
, STL
, 7 " ".
"time value"
S5TIME.
COUNTER
(), . 19.2,
COUNTER
:
S

("set")

CU

" " ("count up")

CD

" " ("count


down")

("reset")

FR

("enable")

xxxx

COUNTER


, xxxx.
, CPU ,
, STL
, 8 " ".
"count value"
, , WORD.
19 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.

BLOCK_xx
OPN -


BLOCK_DB)

UC

( BLOCK_FC)

UC

BLOCK_FB)

CC

( BLOCK_FC)

CC

(
BLOCK_FB) (. )

xxxx


, xxxx.
, CPU
(DB-).
,
, .
,
.
,
, .
, ,
,

.
:
BLOCK_DB
#Data
:
CALL FB 10, #Data
POINTER ANY
POINTER ANY .
26 " " ,

POINTER ANY.

19.3
,
, ,
. .
,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19 - 11

19.

.
,
.
(, )
BOOL;
ARRAY ,
. . 19.3 ,
.
. 19.3

, ,


TIMER,
COUNTER,
BLOCK_xx

POINTER
ANY

,
D-

ANY

. STEP 7
,
TIMER, COUNTER BLOCK_xx
. /
POINTER ANY
. ,
,
.
.
, .
:
"Lift_stat_1"
Up.
,
() :
A

"Lift_stat_1".Up

()
.

19 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.


, . 19.4,
.
19.4

IN

I_O

OU
T

( )

I y.x

IB y, IW y, ID y

( )

Q y.x

QB y, QW y, QD y

M y.x

MB y, MW y, MD y

PIB y, PIW y, PID y

PQB y, PQW y, PQD y

x
x

x
x

x
x

DBX y.x
DBz.DBX y.x

DBB y, DBW y, DBD y


DBz.DBB y,
DBz.DBW y,
DBz.DBD y

L y.x

LB y, LW y, LD y

DIX y.x

DIB y, DIW y, DID y

TRUE, FALSE

x = , y = , z =

, ,
.
;
( , ).
, ,
/ .
,
""
( ).
,
.
.

. L- (
).
,

(. 19.4 " "Pass On" ").

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19 - 13

19.

.
DI- (DI), ""
DI- (
).
: ,
,
(block-local - )
.
BOOL
TRUE ( - "1") FALSE
( - "0").
,
.
.

,
.

(UDT) .
, ,
.
DT STRING

, .
STL.

STRING,
STRING.
STRING ,
,
"" .

IEC-
( STRING IEC-
).
ARRAY STRUCT

.
26.4 "
" "
" " ( TOD)".


(UDT) .
UDT- , - , ,

19 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.

.
.
() ( UDT-)
.
26.4
" " "
".
TIMER, COUNTER BLOCK_xx
TIMER
, COUNTER .
BLOCK_FC BLOCK_FB
.
UC ( CC
).
BLOCK_DB ,
DB-.
26.4
" " "
".
TIMER, COUNTER BLOCK_xx
.
POINTER
POINTER
().
(32-), DB (48).
;
.

POINTER.
ANY
ANY
.
, ( )
, .
ANY
"p#[Data_block.]Address Data_type Number"
.
ANY
ANY. ,
ANY ,
.
ANY ANY,
. "
ANY" , ,
SFC 20 BLKMOV (. " " 26.4
" ").
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

19 - 15

19.


ANY.

19.4

("Pass On")
("Pass On") -
.
("passed on")
.

.
,
, ( ,
). ,

, , ,
. /
(, /) .
, ,
-
.
("pass on")
, .
,
.
TIMER, COUNTER BLOCK_xx
,
. . 19.5


.
("pass on") TIMER,
COUNTER BLOCK_xx
.
WORD INT;
, ,
. ("pass
on") , .
( - "last")
"load"
,
, .

19 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.

. 19.5 ("pass on")

--->

( )

FC FC FB FC FC FB FB FB
E

Input -> Input


x
x
x
x
( -> )
Output -> Output
x
x
x
x
( -> )
In/Out -> Input
x
x
x
(/ -> )
In/Out -> Output
x
x
x
(/ -> )
In/Out -> In/Out
x
x
x
(/ -> /)
E =
C =
P = TIMER, COUNTER BLOCK_xx

19.5

19.5.1 :
.

, 5 "
".
,
, ,

( ). . 19.4
,
.
:
,
, ,
,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19 - 17

19.

FB "Conveyor_belt"
BOOL

Start

Readyload

BOOL

BOOL

Continue

Ready_rem

BOOL

BOOL

Basic_st

Belt_mot_on

BOOL

BOOL

Man_on

BOOL

Stop

BOOL

End_of_belt

BOOL

Mfault
STAT
Load

BOOL

Remove

BOOL

EM_Rem_N

BOOL

EM_Rem_P

BOOL

EM_Loa_N

BOOL

EM_Loa_P

BOOL

. 19.4
, ,
, .
"Conveyor_belt"
. :
- 1, -
2.
,
.
1 "Belt_data1", 2
"Belt_data2" ..

STL_Book "Conveyor Example" ,
.
,
.
;
.
, , DB 21
"Belt_data1" DB 22 "Belt_data2".
.

, , , OB 1.
.
,

19 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.

, .

19.5.2 :
.
"Parts Counter" (" ") 8 " "
.
,
,
(. 19.5).
FB "Parts_counter"
BOOL

Set

BOOL

Acknowledge

BOOL

Light_barrier

COUNTER

Finished

BOOL

Fault

BOOL

Count

WORD

Quantity

TIMER

Tim

S5TIME

Dura1

S5TIME

Dura2
STAT
Active

BOOL

EM_LB_P

BOOL

EM_LB_N

BOOL

EM_Ac_P

BOOL

EM_ST_P

BOOL

TEMP
PM_LB_P

BOOL

PM_LB_N

BOOL

. 19.5

TIMER COUNTER.
. (Quantity)
(Dura1 Dura2)
;
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19 - 19

19.

,
.

STL_Book "Conveyor Example" ,
.

"Parts_counter", "Count_Dat",
.

19.5.3 :
, ,
.
,
"Feed" (" ")
,
. FB "Conveyor_Belt"
(" ") , FB
"Parts_Counter" ("C ") - .
FB ,

"Feed".
. 19.6 ,
( FB "Parts_Counter"
).
"Feed"
/M_fault1
Light_barrier1
Belt_mot1_on
Start

Start

Load

Ready_load

Reset

/M_fault4
Light_barrier4
Belt_mot4_on

Ready_rem
Belt1
(1) Continue

Start

Ready_rem

Ready_load

Belt4
(4)

Remove

Continue Removed

Basic_st

Man_start

Man_on

Stop

Stop
Belt1, ... , Belt4 - "Conveyor_Belt"
. 19.6 "Feed"

19 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.

(Start) Start
Belt 1, Ready_rem Start
Belt 2, .. , , Ready_rem
Belt 4 Remove "Feed".
Removed ->
Continue -> Ready_load -> ... -> Load.
Belt_motX_on, Light_barrierX /M_faultX ( ) -
.
Reset, Man_start Stop
Basic_st, Man_on Stop .
"Feed"
.
. 19.5. ,
Quantity Dura1 Dura2
.

,
UDT, .., .
Belt1
"Conveyor_Belt", Belt2, ..., Belt4;
Check
"Parts_counter".

.
, ,
,
, , .
Man_start
Man_on
.
Basic_st Stop
Reset Stop .
.
(
).


,
"Feed".
(Light_barrierX),
(
/M_faultX
Belt_motX_on). ( ,
).

.
FB "Parts Counter" (" ")
, ,
.
"Feed" FB.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19 - 21

19.

Quantity Dura1
Dura2 "Feed"
. ,
( ),
OB 100 (, ,
).
"Feed"
"FeedDat" STL_Book
"Conveyor Example".
.

19 - 22

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19.

FUNCTION_BLOCK "Feed"
TITLE = Control of several conveyor belts //
//
// "local instances"
//declaration (), calls ()
NAME
: Feed
AUTHOR
: Berger
FAMILY
: STL_Book
VERSION
: 01.00
VAR_INPUT
Start
: BOOL
:= FALSE;
//
Removed
: BOOL
:= FALSE;
//
Man_start : BOOL
:= FALSE;
//
Stop
: BOOL
:= FALSE;
//
Reset
: BOOL
:= FALSE;
//
// (basic_st)
Count
: COUNTER;
//
Quantity : WORD
:= W#16#0200;//
Tim
: TIMER;
//
Dural
: S5TIME
:= S5T#5s;
// /
Dura2
: S5TIME
:= S5T#10s; // /
END_VAR
VAR_OUTPUT
Load
: BOOL
:= FALSE;
//
Remove
: BOOL
:= FALSE;
//
END_VAR
VAR
Beltl : "Conveyor_belt";
// belt 1
Belt2 : "Conveyor_belt";
// belt 2
Belt3 : "Conveyor_belt";
// belt 3
Belt4 : "Conveyor_belt";
// belt 4
Check : "Parts_counter";
//
//
END_VAR
BEGIN
NETWORK
TITLE = Initializing the common signals //
//
A
Man_start;
=
Beltl.Man_on;
=
Belt2.Man_on;
=
BeIt3.Man_on;
=
Belt4.Man_on;
A
=
=
=
=

Stop;
Belt1.Stop;
Belt2.Stop;
Belt3.Stop;
Belt4.Stop;

A
=
=
=
=

Reset;
Beltl.Basic_state;
Belt2.Basic_state;
Belt3.Basic_state;
Belt4.Basic_state;
( )

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

19 - 23

19.

NETWORK
TITLE = Calling the conveyor belt controls //
//
CALL Beltl (
Start
:= Start,
Readyload
:= Load,
End_of_belt
:= Light_barrierl,
Mfault
:= "/Mfaultl",
Belt_mot_pn
:= Belt_motl_on);
A Belt2.Readyload;
= Beltl.Continue;
A BeIt1.Ready_rem;
= Belt2.Start;
CALL Belt2 (
End_pf_belt
:= Light_barrier2,
Mfault
:= "/Mfault2",
Belt_mot_on
:= Belt_mot2_on);
A Belt3.Readyload;
= Belt2.Continue;
A Belt2.Ready_rem;
= Belt3.Start;
CALL Belt3 (
End_of_belt
:= Light__barrier3,
Mfault
:= "/Mfault3",
Belt_mot_on
:= Belt_mot3_on);
A Belt4.Readyload;
= Belt3.Continue;
A Belt3.Ready_rem;
= Belt4.Start;
CALL Belt4 (
Continue
Ready_rem
End_of_belt
Mfault
Belt_mot_on

:=
:=
:=
:=
:=

Removed,
Remove,
Light_barrier4,
"/Mfault4",
Belt_mot4_on);

NETWORK
TITLE = Call for counting and monitoring // /
CALL Check (
Set
:= Start,
Acknowledge
:= "Acknowledge";
Light_barrier := Light barrier 1,
Count
:= #Count,
Quantity
:= #Quantity,
Tim
:= #Tim,
Dura1
:= #Dural,
Dura2
:= #Dura2,
Finished
:= Finished,
Fault
:= "Fault");
NETWORK
TITLE = Block end
BE
END FUNCTION BLOCK

19 - 24

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20

,
.
(main program) .
CPU
. ""
PLC.

, ,
. ,
CPU,

.
,
(interrupt servicing).
: (hardware
interrupts), (watchdog interrupts), (
) (time-of-day interrupts),

(time-delay
interrupts),

(multiprocessor interrupts)
.
.
,
,
( )
.
CPU
(start-up program),
, ,
, ,
.
(error handling)
. STEP 7
(, )
(,
).
(error routine) .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 1

20.

20 (main program)
; ;
; ; ;
;
(start information).
21 (interrupt handling)
(hardware interrupts),
(watchdog interrupts), ( ) (timeof-day interrupts),
(time-delay
interrupts), (multiprocessor
interrupts), .
22 (start-up characteristics)
(power-up); (memory reset);
(retentivity); (complete restart);
(warm restart); ;
.
23 (error handling)
( , );
; ;
.

20 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

20 (main program)
(main program) - (
, "" - "scanned") . "
" -
.

. ,
,
.
OB 1.
,

.
CPU RUN RUN-P.
RUN-P,
PG.
RUN, ,

. RUN,
- .

20.1
20.1.1
-

, .
,
,
()
.

. ,
.

.
( ,
). , ,
-
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 3

20.

- .
.
:



,
OB 1.
(networks). STEP 7 .

.
, ,
, .

OB 1,
.
.
, OB 1.
,
, .
,
, ,
(
).
,
,
,
.
(),


.
(
)
.
STL SCL
,
( ). 3 "SIMATIC S7" ""
.
(..
) 18 " ".
" " ("call interface"),
.
;

.
19 " ". 29 "SCL-"

SCL.

20 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

20.1.2
,
CPU , .
,

. ,
,
(),
.
(Nesting depth)
- ,
(
), CPU. CPU 314, ,
(8), , ,
(1- ),
7 " " ( ).
( ) 7 , CPU
STOP
("Block overflow").
(SFB),
(SFC).
,
, ,
"
" ( , ,
OB 1).

OB 1
(main
program),
.
("processrelated"), ("function-related").

,


.
,
, .
("process-related")
, .

.
,
, ,
( ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 5

20.


.

("function-related") .
( )
,
.
() (
).
, ,

. . 20.1
.
("operating mode program")
("data processing program"), "" ""
, .
1 (Feeding Conveyor 1),
2 (Feeding Conveyor 2), (Process),
(Discharge Conveyor)
("process-related").
. 20.1
. OB 1.
,
,
.
.
1 (Feeding Conveyor 1) 2
(Feeding Conveyor 2) . FB 20
DB 20 1 (Feeding
Conveyor 1) DB 21
2 (Feeding Conveyor 2)
.
FC 20
;
FB 20.
FB 101
. .
DB 20,
.
FB 29.
FB 50 DB
50 ,
FB 29 ( ).
DB 60. FC 51
. FB 51 (
DB 51);
SFB 8, SFB 9, SFB 62. DB 51
SFB "" .

20 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

OB 1

(Main program)
FB 10

(Operating modes)

DB 10
FB 20

1 (Feeding Conveyor 1)

DB 20
FC 20

(Interlocks)

FB 101

. 1 (Belt control 1)

FB 101

. 2 (Belt control 2)

..
FB 29
FB 20

(Data acquisition)

2 (Feeding Conveyor 2)

DB 21
FB 30

(Process)

DB 30
FB 40

. (Discharge)

DB 40
FB 50

(Data processing)

DB 50
DB 60

(Conveyor data)

FC 51

(Data preparation)

FB 51

(Communication)

DB 51
SFB 8

USEND

SFB 9

URCV

SFC 62

CONTROL

. 20.1

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 7

20.

20. 2
20.2.1

CPU (. 1.1.4 "
CPU").
I/O 0
, CPU. CPU

.

,

. CPU
, (configuration
table)

.
(inputs
I) (outputs Q).
CPU
OB 1

.
OB 1;

(inputs I) (
) (outputs Q).
OB 1
OB 1 (. .
20.2).
, ,
- ,
, , OB 85
"Program Execution Errors". OB 85 , CPU
STOP.
(Subprocess images)
, CPU,

( )
9 16.

, .


.
,
1 ... 8 1 ... 15,
20 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.


0. 0
CPU .
, CPU,

,
OB.
CPU 10/1998 .

PII

OB 1

PIO

PII

OB 1

CPU 10/1998 .

PIO

PII

OB 1

PIO

PII

OB 1

CPU 10/1998 .

OB

PII
0
PIO
0

SPIIn
n
SPIIn OB SPIOn SPIOn
n

. 20.2
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 9

20.

SFC 26 UPDAT_PI
SFC 27 UPDAT_PO
,
.

SFC 26 UPDAT_PI,
SFC 27
UPDAT_PO.
0.
20.1 SFC.
20.1 SFC-

SFC

PART

26

27

INPUT

BYTE

(0 ... 15)

RET_VAL

26

27

OUTPUT

INT

FLADDR

26

27

OUTPUT

WORD

,
SFC
. ,
( ),


.

.
, , ,
SFC.

20.2.2
OB 1
" " ("scan cycle
monitor") " " ("scan cycle watchdog").
,
, 150 .
1 6 CPU.

,
, CPU OB 80 ("Timeout" - "
"). OB 80 ,
CPU STOP.

20 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

OB 1.
,
( ). ,
, , GD-
PG CPU,
.
CPU (
"Cycle/Clock memory bits" ["/ "] - "Cyclic load
from communication" [" "]).

(online) PG CPU
: PLC -> Module Information (PLC ->
), .
"Cycle Time" (" ")
,
.

("scan cycle monitoring
time").
,

PLC,

OB 1.
SFC 43 RE_TRIGR

SFC 43 RE_TRIGR
("scan cycle monitoring time");
,
CPU. SFC 43 .
(Operating system run
times)

.
:

("no-load cycle" " "); ;

; ,
;

;
;

() CPU

CPU . ,
CPU ,
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 11

20.

CPU.

CPU .

20.2.3
("background scanning")
, , CPU
("minimum scan cycle
time").
( )
, CPU ,
,
OB 1.
,
, 0 , ,
(disabled). " "
("minimum scan cycle time")
1 6 "Cycle/Clock memory bits"
("/ ") CPU.
("background scanning") 90


CPU OB 90
"Background scanning" (" ") (. . 20.3).
OB 90 " ".
OB 1, OB 90
; , OB 1 ,
OB 90 .
OB 90
; , ,
OB 90, .
OB 90
OB 1.

,
OB 90.
OB 90 .
OB 90 () RUN.
,
, OB 1.

20 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

CPU 10/1998 .


OB 90

PII

OB 1

PIO

OB 90

PII

OB 1

CPU 10/1998 .


OB 90

OB 90

PIO

PIO

PII

OB 1

PII

OB 1

. 20.3
( )
( 1),
OB 90:

B#16#91
CPU

B#16#92
, , OB 90,
.

B#16#93
() OB 90 RUN.

B#16#95
, OB 90
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 13

20.

20.2.4 ("Response Time")


OB 1 (
) ,
, ("response time"),
(
). ,
,
.
, , " " ("limit switch") ,
"0" "1".


(inputs),
"1".
, "1"
(output)
. , ,
;
.
,
,
. ,
,
(. . 20.4).

= 1

PIO

PII

PIO

PII

PIO

PII

= 2

. 20.4
, ,
,
, .
, ,
, PLC

20 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

(input).
, ,
.
, ,

(, , ,
,
, MPI-, ).
,
, ,
. PLC
,
..

I/O
.

20.2.5 ("Start Information")


CPU
OB 1,
. ("start
information") 20 .


Standard Library
Organization Blocks. 20.2
OB 1, ,
, .
, ,
. ,
20
(,
20 ).
SIMATIC S7
, .
OB 1, , B#16#11
OB.
,
, , ,
.

. INT,
,

DATE_AND_TIME ,
1.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 15

20.

20.2 OB 1

OB1_EV_CLASS
OB1_SCAN_1

BYTE
BYTE

OB1_PRIORITY

BYTE

B#16#11
B#16#01 = 1-

B#16#02 = 1-

B#16#02 =
B#16#01

OB1_OB_NUMBR

BYTE

B#16#01

OB1_RESERVED_1

BYTE

OB1_RESERVED_2

BYTE

OB1_PREV_CYCLE

INT

OB1_MIN_CYCLE

INT

OB1_MAX_CYCLE

INT

OB1_DATE_TIME

DT


OB 1


( )

,

,
.
, ""
, SFC
RD_SINFO .
SFC 6 RD_SINFO

SFC 6 RD_SINFO
( , ,
" ")

(. . 20.3).
TOP_SI 12
OB,
START_UP_SI 12
OB.
.
SFC 6 RD_SINFO
, ,

. SFC 6 RD_SINFO ,
, ,
TOP_SI
. SFC
TOP_SI START_UP_SI .
20 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

20.3 SFC 6 RD_SINFO


SFC
6


RET_VAL

OUTPUT

INT



OB (

START_UP_SI)

TOP_SI

OUTPUT

STRUCT

START_UP_SI

OUTPUT

STRUCT

.EV_CLASS

BYTE



OB:
ID

.EV_NUM

BYTE

.PRIORITY

BYTE

(
)

.NUM

BYTE

OB

.TYP2_3

BYTE

.TYP1

BYTE

.ZI1

WORD

.ZI2_3

DWORD

2_3

ID
2_3
ID
1

20.3 (Program Functions)


CPU
Hardware Configuration

.

20.3.1 (Real-Time Clock)



CPU (Real-Time Clock):

SFC 0 SET_CLK
.

SFC 1 READ_CLK
.

SFC 48 SNC_RTCB
CPU.

SFB 20.4.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 17

20.

20.4
CPU (Real-Time Clock)
SFC
0
1
48

PDT

INPUT

DT

( )

RET_VAL

OUTPUT

INT

RET_VAL

OUTPUT

INT

CDT

OUTPUT

DT

( )

RET_VAL

OUTPUT

INT

CPU , ""
"master clock"
(" "). CPU
,
"master clock" ("
").
SFC 48 SNC_RTCB CPU "master
clock" (" ")
, .
"master clock" ( )
SFC 0 SET_CLK
- .

20.3.2 (System Clock)


CPU (system clock)
. (system clock) CPU
() CPU
RUN. CPU STOP HOLD,
" " (system time) "".
"" ("warm") S7-400
CPU,
"" .
""
.
(system time) TIME,

TIME#0ms TIME#24d20h31m23s647ms.
,
0. CPU 3xx ( CPU 318)
10 , CPU 4xx,
CPU 318
.

20 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

SFC 64 TIME_TCK

SFC 64 TIME_TCK
. RET_VAL
TIME.
, ,
CPU ,
,
SFC 64.
TIME-
DINT-.

20.3.3 (Run-Time Meter)


(run-time meter) CPU
.
CPU .
CPU .
CPU STOP HOLD,
; CPU ,

.

32767 ,
.

SFC.

(run-time meter):

SFC 2 SET_RTM

SFC 3 CTRL_RTM

SFC 4 READ_RTM

20.5
. NR
CPU; BYTE.
(
,
). PV ( INT)
. S
SFC 3 "1"
, "0"
. CV
: "1" - ;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 19

20.

"0" - . CV
INT.
20.5
(Run-Time Meter)
SFC
2

NR

INPUT

BYTE

PV

INPUT

INT

RET_VAL

OUTPUT

INT

NR

INPUT

BYTE

INPUT

BOOL

RET_VAL

OUTPUT

INT

NR

INPUT

BYTE


(B#16#01 ... B#16#08)

RET_VAL

OUTPUT

INT

CQ

OUTPUT

BOOL

CV

OUTPUT

INT


(B#16#01 ... B#16#08)



(B#16#01 ... B#16#08)
"1"
;
"0"


- :
"1" -
;
"0" -
.

20.3.4 CPU (Compressing CPU Memory)


(
)
(work) CPU
(load) RAM-, ,
.
"Compress" (""),

. "Compress"
("") PG, CPU,
SFC 25 COMPRESS.
SFC 25 20.6.
.
SFC 25 BUSY "1",
, DONE
"1", .

20 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

20.6 SFC 25 COMPRESS


SFC

25

RET_VAL

OUTPUT

INT

BUSY

OUTPUT

BOOL

DONE

OUTPUT

BOOL


"1",

"1",

SFC 25 COMPRESS ,
,
"Delete Block" PG ,
(, "Status
Block").
,
( CPU) , ..
CPU . "Compress" (""),
PG, , CPU
STOP,
CPU.

20.3.5
SFC 47 WAIT
.
SFC 47 WAIT WT ( INT),
(waiting time)
(s).
32767 ;
,
CPU.
SFC 47 WAIT
. S7-300

.
SFC 48 STP
, CPU STOP.
SFC 48 STP .

20.3.6
S7-400 .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 21

20.

.
S7-400
,
Hardware Configuration
, CPU. CPU .
CPU ,
() .
CPU
"Multicomputing" ("- ").
CPU PLC,
CPU.
CPU
CPU.
"Address"
("") "CPU assignment" (" CPU") (. . 20.5).

CPU. : View ->
Filter -> CPU No.x-Modules ( -> -> CPU No.x)
, CPU .
CPU .
, :

RUN ;

HOLD,
CPU;

STOP, CPU
STOP.

, CPU
OB 86.
CPU ;
.
SFC 35 MP_ALM
OB 60 "Multiprocessor interrupt" ("
") CPU (.
21.6 " ").

20.4

(communications)
I/O

,
CPU, (, (slave) DP) (master) DP-.
(master) DP- (slave)
DP- " (master) DP-".
S7- (master)
DP-.
20 - 22

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

. 20.5
, (slave) DP-
I/O CPU ( ).
(master) DP-, , ""
(slave) DP-: CPU ""
(slave) DP-,
. (slave) DP-
(slave) DP (master) DP-,
CPU.
(slave) DP-,
, ..,
,
, ,
. "DP-S7
slaves" ( " DP-S7 "). "DP V0 standard slaves"
(" DP- V0") EN
50170, 2, PROFIBUS.
.
(I/O)
.
(master) DP-
DP-. ,
.

(I/O).
,
(slave) DP-, 4
S7,
(slave) DP- ,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 23

20.

20.4.1 (I/O)

(slave)

DP-

- (node address),
- (geographical address),
- (module starting address),
- (diagnostics address).
(master) DP- .
20.6).

CPU
32

P-
PROFIBUS DP
3

(slave)
DP-
32

48

(master)
DP-

56

1022

(slave)
DP-
48
56

2
1022

(master)
DP-

DP- 1,
4,
5)

. 20.6 (master) DP-

20 - 24

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

(Node Address)
PROFIBUS ,
(node address) (station number),
.
PROFIBUS .
,
, , , (1), (,
(master) DP-
). S7
.
(Geographical Address)
(geographical address) (slave) DP .
(ID) (master) DP, ,
PROFIBUS ( ).
(slave) DP-
,
(),
( S7-300,
4).
(Module Starting Address)

(module starting address) ("logic base
address" - " ")
(slave) DP-
(compact DP slave) DP-
(modular DP slave). ,
.
(slave) DP-
1, 2 4 ,
(load)
(transfer).
,
.
.
3
, 4 ( ,
CPU),
SFC 14 DPRD_DAT SFC 15 DPWR_DAT.

, .
SFC
RECORD.
. 20.7 .
(master) DP-
"" (slave) DP- ;
32
4 ( DP- 1)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 25

20.

CPU

DP-

CPU


Load
Transfer

P-

PROFIBUS DP

32

32

33

33

n+2

34

34

n+3

35

35

48

48

49

49

50

50

51

51

x+4

52

52

x+5

53

53

x+6

54

54

x+7

55

55

n+1

x+1
x+2
x+3


SFC 14
SFC 15

. 20.7

DP-

32
DP- 1:
33

34
4
35

48
DP- 2:
49

50
8
51
52
53

(master)
DP-

54
55

48
8 ( DP- 2).
(slave) DP 1 (transfer area)
(master) DP- P- CPU
, , CPU
Load Transfer,
.
(slave) DP 2 (transfer
area) (master) DP-,
(48, ) P-.
() ,
(disabled) Hardware Configuration .
SFC 14 SFC 15

(slave)
DP- 2
(48)

20 - 26

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

CPU, , .
Load
Transfer,
.
48 55. ,
SFC 14 SFC 15
.
DP-
(Transfer memory)
(slave) DP I/O
CPU ( "CPU (master) DP" "master CPU").
(slave) DP-
CPU (master) DP-
/ (slave) DP-.
(slave) DP- "
" ("transfer memory"),

. (master) DP-
(slave) DP-
(slave) DP-,
.
" " ("transfer memory")
(slave) DP-. "
" : CPU
(slave) DP-
(slave) DP- CPU (master) DP (slave) DP-
(master) DP-. : DP
CP 342-5DP, "
" ("transfer memory") ,
(master) DP.
(master) DP- ( ,
CPU (master) DP-)
" "
S7-. CPU (slave)
DP- " "
,
(slave) DP-.
" "

, ..,
() ("module
starting address").

Load / Transfer,
SFC 14 / SFC 15, CPU

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 27

20.

(master) DP- CPU (slave)


DP-. CPU (slave) DP-
SFC 7 DP_PRAL
CPU (master) DP-
.
. 20.8 " "
(slave) DP-
.

" "
("transfer memory")

(slave) DP-
n

Q 96

I 32

Q 97

I 33

Q 98

I 34

Q 99

I 35

I 16

Q 48

I 17

Q 49

I 18

Q 50

I 19

Q 51

I 20

Q 52

I 21

Q 53

x+6

I 22

Q 54

x+6

x+7

I 23

Q 55

x+7

n+1

Transfer

n+2
n+3

x
x+1
x+2


(master)
DP-

CPU
(master)
DP-

x+3
x+4
x+5


SFC 14


CPU
(master)
DP-


CPU
(master)
DP-
. 20.8

Load

CPU
(slave)
DP-


SFC 15


CPU
(slave)
DP-

1:
n+1

n+2
4
n+3

2:
x+1

x+2
8
x+3
x+4
x+5


CPU
(slave)
DP-


DP-.

CPU (master) DP- "" 1


,
(
, ).
CPU (slave) DP- 1
,
Load (),

20 - 28

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

.
2 8
CPU (slave) DP-
SFC 15 CPU (master) DP SFC 14.
(Diagnostics Address)
(master) DP- (slave) DP-
" ".

.
(slave) DP- DP V0
SFC 13
DPNRM_DG. (slave) DP- DP
S7 DS 1, ,
SFC 59 RD_REC.
, SFC 13 DPNRM_DG,
, (. . 20.9).

(slave) DP DP V0

0 ... 2
3

1, 2
3
(master)

4 ... 5

ID

6 ... n


,
(slave)
DP-

. 20.9


(slave) DP DP S7

0 ... 3

4 ... n

DS 0
(
OB 82)

,
(slave)
DP-

(Standard
Diagnostics Data) DS 1
(Diagnostics Data Record DS 1).

DS 1, SFC 59 RD_REC,
4 ,
, ,
OB 82 (
DS 0 [Diagnostics Data Record DS 0]).
.
, " "
, ,
, ,
(master) DP- ( )
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 29

20.


(peripheral inputs). STEP 7 ,
I/O- CPU.
Hardware
Configuration .

20.4.2 (I/O)

(I/O)
.
DP (PROFIBUS-) (master) DP-.

:
1)

,
SIMATIC Manager.

2)

SIMATIC Manager
PROFIBUS , , (bus profile).

3)

SIMATIC Manager, (master)


, (master) DP, , S7-400.
(slave)
DP-,
, , S7-300.

Hardware Configuration
(master) .

20 - 30

4)

Hardware
Configuration (master) DP-
(master) . , , CPU
DP-.
PROFIBUS DP-;
(master) DP-.
.
.

5)

S7-
(slave)
DP-,

Hardware Configuration,
DP, , S7-300 CPU DP BM 147/CPU
/ ET 200X.
DP- " (slave) DP-",
DP-
PROFIBUS,
DP- (
"transfer memory").

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.


. .

,
(slave) DP-.
6)

(master) DP , "", ""


PROFIBUS- ( [slave] DP) (hardware catalog)
DP-. ,
,
.

7)

(slave) DP-,
"", ""
"" ( [hardware catalog]
"PROFIBUS DP" "Configured Stations" [
]) DP-.

()

""
DP- ("Connect" - ", "),
(node address)
(master) DP ( CPU
(master) DP-).

(slave) DP-.

8)

.
(master) DP-,

(slave) DP-.


DP- ,
Network Configuration.
Network Configuration ,
, "" .
: View -> DP Slaves ( -> DP) (slave) DP-.
Network Configuration
(master) DP- (, ,
PROFIBUS).
Network Configuration,
.
(slave) DP-,
DP-.
(master) DP-
S7-, SIMATIC
Manager. S7-
(. 2.3 " ").

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 31

20.

, "", ""
DP- (hardware catalog)
(configuration table) .
CPU DP-.
(master) DP- DP .
"" DP-
PROFIBUS,
DP- , DP.
PROFIBUS.
DP- (,
),
DP-, (master) DP : Insert ->
DP Master System ( -> DP-).
PROFIBUS,
, : Edit -> Object Properties ( ->
), "General" ("")
"Properties" (""),
.
CP 342-5DP DP-
DP-
CP 342-5DP, ;
, : Edit -> Object
Properties ( -> ).
"Mode" ("") "DP Master" (" DP").
"Addresses" ("") ,
CP CPU.
CPU (master)
CP 342-5DP " " ("analog module"),
16
.
CP 342-5DP (master)
DP- DP ("DP standard slave") S7 DP- ("DP S7
slave"), DP-.
(slave) DP-
(hardware catalog) "PROFIBUS-DP" / "CP 342-5DP
as DP Master" (CP 342-5DP DP-).
(slave) DP-
"" ""
(master) DP-.
(transfer memory) CP 342-5DP
DP- 240 .
FC 1 DP_SEND FC 2
DP_RECV ( Standard Library
Communication Blocks [ ]).

.
20 - 32

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.


(slave) DP- FC 3 DP_DIAG (,
, ).
FC 4 DP_CTRL CP
342-5DP (, SYNC/FREEZE, CLEAR,
CP 342-5DP).
CPU CP 342-5DP, : View
-> Address Overview ( -> )
, / .
.
(slave) DP-
DP- (compact DP slave)
(hardware catalog)
"PROFIBUS-DP" , , ET 200B.
(slave) DP- ""
"" (master) DP.
;
. (slave) DP-
,
.
""

,
.
/. ""
,
.

DP- (master)
DP-
(

[
]).
(slave) DP-
DP- (modular DP slave)
(hardware catalog)
"PROFIBUS-DP" , , ET 200M.
""
( [basic module]) ""
"" (master) DP. ;
. (slave) DP-
,
.
,
(hardware catalog),
. ""

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 33

20.


, .
,
(master) DP-
(slave) DP-
. , CPU 315-2DP
DP- 122 122
(slave) DP- ( 8 ET 200M : 8 16 = 128
), ET 200X DP-
104 104 .
CPU DP-,
(slave) DP-
CPU
(master) DP- (slave)
DP-. ,
(slave) DP- (master) DP. ,
"" : SIMATIC Manager,
S7-, S7- ""
Hardware Configuration ( ) ,
"",
. (slave) DP-
"" CPU - .
CPU PROFIBUS. (subnetwork)
DP-, . PROFIBUS
,
"New" (""). ,
(slave) DP-.
PROFIBUS-
: DP-, - : Edit ->
Object Properties ( -> )
"" PROFIBUS. "Operating Mode"
(" ") "DP Slave" (" DP-").

"Configuration" ("")
(slave) DP- (. . 20.10).
20.4.1
" (I/O)" "
(slave) DP-".
(transfer memory)
CPU. , CPU 315-2DP
(transfer memory)
32 , .
32 .
122 122
. CPU
(slave)

20 - 34

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

. 20.10
(slave) DP- DP-
(slave) DP-.

("module starting address").
CPU (slave)
(master) DP-
, .
(slave) DP, :
Station -> Save and Compile ( -> ).
(slave) DP-
(master) DP- .
BM 147/CPU,
(slave) DP-
ET 200X
(slave) DP- :
SIMATIC Manager, SIMATIC 300 ,
Hardware ().
Hardware Configuration ( ),
"", "" BM 147/CPU
"PROFIBUS-DP" / "ET200X"
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 35

20.

PROFIBUS DP- (
DP-).
,
SIMATIC 300. CPU
BM 147 ET200X. CPU MPI-
(BM 147/CPU MPI-
[master] ).
CPU CPU;

DP-.
(slave) DP-.
BM 147 128;
32
32 .
8 .

127.

(master)
DP-

.
ET 200X
, S7 300-
.
"BM 147/CPU".
(slave) DP, :
Station -> Save and Compile ( -> ).
(slave) DP-
(master) DP- .
IM 151/CPU,
(slave) DP-
ET 200S
(slave) DP- :
SIMATIC Manager, SIMATIC 300 ,
Hardware ().
Hardware Configuration ( ),
"", "" IM 151/CPU
"PROFIBUS-DP" / "ET200S"
.
PROFIBUS DP- (
DP-).
,
SIMATIC 300. CPU
IM 151 ET200S.
CPU MPI- , MPI (IM 151/CPU MPI-
[master] ).
CPU CPU;

DP-.
(slave) DP-.
20 - 36

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

IM 151/CPU
64 . 8
.
(master)
DP- .
ET 200S
, S7 300-
.
"IM 151/CPU".
(slave) DP, :
Station -> Save and Compile ( -> ).
(slave) DP-
(master) DP- .
S7-300 CP 342-5DP,
(slave) DP-
, SIMATIC 300 ,
Hardware ()
("normal") S7-300.
CP 3425DP.
, SIMATIC 300 ,
DP-; DP-
,
(slave) DP-,
(node address).
, CP 342-5DP, : Edit -> Object Properties ( -> ),
CP 342-5DP,
. "Mode" ("")
"DP Slave" (" DP-").
"Addresses" ("")
CPU (slave)
( 16 ).
(transfer memory) CP 342-5DP
(slave) DP- 86
,

(master) DP-.
(slave) DP, :
Station -> Save and Compile ( -> ).
(slave) DP-
(master) DP- .
(slave) DP-
(master) DP-
(slave) DP-
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 37

20.

(master) DP-
, (master) DP-
(slave) DP- (
DP-). (master) DP-,
(slave) DP-
PROFIBUS.
(master) . ,
(master) DP- (, )
; , , :
Insert -> DP Master System ( -> DP). "PROFIBUS-DP"
"Configured Stations" (" ")
, (slave)
:
"CPU31x-2DP" S7-300
(slave) DP-;
"X-BM147/CPU" ET 200X
BM147/CPU;
"ET 200S/CPU" (slave) DP () ET 200S DP;
"S7-300 CP342-5DP" S7-300
CP342-5 (slave) DP-.
(slave) DP- ""
"" (master) DP.
CPU, ET 200X ET 200S (slave) DP-
"" (slave) DP-
"" (master) DP-
(slave) DP-
.
(slave) PROFIBUS
"Connection" ("").
(slave) DP- ""
"Connect" ("").
(. ).
(slave) DP-
(master) DP- "General"
("").
"Configuration" ("")
(slave) DP-
(master) DP-.
(master) DP-
(slave) DP- .
20.4.1
" I/O" "
DP- (Transfer
memory)".

20 - 38

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

CP 342-5DP (slave) DP-


"" (slave) DP-
"" (master) DP-
(slave) DP-
.
(slave) PROFIBUS
"Connection" ("").
(slave) DP- ""
"Connect" ("").
(. ).
(slave) DP-, ,
,
. " "
("transfer memory"). "Universal submodule"
(" ") (hardware catalog)
(CP),
, "", ""

"Universal submodule"
(" ") .
()
("transfer memory")
; 32.
,
, ,
: Edit -> Object Properties ( ->
),
. : , ,
/.
.
CPU (master) .
64 ;
("transfer memory") 86 .
CP 342-5DP (master) DP-,
("transfer memory")
, CP 342-5DP
("transfer memory")
.
" " ("transfer memory")
, 0- .

CPU (slave) FC 1
DP_SEND FC 2 DP_RECV (
Standard Library Communication Blocks [
]).

.
(slave) DP-
(master) "General" ("").
FC 3 DP_DIAG
( [master] ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 39

20.


20.4.1 "
I/O" "
DP- (Transfer memory)".
GSE-
" " ("post
install") (slave) DP-,
(module catalog).
, (slave) DP-
(GSE-, ).
: Options -> Install GSE ( ->

GSE-)

. ,
GSE-.
, STEP 7
DP-. STEP 7 GSE-
DP- (hardware catalog)
"Other Field Devices" (" ").
GSE-,
S7-, : Options
-> Import Station GSE ( -> GSE).
STEP 7 GSE- \Step7\S7data\gsd.
GSE-,
,
\gsd\bkpx. GSE-
: Options -> Install New GSE ( ->
GSE-).
PROFIBUS-PA
(master) PROFIBUSPA PA-
()
SIMATIC PDM.
(Hardware Configuration)
(master) DP- DP/PA-
(DP/PA-Link).
(Hardware Catalog)
IM 151, "",
"" IM 151
"PROFIBUS-DP" "DP/PA-Link" (master) DP. (slave) DP-
(master) PA PROFIBUS (45,45 /);
.
DP/PA-
,
.

20 - 40

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

PA- (master) PD.


STEP 7 (Hardware Configuration) GSE-.
PA-
(hardware catalog) "PROFIBUS-DP" "Other Field Devices"
(" ").
DP/AS- (DP/AS-i-Link)
DP/AS- (DP/AS-i-Link)
(slave) DP-.
, , , DP/AS-i-Link
20, (hardware catalog) "PROFIBUSDP" "DP/AS-i", "" ""
(master) DP-.
( 16 20 ),
.
DP/AS-i-Link 20
16 / 4
.
Hardware Configuration
16 4 - ,
, 512.
(slave) DP-,
: Edit -> Object Properties ( -> ),
(slave) DP-
, ,
Hardware Configuration ,
(
CPU).
(slave) DP-, :
Edit -> Object Properties ( -> ),
(slave) DP- ,
. "Parameterize" ("")
(slave) DP- AS-i 4-
.
(master) AS-i- c (slave) AS-i Hardware Configuration
.
SYNC/FREEZE
SYNC
(slave) DP- ()
. FREEZE
(slave) DP-
() "" ,
(master) DP-
. UNSYNC UNFREEZE
SYNC FREEZE .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 41

20.


(slave) DP-,
(master) DP-.
(slave) DP- ,
. (slave) DP, : Edit -> Object Properties
( -> ), "General"
("") SYNC FREEZE
"SYNC/FREEZE Capabilities".
(master) DP-
8 , SYNC
FREEZE, SYNC,
FREEZE, .
(slave) DP- .
CP 342-5DP , (slave) DP (
8 ).
SFC 11 DPSYC_FR,

(. 20.4.3 "
I/O"). (master) DP
(slave) DP- .

. 20.11 SYNC- FREEZE-


20 - 42

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

SYNC/FREEZE-
(master) DP- (
(slave) DP- ).
(master) DP- (
), :
Edit -> Object Properties ( -> ).
"Group Properties" (" ")
, "Group Assignment"
(" ")
(slave) DP-.
(slave)
DP- (node number)
, .
- (slave) DP-
, , FREEZE, ,
, , ,
FREEZE. SYNC/FREEZE
"OK".
,
() (bus cycles) 7 8
.
(bus cycle time)
(master) DP-
(slave) DP- ( ).
S7-, , ,
(PG),
PROFIBUS,
.
,
,

I/O
,
(bus cycle time) (
) (master) DP-.
(master) DP- PROFIBUS
(master) DP- 1 (Class 1
master). (bus cycle time)

"
" "DP"
"User-Defined"
("").
PROFIBUS
: PROFIBUS, :
Edit -> Object Properties ( -> )
.
"Network Settings" (" ") "Options"
(""). "Constant Bus Cycle Time" ("
") "Options" ("")
"checkbox" "Activate constant bus cycle time /
Recalculate constant bus cycle time" ("
/ ").
,
,
. "Details" ("")
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 43

20.

,
,
PROFIBUS, (slave)
DP-, (master) DP-.
, SYNC/FREEZE-
("")
, :

(slave) DP-, 7,
(master)
DP-

SYNC/FREEZE .
.

8 "" ,
(slave) DP.
("") ,
(slave) DP- 8.


"" )

(lateral

communication

(master) DP- (master) DP

(slave)
DP-.

( ) ( [master]
[slave] , "" ["receiver"])
PROFIBUS,
(slave) DP- ("" ["sender"])
"" (master) .
"lateral communication" ("
"). (slave) DP-
( )
"" ("sender") .
PROFIBUS

Hardware Configuration c
"Properties" (slave) DP- ("receiver" - "").
-"" DP-,
: Edit -> Object Properties ( ->
). "Configuration" ("")
(slave) DP- (master) DP. "Mode" ("")
DX (Direct Data Exchange - ).
-"sender" (""),
"PROFIBUS DP partner" (" PROFIBUS")
"Address" ("").
,
(master) DP-
PROFIBUS. , DP 1 (slave) DP-
(master) DP- 2 .

20 - 44

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

20.4.3 (I/O)

(I/O):

SFC 7 DP_PRAL
;

SFC 11 DPSYN_FR
SYNC/FREEZE-;

SFC 12 D_ACT_DP
/ (slave) DP;

SFC 13 DPNRM_DG

(slave) DP-;

SFC 14 DPRD_DAT

(slave) DP-;

SFC 15 DPWR_DAT

(slave) DP-.

20.7

20.7
(I/O)

SFC
,

7
REQ
INPUT
BOOL
REQ ="1"
IOID
INPUT
BYTE
B#16#54 = input ID (ID )
B#16#55 = output ID (ID )
LADDR
INPUT
WORD

(transfer memory)
AL_INFO
INPUT
DWORD Interrupt ID (ID -

)
RET_VAL OUTPUT
INT

BUSY
OUTPUT
BOOL
BUSY = "1", ,
(master)
DP-
11
REQ
INPUT
BOOL
REQ ="1"
LADDR
INPUT
WORD

(master) DP-
GROUP
INPUT
BYTE
(slave) DP-
( )
MODE
INPUT
BYTE
(. )
RET_VAL OUTPUT
INT

BUSY
OUTPUT
BOOL
BUSY = "1", ,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 45

20.

20.7
(I/O) ()

SFC
,

12
REQ
INPUT
BOOL
/
REQ ="1"
MODE
INPUT
BYTE
(Function mode):
0 - (slave)
DP- (
)
1 - DP-
2 - DP-
3 - /
DP-
LADDR
INPUT
WORD

(slave) DP-
RET_VAL OUTPUT
INT


BUSY
OUTPUT
BOOL
BUSY = "1", ,
.
13
REQ
INPUT
BOOL
REQ ="1"
LADDR
INPUT
WORD

(slave) DP-
RET_VAL OUTPUT
INT

RECORD OUTPUT
ANY


BUSY
OUTPUT
BOOL
BUSY = "1", ,
.
14
LADDR
INPUT
WORD

( I)
RET_VAL OUTPUT
INT

RECORD OUTPUT
ANY


15
LADDR
INPUT
WORD

( Q)
RECORD INPUT
ANY


RET_VAL OUTPUT
INT

SFC 7 DP_PRAL

SFC 7 DP_PRAL
(master) DP-,
(slave) DP-,
DP-.
AL_INFO ID ,
,
,

(master)
DP- (
OBxx_POINT_ADDR). REQ = "1";
RET_VAL BUSY .
,
.
20 - 46

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

" " ("transfer memory") (master) DP (slave) DP-


, CPU
(master) .

() ("module starting address").
(master) DP (""
).
SFC 7
IOID LADDR CPU (slave)
( I/O (ID) ).
OB
"", , CPU
(master) .
SFC 11 DPSYN_FR
SYNC/FREEZE-
SFC 11 DPSYN_FR
SYNC, UNSYNC, FREEZE UNFREEZE SYNC/FREEZE-,

Hardware Configuration. (SEND)
REQ = "1"
BUSY = "0".
GROUP (
0 1, 7 8).
MODE :

UNFREEZE, 2 = "1";

FREEZE, 3 = "1";

UNSYNC, 4 = "1";

SYNC, 5 = "1".

, SYNC FREEZE (slave) DP ( ).


(slave) DP-
(master) DP-, (slave) DP-
; (slave) DP-

("").
"" ("freeze")
(slave) DP- ,
FREEZE .
(master) DP-
, ,
FREEZE ( "").
,
FREEZE,
(slave) DP-
( )
, (slave) DP "" UNFREEZE.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 47

20.


(slave) DP- ,
SYNC .
(slave) DP-
("").
(slave)
DP-.
SYNC, , DP-

.
(slave) DP- ,
SYNC, ,
(slave) DP- ""
UNSYNC.
SFC 12 D_ACT_DP
(slave) DP-
SFC 12 D_ACT_DP
( ) (slave)
DP- ,
(master) DP-.
("") (slave) DP-
"" (=0) "
" ( " " - "substitute value").
(slave) DP-
,
; ,
.
85 (

[slave] DP-
) 86 ( ) .
(slave) DP-
,
/ ("I/O access errors").
SFC 12 D_ACT_DP
(slave) DP-.
(slave) DP-
(master) DP- ,
("restore")
.

(slave) DP-
85 86 .
BUSY "0" (slave) DP,
.
SFC 13 DPNRM_DG

SFC 13 DPNRM_DG
(slave) DP-.
, REQ = "1",
BUSY = "0".

20 - 48

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

RET_VAL .
(slave) DP-
6 240 .
240 , 240

.
RECORD ,
.
ARRAY STRUCT ANY BYTE
(, P#DBzDBXy.x BYTE nnn).
SFC 14 DPRD_DAT

SFC 14 DPRD_DAT
(slave) DP-
, 3
4- . (slave) DP-
.
LADDR
(slave) DP- ( ).
RECORD ,
.
ARRAY STRUCT ANY BYTE
(, P#DBzDBXy.x BYTE nnn).
SFC 15 DPWR_DAT

SFC 15 DPWR_DAT
(slave) DP-
, 3
4- . (slave) DP .
LADDR
(slave) DP- ( ).
RECORD ,
.
ARRAY STRUCT ANY BYTE
(, P#DBzDBXy.x BYTE nnn).

20.5
20.5.1
(GD-) -
( ),
CPU,
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 49

20.

MPI-. ,
, :

( );

DB;

,
.

GD-
: CPU MPI - S7-400,
CPU STEP 7,
GD-.

:
GD- S7-400.
(Cyclic Transfer)

(Global data table)


OS
CPU

OS
CPU

MPI

, (Event-driven Transfer)

(Global data table)
SFC

SFC

SFC

OS
CPU

OS
CPU

SFC

MPI

. 20.12
20 - 50

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

, CPU-
. , CPU-
, , ""
, , . ,
CPU,
GD- CPU.
,
" " ("scan rate").
,
CPU .

"" ""
,

(, , ).
(GD
packet) CPU, GD- (GD circle).
GD- (GD circle)
CPU, (shared) GD-,
GD- (GD circles). GD- :

CPU, GD-
CPU,
.

CPU,
CPU GD- .

CPU,
CPU GD- CPU
( S7-400 CPU).

GD- 15
CPU. CPU GD.
20.8
GD- CPU.
GD- (GD packet)
GD- (GD packet) (header)
(GD-):

(8 ).

ID 1- GD- (2 ).

1- GD- ( ).

ID 2- GD- (2 ).

2- GD- ( ).

..

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 51

20.

15 CPU
CPU
(1)

CPU
(2)

CPU
(3)

CPU
(4)

CPU
(5)

MPI

GD- 1

GD- 2
2

GD- 3

2
3

GD- 4

. 20.13 GD-
GD- 2 ,
(actual net data). 3
( ), 4
( ), 6
( ). 1
, (net data); ,
.
, 2 , GD- 4
.
GD- .
, MB 0:15 MB 0 MB 15,
DB20.DBW14:8 ,
DB20, DBW14 8
.
GD- 32 S7-300 64
S7-400. ,
GD-, 22 S7-300 54
S7-400.

GD-.
20.8 , CPU

20 - 52

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

, GD- CPU.
GD- , ,
,
, .
20.8 CPU
CPU 315
CPU 316

CPU 318

CPU 412
CPU 413
CPU 414

CPU 416
CPU 417

CPU 312
CPU 313
CPU 314

GD- 1 CPU

16

16

16

32

16

32

32

64

64

64

32

16

32

GD-

GD-
1 CPU
GD-
1 GD-
GD-
1 CPU
GD-
1 GD-


GD-

20.5.2 GD-

, GD-
, MPI
S7-.
CPU. "Properties"
("") MPI- "General" ("")
CPU ( , CPU
, MPI), MPI- MPI
CPU.
(Global data table)
GD-
.
MPI Simatic Manager (Network
Configuration) : Options -> Define Global Data
( -> ).
, : Edit -> CPU ( -> CPU).
,
CPU. CPU
"".

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 53

20.

CPU,
.
15 CPU.
CPU GD CPU-
, (
Enter).
: Edit -> Sender ( -> CPU)
, ,
, - ">" .
CPU- ,
( "Receiver" [""]
).
""; ""
, ,
.
"",
"" (. 20.9).
.
: GD Table -> Compile (GD- -> ).
20.9 GD- (GD Table) (Status)
(Scan Rates)
417 \
CPU 417 (3)

417 \
CPU 414 (4)

416 \
CPU 416 (5)

GST

MD100

MD100

MD100

DB10.DBD200

DB10.DBD200

GDS 1.1

DB9.DBD0

MD92

DB10.DBD204

DB10.DBD204

SR 1.1

44

44

GD 1.1.1

>DB9.DBW10

MW90

DB10.DBW208

DB10.DBW208

GDS 2.1

MD96

MD96

SR 2.1

44

23

GD 2.1.1

>Z10:10

DB3.DBW20:10

44

>MW98

DB10.DBW220

DB10.DBW210

GD-

GDS 3.1
SR 3.1
GD 3.1.1

315 314CP\
(slave)\ CPU 314 (10)
CPU 315 (7)

MD96
0

( 1)
.
GD- (GD-status)

(scan rates)

20 - 54

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

GD-.
(GD ID)
GD-
STEP 7 "GD ID".
GD-, GD-
GD-. , GD ID "GD 2.1.3" GD- 2,
GD- 1 GD- 3. GD- CPU
( GD-)
CPU.
GD- (GD status)
GD-
() GD-.
: View -> GD Status ( ->
GD-). ()
(GST) .

()
(GDS)
GD-.
.
(Scan rate)


CPU,
MPI-. ,
(" ") ,
"Scan rate"
(" ").
,
CPU GD- (GDpacket).
"Scan rate" ("
")
,
GD- ,
.
GD- (
)
"Scan rate" ("SR" - " ") GD-
CPU. : View -> Scan
Rates ( -> ). "Scan rate"
(" ") , "" (
) CPU GD-
10 .
CPU ,
GD- .

") 1 255.

"Scan

rate"

("

, "Scan rate" ("


Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 55

20.

") " " CPU .


, CPU
,
"Scan rate" (" ") CPU-,

S7-300 60 , S7-400 10 .
CPU-
,
S7-300 60 , S7-400
10 .
GD-.
("0") "Scan rate" ("
"),
GD-,
SFC.
() GD
"Scan rate" (" ") (
) GD-. STEP 7
System data ( ).

, GD- CPU
: PLC -> Download (PLC -> ).
GD- ,
System data ( ),
.

20.5.3 GD-
S7-400
GD-.


GD- :

SFC 60 GD_SND
GD-,

SFC 61 GD_RCV
GD-.


20.10.

. STEP 7 "GD
Identifier" ( GD-)
- GD- GD-,
.
GD- SFC 60 GD_SND GD-
CPU ;

20 - 56

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

GD- SFC 61 GD_RCV GD-


CPU. "Scan rate" (" ")
(, "0") GD-,
GD- .
GD-
SFC 60
SFC 61, (disable)
(delay) ,
, "" (Send)
"" (Receive) , SFC 60
SFC 61.
SFC 60 SFC 61 ;
"" . ,
SFC 60 GD_SND GD,
(Receive).
20.10 SFC GD-.

CIRCLE_ID


SFC
60
61

INPUT

BYTE

GD-
GD-,


BLOCK_ID

60

61

INPUT

BYTE

RET_VAL

60

61

OUTPUT

INT

20.6

SFC-

20.6.1 (Station-Internal) SFC-

""
(Station-Internal)
SFC
SIMATIC-.
SFC-
CPU. , SFC-
.
""
("Communication via non-configured connections", basic
communication - "
", ).

(Station-Internal)
SFC-

, ,
PROFIBUS-DP (master)
CPU (slave) CPU (. . 20.14).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 57

20.

(One-way connection)

SFC

SFC

OS
CPU

OS

PROFIBUS

. 20.14 (Station-Internal) SFC-


,
I/O-: LADDR
, IOID ,
(input area)
(output area).

.
(
).
- ,
, , ,
: "Temporary lack of resources" ("
").
.

.

,
. SFC
. ,
, STOP;
.
,
SFC-
SIMATIC- 76
.
CPU
,
("consistent within themselves"). S7-300 8 ;

20 - 58

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

CPU 412/413 16 ; CPU 414/416


32 . CPU
, "" CPU,
.
"" (Station-Internal) SFC-
(Station-Internal) SFC-
, ,
.
PROFIBUS,
SIMATIC Manager ( Proect,
: Insert -> Subnetwork -> PROFIBUS
[ -> -> PROFIBUS])
Network Configuration (. 2.4
" ").
:
(I/O) CPU 315-2DP (master)
CPU 315-2DP
(slave) .
(Station-Internal) SFC-
, .

20.6.2
CPU
:

SFC 72 I_GET
(Read data),

SFC 73 I_PUT
(Write data),

SFC 74 I_ABORT
(Disconnect).


20.11.
SFC 72 I_GET
C (Read data)

REQ BUSY: REQ = "1" BUSY = "0" ( ).
, BUSY (BUSY = "1").
REQ
. ,
BUSY (BUSY = "0"). REQ
(REQ = "1"),
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 59

20.

,
CPU .
SFC .
RET_VAL .
CONT (CONT = "0"),
, CONT (CONT = "1"),
.
, STOP.
RD VAR_ADDR ,
,

,
, ANY.
(
).
20.11 SFC GD-.


SFC

REQ

72

73

74

INPUT

BOOL

CONT

72

73

INPUT

BOOL

IOID

72

73

74

INPUT

BYTE

LADDR

72

73

74

INPUT

WORD

VAR_ADDR

72

73

INPUT

ANY

73

INPUT

ANY

RET_VAL

72

73

74

OUTPUT

INT

BUSY

72

73

74

OUTPUT

BOOL

RD

72

OUTPUT

ANY

SD

,
REQ="1"

CONT="1"



B#16#54 = Input area
( )
B#16#55 = Output area
( )

CPU

""
CPU,


BUSY ="1"

""
CPU,

SFC 73 I_PUT
(Write data)

REQ BUSY: REQ = "1" BUSY = "0" ( ).
, BUSY (BUSY = "1").
REQ
. ,
BUSY (BUSY = "0"). REQ
20 - 60

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

(REQ = "1"),
.
,
CPU-
. CPU VAR_ADDR.
BUSY (BUSY = "0").
,
STOP.
SD VAR_ADDR ,
,

,
, ANY.
(
).
SFC 74 I_ABORT
(Disconnect)

REQ, "1", -
.
SFC 74 I_ABORT ,

SFC 72 I_GET SFC 73 I_PUT. ,
BUSY (BUSY = "1").
REQ .
, BUSY (BUSY = "0").
REQ (REQ = "1"),
.

20.6.3 (Station-External) SFC-

""
(Station-External)
SFC
SIMATIC-.
MPI-.
SFC-
CPU. , SFC-
.
""
("Communication via non-configured connections", basic
communication - "
", ).

(Station-External)
SFC-

,
, (.
. 20.15).
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 61

20.

(Two-way connection)

SFC

SFC

SFC

OS
CPU

OS
CPU

SFC

MPI

(One-way connection)

SFC

SFC

OS
CPU

OS
CPU

MPI

. 20.15 (Station-External) SFC-


,

, MPI-.
MPI- ( DEST_ID).
SFC- SIMATIC-
MPI-
, ,
.
-
, , ,
, : "Temporary lack of
resources" (" ").

20 - 62

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

.
.
RUN STOP
( , X_RECV) .

,
. SFC
. ,
, STOP;
.
,
SFC- SIMATIC-
76 ()
.
CPU
,
("consistent within themselves"). S7-300 8 ;
CPU 412/413 16 ; CPU 414/416
32 .
CPU X_GET
X_PUT , "" CPU,

. SEND/RECEIVE
.
"" (Station-External) SFC-
(Station-External) SFC-
, ,
.
MPI,
.
: S7-400,
CPU 416;
S7-400 MPI- S7-300
CPU 314. CPU
Hardware Configuration, ,
, MPI.
(Station-External) SFC-
.

20.6.4
("" SFC)

-
:

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 63

20.

SFC 65 X_SEND
(Send data),

SFC 66 X_RCV
(Receive data),

SFC 67 X_GET
(Read data),

SFC 68 X_PUT
(Write data),

SFC 69 X_ABORT
(Disconnect).


20.12.
20.12 SFC .

SFC

REQ

65

67

68

69

INPUT

BOOL

CONT

65

67

68

INPUT

BOOL

DEST_ID

65

67

68

69

INPUT

WORD

REQ_ID

65

INPUT

DWORD

67

68

INPUT

ANY

65

68

INPUT

ANY

66

INPUT

BOOL

RET_VAL

65

66

67

68

69

OUTPUT

INT

BUSY

65

67

68

69

OUTPUT

BOOL

REQ_ID

66

OUTPUT

DWORD

NDA

66

OUTPUT

BOOL

RD

66

67

OUTPUT

ANY

VAR_ADDR
SD
EN_DT

20 - 64

,
REQ ="1"

CONT ="1"


(MPI-)


CPU

""
CPU,

EN_DT ="1":





BUSY ="1"



NDA ="1"

;
NDA ="0"
.
""
CPU,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

SFC 65 X_SEND
(Send data)

REQ BUSY: REQ = "1" BUSY = "0" ( ).
, BUSY
(BUSY = "1"). REQ
.
, BUSY (BUSY = "0").
REQ (REQ = "1"),
.

,
CPU .
, BUSY
(BUSY = "1"). -
, BUSY "0"
.
CONT (CONT = "0"),
, CPU
. CONT
(CONT = "1"), .
REQ_ID

ID,
SFC X_RCV.
SD ,
.
, , ANY.

( ).
SFC 66 X_RCV
(Receive data)

.
- .
EN_DT
"0". EN_DT = "0", NDA = "1",
RET_VAL .
REQ_ID ,
SFC 65 X_SEND. EN_DT = "1",
SFC 66 X_RCV
( ) ;
NDA = "1", RET_VAL
. EN_DT = "1",
, NDA = "0".
.

( ), ,
EN_DT = "0",
,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 65

20.

.
RD ,
.
, , ANY.

( ).
, RD SFC 66
X_RCV "" ANY (NIL ).
SFC 67 X_GET
C (Read data)

REQ BUSY: REQ = "1" BUSY = "0" ( ).
, BUSY
(BUSY = "1"). REQ
.
, BUSY
(BUSY = "0"). REQ (REQ
= "1"), .
,
CPU ,
VAR_ADDR. SFC
, RD. RET_VAL
.
CONT (CONT = "0"),
, CONT (CONT = "1"),
.
, STOP.
RD VAR_ADDR ,
,

,
, ANY.
(
).
SFC 68 X_PUT
(Write data)

REQ BUSY: REQ = "1" BUSY = "0" ( ).
, BUSY (BUSY = "1").
REQ
.
, BUSY
(BUSY = "0"). REQ (REQ
= "1"), .

20 - 66

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

,
,
SD, ,
.
CPU ,
VAR_ADDR. BUSY
(BUSY = "0").
,
STOP.
RD VAR_ADDR ,
,

,
, ANY.
(
).
SFC 69 X_ABORT
(Disconnect)

REQ, "1" -
.
SFC 69 X_ABORT ,

SFC X_SEND, X_GET X_PUT. ,
BUSY (BUSY = "1").
REQ .
, BUSY (BUSY = "0").
REQ (REQ = "1"),
.

20.7

SFB-

20.7.1
SFB- (
)
SIMATIC-.
;
MPI, PROFIBUS Ethernet.
.

("Communication via configured connections", extended
communication - "
", ).

, S7-400 CPU.
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 67

20.

(Two-way connection)

(Connection table)
SFB

DB

SFB

OS
CPU

CP

OS
CPU

CP

SFB

DB
SFB

MPI, PROFIBUS Ethernet

(One-way connection)

(Connection table)



SFB

DB

OS
CPU

CP

SFB

OS
CPU

CP

MPI, PROFIBUS Ethernet

. 20.16 SFB-
SFB-,
SFB Standard Library
System Function Blocks ( )
Blocks (),
20 - 68

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

SFB .
SFB
(program element catalog)
.
SFB-


(Connection table),
.
(ID
) . STEP 7
ID (Connection
table). "local ID" (" ID")
SFB ( "" - "own")
"remote ID" (" ID") SFB
.

/ (Send/Receive).
,
(job ID) ID (connection ID),
(Send)
(Receive) .


SFB-.
CPU, "Active connection buildup = Yes"
(" = ") .
SFB OB
,
:

REQ = FALSE ()

ID = ID (connection
table) ( : WORD W#16#xxxx)

PI_NAME = 'P_PROGRAM'
ASCII (, ARRAY[1..9] OF CHAR).


, DONE "1". ERROR
STATUS , ,
, () .
(
ADDR_x, RD_x SD_x).
""
SFB,
REQ EN_R.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 69

20.

20.7.2 (Two-way Data Exchange)


(Two-way Data
Exchange)
(SEND) (Receive)
.
(connection ID),
.
,
(job ID).

SFB:

(Two-way

Data

Exchange)

SFB 8 USEND

, CPU (Uncoordinated sending of
data packet),
SFB 9 URCV

, CPU (Uncoordinated receiving of
data packet),
SFB 12 BSEND
64
(Block-oriented sending of data),
SFB 13 BRCV
64
(Block-oriented sending of data).
SFB 20.13.
SFB 8 USEND SFB 9 URCV

(Uncoordinated sending/receiving of data packet)
SD_x
RD_x ,
.
SD_x RD_x.
-
(), 1.
(
FB; SFB ).
SFB 9 " " (Receive
mailbox);
" ".
, REQ (request "") ,
, R (reset - "")
. "1" EN_R (enable receive ) ,
.
20 - 70

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

20.13 SFB .

SFB

REQ

12

INPUT

BOOL

EN_R

13

INPUT

BOOL

12

INPUT

BOOL

ID

12

13

INPUT

WORD

R_ID

12

13

INPUT

DWORD

REQ ="1"

EN_R ="1" -
,


R

ID
(connection ID)
ID (job ID)

DONE

12

OUTPUT

BOOL

NDR

13

OUTPUT

BOOL

ERROR

12

13

OUTPUT

BOOL

STATUS

12

13

OUTPUT

WORD

SD_1

12

IN_OUT

ANY

SD_2

IN_OUT

ANY

SD_3

IN_OUT

ANY

SD_4

IN_OUT

ANY

RD_1

13

IN_OUT

ANY

RD_2

IN_OUT

ANY

RD_3

IN_OUT

ANY

RD_4

IN_OUT

ANY

LEN

12

13

IN_OUT

WORD

()
1-

2-

3-

4-

1-

2-

3-

4-

ID
(connection ID), STEP 7
(connection table) , (
). R_ID

(job ID), (Send)
(Receive) .
(Send) (Receive)
(
).
ID
R_ID .
( )
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 71

20.

DONE NDR, "1",


, .
,
ERROR. STATUS
ERROR = "0",
, ERROR = "1",
( ).
DONE, NDR, STATUS ERROR .
SFB 12 BSEND SFB 13 BRCV

(Block-oriented sending/receiving of data)
SD_x
RD_x (
);
LEN.
64 ;
(
[frames]).
.
, REQ (request "") ,
, R (reset - "")
. "1" EN_R (enable receive ) ,

ID

(connection ID),
STEP 7 (connection table) ,
(
).
R_ID
(job ID),
(Send) (Receive) .
(Send)
(Receive) (
).
ID
R_ID .
( )
.
DONE NDR, "1",
, .
,
ERROR. STATUS
ERROR = "0",
, ERROR = "1",
( ).
DONE, NDR, STATUS ERROR .

20 - 72

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

20.7.3 (One-way Data Exchange)


(One-way Data Exchange)
SFB
CPU. CPU

.

SFB:

(One-way

Data

Exchange)

SFB 14 GET
,
CPU,
SFB 15 PUT
,
CPU.
SFB
20.14.
CPU
, SFB
14;

CPU

SFB 15.
CPU
.
, REQ (request "") .
ID (connection
ID), STEP 7 (connection
table).
DONE NDR, "1",
, .
(),
ERROR = "1".
STATUS ERROR =
"0", ,
ERROR = "1", ( ).
DONE, NDR,
STATUS ERROR .
ADDR_n
CPU ,
. ,
ADDR_n, ,
SD_x RD_x.
- (), 1.
(
FB: SFB ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 73

20.

20.14 SFB .


SFB

REQ

14

15

INPUT

BOOL

ID

14

15

INPUT

WORD

REQ ="1"

ID (connection ID)

NDR

14

OUTPUT

BOOL

15

OUTPUT

BOOL

ERROR

14

15

OUTPUT

BOOL

STATUS

14

15

OUTPUT

WORD

ADDR_1

14

15

IN_OUT

ANY

ADDR_2

14

15

IN_OUT

ANY

ADDR_3

14

15

IN_OUT

ANY

ADDR_4

14

15

IN_OUT

ANY

RD_1

14

IN_OUT

ANY

()
1- CPU

2- CPU

3- CPU

4- CPU

1-

RD_2

14

IN_OUT

ANY

2-

RD_3

14

IN_OUT

ANY

3-

RD_4

14

IN_OUT

ANY

SD_1

15

IN_OUT

ANY

SD_2

15

IN_OUT

ANY

SD_3

15

IN_OUT

ANY

SD_4

15

IN_OUT

ANY

4-
1-

2-

3-

4-

DONE

20.7.4 (Print Data)


SFB 16 PRINT

CP 441.
SFB 14 GET
20.15.
, REQ (request "")
ID PRN_NR. ID
(connection ID),
PRN_NR (prnter number).
DONE, "1", ,
.

20 - 74

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

(), ERROR = "1".


STATUS ERROR =
"0", ,
ERROR = "1", ( ).
DONE, STATUS
ERROR .
STRING
FORMAT. 4 ,
SD_1SD_4.
- (), 1.
.
420
( ).
20.15 SFB 16 PRINT

REQ

INPUT

BOOL

REQ ="1"

ID

INPUT

WORD

ID (connection ID)

DONE

OUTPUT

BOOL

ERROR

OUTPUT

BOOL

STATUS

OUTPUT

WORD

()

PRN_NR

IN_OUT

BYTE

(prnter number)

FORMAT

IN_OUT

STRING

SD_1

IN_OUT

ANY

1-

SD_2

IN_OUT

ANY

2-

SD_3

IN_OUT

ANY

3-

SD_4

IN_OUT

ANY

4-

20.7.5 (Control Functions)



SFB:
SFB 19 START
"" (complete)
,
SFB 20 STOP

STOP,
SFB 21 RESUME
"" (warm)
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

20 - 75

20.


;
,
.
SFB
20.16.
20.16 SFB
.


SFB

REQ

19

20

21

INPUT

BOOL

ID

19

20

21

INPUT

WORD

REQ ="1"

ID (connection ID)

DONE

19

20

21

OUTPUT

BOOL

ERROR

19

20

21

OUTPUT

BOOL

STATUS

19

20

21

OUTPUT

WORD

()

PI_NAME

19

20

21

IN_OUT

ANY

(P_PROGRAM)

ARG

19

21

IN_OUT

ANY

IO_STATE

19

20

21

IN_OUT

BYTE

, REQ (request "") . ID


(connection ID),
STEP 7 (connection table).
DONE, "1", ,
.
(), ERROR = "1".
STATUS ERROR =
"0", ,
ERROR = "1", ( ).
DONE, STATUS
ERROR .
PI_NAME ,
"P_PROGRAM" (ARRAY [1...9] OF CHAR).
ARG IO_STATE
.
SFB 19 START ""
(complete) CPU .
"" : CPU
STOP,
RUN RUN_P.
SFB 20 STOP CPU
STOP.
: CPU
STOP .
20 - 76

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

SFB 21 RESUME ""


(warm) CPU .
"" : CPU
STOP,
RUN RUN_P

"" .

20.7.6 (Monitoring Functions)



:
SFB 22 STATUS

("status" - ),
SFB 23 USTATUS

("status" - ),
SFC 62 CONTROL
("status" - )
SFB.
SFB 22 SFB
23 20.17,
SFC 62 20.18
20.17 SFB 22 SFB 23


SFB

REQ

22

INPUT

BOOL

EN_R

23

INPUT

BOOL

ID

22

23

INPUT

WORD

REQ = "1"

EN_R = "1"

ID (connection ID)

NDR

22

23

OUTPUT

BOOL

ERROR

22

23

OUTPUT

BOOL

STATUS

22

23

OUTPUT

WORD

PHYS

22

23

IN_OUT

ANY

LOG

22

23

IN_OUT

ANY

LOCAL

22

23

IN_OUT

ANY

()

(Phisical status)

(Logical status)
()

S7 CPU

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 77

20.

20.18 SFC 62 CONTROL

EN_R

INPUT

BOOL

I_DB

INPUT

BLOCK_DB

EN_R = "1"

OFFSET

INPUT

WORD

RET_VAL

OUTPUT

INT

ERROR

OUTPUT

BOOL

STATUS

OUTPUT

WORD

I_TIP

OUTPUT

BYTE

I_STATE

OUTPUT

BYTE

I_CONN

OUTPUT

BOOL

I_STATUS

OUTPUT

WORD

(status)
( I_CONN = "1",
)
STATUS
SFB

, :
(),
ERROR = "1". STATUS
ERROR = "0",
, ERROR = "1",
.
SFB 22 STATUS

SFB 22 STATUS
CPU
PHYS ( ), LOG ( )
LOCAL ( ,
S7 CPU).
, REQ (request "") . ID
(connection ID),
STEP 7 (connection table).
NDR, "1", ,
.
NDR, STATUS ERROR
.
SFB 23 USTATUS

SFB 23 USTATUS
,

20 - 78

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20.

.
PHYS, LOG LOCAL.
EN_R (enable receive - " ")
(EN_R = "1"),
. ID
(connection ID), STEP 7
(connection table).
NDR, "1", ,
.
NDR, STATUS ERROR
.
SFC 62 CONTROL
SFB
SFC 62 CONTROL
SFB (associated)
. I_DB
. SFB ,
OFFSET (0 -
, 1 - , 2 -
, ..).
EN_R (enable receive - " ")
(EN_R = "1"),
. ID
(connection ID), STEP 7
(connection table).
NDR, "1", ,
.
NDR, STATUS ERROR
.
I_TIP, I_STATE, I_CONN I_STATUS ,
SFB.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

20 - 79

20.

20 - 80

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21
.
,
,
, .

.

().
""
(interrupts) . ,
,
. .

(priority class - "" ).
, -,
,
.

.
,
.

21.1
SIMATIC S7 :

(hardware interrupts) , (
, ,
);

(watchdog interrupts) ,
();

( ) (time-of-day interrupts) ,
( );

c (time-delay interrupts) ,
(
);

(multiprocessor interrupts) , CPU ,


.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 1

21.

,
, ,

,
,
.
23 " ".


.
(main program) (
1),
( 26),
(start-up routine).
,
. S7-300 ; S7400

CPU.
, ,
,
3.1.2 " ".

,
,
(disable) , , (enable)
SFC 39 DIS_IRT SFC 40 EN_IRT ,
(.., ),
SFC 41 DIS_AIRT SFC
42 EN_AIRT (. 21.7 " ").

,
I/O
( ,
),
I/O ( ,

).
I/O
, , I/O
(load)
(transfer).

I/O .

, S7-400
(subprocess
image).
. SFC 26

21 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.

UPDAT_PI SFC 27 UPDAT_PO


(. 20.2.1
" ").
S7-400 CPU
(
)
.
,
21.1
. S7-300
- 256 .
S7-400

CPU ( " " [local data] ),



, CPU.
,

, 20 ,
.
.
21.1

60

40.. 47

""

""


(WORD)

(DWORD)

(DT)

1
2

8..9

(INT)
-

10..11

12..19


(DT)

6..7

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

(time-delay
interrupts)
20.. 23

30.. 38

""

""

(time-of-day
interrupts)
10.. 17

""

""

[] (WORD)
-

(WORD)

(TIME)

(DT)

(watchdog
interrupts)


[] (INT)

(DT)

(WORD)

(DT)

21 - 3

21.

21.2 (Hardware Interrupts)


(hardware interrupts)
,
,

. STEP 7 40 47
. , ,
, CPU.

). SFC 55 WR_PARM, SFC


56 WR_DPARM SFC 57 PARM_MOD ()
RUN,
.

21.2.1
,
. , ,
, , ,
, ,
, .
.
,
; ,
,
, ( ).
- ,
,
SFC.
(slave) DP-,
,
CPU (master) DP- SFC 7
DP_PRAL.
,

.
S7-300

,
,
, ,
, ,
.
, -

21 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.

, ,
, .

.
,
, , ,
, ,
,
.
S7-400


,
,
. , ,
,
,
.

21.2.2

, ,
6 7
, .
, 5
B#16#54, B#16#55.
, ,
, 8 11 ;

() .
(start-up program)
(start-up program),
.
RUN. ,
.

,
,
OB 85 ( ,
).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 5

21.

(). OB 85
, CPU STOP.
(disabling), (delaying)
(enabling)

(disable) (enable)
SFC 39 DIS_IRT SFC 40 EN_IRT ,
(delay) (enable)
SFC 41 DIS_AIRT SFC 42 EN_AIRT .

21.2.3
STEP 7

). CPU, : Edit ->


Object Properties ( -> )
"Interrupts" ("").
S7-300 OB 40
16 . S7-400
(
CPU) 2 24;
(0)
.
,
, , 12
.
(enable)
.
CPU.
STEP 7
System data (
) Blocks (),
CPU, CPU
STOP. CPU
;
.

21.3 (watchdog Interrupts)


(watchdog interrupt) - ,


.

21 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.


,
() .
STEP 7 30 38
. , ,
,
CPU.

) CPU.

21.3.1 (watchdog Interrupts)


S7-300
S7-300
OB 35, 12. CPU

1 1 , 1
.
S7-400
CPU
. : ,
.
. ,
, 1
1 , 1 .
2 24,
(0), CPU.
, .
STEP 7 ,
21.2 .
21.2 ,


(Time Interval)
(Phase Offset)
(Priority)
30
5
0
7
31
2
0
8
32
1
0
9
33
500
0
10
34
200
0
11
35
100
0
12
36
50
0
13
37
20
0
14
38
10
0
15

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 7

21.

" " (Phase Offset)


" " (Phase Offset)
,
, ,
.

.
" " (start time) " " (phase offset)
(STARTUP)
(RUN) . OB
(time
interval) (phase offset). . 21.1 ,
.

1
(time interval 1)

2
(time interval 2)


RUN

1
(time interval 1)

2
(time interval 2)


(phase offset)

. 21.1 , "
" (phase offset)
, 1 "
" ( 0); 2
, 1.
2 ,
2
1 .
,
, ,
,
.
(start-up program)
(start-up).

21 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.


, (RUN).

,

,
OB 80 (
[timing error]). OB 80 , CPU
STOP.
,
, .

,
.
, , -
, CPU, ,
.
CPU STOP.
(disabling), (delaying)
(enabling)

(disable) (enable)
SFC 39 DIS_IRT SFC 40 EN_IRT ,
(delay) (enable)
SFC 41 DIS_AIRT SFC 42 EN_AIRT .

21.3.2
Interrupts) STEP 7

(watchdog

). CPU, : Edit ->


Object Properties ( -> )
"Cyclic Interrupts" (" ").
S7-300
12 . S7-400
(
CPU)
2 24;
(0) .
,
, , 12
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 9

21.


"Execution" (""), (..,
) - "Phase Offset"
(" ").
STEP 7
System data (
) Blocks (),
CPU, CPU
STOP.
.

21.4 (time-of-day interrupts)


(time-of-day interrupts) -
, ,
, ,
. STEP 7 10
17 (timeof-day interrupts). , ,
, CPU.

(
)
RUN.


CPU (real-time clock).

21.4.1 (time-of-day
interrupts)


(start time), .
(time-of-day interrupts)

. ,

CPU.
(time-of-day interrupts)
:
:
;

: OB
, , , ,
.
21 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.


.
, SFC 29 CAN_TINT.

, " "
(start time), .
,
SFC 31 QRY_TINT.

"" (cold) (complete)
,

SFC.
,

. "" (warm)
CPU
(complete)
.
,
SFC 31 QRY_TINT ,
.

RUN.
()
OB (time-of-day
interrupts), OB ,
OB 85 ( ,
). OB 85 , CPU
STOP.
, ,
- , CPU,
,
. CPU STOP.

, (start
time) (
), OB 80 (
[timing error]). OB 80 ,
CPU STOP.

, (start
time) (
),
(
).

,
(start time) ,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 11

21.

OB 80 (
[timing error]). OB
(time-of-day interrupts) .

, OB
(time-of-day interrupts)
,
.
OB (time-of-day
interrupts),
( ),
OB 80 (
[timing error]). OB 80 OB
, OB
.
(disabling), (delaying)
(enabling)

(disable) (enable)
SFC 39 DIS_IRT SFC 40 EN_IRT ,
(delay) (enable)
SFC 41 DIS_AIRT SFC 42 EN_AIRT .

21.4.2 (time-ofday interrupts) STEP 7



(
). CPU, : Edit ->
Object Properties ( -> )
"Time-of-Day" (" ").
S7-300
2. S7-400
( CPU)
2 24
0;
0 .
,
, , 12
.
"Active" ("")
(time-of-day interrupts). "Execution"
("") ,
-
.
-

21 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.

" " (
).
STEP 7
System data (
) Blocks (),
CPU, CPU
STOP.
.

21.4.3
(time-of-day interrupts)
(time-of-day interrupts)
:

SFC 28 SET_TINT
(time-of-day
interrupt);

SFC 29 CAN_TINT
(time-of-day
interrupt);

SFC 30 ACT_TINT
(time-of-day
interrupt);

SFC 31 QRY_TINT
(timeof-day interrupt).


21.3.
SFC 28 SET_TINT
(time-of-day interrupt)
( )
, SFC 28 SET_TINT.
SFC 28 SET_TINT " "
("start time"); ,
,
SFC 30 ACT_TINT. " "
SDT DATE_AND_TIME, , DT#1997-06-3008:30.
.
,
, .
,
,
SFC 30
ACT_TINT.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 13

21.

21.3
(time-of-day interrupts)

28

OB_NR

INPUT

INT

SDT
PERIOD

INPUT
INPUT

DT
WORD

RET_VAL
OB_NR
RET_VAL
OB_NR
RET_VAL

OUTPUT
INPUT
OUTPUT
INPUT
OUTPUT

INT
INT
INT
INT
INT

OB_NR

INPUT

INT

RET_VAL

OUTPUT

INT

STATUS

OUTPUT

WORD

29
30
31

,

(/)
DATE_AND_TIME
(
[start time]):
W#16#0000 =
W#16#0201 =
W#16#0401 =
W#16#1001 =
W#16#1201 =
W#16#1401 =
W#16#2001 =
W#16#1801 =

, .

, .

,
.

(time-of-day
interrupt)

SFC 30 ACT_TINT
(time-of-day interrupt)
,
SFC 30 ACT_TINT. ,
, " " ("start time")
.
,
(start time) , SFC 30
.
,
,

.
,
.
( )
.
SFC 29 CAN_TINT
(time-of-day interrupt)
( )

21 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.

,
SFC 29 CAN_TINT.
.
,
,
.
SFC 31 QRY_TINT
(time-of-day interrupt)

, SFC 31 QRY_TINT. SFC 31
QRY_TINT STATUS.
"1",
:
0-

1-

2-

3-

(- -);

4-

5-

6-

( - -).

21.5 c (time-delay interrupts)


(time-delay interrupts) -
,
. STEP 7
20 23
(time-delay interrupts).
, ,
, CPU.

(
);
.

21.5.1 c (time-delay
interrupts)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 15

21.

SFC 32 SRT_DINT;

. ,
,
.

(time-delay interrupts) SFC 33 CAN_DINT,
OB
.

, SFC 34 QRY_DINT.

"" (cold) (complete)
,
(time-delay interrupts).
"" (warm) ,
RUN, " "
(start-up).

(start-up), SFC 32. ,
(
) CPU RUN,

. , CPU
(start-up),

;
.
()
OB (timedelay interrupts), OB ,
OB 85 ( ,
). OB 85
, CPU STOP.
( ) OB
,
,
OB 80 (
[timing error]) STOP, OB 80
.
, ,
- , CPU,
,
. CPU STOP.
(disabling), (delaying) (enabling)

21 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.

(disable) (enable)
SFC 39 DIS_IRT SFC 40 EN_IRT
, (delay)
(enable) SFC 41 DIS_AIRT SFC 42
EN_AIRT .

21.5.2 c
(time-delay interrupts) STEP 7

(
). CPU,
: Edit -> Object Properties ( -> )
"Interrupts" ("").
S7-300 ( CPU 318)
3.
S7-400 ( CPU 318)
( CPU)
2 24
0;
0 .
,
, , 12
.
STEP 7
System data (
) Blocks (),
CPU, CPU
STOP.
.

21.5.3
(time-delay interrupts)

c (time-delay
interrupts) :

SFC 32 SRT_DINT
OB ;

SFC 33 CAN_DINT
(time-of-day
interrupt);

SFC 34 QRY_TINT

(time-of-day interrupt).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 17

21.


21.4.
21.4
(time-delay interrupts)

32

OB_NR

INPUT

INT

DTIME

INPUT

TIME

SIGN

INPUT

WORD

33

RET_VAL
OB_NR
RET_VAL

OUTPUT
INPUT
OUTPUT

INT
INT
INT

34

OB_NR

INPUT

INT

RET_VAL

OUTPUT

INT

STATUS

OUTPUT

WORD

( -
: T#1msT#1m)

OB (
)

, .

,
.

(time-of-day
interrupt)

SFC 32 SRT_DINT
(time-delay interrupt)
(time-delay interrupt)
SFC 32 SRT_DINT.
SFC 32 SRT_DINT
( ).
, CPU

.
SIGN
SFC 32. 6 7

. ( )
, 1 .
" " 1 .
, ,
, ,

, ,
(time-delay interrupt).

SFC 32.
SFC.

21 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.

SFC 33 CAN_DINT
(time-delay interrupt)
(time-delay
interrupt), SFC 33 CAN_DINT.
,
.
SFC 34 QRY_DINT
(time-delay interrupt)

, SFC 34 QRY_DINT.
OB_NR ( ).
SFC 34 QRY_DINT
STATUS.
"1",
:
0-

1-

2-

3-

(- -);

4-

5-

6-

( - -).

21.6

CPU,
.
SFC 35 MP_ALM.

60, , 25.

SFC 35 MP_ALM

. CPU ,
OB 60 .
, OB 60
CPU , , CPU,
SFC 35 OB 60
, CPU .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 19

21.

) - CPU,
. ,
,
( , 20 )
"Local Data" CPU
25.


RUN. SFC 35 MP_ALM
(start-up)
32929 (W#16#80A1) .
()
, SFC 35 , OB 60
, 32928
(W#16#80A0) .
OB 60 CPU.
OB 60 CPU
(disable),
(delay) OB ,
SFC 35 CPU
.
(disabling), (delaying) (enabling)

(disable) (enable)
SFC 39 DIS_IRT SFC 40 EN_IRT
, (delay)
(enable) SFC 41 DIS_AIRT SFC 42
EN_AIRT .
SFC 35 MP_ALM


SFC 35 MP_ALM.
21.5.
JOB
.
6 7
CPU.

21 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.

21.5 SFC 35 MP_ALM

JOB

INPUT

BYTE


( : B#16#00 B#16#0F)

RET_VAL

OUTPUT

INT

21.7

SFC 39 DIS_IRT
(disable) OB ;

SFC 40 EN_IRT
(enable) OB ;

SFC 41 DIS_AIRT
(delay) OB ;

SFC 42 EN_AIRT
(enable) OB .


21.6.

.
SFC 36 SFC 38
(. 23 " ").
21.6
(time-delay interrupts)

39

MODE

INPUT

BYTE

(Disable mode) (. )

OB_NR

INPUT

INT

(. )

RET_VAL

OUTPUT

INT

MODE

INPUT

BYTE

(Enable mode) (. )

OB_NR

INPUT

INT

(. )

RET_VAL

OUTPUT

INT

41

RET_VAL

OUTPUT

INT

()

42

RET_VAL

OUTPUT

INT

40

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 21

21.

SFC 39 DIS_IRT
(disable) OB
SFC 39 DIS_IRT
.
.

SFC 39 DIS_IRT,
; , CPU
STOP.
SFC 39 (disable)
,
SFC 40 EN_IRT.
.
MODE OB_NR ,

. MODE = B#16#00,
.
MODE = B#16#01,
, OB OB_NR.
, MODE = B#16#01 OB_NR = 40,
; OB_NR = 80,
.
MODE = B#16#02,
, OB
OB_NR.
, SFC 39 (disable)
,
.
SFC 40 EN_IRT
( - enable) OB
SFC 40 EN_IRT
,
SFC 39 DIS_IRT.
SFC 40 EN_IRT
;

, CPU STOP ( ,
81, ..
).
MODE OB_NR ,

. MODE = B#16#00,
.
MODE = B#16#01,
, OB OB_NR.
MODE = B#16#02,
, OB
OB_NR.

21 - 22

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21.

SFC 41 DIS_AIRT
(delay) OB
SFC 41 DIS_AIRT
(delay) .
" " ,
,
SFC 41 DIS_AIRT,
, () .
SFC 41,
( )
;
.
SFC 41 (delay) ,
OB,
SFC 42 EN_AIRT.
SFC 41 .
RET_VAL .
SFC 42,
SFC 41,
.
SFC 42 EN_AIRT
( - enable) OB .
SFC 42 EN_AIRT
,
SFC 41 DIS_AIRT.
SFC 42,
SFC 41 ( ). RET_VAL
SFC 41 DIS_AIRT,
; RET_VAL = 0,
( ).
SFC 42 (enable), SFC 41
(delay) , RET_VAL
32896 (W#16#8080).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21 - 23

21.

21 - 24

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22

22.1
22.1.1

(main program) CPU
(restart routine). START-UP ()
CPU, STOP () RUN
(). CPU
START-UP , , START-UP,
(restart routine).
(1) CPU STOP
(.22.1). CPU
RUN RUN-P, CPU
START-UP (2), - RUN (3).
"" , CPU START-UP
RUN, CPU
STOP, CPU STOP (4) (5).

" " HOLD
(). RUN,
START-UP, , ,
(6) (7).
CPU STOP HOLD (8).

(2)
(5)

(1)

STARTUP
()

(3)

(7)

STOP
()

(8)

HOLD
()

RUN
()

(6)

(4)
. 22.1 CPU

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22 - 1

22.

CPU "Restart" ("")


,
"Ready" ("")
, , CPU ,
" ",
CPU.
SIMATIC S7
, : "" (cold restart), ""
(complete restart) "" (warm restart).
"" ""
. ""
,
, "" .
, ,
,
, , ,
. 23 "
".
S7 CPU 1998 . ""
(complete restart) "" (warm restart).

""

""
.
START-UP.
STEP 7 102 ( "" ), 100 ( ""
) 101 ( "" ).
, CPU
" " .

22.1.2 HOLD ()

CPU HOLD () ,
"
" ( ).
"STOP", "RUN" .
HOLD () .
,
.
,
HOLD.
HOLD () ,
, (
). , ,
,
,
.

22 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22.

:
.


, "" ("single step")
,
-
"" .
HOLD () CPU ""
, ,

.
, CPU
HOLD, CPU
STOP, CPU
.

22.1.3 (disable)
STOP HOLD ( ,
OD-). ""
( ) ,
, "
" ( ).
, "Enable
Peripheral Outputs" (" ")
STOP.

. ,
, .
( !)
.
,
,
( [transfer]
PQ),
. CPU (Disable),

.
"" ( 102) "" ( 100)
.
102 100,
,
. ( ,
, [load] PI
I), .

( 1),
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22 - 3

22.

(
),
.
"" ""
,
STOP,
101
.
(
,

).
CPU,
""
. 1 CPU
(Disable),
.

22.1.4
"" CPU
102; "" CPU
100. 100 102 CPU
.
"" CPU
101 .
101 CPU

.

. 22.1
100.
( 1):
B#16#81 - "" ( 100)
B#16#82 - "" ( 100)
B#16#83 - "" ( 101)
B#16#84 - "" ( 101)
B#16#85 - "" ( 102)
B#16#86 - "" ( 102)
(STOP)
( , , ,
""
).

.

22 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22.

22.1

OB100_EV_CLASS

BYTE

OB100_STRTUP

BYTE

(. )

OB100_PRIORITY

BYTE

OB100_OB_NUMBR

BYTE

OB100_RESERVED_1

BYTE

OB100_RESERVED_2

BYTE

6..7

OB100_STOP

WORD

8..11

OB100_STRT_INFO

DWORD

12..19

OB100_DATE_TIME

DT

(STOP)

22.2 (Power-Up)
22.2.1 STOP ()
CPU STOP :

CPU ;


() STOP ();

""
;

SFC 46 STP;

CPU
( STOP ()
CPU).

RUN

CPU STOP
. ,
CPU ,
.
STOP () .
CPU : ,
CPU,
, ,
.
STOP () CPU
GD- ""
. STOP
.
CPU STOP, ,
MPI-,
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

22 - 5

22.

CPU.

22.2.2 (Memory Reset)


(Memory Reset) CPU .
,
STOP () .
MRES 3
, - 3
MRES 3 .
CPU -
(work) (load) RAM-.
(, )
.
CPU (
) , "
". , MPI-
, CPU, "",
MPI-.
,
( ).
Flash EPROM, CPU
(work) .
CPU ,
.

22.2.3 (Retentivity)
, ,
,
STOP () RUN ()
( "" "" ).
, ,
, S7-300, . ,
, CPU.

"Retentivity" ("") CPU.
(SDB)
(load) , .
RAM,
.
,
, , .
.

- RAM -EPROM.

22 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22.

Flash EPROM
, S7-300 S7-400 -.
S7-300 , , ,
, , S7-400 -
.

S7-300. , S7-300
CPU, .
S7-300
S7-400 (work)
. ,
, , . ,
SFC 22 CREAT_DB,
.
, , ..
, .

22.2.4
CPU "Startup" ("")
, :

"Restart when the set configuration is not the same as the actual
configuration" (
).

"Hardware test at complete restart (warm restart)" (


"" ( "" )).
S7-300 CPU
.

"Delete PIQ at warm restart" (


"" ).
S7-400 CPU
"" .

"Disable warm restart at manual restart" ( ""


).
"" .

"Restart following POWER UP" ( ).


.

"Monitoring time for ready signal of the modules" (


, ).
,
, CPU STOP;
(
).

"Monitoring time for transferring the parameters to the modules" (


,
).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22 - 7

22.

, ,
CPU STOP;
. (
CPU
-
. ""
,
,
, ""
).

22.3

"Monitoring time for warm restart" ( ,


"" ).

STOP
RUN , ,
CPU STOP. ,
0, .

22.3.1 (START-UP)
CPU :

STOP ()
RUN () RUN-P;

(,

CPU).

(Manual)
. (Automatic)
.
,
;
.

.

RUN (
).
CPU ,
.
,
.. .

.
, ,

22 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22.

,
. ""
, "" .
"" ,
.
22.2 CPU .

22.3.2 "" (Cold Restart)


CPU

, (
), 102
1 .

(work) - ,
SFC; (load) .
(
(load) RAM- ).
"" (Manual cold restart)
""
:
CPU:
CPU 3
MRES STOP () RUN
() RUN-P;

PG SFB
CPU:
RUN () RUN-P.

"" ,
CPU .
"" (Automatic cold restart)
""
. ""
:
CPU STOP (),
;

RUN ()
RUN-P.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22 - 9

22.

""

""

""

()

100
"" "

102
"" "

101
"" "

""

RUN
()

""

S T O P ()

. 22.2 CPU
22 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22.

""
;

"Automatic cold restart on power


( "" ).

up"

CPU
"" (..
) "" . CPU
,
(work) .
Flash EPROM.

22.3.3 "" (Complete Restart)


CPU

, ,
100
1 .
"" (Manual complete restart)
""
:
CPU:
STOP () RUN () RUN-P ( S7-400
CPU) ,
CRST;

PG SFB
CPU:
RUN () RUN-P.

"" ,
CPU .
"" (Automatic complete restart)
""
. ""
:
CPU STOP (),
;

RUN ()
RUN-P.

""
;

"Automatic complete restart on power up"


( "" ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22 - 11

22.

,
"" .
CPU
"" (..
) "" . CPU
,
(work) .
Flash EPROM.

22.3.4 "" (Warm Restart)

"" S7-400.
STOP ()
CPU ,
,
. ""
,
, . ,
,
, .
, "" ,
.
" " ("residual
cycle"), ,
, , CPU ""
.
() .
.
"" ,
, CPU
STOP, .
CPU ,
CPU
"" ( 100 1
). ,
"" .
RUN () STOP ()
RUN
( OB 101
" ").
"" (Manual warm restart)
"" :
CPU
RUN () RUN-P STOP (),

22 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22.

, WRST (
CPU, );

PG SFB
CPU:
RUN () RUN-P.

"" ,
"Restart" ("") CPU
"" . STOP
,
; CPU
"" , CPU
STOP.
"" (Automatic warm restart)
""
. ""
:
CPU STOP (),
;

RUN ()
RUN-P, CPU ;

"Automatic warm restart on power


( "" );

up"


.

"" .

22.4



:
SFC 5 GADR_LGC
;

SFC 50 RD_LGADR
;

SFC 49 LGC_GADR
.

22.2
.
SFC IOID
(= I/O).
IOID B#16#54,
(PI) B#16#55, (PQ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22 - 13

22.

22.2
SFC
5

50

49

SUBNETID

INPUT

BYTE

RACK

INPUT

WORD

SLOT

INPUT

WORD

SUBSLOT

INPUT

BYTE

SUBADDR

INPUT

WORD

RET_VAL

OUTPUT

INT

IOID

OUTPUT

BYTE

LADDR

OUTPUT

WORD

IOID

INPUT

BYTE

LADDR

INPUT

WORD

RET_VAL

OUTPUT

INT

PEADDR

OUTPUT

ANY

PI-

PECOUNT

OUTPUT

INT

PI-

PAADDR

OUTPUT

ANY

PQ-

PACOUNT

OUTPUT

INT

PQ-

IOID

INPUT

BYTE

LADDR

INPUT

WORD

RET_VAL

OUTPUT

INT

AREA

OUTPUT

BYTE

RACK

OUTPUT

WORD

SLOT

OUTPUT

WORD

SUBADDR

OUTPUT

WORD

LADDR I/O- PI- PQ-,


. 0,
.

(
) (
).
SFC 5 GADR_LGC

SFC 5 GADR_LGC
, ("" ).
SUBNETID,
(I/O), B#16#00,
. RACK
, I/O, .
, B#16#00 SUBSLOT.
SUBADDR

22 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22.

(, W#16#0000
).
SFC 49 LGC_GADR

SFC 49 LGC_GADR ,
.
( SUBADDR)
,
. AREA ,
(. . 22.3).
22.3 SFC 49 LGC_GADR
AREA
()
0

System
()
S7-400

S7-300

I/O

S5 P

S5 Q

S5 IM3

S5 IM4

RACK, SLOT, SUBADDR


RACK =
SLOT =
SUBADDR =
RACK, SLOT, SUBADDR
RACK =
SLOT =
SUBADDR =

SFC 50 RD_LGADR

S7-400
( ; ).
SFC 50 RD_LGADR
,
.
PEADDR PAADDR WORD
("" ANY-; :
P#DBzDBXy.x WORD nnn).
SFC 50 RD_LGADR PECOUNT PACOUNT
, .

22.5



:
SFC 54 RD_DPARM

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22 - 15

22.

SFC 55 WR_PARM
;

SFC 56 WR_DPARM
;

SFC 57 PARM_MOD
;

SFC 58 WR_REC
;

SFC 59 RD_REC
.

22.4 (
) .
22.4

REQ


SFC
-

55

56

57

58

59

RACK,
SLOT, SUBADDR

INPUT

BOOL

REQ =1

IOID

54

55

56

57

58

59

INPUT

BYTE

B#16#54 =
(PI)
B#16#55 =
(PQ)

LADDR

54

55

56

57

58

59

INPUT

WORD

RECNUM

54

55

56

58

59

INPUT

BYTE

RECORD

55

58

INPUT

ANY

RET_VAL

54

55

56

57

58

59

OUTPUT

INT

55

56

57

58

59

OUTPUT

BOOL

BUSY =1

54

59

OUTPUT

ANY

BUSY
RECORD

2 127

128 255


S7- ,
,
, , " ".
22 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22.



.
System Data Blocks () PLC
.
CPU
:
;

"" ("return")
.


.
Hardware Configuration ,
.
, SFC.
,
SFC, (
CPU) ,
Hardware Configuration.

: - " 0" ("data record 0"),
- " 1" ("data record 1").

SFC 57 PARM_MOD,
" 0" " 1" - SFC 56
WR_DPARM " 1" SFC 55 WR_PARM.
CPU.
S7-400
, 2 ("Operating mode" - " ")
2 0 "RUN"
("") (
SFC 59 RD_REC).
:
( LADDR)
,
( IOID).

, .
I/O ,
(Read) (Write).
BYTE
RECORD ANY.
ARRAY, STRUCT
UDT, ANY- BYTE (, P#DBzDBXy.x BYTE nnn).
, ""
-
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22 - 17

22.

SFC 54 RD_DPARM

SFC 54
RD_DPARM ,
RECNUM, SDB
, RECORD.
, ,
SFC 58
WR_REC.
SFC 55 WR_PARM

SFC 55 WR_PARM
, RECORD
, IOID LADDR.
RECNUM.
, ,

SDB .
, ,
;
.
BUSY
"1".
SFC 56 WR_DPARM

SFC 56 WR_DPARM
,
RECNUM, SDB ,
IOID LADDR.

.
BUSY "1".
SFC 57 PARM_MOD

SFC 57 PARM_MOD
,
Hardware
Configuration.

.
BUSY "1".

22 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22.

SFC 58 WR_REC

SFC 58 WR_REC
, RECORD
RECNUM ,
IOID LADDR. , REQ
"1". , ,
.

.
BUSY "1".
SFC 59 RD_REC

REQ "1",
SFC 59 RD_REC ,
RECNUM
RECORD. ,
, .
, RET_VAL
.

.
BUSY "1".
, S7-300 1997 SFC
,
.
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

22 - 19

22.

22 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23

, CPU,
CPU :

,
(, REAL), -
( OV, ,
);

,
("synchronous errors" - " "), -
121 122;

("asynchronous errors" - " "), -


80 87.

CPU , ,
,

()

- ,
. ,
(, ), CPU
STOP.
CPU STOP,
PG CPU
(B stack), (I
stack) (L stack),
.
/
.
CPU (
CPU STOP)
.

STOP, ,
.

PG.
CPU CPU
,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23 - 1

23.

23.1
CPU ,
, ,
. ,
, CPU
STOP. :

,
OB 121

,
122.

23.1

23.1

OB12x_EV_CLASS

BYTE

OB12x_EV_CLASS = B#16#25:
121 ;
OB12x_EV_CLASS = B#16#29:
122 .

OB12x_SW_FLT

BYTE

(. 23.2.1 " ")

OB12x_PRIORITY

BYTE

OB12x_OB_NUMBR

BYTE

(B#16#79 B#16#80)

OB12x_BLK_TYPE

BYTE

,
( S7-400):
OB: B#16#88; FB: B#16#8E; FC: B#16#8C.

OB121_RESERVED_1

BYTE

(B#15#xy):
7
(x)
4 3

OB122_MEM_AREA

1
2
3
4

OB121_FLT_REG
OB122_MEM_ADDR

WORD

OB12x_BLK_NUM

WORD

OB12x_PRG_ADDR

WORD

OB12x_DATE_TIME

DT

0
1
2
3
4
5
6
7

(y)

OB121:
( /)
( )
, /
OB122: ,
, ( S7-400)
,
( S7-400)


, .
,
23 - 2

I/O PI PQ
. . I
. . Q

DB
DI
L

- V

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23.

, OB
(
) ,
.
, OB
, 20 L-
, ,
OB
,
OB.
S7-400 OB
OB .
OB 3
S7-400 CPU 4 S7-300 CPU.
(disable) (enable) OB
SFC 36
MSK_FLT, SFC 37 DMSK_FLT, SFC 38 READ_ERR.

23.2

:

SFC 36 MSK_FLT
SFC 36 MSK_FLT
( OB);

SFC 37 DMSK_FLT
SFC 37 DMSK_FLT
( OB);

SFC 38 READ_ERR
SFC 38 READ_ERR
.



SFC 36, SFC 37 SFC 38.
23.2
.

23.2.1
, ,
, " "
("error filters").
;
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23 - 3

23.

23.2
SFC
36

37

38

PRGFLT_SET_MASK

INPUT

DWORD

ACCFLT_SET_MASK

INPUT

DWORD

RET_VAL

OUTPUT

INT

PRGFLT_MASKED

OUTPUT

DWORD

ACCFLT_MASKED

OUTPUT

DWORD

INPUT

DWORD

INPUT

DWORD

RET_VAL

OUTPUT

INT

PRGFLT_MASKED

OUTPUT

DWORD

ACCFLT_MASKED

OUTPUT

DWORD

PRGFLT_QUERY

INPUT

DWORD

ACCFLT_QUERY

INPUT

DWORD

RET_VAL

OUTPUT

INT

PRGFLT_CLR

OUTPUT

DWORD

ACCFLT_CLR

OUTPUT

DWORD

PRGFLT_RESET_
MASK
ACCFLT_RESET_
MASK

()

()

W#16#0001 ,


""

""
()

()

W#16#0001 ,
,
(
)

""

""

W#16#0001 ,
,
(
)





, ,
,
. SFC 38
"1" , ,
, .
23.3.
Error Code OB122_SW_FLT
OB 122.
23.4.
Error Code OB121_SW_FLT
OB 121.
S7-400 CPU :

. ,
"" 150 .

23 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23.

, I/O
.
23.3


(Error Code)
B#16#42

B#16#43

B#16#44

B#16#45

I/O
S7-300:
S7-400:
I/O ( )
I/O
S7-300:
S7-400:
I/O ( )
S7-400:
I/O
( ) ,

S7-400:
I/O
( ) ,

23.4


(Error Code)
B#16#21

B#16#22

B#16#23

B#16#24

B#16#25

B#16#26

7
8

B#16#27
B#16#28

B#16#29

16

B#16#30

17

B#16#31

18

B#16#32


( <>0 , ,
)
( <>0 , ,
)
(
)
(
)
(DB )

19

B#16#33

(DI )

20

B#16#34

(FC)

21

B#16#35

(FB)

26

B#16#3A

(DB)

28

B#16#3C

(FC)

30

B#16#3E

(FB)

BCD- (
"-")
(
)
(
)
(
)
(
)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23 - 5

23.

CPU I/O,
,
( I/O)
( ).
, ,
.

23.2.2
SFC 36 MSK_FLT
. "1"
,
(
, "" - "masked").

,
. SFC 36
, W#16#0001, ,


.
SFC 36 "1"
.
, ,
,
. (Disable)
( - "priority
level"). ,
,
,
, .

23.2.3
SFC 37 DMSK_FLT
()
. "1"
,
(
, "" - "unmasked").

, .
SFC 37 W#16#0001, ,

( ) ,

( ).

23 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23.

SFC 37 "1"
.
, ,
,
. (Disable)
( - "priority
level").

23.2.4
SFC 38 READ_ERR
. "1"
,
. SFC 38
W#16#0001,
( ) ,

.
SFC 36 "1"
, ,
, .
,
(
- "priority level").

23.2.5 "" ( )
(Substitute Value)
SFC 44 REPL_VAL
"" 1
(accumulator 1) OB
. SFC 44 REPL_VAL,

(, , ).
SFC 44,
OB 122 (
). SFC 44,
.
.
SFC 44 REPL_VAL 23.5.
23.5 SFC 44 REPL_VAL

VAL

INPUT

DWORD

RET_VAL

OUTPUT

INT

SFC
44

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23 - 7

23.

23.3
- ,
() .
- ,
:
80 - (timing error);
81 - (power supply error);
82 -
(diagnostic interrupt);
83 - /
(insert/remove module interrupt);
84 - CPU
(CPU hardware fault);
85 -
(program execution error);
86 - (rack failure);
87 -
(communication error).
82 ( )
23.4 " ".
S7-400H
:
70 -
(I/O redundancy errors);
72 - CPU
(CPU redundancy errors);
73 -
(communication redundancy errors).
,
, (disable) ,
, (enable) SFC 39
DIS_IRT SFC 40 EN_IRT ,
(),
SFC 41 DIS_AIRT SFC 42 EN_AIRT
.

(Timing Error)
OB 80,
:

23 - 8

(OB,
,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23.

);

( TOD-)
(, TOD-, -
-
RUN []).

80 , ,
CPU STOP (). CPU
STOP, 80
.

(Power Supply Error)
OB 81,
:

24
.

81
"" ("incoming"), "" ("outgoing") .
81 ,
, CPU .
/
(Insert/Remove Module Interrupt)

, . , -
RUN
(), STOP () START-UP (),

.
,
OB 83, CPU RUN ().
83 ,
, CPU STOP ().
,
" / " (insert/remove module interrupt)
.
(
)
, .
,
CPU ,
, CPU. 83

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23 - 9

23.

, ,
.
CPU
(CPU Hardware Fault)
OB 84,
( MPI
PROFIBUS DP). 84 ,
CPU, CPU STOP ().

(Program Execution Errors)
OB 85,
:

,
;


(,
SFB);

()
( ).

S7-400 CPU CPU 318 85


(I/O) ( ),
, .

,
.
S7-300 CPU ( CPU 318) 85
(I/O)
.

, ,
.
CPU
CPU 85
(I/O):

23 - 10

OB 85 ;

, ;

OB 85
"incoming" (" ");

, ,
;
, OB 85 , "outgoing"
" ",
;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23.

OB 85 ;

, ,
.

85 ,
, CPU STOP ().

(Rack Failure)
OB 86,
( , ,
IM),
. 86
" ", " ".
86
CPU, .
86 , ,
CPU STOP ().

(Communication Error)
OB 87,
.
:

() GD
.

87 ,
, CPU STOP ().

(I/O Redundancy Errors)
H CPU OB 70,
-
PROFIBUS-DP, ,
(master) DP-
(slave) DP-.
70 ,
, CPU .
CPU
(CPU Redundancy Errors)
H CPU OB 72,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23 - 11

23.

CPU;

(, RAM-, PIQ-);

SYNC;

.
72 ,
CPU, CPU .

23.4
23.4.1
,
,
. : ,
, .
:

, ,
;

CPU
;

,
.


:
.

, ,


,
.
:

23 - 12


CPU;


CPU;

,
, (
).

(),

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23.

,
CPU,
(diagnostic buffer) , ,
. -
CPU ,
, .
,
CPU. ,

.

PG.
System Diagnostics CPU
,
(
).

MPI- , CPU
STOP ().

23.4.2

SFC 52 WR_USMSG
,
MPI-.
SFC 52 WR_USMSG
23.6.
23.6 SFC 52 WR_USMSG
SFC
52

SEND

INPUT

BOOL

EVENTN

INPUT

WORD

INFO1

INPUT

ANY

INFO2

INPUT

ANY

RET_VAL

OUTPUT

INT

,
SEND = "1",


1
( )
1
( )


, ,
.

()
(
EVENTN)

( INFO1 INFO2).
ID
(. . 23.1).
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

23 - 13

23.


Event ID
15 14 13 12 11 10
:
Event class:
1000 =

1001 =

1010 =

1011 =


Event number
"1" - ""
"1" -
"1" -
"1" -

Event bits

. 23.1 ID ,

8
( ), 9 (
), A ( ).
(INFO1) 7 8
( ) (INFO2)
9 12 ( ).
.
,
SEND "1".
(, - ,
, - , (Send)
)
( 9 ).

23.4.3
"" ""
,

82. 82 , CPU
STOP () .
82
(disable) , , (enable)
SFC 39 DIS_IRT SFC 40 EN_IRT ,
(),
SFC 41 DIS_AIRT SFC 42 EN_AIRT
.

23 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

23.

B#16#39
"" , B#16#38
"" .
(B#16#54
B#16#55 - ). INT
, .
,
.
82 SFC 59
RD_REC ("read data record" - " "),
.
82,
"" ("frozen"). 82
.
DS0
DS1. DS0 ,
.
8 11
82.
DS1 DS0 ,
, ,
.

23.4.4
(SSL - "system status list")

"" (
). ( "")
SFC 51 RDSYSST. -
"" , ,
CPU .
23.7 SFC 51
RDSYSST.
23.7 SFC 51 RDSYSST
SFC
51

REQ

INPUT

BOOL

SZL_ID
INDEX
RET_VAL

INPUT
INPUT
OUTPUT

WORD
WORD
INT

BUSY

OUTPUT

BOOL

SZL_HEADER
DR

OUTPUT
OUTPUT

STRUCT
ANY

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

,
REQ = "1",




BUSY = "1",


23 - 15

23.

REQ = "1", .
BUSY = "0" ,
.
" ".
CPU "".
SFC 51 ,
( W#16#8085),
.
SZL_ID INDEX CPU.
SZL_HEADER STRUCT, LENGTHDR
( WORD) N_DR ( WORD)
. LENGTHDR ,
N_DR ,
.
DR
, SFC 51
. , P#DB200.DBX0.0 WORD 256
256 DB 200, DBB 0.
,

. .
,
.

23 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL


.
,

.
(data types)
STL-,
, (memory
functions) (load) (transfer).

.
- ,
.
(indirect addressing)
, (
).
(memory-indirect addressing)
(register-indirect addressing).
, .

, .
(direct variable
access) .
,
( ),
. ,
.
26.4 "
". ,
. "
" ("Message Frame Data"), " "
("Preparing a Message Frame"), " " ("Clock Check")

.
" " ("Checksum") " "
("Data Item Conversion") , ,
, .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24 - 1

" " ("Save Message Frame")


, SFC 20 BLKMOV
,
.

24
, ;
.
25
, DB, ANY-;
(memory-indirect addressing)

(register-indirect
addressing); (area-internal) (areacrossing) ; .
26
; ;.
; "" ANY; .

24 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24
,
,
. STEP 7
, ,
.
. .
3.7 " "
.

; .
,
.
,
, "Variable Handling" (" ")
FB 101, FB 102 FB 103
Chap_24.

24.1
,
;
(load) (transfer)
.

24.1.1
, ,
.
(Declaration)
varname : datatype := pre-assignment;
varname -
datatype -
pre-assignment - ()
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

24 - 3

24.

(, BOOL, REAL)
; .

.
(Pre-assignment)
(
).
,
.



( POINTER ANY)
STL-
(, , [load]).

,
.
, .

24.1.2 BOOL, BYTE, WORD, DWORD, CHAR


BOOL (,
I 1.0). BYTE, WORD DWORD

8, 16 32 ;
. 3 "SIMATIC S7"
.
BCD- (
- ) ,
, CHAR,
ASCII (. . 24.1).
BCD- ( - )
BCD- STL.
BCD- 16# (),
0 9.
BCD-
. S5TIME#

(. ),
: 16# #. # - BCD 000 999, 0.
24 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24.

BCD- - .
BCD-
() . BCD-
.
, BCD- ,
15. ,
"0", ,
"1", - .
. 32 .
0 999 32- BCD-.

CHAR
m

7 6 5 4 3 2 1 0

15

ASCII

12

m+1

11

10 2

10 1

0
10 0

BCD-, 7
m
31

m+1

28 27

24 23
10 6

16 15

20 19
10 5

m+2

10 4

12
10 3

11

m+3
8

10 2

4
10 1

0
10 0

. 24.1 BCD- ( - )
CHAR

CHAR
CHAR (character - ) .
CHAR ASCII.
, 'A'.
.
(load) STL
,
24.1. , L '$$'
ASCII.
,
CHAR, ASCII.
, L '' (
) ; L ''
, L '' .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24 - 5

24.

24.1 CHAR

CHAR

Hex

$$

24hex

$'

27hex

$L $l

0Ahex

$P $p

0Chex

$R $r

0Dhex

$T $t

09hex

24.1.3
INT, DINT
REAL. . 24.2
.
INT
15 14
S

14

13

2 21 20

S -
DINT
16 15

31 30
S

30

29

16

15

0
2

2 2 20

S -
REAL
31
S

30

23 22

-1

-2

-23

2 2

. 24.2 INT, DINT REAL


INT
INT ( ),
16- .
INT .
INT (word).

24 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24.

0 14 ;
15 (S).
"0", ,
"1", .
(two's complement).
INT- :
+ 32 767 (7FFFhex)
- 32 768

(8000hex).

DINT
DINT ,
32- .
DINT, +32767 ,
-32768 ,
L#.
DINT
(duobleword). 0 30
; 31 .
"0", ,
"1", .
(two's complement).
DINT- :
+ 2 147 483 647

(7FFF FFFFhex)

- 2 147 483 648

(8000 0000hex).

STL: L -100
INT-, L# -100
DINT-.
:
INT-
0000hex, DINT-
FFFFhex.
SCL: -100,
,
DINT-,
INT- DINT- ("" ).
REAL
REAL ,
32- .
REAL,
.
STL: 100 L#100
INT- DINT-, REAL
100 100.0, 1.0+2 (
, ,
).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24 - 7

24.

SCL: REAL
. 100, ,
,
REAL-,
REAL- ("" ).

7
"" "". "" ""
10 ("").
REAL-
STEP 7.
REAL- ,
(""
"" ("normalized") ) ,

("" "" ("denormalized")
).
:
+38

- 3.402 823 10

-38

-1.175 494 10

+1.175 494 10-38

+ 3.402 823 10+38.


:
-38

-1.175 494 10

-1.401 298 10-45

+1.401 298 10-45 + 1.175 494 10-38.


S7-300 CPU
. ,

.
,
OV OS
(" ").
CPU
. -
, ,
.
REAL :
- ,
- 8- 2,
- 32- .
"0" ( ) "1"
( ). ,
1 ( +127),
0 255. .
(integer component) ,
1 ( ),
0 (
24 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24.

). 24.2
.
24.2

255

255

1254

1254

255

255


( )
+




+
-




-

( )

24.1.4
S5TIME,
DATE, TIME TIME_OF_DAY. . 24.3
.
TIME_OF_DAY
,
8 .
S5TIME
S5TIME
SIMATIC- STL, LAD FBD
( SCL TIME).
S5TIME 16- "1+3
" (. . 24.3).
, , .
S5TIME-
STEP 7. BCD ( - ) 000 999.
(time base) : 10
(0000), 100 (0001), 1 (0010), 10 (0011).
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24 - 9

24.

:
S5TIME#500ms

(= 0050hex)

S5T#2h46m30s

(= 3999hex)

S5TIME
15 14
10

10

10

10

DATE
15 14

215 214 213

22 21 20

TIME
16 15

31 30
S

30

29

16

15

16

15

0
2

2 2 20

S -
TIME_OF_DAY
31 30
31

30

29

16

2 2

15

0
2

2 21 20

. 24.3 S5TIME, DATE, TIME TIME_OF_DAY


DATE
DATE
.
, 01.01.1990 . ,
, .
:
DATE#1990-01-01

(= 0000hex)

D#2168-12-31

(= FF62hex)

TIME
TIME .
(d), (h), (m), (s)
24 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24.

(ms);
.
32-
.
:
TIME#24d20h31m23s647ms

(= 7FFF FFFFhex)

TIME#0ms

(= 0000 0000hex)

T#-24d20h31m23s647ms

(= 8000 0000hex)

SCL
SIMATIC-.
, TIME, S5TIME ( 1+3
) , .
"" TIME ,
, TIME#2.25h T#2.25h. SCL
.
:
TIME#0.0h

(= 0000 0000hex)

TIME#24.855134d

(= 7FFF FFFFhex)

TIME_OF_DAY
TIME_OF_DAY .
(ms),
(0.00 ) 32-
.
, , .

.
.
:
TIME_OF_DAY#00:00:00

(= 0000 0000hex)

TOD#23:59:59.999

(= 0526 5BFFhex)

24.2
,
STL-,
SCL-. STEP 7
:

DATA_AND_TIME
( - BCD-)

STRING
, 254

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24 - 11

24.

ARRAY
("field" - "", )

STRUCT
( )

STRING, ARRAY STRUCT


() - STRING
, ARRAY STRUCT
-.

,
.

24.2.1 DATA_AND_TIME
DATA_AND_TIME
. DATA_AND_TIME
DT.
(Declaration)
varname : DATA_AND_TIME := pre-assignment;

varname : DT := pre-assignment;
varname -
pre-assignment -
DATA_AND_TIME DT - ;
.
(Pre-assignment)
(
,
).
,
.
:
DATA_AND_TIME#---::.

DT#---::.
(. . 24.3).

DT
( - DT
ANY); ,
SFC 20 BLKMOV.

24 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24.

("IEC-functions" - "IEC-").

DATA_AND_TIME DT 8 (.
24.4). (
). BCD- (
- ).
24.3 DT STRING

Date1

DT

DT#1990-01-01-00:00:00


DT

Date2

DATA_AND_TIME

DATA_AND_TIME#
2089-12-31-23:59:59.999


DT

First_name

STRING[10]

'Jack'

STRING,
4 10

Last_name

STRING[7]

'Daniels'

STRING,
7 7

NewLine

STRING[2]

'$R$L'

STRING,

EmptyString

STRING[16]

''

STRING,

DT

STRING

0 99

(k)

n+1

1 12

n+1

(m)

n+2

1 31

n+2

1-

n+3

0 23

n+3

2-

n+4

0 59

n+5

0 59

n+m+1

m-

n+6

0 999

n+k+1

n+7

: 1 =
7 =

. 24.4 DT STRING

24.2.2 STRING
STRING - , 254
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24 - 13

24.

(Declaration)
varname : STRING[ ] := pre-assignment;
varname -
pre-assignment -
STRING - ;
.
- ,
( ), .
, 0 254 .
;

( ) , 254 .
FC "
",
, 254 .
(Pre-assignment)
(
,
).
ASCII-,
, ,
(. . 24.3).
,
, .
STRING-
, .
" " ("emptystring").

STRING
STRING ANY; ,
SFC 20 BLKMOV.
("IECfunctions" - "IEC-").
SCL
27.5.2 " DT
STRING".

STRING ( )
256 , 254
. STRING
( ).
STRING-
. "" ( ,
, "" )

24 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24.

STRING- .
(
) ;
. 3-
- ASCII (. 24.4).

24.2.3 ARRAY
ARRAY ( "" - "field"),

.
(Declaration)
fieldname : ARRAY[minIndex..maxIndex] OF datatype := pre-assignment;

fieldname : ARRAY[minIndex1 ..maxIndex1,...,minIndex6 ..maxIndex6,]


OF datatype := pre-assignment;
ARRAY OF - ;
.
fieldname - ARRAY ();
pre-assignment - ;
minIndex - ();
maxIndex - ();
INT :
-32768 +32767; maxIndex
minIndex. .

. ARRAY
6:
minIndex1..maxIndex1,.., minIndex6..maxIndex6
datatype - , ;
,
, ARRAY.
(Pre-assignment)

( ,
).
,
.
;
,
.
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24 - 15

24.

.


(. . 24.4).
24.4 ARRAY

Meas_Val

ARRAY[1..24]

0.4, 1.5, 11 (2.6, 3.0)

ARRAY
24 REAL

21 (TOD#08:30:00)

TOD
21

96 (L#-0)


96

2 (''), 2 ('b')

REAL
Time_Of_Day

ARRAY[-10..10]
TIME_OF_DAY

Result

ARRAY[1..24,1..4]
DINT

Character

ARRAY[1..2,3..4]
CHAR

ARRAY
ARRAY
ANY. ,
SFC 20 BLKMOV.
ARRAY,
, .
,
STL-.

. STL
(
).
SCL
INT;
.

.
ARRAY 6.
.

.
STL,
. SCL
(. 27.5.4 "
").
24 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24.


ARRAY (..,
). ARRAY
.
BOOL ;
BYTE CHAR
(. . 24.5, ).
.
, (
), (.
. 24.5, ). , 1 1 ,
,

( , ).


7 6 5 4 3 2 1 0
1)

8 7 6 5 4 3 2 1 ,

n+1 .. 14 13 12 11 10 9 = 1
1)

n+1

n+2

n+3

..

1)

n+1
n+2
n+3
n+4
n+5

1)


: 1
ARRAY[1..2,1..3,1..2] OF BYTE

1.1.1
1.1.2
1.2.1
1.2.2
1.3.1


1
1

1.3.2

2-

2-

1-

2-

2.1.1
2.1.2
2.2.1
2.2.2

..

2.3.1
2.3.2

n =

. 24.5 ARRAY

24.2.4 STRUCT
STRUCT ,
,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24 - 17

24.

(Declaration)
structname : STRUCT
komp1name : datatype := pre-assignment;
komp2name : datatype := pre-assignment;

END_STRUCT;
STRUCT END_STRUCT - ;
.
structname - ;
pre-assignment - ;
komp1name, komp2name - ;
datatype - ;
(Pre-assignment)

( ,
).
,
.
24.5 STRUCT

STRUCT

MotCont

On

BOOL

FALSE ()

MotCont.On
BOOL

Off

BOOL

TRUE ()

MotCont.Off
BOOL

Delay

S5TIME

S5TIME#5s

MotCont.Delay
S5TIME

maxSpeed

INT

5000

MotCont.maxSpeed
S5TIME

END_STRUCT

STRUCT
STRUCT
ANY. ,
SFC 20 BLKMOV
STRUCT.
STRUCT,
, .

, STL.
24 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24.


, .

STRUCT ( ,
);
,
. STRUCT
.
BOOL ;
BYTE CHAR
(. . 24.6). .
. -
, .
.
,
STL-.
.

7 6 5 4 3 2 1 0
1)

8 7 6 5 4 3 2 1

10 9 1

n+1
n+2

n+3

n+4

n+5

n+6
n+7
n+8
n+9

n+12

1)

3 2 1 = 1

n+10
n+11

= 1

..

ARRAY


STRUCT

..

n =

. 24.6 STRUCT

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24 - 19

24.

24.3
(UDT - "User-defined Data Type")
( ,
),
.
(UDT),
.
UDT
, ,
. UDT

STL,

SCL

UDT

SCL,
Blocks ()).
UDT , ,
, .
UDT (
); UDT
(symbol table). UDT (
) .
,
UDT,
, ""
. UDT
(UDT0 UDT65535), (
).
UDT .

UDT .
" " ("Message Frame Data")
26.4 " " ,
.

24.3.1 ,
(UDT)
(UDT)
SIMATIC Manager, Blocks
(), - : Insert -> S7 Block -> Data Type ( ->
S7 Block -> ) , : File -> New
( -> ) "UDTn" " ".
UDT
, ,
. UDT ,
: (Name), (Type),

24 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24.

(Initial value) (Comment).


,
(data view). (
UDT ,
;
).
, UDT,
.

24.3.2 UDT

,
, , (UDT),
STRUC (""),
TYPE END_TYPE.
(Declaration)
TYPE udtname :
STRUCT
komp1name : datatype := pre-assignment;
komp2name : datatype := pre-assignment;

END_STRUCT;
END_TYPE
TYPE, END_TYPE, STRUCT END_STRUCT - ;
.
udtname - , (UDT);
udtname UDTn.
pre-assignment - ;
komp1name, komp2name - ;
datatype - ;
, POINTER ANY.
(Pre-assignment)
, (UDT),
, STRUCT.
STRUCT.
, (UDT),
, STL,
SCL (. 3.7.3 "
").

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

24 - 21

24.

24.6 UDT

STRUCT
Identifier

WORD

W#16#F200

UDT Identifier
WORD

Number

INT

UDT Number
INT

TimeofDay

TIME_OF_DAY

5000

UDT TimeofDay
TIME_OF_DAY

END_STRUCT

24 - 22

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25

,
.
,
, , , ,
.

STL.
SCL 27.2.3 "
SCL".

, ,

!
!
,
, "Variable Handling" (" ")
FB 125 Chap_25.

25.1

, , ,
, (address area).
, (Pointer).
"" .
STEP 7 :

(area pointers)
32
;

DB (DB pointers)
48
( ) ;

ANY- (ANY pointers)


80
, DB, ,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25 - 1

25.

, .. (area pointers),
. DB ANY .
,
DB ANY-.

25.1.1 (area pointers)


(area pointers) ,
, , .
() , "
" (area-internal pointer), , ()
, (area-crossing pointer).
(area pointer)
(load)
, 32 .

:
P#y.x

" " (area-internal pointer),


, P#22.0

P#Zy.x

"
, P#M22.0,

"

(area-crossing

pointer),

x = , x = , Z = " ". "


" . 31
(
) (. . 25.1).
(area pointers) ,
, .
0 ().
P#M22.0 , ,
(memory bit) M 22.0,
(memory byte) MB 22, (memory word) MW 22
(memory duoble word) MW 22.

25.1.2 DB (DB pointers)


DB (DB pointers) (
)
INT. ,

.
DB .

25 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25.

n+1

n+2

n+3

0 0 0 0 0 0 0 0

0 0 0 0 0 y y y

y y y y y y y y

y y y y y x x x

n+1

n+2

n+3

1 0 0 0 0 Z Z Z

0 0 0 0 0 y y y

y y y y y y y y

y y y y y x x x

""

ANY

n

n+1
n+2

ANY
/

16#10

16#10

16#0000

16#0000

n+2
n+3
n+4
n+5
n+6

n+3

n+7

n+4

n+8

n+5

ANY

16#10

n+1

ANY
DB

16#0000

16#00

n+9

, ANY-

/ (P)

(I)


01 BOOL

(Q)

02

BYTE

13 STRING

CHAR

0E DT

()

03

(DBX)

04

WORD

17 BLOCK_FB

(DIX)

05

INT

18 BLOCK_FC

06

DWORD

19 BLOCK_DB

07

DINT

1A BLOCK_SDB

08

REAL

1C COUNTER

(L)


(V)

2)

1)

2)

1)

09

DATE

1D TIMER

0A

TOD

0B

TIME

-
(Zero-pointer)

0C

S5TIME

00 NIL

. 25.1
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

25 - 3

25.

,
.
:
P#DataBlock.DataAddress
:
P#DB 10.DBX 20.5
; ,
POINTER
( SCL). STEP 7
.

25.1.3 ANY- (ANY pointer)


ANY (ANY pointer) ,
DB, .
ANY
.
ANY :
.
, ANY
DB, .
, ANY
DB.
(n+6); (n+7)
B#16#00.
W#16#0000.
ANY ID;
STEP 7 10hex. ,
ANY . ,
DT STRING , 25.1, 1.
ARRAY
STRUCT ( UDT)
ANY, ANY .
ANY BYTE
(02hex) ,
(quantity).
. ANY
(WORD).
: , CHAR
CHAR (03hex).
ANY
" ANY",
.

:
P#[DataBlock.]Address Type Quantity = P#[.] .

25 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25.

P#DB 11.DBX 30.0 INT 12


12 DB 11, DBB 30;

P#M 16.0 BYTE 8


8 , B 16;

P#I 18.0 WORD 1


IW 18;

P#I 1.0 BOOL 1


I 1.0.


:
L# Number Type Quantity = L# .
:

L# 10 TIMER 1
10;

L# 2 COUNTER 1
Z 2.

ANY,
.
, ANY
.
ANY ,
,
. ,
ANY. ,
"P#I 1.0 BOOL 1" "I 1.0"
.
ANY
.

ANY,

(. 16.3.3
" " ANY"").

ANY ,
10hex ID 00hex -
. () ANY
( ) :
P#P0.0 VOID 0.

25.2 STL

STL;
SCL
27.2.3 " SCL".
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

25 - 5

25.

25.2.1

.
(

STL). ,
. STL
(. ).
:
(immediate addressing);
(direct addressing);
(indirect addressing).
-
: ,
,
.
(immediate addressing),
( )
.
(load) ,
,
SET () CLR
().
(direct addressing)
, , A I 1.2 L MW 122. ,
, ,
, ,
. ,
STL.
(indirect addressing) STL-
, , .
,
. :

(memory-indirect
addressing),
; : T QW [MD 220]
, ,
MD 220;

(register-indirect
addressing),
; : T QW [AR1,P#2.0]
, ,
2 , AR1.


(register-indirect addressing) :
(area-internal registerindirect addressing)
(area-crossing register-indirect addressing).
25 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25.


(area-internal register-indirect addressing)
,
. ,
(: L MW
[AR1,P#0.0] [load] ,
AR1).
(areacrossing register-indirect addressing)
() (, , , ).
,
(: L W [AR1,P#0.0]
[load] ,
AR1).

25.2.2 (Indirect Addresses)


, ,
:

, ;

, .



,
(.
25.1). , ,
, 16-
( INT-).
25.1
,

/
(I/O), , , ,
,
,
.

:

,

, , ,
,

16-

0
65535 ( ).
CPU.
( ) 0 7.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25 - 7

25.

25.2.3 (memory-indirect
addressing)
(memory-indirect
addressing) .
,
(area pointer),
(WORD),
.

:

L- ( )
;


;

,
DB-; , ,

, ( )
,
.

; ( . ).


, ,
; DI-
DB-. .

,
CODE_VERSION1 ( "").
(area pointer)
(area pointer),
,
(area-internal pointer). ,
. ,
0.
: MD 10 P#30.0.
A M [MD 10] ,
MD 10; ,
30.0 (. 25.2).
L MW [MD 10]
MW 30 .
25 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25.



,
(load) (transfer).

L

P#30.0;

MD 10;

L MW [MD 10];

A M [MD 10];

//
//accumulator 1
//
//
//

[MD 10];
MD 10
P#30.0

//

30.0;

133;

MW 20;

//
//accumulator 1
//

OPN DB [MW 20]; // DB

SP T [MW 20];
//

OPN DB

[MW 20];
MW 20
133

OPN DB

133;


LAR1 P#10.0;

AR1

//
// 1

L MW [AR1,P#4.0]; //
//

A I [AR1,P#2.1]; //

P#10.0
A

[AR1, P#2.1];

+
P#2.1

12.1


LAR1 P#M12.0;

AR1

//
// 1

B [AR1,P#4.0]; //
//

P#M12.0
A

[AR1, P#4.0];

+
P#4.0

I [AR1,P#0.7]; //
A MB

16.0

. 25.2

, ,
16 . , (WORD),
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

25 - 9

25.

.
: MW 20 () 133.
OPN DB [MW 20]
,
MW 20.
SP T [MW 20]
133 .

.
DB- (OPN DB []),
DI- (OPN DI []). 0, CPU
NOP-.
, UC
FC[..] CC FC[..] UC FB[..] CC FB[..].
UC CC ;
,
.

25.2.4
(Register-Indirect Area-Internal Addressing)
(registerindirect area-internal addressing)
.
.
(register-indirect
addressing)
.
(
).
(area-internal pointer).
,
.
(=0).
P#8191.7.
: AR1 (area
pointer) P#10.0 ( LAR1
AR1, . ).

A I [AR1.P#2.1]
AR1 , ,
, .

L MW [AR1.P#4.0]
MW 14 .

25 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25.


(area-crossing
pointer),
,
.
: (load)
AR1 (area-crossing pointer) DBX 20.0
,
AR1
.
MD 20.
LAR1

P#DBX 20.0;

MD[AR1,P#0.0];

25.2.5
(Register-Indirect Area-Crossing Addressing)
(registerindirect area-crossing addressing)
.
(area-crossing pointer).

(area pointer)
.
ID :
, "B" - , "W" - , "D" - .

,
.
.
: AR1 (area
pointer) P#12.0 (
LAR1 P#M12.0
AR1,
. ).
L B [AR1.P#4.0]
P#4.0 AR1 , ,
, (MB 16
).
=

[AR1.P#0.7]

(.. RLO)
M 12.7.
( )
( CPU
STOP). ,
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

25 - 11

25.

25.2.6
, ?
,
(register-indirect area-internal addressing).
STL
. ,
. , CPU

(register-indirect area-crossing addressing)
.
, (memoryindirect addressing) ,
, .
"" () :
,
-
;

;

.

,
.
25.2
.
- Q 4.7.
25.2

P#4.7

LAR1

P#4.7

LAR1

P#Q4.7

MD 24

Q [MD 24]

Q [AR1, P#0.0]

[AR1, P#0.0]

25 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25.

25.3
,
STL :
(. . 25.3.1) (. . 25.3.2):

LAR1

AR1

LAR2

AR2

P#Zy.x

P#y.x

LAR1

AR1

LAR2

AR2

MD y

LD y

DBD y

DID y

1)

LAR1

AR1 Accu 1

LAR2

AR2 Accu 1

LAR1

AR2

AR1 AR2

TAR1

AR1

TAR2

AR2

MD y

LD y

DBD y

DID y

1)

TAR1

AR1 Accu 1

TAR2

AR2 Accu 1

TAR1

AR2

AR1 AR2

CAR

+AR1

Accu 1 AR1

+AR2

Accu 1 AR2

+AR1

P#Zy.x AR1

+AR2

P#y.x

AR2

1)

(.
" ")

. 25.3.1 STL

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25 - 13

25.

MD


DBD

DID


LD
LAR1 xx

LAR2 xx

TAR1 xx

TAR2 xx

LAR1 P#Zy.x

TAR1 AR2

LAR2 P#Zy.x

LAR1 P#y.x

LAR1 AR2

LAR2 P#y.x

+AR1 P#y.x

AR1

CAR

AR2

+AR2 P#y.x

LAR1
+AR1

LAR2
+AR2

TAR1

TAR2
Accumulator 1

. 25.3.2 STL

25.3.1
LARn (area pointer)
ARn.

, ,
.

(area pointer).
, , LARn
accumulator 1 ARn.
LAR1 AR2,

AR2 AR1.
:

25 - 14

LAR2
L
LAR1

P#20.0;
P#24.0;
;

LAR1
LAR1

MD 120;
AR2;

// P#20.0 AR2
// P#24.0 Accu1
//
//Accumulator 1 AR1
// MD 120 AR1
// AR2 AR1

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25.

25.3.2
TARn (area pointer)
ARn.
,
,
.
, , TARn
ARn accumulator 1.
accumulator 1
accumulator 2;
accumulator 2 . accumulator 3
accumulator 4 .
TAR1 AR2,

AR1 AR2.
:
TAR2
TAR1

MD 140;
;

TAR1

AR2;

// AR2 MD 140
// AR1
// Accumulator 1
// AR1 AR2

25.3.3
CAR
AR1 AR2.

:
8 (MB 100)
(DB 20.DBB 200).
M 126.6. M 126.6 "0",
.

, (
OPN DB OPN DI)
TDB.
LAR1 P#M100.0;
LAR2 P#DBX200.0;
OPN
DB 20;
A
M 126.6;
JC
OV;
CAR
;
OV: L
D[AR1,P#0.0];
T
D[AR2,P#0.0];
L
D[AR1,P#4.0];
T
D[AR2,P#4.0];
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

25 - 15

25.

: SFC 20 BLKMOV
.

25.3.4

, , ,

.
( ),
accumulator 1.
( )
.

+AR1 P#y.x +AR2 P#y.x
AR1 AR2.

,
(area pointer) P#4095.7.
, , P#4095.7,

(two's complement) .
:

. ,
, (
"1"), (
"0").
OPN DB 14;
LAR1 P#DBX20.0;
LAR2 P#M10.0;
L
Quantity_Data;
Loop: T
LoopCounter;
L
ComparisonVal;
L
W[AR1,P#0.0];
>I ;
=
[AR2,P#0.0];
+AR1 P#2.0;
+AR2 P#0.1;
L
LoopCounter;
LOOP Loop;

+AR1 +AR2 Accu1

25 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25.

INT,
24-
AR1 AR2. ,
.
(0 65535) : ""
(. . 25.4).
,
0 2.
Accumulator 1, 3 (
, ).
: DB 14 16 ,
MD 220
MB 18, .
AR1 MB 18
3 (SLW 3).
OPN
LAR1
L
SLW
+AR1
L
T
T
T
T

DB 14;
MD 220;
MB 18;
3;
;
0;
DBD[AR1,P#0.0];
DBD[AR1,P#4.0];
DBD[AR1,P#8.0];
DBD[AR1,P#12.0];

:
SFC 21 FILL
.
Accumulator 1
n

n+1

----------------- ----------------x =
y =
Z =
S =

n+2

n+3

S y y y y y y y

y y y y y x x x

( 24- )
S S S S S S S S

S y y y y y y y

y y y y y x x x

n+1

n+2

n+3

1 0 0 0 0 Z Z Z

0 0 0 0 0 y y y

y y y y y y y y

y y y y y x x x

""

. 25.4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25 - 17

25.

25.4
25.4.1 AR1
STL AR1
, DB-.
AR1
,
/
.
, ,
,
INT- ,
AR1 , DB-.
,
.
AR1 (
),
( ). ,
AR1

.
:
AR1
. (load)
Motor.Act. Motor.Act
DB- AR1;
,
(. . 25.5, ).

25.4.2 AR2

" " ( 2), AR2
STEP 7 " " ("Base address
register") .
AR2 P#DBX0.0
FB
DI
.

" " ("base address") +AR2 P#y.x,

,
.
,
, (
).
25 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25.

//********** AR1 *********


...
VAR_TEMP
AR1_Memory
: DWORD;
DB_Memory
: WORD;
END_VAR
...
// AR1 DB-
LAR1 P#y.x;
OPN
DB z;
...
//
L
DBNO;
T
DB_Memory;
TAR1 AR1_Memory;
//
L
Motor. Act;
//
OPN
DB [DBMemory];
LAR1 AR1_Memory;
T
DBW[AR1,P#0.0];
//

//
//********** AR2 *********
...
VAR_TEMP
AR2_Memory : DWORD;
DI_Memory : WORD ;
END_VAR
...
//
L
DINO;
T
DI_Memory;
TAR2 AR2_Memory;
// AR2 DI-
LAR2 P#y.x;
OPN
DI z;
...
L
DIW[AR2,P#0.0]
...
//
OPN
DI [DI_Memory];
LAR2 AR2_Memory;
. 25.5 AR1 AR2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25 - 19

25.

1, ,
" ", STEP 7
AR2.
, AR2
" ",
AR2 DI
.

, AR2.
AR2
.
:
AR2
DI- .
DI- AR2.

,
(. . 25.5, ).

25.4.3

,
CODE_VERSION1 ( " "),
(),
.

" ", (Editor)
AR2; ,
.
.
,
(area pointers),
. ,
,
" " (duoble indirect addressing).
25.3 :

" ",
,
.
, .
(load)


( ).

25 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

25.

25.3 FB 1 2
FB,
CODE_VERSION1
( " ")

FB,
CODE_VERSION2
( " ")

VAR

VAR

sPointer : DWORD;
END_VAR

sPointer : DWORD;
END_VAR
VAR_TEMP
tPointer : DWORD;
END_VAR

MW[sPointer];

LAR1 sPointer;

sPointer;

tPointer;

MW[tPointer];

sPointer;

LAR1;
TAR1 sPointer;

TAR1;
T

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

sPointer;

25 - 21

25.

25 - 22

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26

,
.
"" STL-
. ,
POINTER ANY
"".
, ,
,
.
, .
,
, STL_Book "Variable Handling" ("
") FB 126
Chap_26.

26.1


:
L
LAR1
LAR2

P#name;
P#name;
P#name;

name - .
(area-crossing pointer)
Accumulator 1, AR1 AR2
.
. name
, "#"
, , , :
L

P##name;

26.1 , ,
, name.
FC
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26 - 1

26.


:
L
LAR1

Accumulator

1,

P#name;
;

(FB),
CODE_VERSION1 ( , 1, "
"),
(load).
(FB), 2,
, " ",
( AR2)
(load),
.
,
(area-internal pointer) (
) AR2 .
26.1

name

P#name

LARn P#name

1)

OB

FC

FB V1

FB V2

x 1)

x 1)

x 1)

x 1)

, AR2

1:
AR1.
TAR2
AD
LAR1
+AR1

;
DW#16#00FF_FFFF;
P#name;
;

AR2
AR1 +AR1.
#name AR1.
2:
Accumulator 1.

26 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.

TAR2
AD
L
+D

;
DW#16#00FF_FFFF;
P#name;
;


Accumulator 1
#name.
(area-internal pointer)
, P#0.0. ,
.
, "LAR2 P#name"
AR2,

" " " "
!
(LARn) (load)
,
,
.

, , /
.
26.2 ,
INT STRING
.
, ,
, .
26.2 ()
// (
//!)
// P#0.0
VAR
Field
: ARRAY[1..22] OF BYTE; // ARRAY 22
Number
: INT := 123;
// INT 2
FirstName : STRING := 'Joane';
// STRING 5
END_VAR
LAR1

P#Number;

Number AR1
AR1 P#DIX22.0

W[AR1,P#0.0];

L DIW 22 L Number

LAR1

P#FirstName;

FirstName AR1
AR1 P#DIX24.0

B[AR1,P#0.0];

1- (
) Accu 1

B[AR1,P#2.0];

3- (1- )
Accu 1

L
T

'John'
D[AR1,P#2.0];

'John'

L
T

4;
B[AR1,P#1.0];

(=4)
FirstName 'John'

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26 - 3

26.

26.2

26.2.1

. :

"" ( 1 )
0
;
.

"" ( 1 )

.

, ""
, ,
, .

DT STRING ,
.

ARRAY ,
, .
.
, .
, .

.

STRUCT ,
, .
"" .
, .
, .


,
.
26.1
.
, ""
ARRAY STRUCT , ,
,
. ,
.

26 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.

DATA_BLOCK StorageNonOptimized

DATA_BLOCK StorageNonOptimized

STRUCT

STRUCT

Bitl

: BOOL;

Bitl

: BOOL;

Bit2

: BOOL;

Bit2

: BOOL;

Bit3

: BOOL;

Bit3

: BOOL;

Reall

: REAL;

Bytel

: BYTE;

Bytel

: BYTE;

Reall

: REAL;

Bit_field : ARRAY [1..3] OF BOOL;

Bit_field : ARRAY [1..3] OF BOOL;

Structure : STRUCT

Structure : STRUCT

S_Bitl

: BOOL;

S_Bitl

: BOOL;

S_Bit2

: BOOL;

S_Bit2

: BOOL;

S_Bit3

: BOOL;

S_Bit3

: BOOL;

S_Intl

: INT;

S_Byte

: BYTE;

S_Byte

: BYTE;

S_Intl

: INT;

END_STRUCT;

END_STRUCT;

Character : STRING[3];

Character : STRING[3];

Datel

: DATE;

Byte2

: BYTE;

Byte2

: BYTE;

Datel

: DATE;

END_STRUCT

END_STRUCT

BEGIN

BEGIN

END_DATA_BLOCK

END_DATA_BLOCK

BOOL

3 2
( )

BOOL
BYTE
REAL

REAL

<

1
<

BYTE

ARRAY

( )
ARRAY
STRUCT

OF BOOL
3 2
( )
BOOL
3 2

1 <

STRUCT

1 <
<

BOOL
BYTE

1 <
1 <

INT

( )
INT

OF BOOL
3 2
( )

STRING

<

BYTE
DATE

<

BYTE
( )
STRING

<

( )
DATE

<

BYTE

. 26.1
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

26 - 5

26.

26.2.2
DB,
:
;
;
/ ;
(
).

. (
) ""
, .
,
( ).
26.2
.

26.2.3

( L) .
0 ( ).
, 20
.
, 20
(, , 20 .).
, ,
.

,
, ,
.
,
"" ( ), ,
.
,
, , , (field)

(, ).
, , .
,
20 ,
.

26 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.

FUNCTION_BLOCK StorageExample
VAR_INPUT
E_Bitl
: BOOL;
E_Bit2
: BOOL;
E_Bit3
: BOOL;
E_Reall
: REAL;
END_VAR
VAR_OUTPUT
A_BYTE l
: BYTE;
A_BYTE 2
: BYTE;
A_BYTE 3
: BYTE;
END_VAR
VAR_IN_OUT
D_BYTE l
: BYTE;
D_Bitl
: BOOL;
D_Bit2
: BOOL;
D_Bit3
: BOOL;
END_VAR
VAR
Datel
: DATE;
Character : STRING[3];
Bit_field : ARRAY [1..3] OF BYTE;
END_VAR
BEGIN
END_FUNCTION_BLOCK
7

1 <

( )

REAL

<

BOOL

ORGANIZATION_BLOCK Cycle
VAR_TEMP
SInfo
: ARRAY [1..20] OF BYTE;
LData
: ARRAY [1..16] OF BYTE;
Temp1
: STRING [36];
Temp2
: BOOL;
Temp3
: BOOL;
Temp4
: BOOL;
Temp5
: BYTE;
Temp6
: INT;
END_VAR
BEGIN
//
...
T
LW 20;
...
=
L 22.2;
//
T
Temp6;
=
Temp3;
T
LData[16];
//
L
P#Temp1;
LAR1 P#Temp2;
...
END_ORGANIZATION_BLOCK
7

0
.

ARRAY
.

ARRAY

BYTE
( )
BYTE

<

BOOL

DATE

<

STRING

<

( )
ARRAY

OF BOOL

1 <

)
STRING

<

I/O

BYTE

<

.
BYTE

DATE
BOOL

<
3

( )
REAL

<

( )

. 26.2
DB
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

. 26.3
L-
26 - 7

26.

26.3
.
"LData"
LB 20 , , LB 35.
,

.
.

, ;
LB 0.

26.3


-
. ;
.
,
.

26.3.1
(
, " ";
- " ")
(area pointer) ;
,
.
,

( )
,
(. . 26.3). :
: TIMER, COUNTER BLOCK_xx
16- ,
().
26.3

INPUT
IN_OUT
OUTPUT
()
(-)
()
(area pointer) :

DB-

DB-

DB-

TIMER, COUNTER BLOCK

POINTER

DB-

DB-

DB-

ANY

ANY-

ANY-

ANY-

26 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.


(. 26.4).

FC

(area pointer)

(area pointer)


FC

(area pointer)

ANY

(area pointer)

ANY

(area pointer)

DB-
(DB-pointer)

(48 )

ANY-
(ANY-pointer)

ANY

ANY

(80 )

ANY-

ANY
(
ANY
V-)

ANY

(ANY-pointer)
(80 )

. 26.4
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

26 - 9

26.

, (area-pointer)

, .

, ( ),

"" (area-pointer) .
"V" (
"" V-).
FC V , :
- ,
- ,
, .
,
.
,
,
"" (),
""
"" ("actual") .
:

V-, (load) ""
V- .
- , ,

,
.
(, -
-
),
. ,
.
"" .
, DT, STRING, ARRAY, STRUCT,
UDT, ,
V-. (area-pointer)
,
DB- V-
. DB-
( DB 0), V-
( DB 0). DB- V FC.
, TIMER, COUNTER BLOCK_xx,
(16- ,
32- )
(area-pointer).
, POINTER,
, .
, ANY, 10-
ANY- V-, (ANY)

26 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.

.
.
,
ANY ,
ANY.
ANY-,
" " (area-pointer) ( )
( ANY-
, .
26.3.3 "" ANY-).

26.3.2

.
,

"" ,

.
, ,
- .

( 16- ), ,
(. . 26.4).
,
. , , 6
(DB-) 10 (ANY-).
26.4
INPUT
()

IN_OUT
(-)

OUTPUT
()

DB-

TIMER, COUNTER BLOCK

POINTER

DB-

DB-

ANY

ANY-

ANY-

,
. 26.5.

( )
( )
SFC 20 BLKMOV,

.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26 - 11

26.



DB

DB

INPUT
OUTPUT
IN_OUT

IN_OUT

DB-
(DB-pointer)

(48 )
INPUT
IN_OUT

ANY-
(ANY-pointer)

ANY

(80 )

INPUT
OUTPUT

INPUT
IN_OUT

ANY
(
ANY
V-)

ANY

ANY-

ANY-

(ANY-pointer)

(ANY-pointer)

(80 )

(80 )

ANY
V-

. 26.5


,
.
,
/
. ,

. , , ()
, .
(load) , ,
() ,
.
,

26 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.


.
, ""
- ,
, ,

,
, ,
(
).
.
ANY ANY, ANY ( ) .

26.3.3 "" ANY- (ANY-pointer)


ANY-
, .
:

SFC 20 BLKMOV:
CALL SFC 20 (
SRCBLK := "ReceiveMailbox".Data,
DSTBLK := P#DB63.DBW0.0 BYTE 8,
RET_VAL := SFC20Error);

,
ANY-
(. ).
, ,

ANY. ANY, ANY-
ANY- . , ANY ANY-.
ANY
, ANY.

:

""

ANY-

ANY ( ANY

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26 - 13

26.

):
VAR_TEMP
ANY_POINTER

: ANY;

END_VAR

ANY- :
,

,

LAR1 P#ANY_POINTER;

W#16#1002;

W#16#1002;

LW 0;

LW[AR1,P#0.0];

16;

16;

LW 2;

LW[AR1,P#2.0];

63;

63;

LW 4;

LW[AR1,P#4.0];

P#DBB0.0;

P#DBB0.0;

LD 6;

LD[AR1,P#6.0];

ANY-, , SFC 20:


CALL SFC 20 (
SRCBLK := "ReceiveMailbox".Data,
DSTBLK := P#DB63.DBW0.0 BYTE 8,
RET_VAL := SFC20Error);


SFC 20 BLKMOV; ANY .
:
,
.
. SFC 20 BLKMOV
.
- FC - :
VAR_INPUT
QDB

: INT; //

SSTA

: INT; //

NUMB

: INT; //

DDB

: INT; //

DSTA

: INT; //

END_VAR

SFC 20.
BR
"0" .

26 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.


ANY-: - , :
VAR_TEMP
SANY

: ANY; //ANY-

DANY

: ANY; //ANY-

END_VAR
ANY-
, ,
, , ANY-
:
L

W#16#1002;

// BYTE

LW 0;

NUMB;

LW 2;

QDB;

LW 4;

SSTA;

SLD

3;

OD

DW#16#8400_0000;

LD 6;

//
// DB
//

LB

10

SFC 20:
CALL SFC 20 (
SRCBLK

:= SANY,

DSTBLK

:= DANY,

RET_VAL := RET_VAL);
RET_VAL SFC 20
RET_VAL FC.
,
( FC 47 "General
Examples" (" ")).
, ANY- ;
, 2
(area pointer);
, , .
:
ANY-, ,
,
, V-

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26 - 15

26.

- ("operand area"),

("predecessor") .

26.4


( )

"Message

Frame

Example"

-
.
,
. , ,
, , "Generate_Frame" (" ") "Checksum"
(" "), ,
, , ,
.
, ,
"Message Frame Example" (" ").
.
- :

Message frame data (UDT 51, UDT 52, DB 61, DB 62, DB 63)
( " "
);

Clock Check (FC 61)


( " "
);

Checksum (FC 62)


( " "
);

Generate frame (FB 51)


( " "
SFC 20 BLKMOV );

Store frame (FB 52)


( " "
"" ANY-);

Date conversion (FC 63)


( " "
).

"Message frame data"


(" ")
"Message frame data" (" ") ,
,
, , UDT-,

.

26 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.

-
: " " ("send
mailbox") , " "
("receive mailbox") ("receive")

(. . 26.6).
DB "Send_mailb"

UDT "Header"
ID
()

WORD

Data
()

NUMB
()

INT

DB "Rec_mailb"

Tim
()

TOD

Data
()

UDT "Frame"
Header
()

UDT "Frame"

UDT "Frame"

DB "Buffer"
Entry[1]
(1)

UDT "Frame"

Entry[2]
(2)

UDT "Frame"

Entry[3]
(3)

UDT "Frame"

Measured_values[3]
(_)

Entry[4]
(4)

UDT "Frame"

Measured_values[4]
(_)

Entry[5]
(5)

UDT "Frame"

Checksum
( ) DINT

Entry[6]
(6)

UDT "Frame"

Entry[7]
(7)

UDT "Frame"

Entry[8]
(8)

UDT "Frame"

Measured_values[1]
(_)
Measured_values[2]
(_)

UDT "Header"
("")
ARRAY [1..4]
OF INT

. 26.6 "Message frame data" ("


")
,
(UDT) Frame.
(frame header);
. " " ("send
mailbox") " " ("receive mailbox")
,
Frame. ,

8 ,
Frame.
UDT Header , - UDT
Frame.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26 - 17

26.

UDT Frame UDT Header,


Measured_values 4 Checksum.
0.
"Send_mailb", "Rec_mailb"
Data Frame.
.
ID ,

UDT. "Buffer" Entry
, 8 ,
Frame.

(: Entry[1].Header.Numb := 1).
, ,
:
UDT 51

- Header,

UDT 52

- Frame,

DB 61

- "Send_mailb" (" "


),

DB 62

- "Rec_mailb" (" "


),

DB 63

- "Buffer".

"Clock Check"
(" ")
" " ,
( ,
, ).
"Clock_check"
, CPU ,
.
SFC 1 READ_CLK,
, DATE_AND_TIME
DT. ,
IEC- FC 8 DT_TOD.
TIME_OF_DAY TOD
DT (. . 26.7).

"Data66".
"Date conversion" (" ").
,

CPU_Tim.
(Error evaluation)

26 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.

BR
RET_VAL. , BR =
"0"; RET_VAL
- 15. IEC-
BR.
.
"Clock_check" BR "1".
BR "0".
.
"Clock_check" ,
BR.

FC "Clock_check"
CPU

SFC1 : READ_CLK

DB "Data66"
CPU_Tim [DT]

Dat [STRING]

FC "DT_Conv"


DT

STRING

FC 8 : DT_TOD

"Date conversion"
( )
RET_VAL [TOD]

. 26.7 "Clock check" (" ")

(offline)

""
SFC 1
FC 8.
STEP 7.
. ( ,
CPU, (block library)
.
(offline)
;
CPU. , , IEC-
.)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26 - 19

26.

: File -> Open ( -> ) Simatic


Manager, " " Standard Library
System Function Blocks (
).
. ,
, :
Window -> Arrange -> Vertically ( -> -> ),
"" ""
, "Drag-n-Drop" (
SFC ,
, "" Blocks
).
FC 8 .
IEC Function Blocks (
IEC). FC 8 ,
, ,
SFC 1.

(Editor's ProgramElement Catalog) "Libraries"
,
Blocks .


.
(, FC 8)
. ,
(, FC 98). F1,
( FC 98),
( Help),
FC 8.
,
, ,
:

.


,
.
,
.
( ).
"Checksum"
(" ")

ANY
(. 26.8).

26 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.

FC "Checksum"
ANY-


0

16#10

Type ()

2
3
4

Area

Quantity
()

7
8

Type check
( )
Field check
(

DB number
( DB)


DB
;
DB

Area
pointer
(
)


(area
pointer)


,

"Area" ANY,

ANY
-

(area pointer),
ANY-

. 26.8 "Checksum" (" ")




(, DINT).
(STRUCT UDT)
( 1 ),
ANY. ,

(ARRAY OF BYTE),
(STRUCT).
,
( ID ANY).

(, , ANY-).
ID (
BYTE) (>1).
"0"
, 0.
(
) ANY-.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

26 - 21

26.

AR1. ,
.
,
.
, Quantity
(
).
.
"Generate frame"
(" ")
"Generate frame" (" ")
SFC 20 BLKMOV
.
"Send_mailb"
.

ID .
;
" " ("send
mailbox") BLKMOV.
,
CPU, "Clock_check" (. ),

(. "Checksum"
[" "]). . 26.9
.

FB "Generate_Frame"

DB
"Measured_values"

DB "Send_mailb"

ID

Data.Header.ID

ConsecNum + 1

Data.Header.Numb
Data.Header.Tim

FC "Clock_check"

Values1
( 1)
Values2
( 2)
Values3
( 3)

FC "BLK_MOV"

Data.Measured_values

Values4
( 4)
Data.Checksum

FC "Checksum"

. 26.9 "Generate frame" (" ")

26 - 22

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.

FB "Generate_frame"
ID,
. ConsecNum (+1)
.
"Clock_check",

TIME_OF_DAY .

SFC 20 BLKMOV ,
,
. ,
.
:
.
1 4. "Buffer entry" (" ")
, ,
" "
(. 26.10).

. "Checksum"
,

Block. Block
,
.
FB "Generate_Frame"
,
.
"Store frame"
(" ")
"Store frame" (" ") ,
"" ANY-).
"Rec_mailb"
"Buffer". Entry
;
, (. . 26.10).
" "
("receive mailbox") ,
.
, 8 .
, ,
.
"Store_Frame"
"Rec_mailb".
, , ,
, , "
" ("receive mailbox"),
"Buffer" . SFC 20 BLKMOV
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

26 - 23

26.

FB "Store_Frame"
Entry +1

DB "Buffer"
Entry[1]
( 1)
Entry[2]
( 2)
Entry[3]
( 3)

DB "Rec_mailb"
Data ()

Copy

Entry[4]
( 4)
Entry[5]
( 5)
Entry[6]
( 6)
Entry[7]
( 7)
Entry[8]
( 8)

. 26.10 "Store frame" (" ")


,
Entry.
, ANY- ANY_pointer
SFC DSTBLK.
,

.
Frame , 20 (: 8
, : 8 : 4 ).
Receive "Rec_mailb", ,
20 ,
Entry "Buffer" 20 . ,
Entry[n] n 20, n
Entry.
"Date conversion"
(" ")
"Date conversion" (" ")


.
"Data66" CPU_Tim (
DATE_AND_TIME) Dat ( STRING).
CPU_Tim
"YYMMTT" Dat.
"DT_Conv"
A1 DB- Tim.

26 - 24

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26.

A2 DI-
( Dat,
STRING, "Data66").
, DB-, DI-,
.

Tim,
("") ,
DB- AR1.
(
)
( V-).
, DB, (area pointer) AR1
DB.
V-, DB- ,
(area pointer) AR1
V.
""
,
AR2 DI-.
DI-, DI
AR2. ,

DB , V - V-.
24- AR2 "1"
DB DI,
V.

,
,
.
6 . 6 ,
BR "0" (
BR = "1"),
. ,

"DT_Conv".

Tim ( - [BCD] ),
ASCII (
"3")
. ,
.

.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

26 - 25

26.

26 - 26

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

SCL

SCL (Structured Control Language)


SIMATIC S7.
DIN EN 61131-3 ( "Structured Text"
[" "]) PLC
Base Level [ ] V4.01
(
, ). SCL
(PLC). SCL
(Paskal) PLC
, , , "" ("input") "" ("output").
SCL
, . SCL
STEP 7 ,
S7-,
STL, LAD FBD.
S7-SCL ( ,
) . S7SCL STEP 7 Basic
Package. S7-SCL
SCL V.5.1
S7-SCL
SIMATIC Manager

(, STL). SCL-,
S7- ,
SCL-.
SCL-; , ,
,
.
, SCL,
(online) CPU SCL
Debugger.
SCL
() ( ,
, ). ,
, , .
(control statements),
,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 1

(SCL)

,
, .
SCL
- ( ,
),
SCL, S7.
SCL,
.
, ,
SCL-; , , SCL
STL, . , ,

IEC-
STEP 7 Basic Package.

27 ,
SIMATIC; ; ; ;
.
28
IF, CASE, FOR, WHILE, REPEAT, CONTINUE, EXIT, GOTO, RETURN.
29 SCL-
; ; OK;
EN/ENO.
30 SCL-
; ; ;
; ;

SCL STL.
31 IEC-
; ; STRING-
( STRING);
; .

27 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 .

,
SCL. 2
" STEP 7" 3 "SIMATIC S7-"
,
.
2 " STEP 7"
, , ,
(symbol editor), SCL- (SCL program editor),
. SCL.
3 "SIMATIC S7-"
.
, ,
.
" " " ,
STEP 7".
, ,
STL_Book library "27
Language Elements" (" ").

27.1

SIMATIC

27.1.1 ()
SCL

SIMATIC
Manager

.
SCL
SETUP;

8 .
, SCL
( ),
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 3

27. .

27.1.2
SIMATIC Manager
SCL. ,
SCL, SIMATIC
Manager ,
(. 2.1 "
STEP 7 (STEP 7 Basic Package)").
""
Wizard -" ".
CPU,
SIMATIC Manager S7. S7-
CPU .
, . ,
: S7 Program [S7 ], Blocks [],
Symbols [] . -
, .
Insert ().
,
STL
, , , FBD. SCL. SCL-
, ,
.

27.1.3 SCL-
Sources [ ]
: Insert -> SCL Source ( -> SCL) (
, ,
SCL ).
SCL Source(1).
, SCL-,
"" SCL-.
SCL-.
SCL-,
2.5.4 " SCL- (SCL-Program Editor)".
() .
3.5
" SCL".
:
"Delimiter",
, (
); ,
(. . 27.1).

27 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27. .

FUNCTION Delimiter : INT


VAR_INPUT
MAX : INT;

//

IN

//

: INT;

MIN : INT;

//

END_VAR
BEGIN
IF IN > MAX THEN Delimiter := MAX;

//

ELSIF IN < MIN THEN Delimiter := MIN;//


ELSE Delimiter := IN;

//

END_IF;
END_FUNCTION
ORGANIZATION_BLOCK Mainjprogram
VAR_TEMP
SINFO : ARRAY [1..20] OF BYTE;
END_VAR
BEGIN
Result := Delimiter (MAX := Maximum, IN := INPUT_VALUE, MIN := Minimum);
END_ORGANIZATION_BLOCK

. 27.1 "Delimiter"

"Delimiter" ( FC) (INT).
: MAX (
, ), IN ( ) MAX
( , )
(INPUT), INT.
.
, IN ,
, ,
. , IN ,
, ,
.
, ,
IN.

"Main Program". SCL,
20
,
.
, SCL
FC

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 5

27. .

"" ,
(),
. "Main Program"
"Delimiter"
"Result" ("");
"Input_value",
"Maximum" "Minimum".
SCL- , , .
SCL-,

.
SCL- ,
: File -> Save ( -> ).
,
(Symbol Table) .

27.1.4 (Symbol Table)


(Symbol Table) SCL
(. 2.5.2 "
(Symbol Table)").
.
S7-
. S7
Program [S7 ] Symbols [].
(symbol editor),
: Options -> Symbol Table ( -> )
SCL- ""
Symbols [] SIMATIC Manager. ,
(, ),
(. . 27.1).
, .
27.1 (Symbol Table)
"Delimiter"
Symbol
()

Address
()

Data Type
( )

Main program

OB1

OB1

Delimiter

FC271

FC271

Input_value

MW10

INT

Maximum

MW12

INT

Minimum

MW14

INT

Result

MW16

INT

27 - 6

Comment ()



INT

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27. .

27.1.5 SCL-
, SCL-
Sources [ ] ( ).
, : Options ->
Customize ( -> ) "Compiler"
[""]. (
"Blocks generated" (" ")).
SCL-
: File -> Compile ( -> );
Blocks [].
2.5.4
" SCL- (SCL-Program Editor)".

;

.
,

, Blocks [], (
) , Sources
[ ], ,
Standard Library.

27.1.6 SCL-
( PLC)
CPU, : PLC -> Load (PLC -> )

CPU. CPU STOP (),

.
,
, 2.6
" (Online mode)".
"" ("online")
"" ("offline") SIMATIC Manager.

27.1.7 SCL-
SCL-
"Program Status" (" ")

. "Program Status" ("
") ,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 7

27. .

.

,
(. 2.7 " ").
(VAT)
SCL-.

.

27.1.8

,
SCL, ,
(. 1.5
" "):

I, Q, M;

PI;

PQ;

D;


( );

, FB, FC
, ; DB.

SCL " " (. 30.1 "


" 30.2 " ").
:

. ,
SCL, 27.2.1
" ".
SCL , " ",
.

:

27 - 8

()
(, integer [], character string [ ]);


(, , );

,
;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27. .

, SCL,
,
( 3.7 " "
, 24
" " ).
,
, (8#17
16#F 15dec) .

, SCL
,
:

ANY_INT INT DINT;

ANY_NUM INT, DINT REAL;

ANY_BIT BOOL, BYTE, WORD


DWORD.

,
;
.

- ,
.

()
(,
).
SCL "" ,
. , 1234
INT REAL,
:
int1

:= int2 + 1234;

// INT

real1

:= real2 + 1234;

// REAL

SCL (
- "type-defined").

,
,
,
WORD
, , .
, ,
, :
W1

WORD

:=

W#1234 ;

//

W2

WORD

:=

W#16#04D2 ;

//

W3

WORD

:=

W#8#2322 ;

//

W4

WORD

:=

W#2#0000_0100_1101_0010; //

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 9

27. .


ANY_BIT
(, MD10 DWORD).
( ANY_BIT) ,
(" "),
.
MW14

:= SHL(IN := MW12, N := 2);

real1

:= real2 + DWORD_TO_REAL(MD10);

STRING
.
;
$hh ( hh ASCII
).
string1

:= '$0A$0D';

//


(
)
'$>' '<$':
string2

:= 'ABCDEFGHIJKLMNOP$>'//
'<$QRSTUVWXYZ';

27.1.9 (Data Type Veiws)


SCL
, , ,
(data type veiws).

, .
:
, Station
STRING. Station
, , ,
. ,
Station.
, , .
,
.
Len,
max cur.
VAR_INPUT
Station : STRING24 := ' ';

27 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27. .

Len AT Station : STRUCT


max : BYTE;

//

cur : BYTE;

//

END_STRUCT;
END_VAR
...
IF WORD_TO_INT(Len.cur) > 12
THEN ...
END_IF;
...

""
.
(data type veiws) AT:
View AT Variable : Data_type;

//

(data type veiws)


, .
()
.
(data type veiw)
,
(
).
(data type veiws)
, .

Station :
.
(data type veiw)
.
(data type veiw)
, .
27.2 , (data type veiws)
. , ,

FC, ,
(data type veiws),
: ,
, POINTER ANY.
TIMER, COUNTER BLOCK_xx
(data type veiws).
27.2 :
:
E - (elementary) - (BOOL, CHAR, BYTE, WORD, INT, DINT, REAL,
S5TIME, TIME, DATE, TIME_OF_DAY);
C - (complex) - (DATE_AND_TIME, STRING, ARRAY, STRUCT UDT);
P - (POINTER) - ;
A - (ANY) - ANY-.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 11

27. .

27.2 (data type veiws)

FC


()
(C)
(elementary)
(complex)

VAR_INPUT

VAR_OUTPUT

VAR_IN_OUT

1)

ANY (A)

1)

VAR_TEMP

VAR_INPUT

VAR_OUTPUT

VAR_IN_OUT

VAR

VAR_TEMP

VAR

FB

POINTER (P)

27.2

27.2.1

; , I 1.0 (0- 1- ).
SCL
(. 3.3 "
")
, (. . 27.3).
27.3

I y.x

IBy

IWy

IDy

Qy.x

QBy

QWy

QDy

PIBy

PIWy

PIDy

PQBy

PQWy

PQDy

My.x

MBy

MWy

MDy

DBz.DXy.x

DBz.DBy

DBz.DWy

DBz.DDy

DBz.Dy.x

x = , y = , z =

27 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27. .

SCL
.
BLOCK_DB (. 27.2.3 "
SCL").
:
SCL ( ""
"") .
:
SCL
;
;
.

27.2.2

.
;
.
SCL
(. 3.3 "
").
- (mixed absolute/symbolic) ,
:
DB10.Setpoint
"Motor1Data".DW12


.
SCL
.

27.2.3 SCL


.
INT (
INT ):

I[byteindex.bitindex];

MB[byteindex],

byteindex bitindex ,
,
INT.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 13

27. .

PI PQ
( );

I, Q, M;

D
( );


( );


( ).



,
.

:

DB10.DX[byteindex.bitindex];

MotorData.DW[byteindex],

byteindex bitindex ,
,
INT.
WORD_TO_BLOCK,
. DB
,
WORD (. . 27.2).

WORD_TO_BLOCK_DB[dbindex].DW0,

dbindex ,
, WORD.
,
.
BLOCK_DB
BLOCK_DB,

, (. . 27.2).
Data BLOCK_DB:

Data.DW0;

Data.DX2.0;

Data.DW[byteindex];

Data.DX[byteindex.bitindex],

byteindex bitindex ,
,
INT.
27 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27. .

BLOCK_DB,
.
//*************************************************************************
//
k := 120; FOR i := 48 TO 62 BY 2 DO
MW[k] := PIW[i]; k := k + 2; END_FOR;
//*************************************************************************
//
// DB WORD
M0.0 := WORD_TO_BLOCK_DB(dbindex_w).DX0.0;
M0.0 := WORD_TO_BLOCK_DB(dbindex_w).DX[byteindex,bitindex];
// DB INT
M0.0 := WORD_TO_BLOCK_DB(INT_TO_WORD(dbindex_i)).DX0.0;
M0.0 := WORD_TO_BLOCK_DB(INT_TO_WORD(dbindex_i)).DX[byteindex,bitindex];
//*************************************************************************
//
// "Data" BLOCK_DB
M0.0 := Data.DX0.0;

//

M0.0 := Data.DX[byteindex,bitindex]; //
//*************************************************************************

. 27.2

SCL
, , INT,
.
(.
27.5.4 " ").

.

27.3

.
() (
) ()
( ), .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 15

27. .

:
a + b;
a b - ( = ),
"+" - .

.
.
,
SCL ( ,
), .
SCL ,
27.4.
, ,
.
27.4 , SCL

()

(, )

**

, ()

+, -

*, /, DIV, MOD

+, -

, ,

<, <=, >, >=

=, <>

NOT

""

AND, &

" "

XOR

""

OR

10

:=

11

, ,

()

"" , ()

27.4

- ,
. ()
() .
() ,
,

27 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27. .

.
()
(), .
;
.

.
, ,
,

(control instruction).

() ,
.

27.4.1


.
:
Voltage * Current
27.5
,
.
ANY_NUM ,
INT,
DINT REAL.
INT DINT, DINT;
INT DINT
REAL, REAL.
, (
) ,
(. 30.4 "
(Implicit Conversion Functions)").
, ()
.
. 27.3
.

27.4.2

; ,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 17

27. .

TRUE (), - FALSE


().
:
Voltage1 > Voltage2

(ANY_INT,
ANY_NUM ANY_BIT).
27.5
, .
27.5 SCL-

**

ANY_NUM

INT

REAL

ANY_NUM
TIME

ANY_NUM
ANY_INT

ANY_NUM
TIME

ANY_NUM

ANY_NUM

ANY_NUM

DIV

ANY_INT
TIME

ANY_INT
ANY_INT

ANY_INT
TIME

MOD

ANY_INT

ANY_INT

ANY_INT

ANY_NUM
TIME
TOD
DT

ANY_NUM
TIME
TIME
TIME

ANY_NUM
TIME
TOD
TOD

ANY_NUM
TIME
TOD
DATE
TOD
DT

ANY_NUM
TIME
TIME
DATE
TOD
TIME

ANY_NUM
TIME
TOD
TIME
TIME
DT

<, <=, >, >=

ANY_NUM
CHAR
STRING
TIME
DATE
TOD

BOOL

, ,
, ,

ANY_NUM
CHAR
STRING
TIME
DATE
TOD

=, <>

ANY_BIT

ANY_BIT

BOOL

NOT

ANY_BIT

ANY_BIT

""

AND, &

ANY_BIT

ANY_BIT

ANY_BIT

"
"

XOR

ANY_BIT

ANY_BIT

ANY_BIT

""

OR

ANY_BIT

ANY_BIT

ANY_BIT

BOOL
BOOL
BOOL
BOOL


.
27 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27. .


, , :
(Value1 > 40)

AND NOT

(Value2 = 20)

CHAR
ASCII. IEC-
, STRING
DT. IEC- FC ,
Standard Library IEC
Function Blocks.
. 27.3
.
(********************* *************************
Automatic
Setpoint
Deviation
Display

:=
:=
:=
:=

TRUE;
StartSetpoint;
ActualValue - Setpoint;
INT_TO_WORD(Deviation);

//
//
//
//

(******************* **********************
Power
Volume
Solutionl
MeanValue

:=
:=
:=
:=

Voltage * Current;
4/3 * PI * Radius**3;
-P/2 + SQRT(SQR(P/2)-Q);
(Motor[1].Power + Motor[2].Power)/2;

(********************* *************************
TooLarge :=
Warning
:=
M101.0
:=
IF Deviation

Voltage_Act > Voltage_Set;


(Voltage * Current) >= 20_000;
Setpoint = ActualValue;
> 2_000 THEN Display := 16#F002; END_IF;

(********************* *************************
Q4.0
ON
MW30
Pulses

:=
:=
:=
:=

II.0 & II.1;


(Manual_on OR Auto_pn) AND NOT Fault;
MW32 AND Mask;
(Edge_mem_bits XOR ID16) AND ID16; Edge_mem_bits := ID16;

(*******************************************************************
. 27.3 , ,

27.4.3
,
ANY_BIT,
AND (), OR () XOR ( ).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 19

27. .

:
Automatic

AND NOT

Manual_on

() ;
.
,
ANY_BIT.
BOOL, BOOL.
BYTE, WORD DWORD,
" " .
. 27.3
.

27.5



.
":=" ,
,
.
, ,
.
" " ("Implicit data type
conversion"):
,
, ""
(
). ,
" " (
) .

27.5.1
, ,

(. . 27.3).
(, MW 10) ANY_BIT;
, (
BOOL, BYTE, WORD, DWORD).
,
,
.

27.5.2 DT STRING
DT- DT27 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27. .

DT-.
STRING-
STRING- .
, ,
,
.

.
STRING-, , IEC-, STRING (, ),
.

27.5.3
STRUCT-
STRUCT- ,
:


; ,
Motor1.Setpoint INT INT-,
- (INT)
.

27.5.4
ARRAY-
ARRAY- ,
,
( )
, .

.
,

(ARRAY- ):
,
.
: :
Field1 : ARRAY [1..8,1..16] OF INT;
, Field1 .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

27 - 21

27. .

, :

, Field1;

, Field1[i]
( );


Field1[i,j].

Field1[i]
( , ARRAY-),
, :
Field12 := Field1[i],
:
i 1 8;
Field2 :
Field2

27 - 22

ARRAY [1..16] OF INT;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

28 (Control Statements)

(control statements)
,

. SCL
:

IF
(
, (
BOOL));

CASE
(
, (
INT));

FOR
(
- );

WHILE
( ,
);

REPEAT
(
);

CONTINUE (
);

EXIT

GOTO
( ,
);

RETURN

( );

( ).

28.1 IF
IF
. IF
,
, .
IF

condition
THEN statements;
END_IF;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

28 - 1

28.

condition - BOOL.
condition TRUE (),
THEN. condition FALSE
(), END_IF.
END_IF IF.
IF

condition
THEN statements1;
ELSE statements0;
END_IF;
, , condition
TRUE () FALSE (). condition
TRUE (),
THEN. condition FALSE (),
ELSE.
IF

condition1
THEN statements1;
ELSEIF condition2
THEN statements2;
ELSE statements0;
END_IF;
IF . ,
, condition1 TRUE (),
statements1
THEN, ,
END_IF. condition1 FALSE
(), condition2
ELSEIF. condition2 TRUE (),
statements2
THEN, ,
END_IF. condition2 FALSE
(), statements0
ELSE.

ELSEIF ... THEN ... IF ... THEN
... ELSE. ELSE
.
:
Actual_value , Setpoint,
, THEN. ,
, Actual_value , Setpoint,
, ELSEIF.
,
ELSE.
IF

28 - 2

Actual_value > Setpoint


THEN greater_than := TRUE;
less_than
:= FALSE;
equal_to
:= FALSE;
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

28.

ELSEIF Actual_value <


THEN greater_than
less_than
equal_to
ELSE greater_than
less_than
equal_to
END_IF;

Setpoint
:= FALSE;
:= TRUE;
:= FALSE;
:= FALSE;
:= FALSE;
:= TRUE;

28.2 CASE
CASE

( INT).

:

CASE

CASE Selection OF
CONST1 :
statements1;
CONST2 :
statements2;
...
CONSTx :
statementsx;
ELSE
:
statements0;
END_CASE;
Selection - INT.
Selection CONST1,
statements1. Selection CONST2,
statements2 .
Selection ,
, ,
ELSE. ,
ELSE, .
CONST1, CONST2 .. (INT) .

CASE, "" CONST :

(INT) ;

(INT) (: 15..20);

(INT)
(: 21,25,31..33).

-"" CONST
, CASE
.
CASE .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

28 - 3

28.

CASE
CASE.
:
,
ID.
CASE ID OF
0
:
1,3,5 :
...
6..10 :
ELSE
:
END_CASE;

Error_number,

Error_number := 0;
Error_number := ID + 128;
Error_number := ID;
Error_number := 16#7F;

28.3 FOR
FOR .
, " "
.
FOR
:
FOR i :=
TO
BY
DO
END_FOR;

limit1
limit2
step
statements;

limit1
i.
- ; INT
DINT. limit1
INT DINT, limit2
- step.
-
.

limit2 - step (

).
, ,
.

step (
) step (
).

28 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

28.

BY step ( ,
BY) .
- , (
) +1.
(limit1...limit2),

END_FOR.
-
, , ( ,
limit2 )
-,
(limit2 - step).
-
,
.
FOR :
FOR
FOR -
.
FOR
(
CONTINUE)
,
END_FOR, ( EXIT).
:
, PIW 128 PIW 142
MW 128 MW 142.
FOR i := 128 TO 142 BY 2 DO
MW[i] := PIW[i];
END_FOR;

28.4 WHILE
WHILE ,
,
.

:
WHILE Condition
Statements;
END_WHILE;

WHILE

DO

Condition - BOOL.
( , Condition =
TRUE()), Statements.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

28 - 5

28.

Condition.
(Condition = FALSE()),
,
END_WHILE. ,
( ),
, Statements
.
WHILE ;
WHILE
WHILE.
WHILE
(
CONTINUE)
,
END_WHILE, ( EXIT).
:
, DB10
16#FFFF. DW0 16#FFFF,
, 16#FFFF,
.
i := 0;
WHILE DB10.DB[i] := 16#FFFF DO
i := i + WORD_TO_INT(DB10.DB[i]);
END_WHILE;

28.5 REPEAT
REPEAT ,
,
.
REPEAT
:
REPEAT
Statements;
UNTIL Condition
END_REPEAT;
Condition - BOOL.
( , Condition =
FALSE()), Statements.

Condition. (Condition = TRUE()),

END_REPEAT.

28 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

28.

,
,
, , Statements
.
REPEAT ;
REPEAT
REPEAT.
REPEAT
(
CONTINUE)
,
END_REPEAT, ( EXIT).
:
, SFC 25 COMPRESS
, ""
.
REPEAT
SFC_ERROR := COMPRESS(
BUSY := busy,
DONE := done);
UNTIL done
END_REPEAT;

28.6 CONTINUE
CONTINUE
, FOR, WHILE
REPEAT.
CONTINUE
( ,
REPEAT WHILE) (
, FOR) ,
, ?
, CONTINUE
.
:
,
FOR; (i)
0, (k) 2,
FOR (
M0.3).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

28 - 7

28.

FOR i := 0 TO 2 DO
FOR k := 0 TO 7 DO
IF (k<2 & i=0)
THEN CONTINUE;
END_IF;
M[i,k] := TRUE;
END_FOR;
END_FOR;

28.7 EXIT
EXIT (
), FOR, WHILE
REPEAT. EXIT
, ,
. EXIT
END_FOR,
END_WHILE END_REPEAT.
EXIT
, .
:
,
FOR; (i)
2, (k) 5, FOR
( M2.5).
FOR i := 0 TO 2 DO
FOR k := 0 TO 7 DO
IF (k=2 & i>5)
THEN EXIT;
END_IF;
M[i,k] := TRUE;
END_FOR;
END_FOR;
FOR
k EXIT.
FOR i
. , ,
FOR i.

28 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

28.

28.8 RETURN
RETURN .

, ( RETURN
).
RETURN .
RETURN OK
ENO ( RETURN) .
:
, .
IF Error <> 0 THEN RETURN;
END_IF;

28.9 GOTO
GOTO
.
:
, .

M1:

GOTO M1;
...;
...;

//
//

...;

// -

GOTO
.
: LABEL END_LABEL.
,
.
( ).

GOTO .

, .
.
().
"" :
Label1: ;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

28 - 9

28.

, GOTO,
:

,
GOTO;

"" ,
.

:
LABEL
M1, M2, M3, End;
END_LABEL
...
CASE Selection OF
1 : GOTO M1;
2 : GOTO M2;
3 : GOTO M3;
ELSE GOTO End;
END_CASE;
M1: ... statement1 ...;
GOTO End;
M2: ... statement2 ...;
GOTO End;
M3: ... statement3 ...;
END:;
:
GOTO . SCL

, GOTO .

28 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29 SCL-

29.1 SCL-:
SCL
, .

SCL, , , FBD-,
SCL- ,
STL.
, ,
,
.
EN ENO (. 29.4
" EN/ENO").
, ,
SCL_Book library "29
Block Calls" (" ").

.
CPU
, , , .

"" .
1,


1 (. 3.1 " ").

OB1
( "" - "blocks").
(Code Block) (Data
Block), . -
,
(. 20.1 " ").

STEP 7 FC FB
. FB
, (
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

29 - 1

29. SCL-

"" ). , FB,
" " ("instance data block");
,
("higher-level" data block). FC
, " "
("function value"). , ,

FC (, )
(. 3.2 "").
.
"" ( ).

" " ("input parameter") (VAR_INPUT),
() , "
" ("output parameter") (VAR_OUTPUT),
, "/ "
("in-out parameter") (VAR_IN_OUT),
, .

" " ("formal parameter")
( ).
" " ("actual parametr"),
CPU .

,
, .

29.2 SCL-
SCL- 2
" STEP 7";
3.5 "
SCL". UDT
STL (.
3.6 " " 24.3
" ").
,
, -
,
"Delimiter" 27 ". "
:

29 - 2

FC 291 ;

FC 292 ;

FB 291
DB 291;

FB 291
FB 290.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29. SCL-


(FB 290 DB 290 ).
.
.
:
"Delimiter"
,
FC
.

29.2.1 FC
FC
VOID. FC 291 MAX,
IN, MIN OUT.
FUNCTION FC291 : VOID
VAR_INPUT
MAX : INT;
IN : INT;
MIN : INT;
END_VAR
VAR_OUTPUT
OUT : INT;
END_VAR;
BEGIN
IF IN > MAX THEN OUT := MAX;
ELSIF IN < MIN THEN OUT := MIN;
ELSE OUT := IN;
END_IF;
END_FUNCTION


.
,
.

29.2.2 FC
FC ,
(
). FC 292
MAX, IN, MIN (

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29 - 3

29. SCL-

), ()
.
, .
FUNCTION FC292 : INT
VAR_INPUT
MAX : INT;
IN : INT;
MIN : INT;
END_VAR
BEGIN
IF IN > MAX THEN FC292 := MAX;
ELSIF IN < MIN THEN FC292 := MIN;
ELSE FC292 := IN;
END_IF;
END_FUNCTION

, :
DATE_AND_TIME, STRING UDT.
ARRAY, STRUCT, POINTER ANY .
STRING,
,
( ,
).


.
,
.
FC
,
.

.

29.2.3 FB
,
(
,
).


. IN
OUT .

29 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29. SCL-

FUNCTION_BLOCK FB291
VAR_INPUT
IN : INT;
END_VAR
VAR_OUTPUT
OUT : INT;
END_VAR;
VAR
MAX : INT := 10_000;
MIN : INT := -5_000;
END_VAR
BEGIN
IF IN > MAX THEN OUT := MAX;
ELSIF IN < MIN THEN OUT := MIN;
ELSE OUT := IN;
END_IF;
END_FUNCTION_BLOCK
,
.
:
.

. , ,


: .
:

, -

(. 26.3.2 " ").

29.2.4
,

. SCL
,
.
18.1.5 " ".

VAR_TEMP.
, , (UDT) ,
POINTER ANY. ANY
(. ).
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

29 - 5

29. SCL-


. , L-
STRING ,
"Compiller" (""),
: Option -> Customize ( ->
).

, .
STRING,
, , IEC-.
IEC-
. ,
( )
.
SCL ,
, :
VAR_TEMP
VALUE1, VALUE2, VALUE3 : INT;
...
END_VAR
, SCL

.
ANY
ANY
,
:
ANY_VAR := MW10;
ANY_VAR := Setpoint;
ANY_VAR := DB10.Field;
ANY
NIL, "":
ANY_VAR := NIL;
:
, " "
("send mailbox") SFC 20
BLKMOV :
VAR_TEMP
Address := ANY;
END_VAR
...
CASE Identifier OF
1: Address := DataRecord1;
2: Address := DataRecord2;
...

29 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29. SCL-

ELSE Address
END_CASE;
SFC_ERROR :=
SRCBLK :=
DSTBLK :=

:= NIL;
BLKMOV(
Address,
SendMailbox);

ANY-,
DB ,
(. 27.1.9 " (Data Type Veiws)").

29.2.5
- "" .
.
,
,
.


.
18.1.6 " ".

VAR END_VAR.
, , (UDT) ,
POINTER ANY.
SCL
, . ,
,
( ).
:
VAR
VALUE1, VALUE2, VALUE3 : INT;
VALUE4
...

: INT:=3;

END_VAR
, SCL

.
,
,
.
, .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29 - 7

29. SCL-

29.2.6

.
(Input), - (In/Out) (Output) (.
19.1.3 " ").
(Input) , (Output)
. ,
, , ,
, , (In/Out) .
FC,
.
FB,
(. 26.3 "
").
SCL
, . ,
,
( ).
:
VAR_INPUT
VALUE1, VALUE2, VALUE3 : INT;
...
END_VAR
,
, .
,
.
Result
Result
Result
Result

:=
:=
:=
:=

DB279.DW20;
DB279.Total;
Totalizer.Total;
Totalizer.DW20;


(Output) (. ,
29.3.3 "
", 29.3.4 "
").


,
.
,
(Input) (Output) .
,

29 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29. SCL-


, ,
. BLOCK_DB
DB1 (DB0 ,
).
STRING,
254 0 -
,
, "Compiler" (""),
: Options -> Customize
( -> ).

29.2.7

. ,
,
.


,
;
.


.

(UDT)

(assignment)
, ;
.

ARRAY, STRUCT UDT.


.
DT STRING,
.
TIMER COUNTER
TIMER COUNTER
SIMATIC-
SIMATIC- (. 30.1 " "
30.2 " ").
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

29 - 9

29. SCL-

BLOCK_xx
BLOCK_xx
(. 27.2.3 "
SCL").
BLOCK_FB BLOCK_FC
SCL
(
).
POINTER ANY
POINTER ANY

SCL. ,
,
.

POINTER ANY
.
ANY ,
ANY- .

29.3

SCL-
SCL
(function value)
.
FB FC
"" ( );

SFB SFC .
FC
,
. 29.1 .
SFB ,
FB, SFC
, FC.
SFB ,
.

. -
, ,
,
.

FC SFC.
FB
SFB .

29 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29. SCL-

FB
SFB

.
29.1 SCL-

:= FCx(...);
:= FC_name(...);

FCx(...);
FC_name(...);

FBx.DBx(...);
FB_name.DB_name(...);

local_name(...);

29.3.1 FC
FC :
FC291(MAX
IN
MIN
OUT

:=
:=
:=
:=

Maximum,
InputValue,
Minimum,
Result);

,
, .
,
. ,
FC .
,
.
:
, INT-
Speed STRING- Display:
Display := I_STRING(Speed);

29.3.2 FC
FC :
Result := FC292(
MAX := Maximum,
IN := InputValue,
MIN := Minimum);

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29 - 11

29. SCL-

FC
, ,
.
Result FC 292.
,
, .
,
. ,
FC .
,
.
EN,
FALSE (),
(
).

29.3.3

,
.
( ),
SCL,
.
SCL , , (.
3.6.1 " ").

.
.
DATA_BLOCK DB291
FB291
BEGIN
END_DATA_BLOCK
:
FB291.DB291(IN := InputValue);
Result := DB291.OUT;

, , -
.
, .
.
/
,
.
,
. ,
.
29 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29. SCL-


.
.

:
DB291.MAX := Maximum;
DB291.MIN := Minimum;

. ,

.
IF DB291.OUT > 10000 THEN ... END_IF;
DB291.MIN := Minimum;

29.3.4
"
" (local instance) .
()

.
FUNCTION_BLOCK FB290
...
VAR
Delimiter : FB291;
END_VAR
...
BEGIN
Delimiter (IN := InputValue);
Result := Delimiter.OUT;
...
END_FUNCTION_BLOCK
;
(, Delimiter)
(FB291 ) .
,
,
Blocks (), (
) ,
.

SFB .

.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

29 - 13

29. SCL-

/
,
.
,

. ,
.

.

-
.
.
:
Delimiter.MAX := Maximum;
Delimiter.MIN := Minimum;

( ).
,
:
Result := Delimiter.OUT;

" " .

(DB290),
(Delimiter) :
DB290.Delimiter.MAX := Maximum;
DB290.Delimiter.MIN := Minimum;
Result := DB290.Delimiter.OUT;

29.3.5

( - "actual parameter")
(. ).
STL SCL
(. 19.3 "
"), :

29 - 14

DT STRING SCL
.

POINTER SCL

P#Operand. :
"" (NIL) .

ANY
ANY-
P#(DB.( )). :
"" (NIL) .
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

29. SCL-


,
. , FC
.

:
POINTER ANY
FB FC,
.
.

29.4

EN/ENO
SCL
()
, , ,
?
"". ""
ENO . ,
EN .
EN ENO
(FC, SFC, FB, SFB, IEC-),
(,
), .
15 " ", 15.4 "
" , EN/ENO
.

29.4.1 -
SCL
"" BOOL.
, SCL, , "Set OK flag"
(" OK-") "Compiler" (""),
: Options -> Customize ( ->
) SCL-.
,
, - .
- TRUE ().
-
FALSE (). -
SCL-,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29 - 15

29. SCL-

SUM := SUM + IN;


IF OK
THEN (* *);
ELSE (* *);
END_IF;
-
(.
30.5.2 " ").
, ,
, ENO (.
).
- ENO.

29.4.2 ENO (ENO output)


- ENO
("ENO output" = "Enable output" = " "). ENO
BOOL. ENO
, (
ENO = TRUE []) (
ENO = FALSE []).
FC15 (In1:= ..., In2:= ...);
IF ENO
THEN (* *);
ELSE (* *);
END_IF;
ENO
,
-:
FC15 (In1:= ..., In2:= ...);
OK := ENO;
ENO
-:
IF (* *)
THEN OK := FALSE; RETURN;
END_IF;
ENO , ,
, ENO. ENO
. ENO
.
EN (.
), EN FALSE (),
, ENO
FALSE ().

29 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29. SCL-

:
,
, "
" BR, SCL
ENO (. 15.4
" ").

29.4.3 EN (EN input)


EN. EN
BOOL. EN TRUE
(), . EN
FALSE (),
.
.
FC15 (EN := I1.0,
In1:= ...,
In2:= ...);
(* FC15 , I1.0 = "1" *)
EN, .
EN , ,
, EN. EN
. EN
, .
EN ENO;

, .
:
FC16 ,
FC15 ,
:
FC15 (EN :=
In1:=
In2:=
FC16 (EN :=
In1:=
In2:=

I1.0,
...,
...);
ENO,
...,
...);

, ENO
TRUE ().
, FC SFC
( ),
EN, EN
FALSE ().

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

29 - 17

29. SCL-

29 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30 SCL-

30.1

CPU SCL
, ()
. ,
, :

S_PULSE ("pulse timer" - " ")

S_PEXT

("extended pulse" - " ")

S_ODT

("ON delay" - " ")

S_ODTS

("latching ON delay" - " ")

S_OFFDT ("OFF delay" - " ")

, 30.1.
30.1 SIMATIC-

T_NO

INPUT

TIMER

INPUT

BOOL

TV

INPUT

S5TIME

INPUT

BOOL

OUTPUT

S5TIME


- (BCD)

OUTPUT

BOOL

BI

OUTPUT

WORD


(binary)

:
Time_BCD
T_NO
S
TV
R
Q
BI

:=
:=
:=
:=
:=
:=
:=

S_PULSE(
Timer_address,
Start_input,
Timer_duration,
Reset,
Timer_status,
Binary_time);

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30 - 1

30. SCL-

7
" (Timer Functions)".
, (. . 7
" (Timer Functions)" SCL.

:

T_NO

S TV

BI

SIMATIC- CPU

IEC-
SFB:

SFB 3 TP
Pulse generation -

SFB 4 TON
ON delay -

SFB 5 TOF
OFF delay -

7.7 "IEC- (IECTimer Functions)".


" " Standard
library System Function Blocks (
).
SIMATIC- IEC-
, ,
"SCL_Book" "Timer Functions" (" ")
"30 SCL Functions" ("30 SCL-").

30.2
CPU SCL
, ()
. ,
, :

S_CU

("up counter" - " ")

S_CD

("down counter" - " ")

S_CUD

("up-down counter" - "


")

SIMATIC-
30.2.

30 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30. SCL-

30.2 SIMATIC-

C_NO

INPUT

COUNTER

CU

INPUT

BOOL

CD

INPUT

BOOL

INPUT

BOOL

PV

INPUT

S5TIME

INPUT

BOOL

OUTPUT

WORD


- (BCD)

OUTPUT

BOOL

CV

OUTPUT

WORD


(binary)

:
BCD_Count_Value := S_CU(
C_NO := Count_address,
CU
:= Count_up,
S
:= Set_input,
PV
:= Count_value,
R
:= Reset,
Q
:= Counter_status,
BI
:= Binary_count_value);
8
" (Counter Functions)".
,
SCL.

:

CD
S_CU

CU
S_CD

C_NO


CD CU

S PV

CV

PV

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30 - 3

30. SCL-

INT 0
999 16#000
16#3E7.
SIMATIC- CPU
IEC-
SFB:

SFB 0 CTU
("up counter" - " ")

SFB 1 CTD
("down counter" - " ")

SFB 2 CTUD
("up-down counter" - " ")

8.6 "IEC- (IECCounter Functions)". "


" Standard library System Function Blocks
( ).
SIMATIC- IEC-
, ,
"SCL_Book" "Counter Functions" ("
") "30 SCL Functions" ("30 SCL-").

30.3

:

:
EXP
EXPD
LN
LOG

(Arc-):
ASIN
ACOS
ATAN

:
SIN
COS
TAN

SCL


10

:
ABS
SQR
SQRT

INT, DINT REAL.

30 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30. SCL-

INT DINT
,
REAL.

REAL;
REAL. ABS,
, .
,
, , 0 2 ( =
3,141593e+00), 0 360.

ASIN

-1 ... +1

-/2 ... +/2

ACOS

-1 ... +1

ATAN

0 ...
-/2 ... +/2

:
Reactive_power,
Voltage Current
:
Reactive_power

:= Voltage * Current * SIN();

Volume,
PI Radius
Level:
Volume

:= PI * SQR(Radius) * Level;

:
c

:= SQRT(SQR(a) + SQR(b));

30.4 (Shifting) (Rotating)


(Shifting) (Rotating)
:
Result
IN
N

:= Function(
:= Input_value,
:= Shift_number);

.
N ,
,
INT. IN ,
,
ANY_BIT ( , BOOL, BYTE, WORD,

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30 - 5

30. SCL-

DWORD). ,
.
:
MW14

:= SHL(IN := MW12, N := 2);

res_dword := ROR(
IN := in_dword,
N := shift_int);
30.3 (Shifting) (Rotating)
SHL

IN N ;
.

SHR

IN N ;
.

ROL

ROR

IN N ;

"" .
IN N ;

"" .

30.5 (Conversion Functions)



() .
,
.
, ,
.
(Conversion Functions).
SCL
.
("Class A"). SCL (""),
(,
BYTE WORD).
B ("Class B").
, "", (,
REAL INT).

"OK-"
(
- Compiler
Properties [ ]).

DATE_AND_TIME STRING IEC-.
Standard Library IEC

30 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30. SCL-

Function Blocks [IEC ]) 31


"IEC-".

30.5.1
(Implicit Conversion Functions)
SCL
(""). ,
, , ,
.
30.4
SCL .
30.4 (Implicit Conversion Functions)

OK

BOOL_TO_BYTE

BOOL_TO_WORD

BOOL_TO_DWORD

BYTE_TO_WORD

BYTE_TO_DWORD

WORD_TO_DWORD

INT_TO_DINT

INT_TO_REAL

DINT_TO_REAL

CHAR_TO_STRING

, ,


( CHAR_TO_STRING), STRING,
1 ( ), -
FALSE ().
:

MB10
real_var

//
:= M7.0;
//BOOL -> BYTE
:= int_var;
//INT -> REAL

string_var := char_var;

//CHAR -> STRING

M10.7
M7.0. "0".

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30 - 7

30. SCL-

30.5.2
(Explicit Conversion Functions)

; ,

(. . 30.5
" ").
.
:
MB10
int_var
real_var

:= CHAR_TO_BYTE(char_var);
:= WORD_TO_INT(MW20);
:= DWORD_TO_REAL(MD30);

,
.
REAL.
REAL_TO_xxx
FALSE (), ,
REAL .

30.6 SCL

SCL- IEC-, SCL
,
.
- FC
. FC

29.2.2 " FC
" 29.3.2 " FC
" .
SCL
.

STL (. 30.7 "
STL"). ,
("data type views") SCL
. 27.1.9 "
(Data Type Views)" ,
.

,
(doubleword) , ,

30 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30. SCL-

30.4 (Implicit Conversion Functions)

BYTE_TO_BOOL
WORD_TO_BOOL
DWORD_TO_BOOL

OK

= "1", = TRUE

()

WORD_TO_BYTE

DWORD_TO_BYTE

DWORD_TO_WORD

CHAR_TO_BYTE

BYTE_TO_CHAR

CHAR_TO_INT

INT_TO_CHAR

= "1",
= TRUE ()


STRING <> "1",
= FALSE ()

STRING_TO_CHAR

WORD_TO_INT
DWORD_TO_DINT
INT_TO_WORD
DINT_TO_DWORD
REAL_TO_DWORD

DWORD_TO_REAL

N
N
N
N

DINT_TO_INT

REAL_TO_INT

INT

DINT

ROUND

REAL
DINT

TRUNC

REAL
DINT
("" )

REAL_TO_DINT

DINT_TO_TIME

DINT_TO_TOD

DINT_TO_DATE

DATE_TO_DINT

TOD_TO_DINT

BLOCK_DB_TO_WORD

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL


, = FALSE
()


TOD, = FALSE ()

, = FALSE
()

TIME_TO_DINT

WORD_TO_BLOCK_DB


, = FALSE
()

N
N

30 - 9

30. SCL-

.

.
VAR_TEMP
DW_VAR
: DWORD;
Pattern AT DW_VAR : ARRAY[0..31] OF BOOL;
END_VAR
...
Pattern[1] := Pattern[10]&Pattern[11]
...
10- 11- DW_VAR
AND (),
1- .
DT STRING
DT STRING SCL
"", ,
.
IEC- STEP 7
Standard Library DT STRING.
DT STRING
SCL- (Data Type
View) , . (OF
BYTE) DT STRING (.
. 30.6).
SCL-
"Hour" (""),
DT
Hour.
FUNCTION Hour : INT
VAR_INPUT
DAT : DT;
TMP AT DAT : ARRAY[1..8] OF BYTE;
END_VAR
BEGIN
Hour :=
WORD_TO_INT(SHR(IN:=TMP[4],N:=4))*10 +
WORD_TO_INT(TMP[4] AND 16#0F);
END_FUNCTION
(* CPU
"Hour" *)
SFC_ERROR := READ_CLK(DATE_TIME);
IF Hour (DATE_TIME) >= 18
THEN FINISH_WORK := TRUE;
END_IF;
30 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30. SCL-

30.6 (Data Type View)


(Data Type View)


BOOL

DT


BYTE

ARRAY


CHAR
STRUCT

ANY

STRUCT

STRING


TEMPVAR : DWORD;
VEIW AT TEMPVAR : ARRAY[0..31] OF BOOL;
TEMPVAR : DT;
VEIW AT TEMPVAR : ARRAY[1..8] OF BYTE;
TEMPVAR : STRING[max];
VEIW AT TEMPVAR : ARRAY[1..max] OF CHAR;
TEMPVAR : ARRAY[0..255] OF BYTE;
VEIW1 AT TEMPVAR : STRUCT
name : data_type;
.... : ...
END_STRUCT;
VEIW2 AT TEMPVAR : STRUCT
name : data_type;
.... : ...
END_STRUCT;
TEMPVAR : ANY;
VEIW1 AT TEMPVAR : STRUCT
ID : BYTE;
TYP : BYTE;
ANZ : INT;
DBN : INT;
PTR : DWORD;
END_STRUCT;


ARRAY STRUCT
(Data Type View), ARRAY
STRUCT.
" " ("mailbox")
.
,
" " ("mailbox"), .
, " "
("mailbox"), " "
, .

, , , ,
" " ("mailbox").
ANY

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30 - 11

30. SCL-

ANY
ANY, ,
(. 29.2.4 " ").
ANY-
(Data Type View),

.
:
, ,

DATABLOCK,
DATASTART

NUM_OF_BYTES , SEND_MAILBOX.
FUNCTION_BLOCK
VAR_INPUT
AREA
DATABLOCK
DATASTART
NUM_OF_BYTES
END_VAR
VAR_TEMP
SFC_ERROR

:
:
:
:

ANY;
INT;
INT;
INT;

: INT;

SEND_MAILBOX : ANY;
VEIW AT SENDEFACH : STRUCT;
ID : WORD;
TYP : BYTE;
NUM : INT;
DBN : INT;
PTR : DWORD;
END_STRUCT;
END_VAR
BEGIN
VEIW.ID
:= 16#10;
VEIW.TYP := 16#02;
VEIW.NUM := NUM_OF_BYTES;
VEIW.DBN := DATABLOCK;
VEIW.PTR := INT_TO_WORD(8*DATASTART);
SFC_ERROR := BLKMOV(
SRCBLK := AREA,
DSTBLK := SEND_MAILBOX);
END_FUNCTION_BLOCK
(* *)
COPY.COPYDATA(
AREA
:= SEND_MAILBOX,
DATABLOCK
:= 309,
DATASTART
:= 32,
NUM_OF_BYTES := 32);
30 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30. SCL-


SCL_Book "General
Examples" (" ").

30.7 STL
FC

SCL. ,
,
,
STL SCL-.
STL, ,
,
.
STL- :
(.
3.4 " STL").
-
- SCL-:
1. STL- Source
Files.
2. STL- Source
Files "" .
3.
STL (. ).
4. ,
Symbol Table.
5. STL-, ,
Blocks ()
.
6. , ,
, SCL-.
STL-
, SCL
(. 3.3 3.4.3 "
STL, ").
,
, , STL RET_VAL ( ret_val). ,
RET_VAL .

, .
.
7 " (Timer Functions)" ,
STL.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30 - 13

30. SCL-

T_SCAN
:
FUNCTION T_SCAN : BOOL
VAR_INPUT
T_NO : TIMER;
END_VAR
BEGIN
U T_NO; = RET_VAL;
END_FUNCTION
T_PULSE :
FUNCTION T_PULSE : VOID
VAR_INPUT
T_NO : TIMER;
START : BOOL;
Time_value : S5TIME;
END_VAR
BEGIN
U Start; L Time_value; SI T_NO;
END_FUNCTION
T_RESET :
FUNCTION T_RESET : VOID
VAR_INPUT
T_NO : TIMER;
END_VAR
BEGIN
Set; R T_NO;
END_FUNCTION
SCL, , :
IF NOT T_SCAN(T1)
THEN T_PULSE (T_NO

:= T2,

START := I1.0,
Time_value := S5T#5s);
ELSE T_RESET(T3);
END_IF;

SCL_Book "General Examples" (" ").

30 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30. SCL-

30.8 SCL
30.8.1 "Conveyor" ("")
"Conveyor" ("")
, / .
STL. STL,
SCL,
STL- SCL-.
30.1 .
:

5.5 " " (FC 11)

8.7 " " (FC 12)

19.5.1 ": " (FC 21)

19.5.2 ": " (FC 22)

19.5.3 ": " (FC 20)


SCL_Book "Conveyor Example" ("
").


FC 11



FB 21, DB 21

FB 20, DB 20

FB 21
.

FB 21, DB 22

FC 12

FB 22, DB 29

FB 21
.
FB 21
.
FB 21
.

FB 22

. 30.1

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30 - 15

30. SCL-

30.8.2
"Message Frame" (" ") ,

.



STL
ANY- (.
26.4 " "Message Frame Example"
( )").
,
SCL, .


(. . 30.2).
, SCL
( ,
).
, ( SCL)
STL
. ,
SCL STL
.

SCL_Book "Message Frame Example"
(" ").

30.8.3

ANY- .

SCL:

FC 61 DT_TO_STRING

STRING

FC 62 DT_TO_DATE

DATE

FC 63 DT_TO_TOD

TOD


, -
FIFO :

30 - 16

FB 61 Variable_length (" ")

FB 62 Checksum (" ")

FB 63 Ring_buffer (" ")

FB 64 FIFO_register ("FIFO ")

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30. SCL-

"STL Functions" ("STL-") "Call STL


Functions" (" STL-") , STL
SCL-.
SIMATIC ,
SCL,
.

SCL_Book "General Example" ("
").

DB 55 Meas_values
( )

FB 51 Generate_frame
( )

FB 53 Send_mailb
( .)

M1[1..4]

(Identifier Number)

(Identifier Number)

M2[1..4]

SFC 1
READ_CLK

M3[1..4]

FC 8
DT_TOD

FC 51
Time_
check

(Time_Of_Day)

(Data)

(Data)

M4[1..4]


(Checksum)


(Checksum)

FB 54 Receive_mailb
( .)

FB 52 Store_fraim
( )

(Identifier Number)

[1]

[3]

[4]

(Time_Of_Day)

(Data)

(Checksum)

[2]

[5]
[6]
[7]
[8]

. 30.2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

30 - 17

30. SCL-

30 - 18

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31 IEC-

IEC- - FC;
STEP 7. IEC-
Standard Library IEC Function Blocks
( IEC ).
SCL ,
, STL. IEC-
.
:

DATE_AND_TIME

STRING

STRING

Date/Time-of-day

SCL-. IEC STL-,


RET_VAL .
:
SCL:
CompResult := EQ_STRING(
S1 := string1,
S2 := string2);
STL:
CALL EQ_STRING(
S1 := string1,
S2 := string2,
RET_VAL := CompResult);
IEC- BR
. BR SCL
ENO, STL
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31 - 1

31. IEC-

31.1 (Conversion Functions)



. ,
,
,

.
:
var_out := _(var_in);
:
var_in -
var_out - ( )

BR ENO FALSE (),
.
.
:
, INT, Speed,
,
Display.
Display := I_STRNG(Speed);
IF ENO
THEN (* *);
ELSE (* *);
END_IF;
STRING
STRING, ,

(
).
( )
STRING, .
Compiler Properties.
STRING,
254(+2) .
FC 33 S5TI_TIM
S5TIME TIME
FC 33 S5TI_TIM
S5TIME TIME.
FC 33 S5TI_TIM .

31 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31. IEC-

FC 40 TIM_S5TI
TIME S5TIME
FC 40 TIM_S5TI
TIME S5TIME.
.
,
S5TIME ( TIME#02:46:30.000),
TIME#999.3,
ENO
FALSE ().
FC 16 I_STRNG
INT STRING
FC 16 I_STRNG INT
STRING. ( )
"" (
).
, ,
, ,
ENO FALSE
().
FC 5 DI_STRNG
DINT STRING
FC 5 DI_STRNG
DINT STRING. ( )
"" (
).
, ,
, ,
ENO FALSE
().
FC 30 R_STRNG
REAL STRING
FC 30 R_STRNG
REAL STRING. ( )
14 :
v.nnnnnnnExx ,
- ;
v - ;
n - 7- ;
x - 2- 10 (
).
, ,
, ,
,
,
ENO FALSE ().

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31 - 3

31. IEC-

FC 38 STRNG_I
STRING INT
FC 38 STRNG_I
STRING INT.
, .
0 6,
,

INT, ,
ENO FALSE ().
FC 37 STRNG_DI
STRING DINT
FC 37 STRNG_DI
STRING DINT.
,
.
0 11,
,

DINT, ,
ENO FALSE ().
FC 39 STRNG_R
STRING REAL
FC 39 STRNG_R
STRING REAL.
:
v.nnnnnnnExx ,
- ;
v - ;
n - 7- ;
x - 2- 10.
, 14, ,
, , ,
,
REAL,
, ENO
FALSE ().

31.2 (Comparison Functions)



.
TRUE (),
, FALSE (),
.
.
DT STRING.
31 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31. IEC-

:
Result := __DT(
DT1 := DT_var1,
DT2 := DT_var2);
Result := __STRING(
S1 := STRING_var1,
S2 := STRING_var2);
FC 9 EQ_DT
DT ( )
FC 9 EQ_DT
DATE_AND_TIME,
. TRUE (),
, , ,
DT1 DT2.
FC 28 NE_DT
DT ( )
FC 28 NE_DT
DATE_AND_TIME,
. TRUE
(), ,
, , DT1
DT2.
FC 14 GT_DT
DT
( ", ")
FC 14 GT_DT
DATE_AND_TIME,
", ".
TRUE (), ,
, , DT1
( , ),
DT2.
FC 12 GE_DT
DT
( " ")
FC 12 GE_DT
DATE_AND_TIME,
" ".
TRUE (), ,
, ,
DT1 ( , ),
DT2 ( ,
).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31 - 5

31. IEC-

FC 23 LT_DT
DT
( ", ")
FC 23 LT_DT
DATE_AND_TIME,
", ".
TRUE (), ,
, , DT1
( , ),
DT2.
FC 18 LE_DT
DT
( " ")
FC 18 LE_DT
DATE_AND_TIME,
" ".
TRUE (), ,
, ,
DT1 ( , ),
DT2 ( ,
).
FC 10 EQ_STRNG
STRING ( )
FC 10 EQ_STRNG
STRING,
. TRUE
(), ,
, , S1
S2.
FC 29 NE_STRNG
STRING ( )
FC 29 NE_STRNG
STRING,
. TRUE
(), ,
, , S1
S2.
FC 15 GT_STRNG
STRING
( ", ")
FC 15 GT_STRNG
STRING,
", ".
TRUE (), ,
, , S1
, S2.

31 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31. IEC-

ASCII- (, 'A'
, 'a' ?), .
. ,
,
,
,
S1 S2.
FC 13 GE_STRNG
STRING
( " ")
FC 13 GE_STRNG
, STRING,
"
". TRUE (),
, , ,
S1 , S2
.
ASCII- (, 'A' , 'a' ?),
.
. ,
,
, ,
S1
S2.
FC 24 LT_STRNG
STRING
( ", ")
FC 24 LT_STRNG
STRING,
", ".
TRUE (), ,
, , S1
, S2.
ASCII- (, 'A'
, 'a' ?), .
. ,
,
,
,
S1 S2.
FC 19 LE_STRNG
STRING
( " ")
FC 19 LE_STRNG
, STRING,
"
". TRUE (),
, , ,
S1 , S2
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31 - 7

31. IEC-

ASCII- (, 'A' , 'a' ?),


.
. ,
,
, ,
S1
S2.

31.3 STRING (STRING Functions)


STRING (STRING Functions)
.
STRING BR
ENO FALSE (),
.
STRING (STRING Functions)
()
(: , ,
STRING ?).
STRING
,
()
STRING .
,
. ,

, STRING
,
.

.
( )
STRING, .
Compiler Properties.
STRING,
254(+2) .
FC 21 LEN
STRING
:
int := LEN(string);
FC 21 LEN (
) .
. 254
.
.

31 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31. IEC-

FC 11 FIND
STRING
:
int:=FIND(IN1:=string,IN2:=string);
FC 11 FIND IN2 (
STRING) IN1 (
STRING). ;
IN2 .
IN1 IN2,
.
.
FC 20 LEFT

STRING
:
string:=LEFT(IN:=string,L:=int);
FC 20 LEFT (L)
, 1- ( ,
L ). L ,
, (IN) . L
= 0 IN = 0, "" .
L ,
"" , BR
ENO FALSE ().
FC 32 RIGHT

STRING
:
string:=RIGHT(IN:=string,L:=int);
FC 32 RIGHT (L)
, 1- ( ,
L ). L ,
, (IN) . L
= 0 IN = 0, "" .
L ,
"" , BR
ENO FALSE ().
FC 26 MID

STRING
:
string:=MID(IN:=string,L:=int,P:=int);
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

31 - 9

31. IEC-

FC 26 MID (L)
, P-
. L P ,
,
, P- IN.
. L = 0 IN = 0,
"" .
( P L
1, P / L
, "" ,
BR ENO FALSE
().
FC 2 CONCAT
() STRING
:
string:=CONCAT(IN1:=string,IN2:=string);
FC 2 CONCAT ()
STRING .
,
,
(RET_VAL),
, BR ENO
FALSE ().
FC 17 INSERT
STRING
:
string:=INSERT(IN1:=string,IN2:=string,P:=int);
FC 17 INSERT
IN2 IN1 - .
0, string2
string1; ,
,
.
,
"" , BR
ENO FALSE ().
BR ENO FALSE
(), ,
, ;

.
FC 4 DELETE
STRING
:
string:=DELETE(IN:=string,L:=int,P:=int);
31 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31. IEC-

FC 4 DELETE L
, P- . L
= 0 / P = 0, P ,
IN, .
L P ,
,
, P- .
P / L ,
"" , BR
ENO FALSE ().
FC 31 REPLACE
STRING
:
string:=REPLACE(IN1:=string,IN2:=string,L:=int,P:=int);
FC 31 REPLACE L
(IN1), P- ,
(IN2). L = 0,
(IN1). P = 0 P = 1, L
(IN1), 1- .
P ,
(IN1),
( ).
P / L ,
"" , BR
ENO FALSE ().
BR ENO FALSE (),
,
, ;

.

31.4 Date/Time-of-Day (Date/Time-of-Day


Functions)
Date/Time-of-Day (Date/Time-of-Day Functions)
DATE, TIME-OF-DAY
DATE_AND_TIME.
Date/Time-of-Day
BR ENO
FALSE (), .

FC 3 D_TOD_DT
DATE
, DATE_AND_TIME

TIME_OF_DAY

date_and_time:= D_TOD_DT(IN1:=date,IN2:=time_of_day);
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

31 - 11

31. IEC-

FC 3 D_TOD_DT DATE (D#)


TIME_OF_DAY (TOD#)
DATE_AND_TIME (DT#). IN1
DATE#1990-01-01 DATE#2089-12-31.
.

FC 6 DT_DATE
DATE DATE_AND_TIME
:
date:=DT_DATE(date_and_time);
FC 6 DT_DATE DATE (D#)
DATE_AND_TIME (DT#). DATE
DATE#1990-1-1 DATE#208912-31.
.
FC 7 DT_DAY

DATE_AND_TIME
:
int:=DT_DAY(date_and_time);
FC 7 DT_DAY
DATE_AND_TIME (DT#).
INT ( 1 7):
1
2
3
4
5
6
7
.
FC 8 DT_TOD

DATE_AND_TIME
:
time_of_day:=DT_TOD(date_and_time);
FC 8 DT_TOD
( TIME_OF_DAY (TOD#))
DATE_AND_TIME (DT#).
.

31 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31. IEC-

FC 1 AD_DT_TM

date_and_time:=AD_DT_TM(T:=date_and_time,D:=time);
FC 1 AD_DT_TM
( TIME (T#))
( DATE_AND_TIME (DT#))
(
DATE_AND_TIME (DT#)). ( T)
:
DT#1990-01-01-00:00:00.000 DT#2089-12-31-23:59:59.999.
.

, ,
BR ENO
"FALSE" ("").
FC 35 SB_DT_TM

date_and_time:=SB_DT_TM(T:=date_and_time,D:=time);
FC 35 SB_DT_TM
( TIME (T#))
( DATE_AND_TIME (DT#))
(
DATE_AND_TIME (DT#)). ( T)
:
DT#1990-01-01-00:00:00.000 DT#2089-12-31-23:59:59.999.
.

, ,
BR ENO
"FALSE" ("").
FC 34 SB_DT_DT

date_and_time:=SB_DT_DT(T1:=date_and_time,
T2:=date_and_time);
FC 34 SB_DT_DT
(
DATE_AND_TIME (DT#)).
( TIME (T#)).

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31 - 13

31. IEC-

:
DT#1990-01-01-00:00:00.000 DT#2089-12-31-23:59:59.999.
.
( T1) (
), ( 2),
; (
), , .

TIME,
, BR
ENO "FALSE"
("").

31.5
(Numerical Functions)
(Numerical Functions)

BR ENO
"FALSE" (""), :

,
, ;

REAL
(
).

FC 22 LIMIT
(Delimiter)
:
any_num:=LIMIT(MN:=any_num,IN:=any_num,MX:=any_num);
FC 22 IN
: MN MX.
INT, DINT REAL.
( )
.
( MN) ,
( MX).
,
, , :
( MN) ,
( MX).

31 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31. IEC-

FC 25 MAX

:
any_num:=MAX(IN1:=any_num,IN2:=any_num,IN3:=any_num);
FC 25 MAX
.
, INT,
DINT REAL. ( )
.
FC 27 MIN

:
any_num:=MIN(IN1:=any_num,IN2:=any_num,IN3:=any_num);
FC 27
.
, INT, DINT REAL.
( )
.
FC 36 SEL
" " (Binary selection)
:
any:=SEL(G:=bool,IN0:=any,IN1:=any);
FC 36 SEL
(IN0 IN1)
( G). IN0 IN1
, (
BOOL).
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

31 - 15

31. IEC-

31 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

:
, STEP 5,
STEP 7, STEP 7
STL- SCL- .
S5/S7 Converter (S5/S7-)
( , )
. S5/S7-
,
STEP 5, STL- STEP 7 .
STEP 7
Block Libraries ( ),
,
SFC
SFB.
FC SFB
,
(, , [offline]
Blocks []), .
""
, ,
CPU.

, , ,
. ,
,
(Help). ,

F1.
, ,
FAMILY () NAME ().
SFC SFB
CPU.
(offline) ,

( , , CPU).

(offline) Blocks ()
.
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

32 - 1

,
,
.


, , .
.


,

.
STL- SCL.

32 S5/S7- (S5/S7 Converter)


,
STEP 5, STEP 7.
33 (Block Libraries)
(), (SFC),

(SFB),

IEC-
( IEC-), S5-S7-
( ), -
( ),
(DP-).
34 STL-
STL-.
35 SCL-
SCL- SCL-.

32 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 S5/S7-

S5/S7-
, STEP 5,
STL- ( STEP 7) . S5/S7-

S5-

STEP 7. STEP 5,
STEP 7,

.
S5/S7-

() . ()

.
GRAPH
5 (sequential control) STEP 7,
S7-GRAPH.
S5/S7-
STEP 7.
, .
CA01 (CD)
SIMATIC S5
SIMATIC S7 : Selection Aids -> SIMATIC ( ->
SIMATIC). S5 : Edit ->
Generate Signal List ( -> ) Edit ->
Generate Configuration ( -> )
S7- S5.

32.1


STEP 5
nameST.S5D,
nameXR.INI , ,
nameZ0.SEQ. , -.
,
STEP 5.
STEP 7, ,
, .
, STEP 5.

STEP 7,
- FC.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 - 3

32. S5/S7-

FC
;
.
. 32.1 ,
() .

xxxST.S5D

xxxXR.INI

-
S7U5CAPx.MAC

xxxZ0.SEQ



S7
xxxAC.AWL


xxxAF.SEQ

xxxS7.SEQ

xxxA0.SEQ

. 32.1

(Siemens):
;
;
;
.
STEP 7
S5/S7
Converting Blocks ( S5/S7
). ,
S5/S7
(Siemens).
("integral
functions" - " "),
, CPU S5-115U.
STEP 5
, ,
.
32 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32. S5/S7-


,
.
STEP 5
, :

STEP 7;

, STEP 5 - (,
,
CPU);

, (,
STEP 5 STEP 7
);

(
STEP 7);

STEP 7
, ,
,
;

,
STEP 7;

STEP 7.

,
,

STEP 5
STEP 7
.

32.2

32.2.1
(PLC)
STEP 5
SIMATIC S7, ,
(PLC).
, :

CPU ?
?

, STEP
5? ,
STEP 7?

CPU STEP 7 (
, , )?

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 - 5

32. S5/S7-

S5
IM 463-2 S5- S7-400.
SIMATIC S5 SIMATIC S7
(I/O)
PROFIBUS-DP.

32.2.2
SIMATIC S5 " " ("program
execution levels")
SIMATIC S7, "
" ("priority classes"). ,
DB1, DX0, , ,
S7-CPU (, ,
["watchdog"] ).

S5 S7.
S5, S7

CPU.
DB1
S5-115U
DB1 RS. 32.1.1 ,
SIMATIC S7.
32.1.1 SIMATIC S5 SIMATIC S7
DB1 System Data (S5-115U)
941
945
S7 :
944
Restart delay ( )

CPU "Restart" ("")


Retentive feature ()
Cycle time monitoring
( )
Time interval for watchdog interrupt
( )
Software protection ( )

Output disable process images


( )

Integral clock ( )

CPU "Interrupts" ("")

CPU "Interrupts" ("")

- -

- -

Delay interrupt OB 6
( )
Time duration ()
Execution priority (
)
Sequential process image transfer
(
)
Reduced PIQ transfer
(
)
32 - 6

CPU "Retentivity" ("")


CPU "Cycle/Clock memory"
("/ ")
CPU "Watchdog interrupt" ("
")
CPU "Protection" ("")

SFC 26 UPDAT_PI, SFC 27 UPDAT_PO
CPU "Diagnostics/Clock"
("/")
SFC 0 SET_CLK, SFC 1 READ_CLK

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32. S5/S7-


CPU S5-115U ,
250 (CPU 945)
RS 125 (CPU 941 ... CPU 944).
32.1.2
SIMATIC S7.
32.1.2 SIMATIC S5 SIMATIC S7
OB 250 BS 125

Time intervals for watchdog interrupts


(
)
Time duration of delay interrupt
(

)
Reduced PIQ transfer
(
)

OB 250

BS 125

CPU "Watchdog interrupt"


(" ")

CPU "Interrupts" ("")

- -

, ,
L DBNO, L DBLG;

- -

- -

- -

SFC 22 CREAT_DB

:
SFC 36 MSK_FLT, SFC 37 DMSK_FLT,
SFC 38 READ_ERR,

Master Control Relay MCR


( )

Update process image


( )

Interpret data block DB1


( DB1)

Read/write DBA/DBL register


(/ DBA/DBL )
Call DX/FX blocks indirectly
( DX/FX
)
Change block ID
( )
Update configuration image
(
)
Set up block address list
( )
Create data block
( )
I/O accesses without QVZ
( (I/O)
QVZ)
Disable/Enable digital outputs
(/
)
Delete block
( )

S7 :

:
SFC 23 DEL_DB

:
SFC 26 UPDAT_PI, SFC 27 UPDAT_PO
- -

DX0
CPU, CPU,
DX0
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 - 7

32. S5/S7-

32.1.3 SIMATIC S7.


32.1.3 SIMATIC S5 SIMATIC S7
DX0

135U

155U

CPU "Restart" ("")

- - ( )

CPU "Cycle/Clock memory"


("/ ")

- -

- -

CPU "Watchdog interrupt"


(" ")

CPU "Interrupts" ("")

OB 122 (
/ [I/O])

OB

Restart characteristics
( )
Number of processed timer cells
( )
Cycle time monitoring
( )
Multiprocessor restart, interprocessor
communication flags (
,

)
Accuracy of floating point arithmetic
(

)
Timed interrupt handling
(
)
Process interrupt handling
( )
Process interrupt level/ level-triggered
interrupt (
/
)
Addressing error monitoring
( )
Error handling (system stop)
( (
))

S7 :

32.2.3
I/O
I/O
SM- S7.
?
,
S5 S7.
I/O IP
IP- S7-400
:

32 - 8

IP 240

,
, ;

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32. S5/S7-

IP 242B

IP 244

IP 246/247

WF 721/723

WF 705

.
,
S5 S7
. ,
IP-,
FM-.
CP
S5
CP- . CP- S7
SFB- (
)
S5. ,
STEP 7.
S5-
SFB-.
S5- S7-400
S5 S7-400,
IM 463-2.

S5.
IM 463-2.
S5 IM 314.

. (
). I/O S5- S5 IM 314 ( S5).
/ (I/O) P, Q, IM3 IM4.
S7-400 IP WF (. )
. , , S5- .
S5- S7-

Hardware
Configuration. IM 463-2
("adapter casing") :
Simatic 400 -> IM-400 -> S5 Adapter.
, ,
S7-, /
(I/O), .
:
, S7
S5 .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 - 9

32. S5/S7-

32.2.4
CPU
. , ,
, ?
"" ("extended") ( S )
, M 256.0.
S7 /
(I/O). , S5 / (I/O), P,
Q, IM3 IM4 " " ("global area"),
S7 P / (I/O) (
,
"" ["extended"] I/O
S7-400, , IM 4632). "" ("the page memory area")
.

( ) , ,
(PB),
(SB) (FB FX)
(FC).
(DB DX) S7.
,
(PLC) S7-300.
RI, RJ, RS RT
S7. ,
S7 .

RS- ;

CPU.
STEP 5
STEP 5
STEP
7 ( ;

STEP 7).
STEP 5
(warnings)
. ,
STEP 5 ,
:

32 - 10

DB1 DX0;


RS;
S7-CPU;

, ,
/ (I/O) "" ;
,
STEP 5,
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

32. S5/S7-

;
;


,
"" STEP 5- ;
( STEP 7)
"" STEP 5-, .

( )
( , ,
), ,
, , ,
,

(
)
, :
Buffer : ARRAY[1..256] OF WORD;


, .

32.3

32.3.1

STEP 5 , ,

(). "
" ("conversion macros") .
, .
SIMATIC
S7U5CAPA.MAC,
()
S7U5CAPB.MAC.
(instruction macros) OB (OB macros).
256
256 OB.
(instruction macros) STEP
5 STEP 7.
(instruction macros)
:
$MACRO: < STEP 5>
< STEP 7>
$ENDMACRO
STEP 5
. STEP 5
STEP 7.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 - 11

32. S5/S7-

:
STEP 5 CPU 945
("delay interrupt" - 6).

250:
L

KF

+200

KB

JU

OB

250

,
6.
,
STEP 5,
, , TB RT 200.0; ,
STEP 5
:
L

KF

+200

TB

RT

200.0

-:
$MACRO: TB RT 200.0
T MD 250;
CALL SFC 32 (
OB_NO

:= 20,

DTIME

:= MD 250,

SIGN

:= W#16#0000,

RET_VAL

:= MW 254);

$ENDMACRO
STEP 5 TB RT 200.0
STEP 7.
, ,
(" ") MW 250;
SFC 32.
20
6 .
(OB macros)
(JU OB JC OB) STEP 5
STEP 7.
(OB macros) :
$MACRO: < >
< STEP 7>
$ENDMACRO
:
STEP 5 CPU 945
160
.

32 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32. S5/S7-

STEP 7
SFC 47 WAIT.
:
$OBCALL: 160
T MW 250;
CALL SFC 47 (WT := MW 250);
$ENDMACRO

160 ( )
.
: Edit ->
Replace Macro ( -> ).
S7U5CAPA.MAC, .
: File -> Save ( -> ).
: File ->
Exit ( -> ).

32.3.2
nameXR.INI
STEP 5,
( STEP 5 : Manage ->
Create XREF ( -> ).
:

()

( ),
STEP 5 (
STEP 5 [ STEP 7])

(
STEP 5 ).

()
nameST.S5D, nameXR.INI, , ,
nameZ0.SEQ. "
" nameAC.AWL, nameA0.SEQ , ,
nameAF.SEQ nameS7.SEQ.
S7S5CAPx.MAC Windows.

32.3.3
S5/S7- ,
Windows 95/NT: Start -> Simatic -> Step 7 -> Convert File ( ->
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

32 - 13

32. S5/S7-

Simatic -> Step 7 -> ). : File ->


Open ( -> ) S5-,
. "OK"
,
"" "". ,

(
)

.
,

""

.
(

(offline) ,
S7-).
"Start" ("").
S5-
S5-ASCII (nameA0.SEQ),
S7-. ()
.

.
nameAF.SEQ.
, S5 S7 .
; ,
.
S5- (,
MC 5 ) S7- (,
).
"" ,
, .

.

32.3.4
32.2 ,
S5- S7-.
,
STEP 7 (, ,
" S " ["extended S memory bits"],
, 256).

(, +G
+R).
.

32 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32. S5/S7-

32.2
STEP 5

STEP 7

,


(Timers/counters functions)

,


(Timers/counters functions)


(Bit test functions)

SET

Set/Reset
(/)

(load)
(transfer) (
)

(Comparison functions)

(Calculation functions)

(Digital logic operations)

(Shift functions)

(Jump functions)

(Conversion functions)
/
(Disable/Enable interrupts)
Stop
(Stop functions)
- (NOP, ***, )
(Null operations)

(load)
(transfer)

(Comparison functions)

(Calculation functions)

(WORD logic operations)

(Shift functions)

(Jump functions)

(Conversion functions)
SFC 41, SFC 42
SFC 46
NOP, NETWORK, // (
)

( )
.
,
(, SEC =parname [_]),
(DO =parname [_]).

( !):
.
, STEP 7.

FC. DB
. DX
DB, 256 ( DX 1 DB 257, ..).
;

.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 - 15

32. S5/S7-

AUTHOR
() .
NAME () ( ,

).
(
, , ).
.
(load) (transfer)
P- PI
PQ . Q P-
( / [I/O]), 256 (,
L OB 0 L PIB 256; T OB 1
T PQB 257 ..).
F .
, "
" ("scratchpad memory"), FY 200 FY
255. STEP 5
, " " ("scratchpad
memory") .
STEP 5 STEP 7,
" "
. ,
STEP 5
STEP 7. " S " ["extended S
memory bits"] ,
256 (, A S 0.0 A M 256.0;
L SY 2 L MB 258 ..).
.

STEP 7
.

SET CLR
.
, STEP 7
( STEP 7 STEP 5
""). , DL 0 DBB 0; DR 0 DBB 1.
32.3
.
S7;
.

,
(load) ,

STEP 7. ,
STEP 5,
STEP 7 ( REAL).

32 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32. S5/S7-

32.3
STEP 5

STEP 7

DL [n]

DBB [2n]

DR [n]

DBB [2n+1]

DW [n]

DBW [2n]

DD [n]

DBD [2n]

D [(n).0..7]

DBX [(2n+1).0..7]

D [(n).8..15]

DBX [(2n).0..7]

STEP 5
,
, , ,
( )
STEP 5 REAL.

32.4

32.4.1 STEP 7

STEP 7,
(PLC) (
S7).
,
(execution properties) CPU,
( , ).

,
(module-independent program).
:

(S7-300 S7-400),
Hardware (), .

CPU (, OB ).
CPU SIMATIC Manager
.

Sources (), : Insert


-> External Sources File... ( -> ...)
nameAC.AWL ( )
.

S5-,
S5/S7 Converting Blocks ( S5/S7) Standard Library

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 - 17

32. S5/S7-

Blocks ()
S7-,
. S7-
(, SFC 20 BLKMOV),

System
Function
Blocks
(
)
, Blocks () .

,
() Symbols
: Symboltable -> Import... ( -> ...)
nameS7.SEQ .

,
,
(
,
).

32.4.2

.
, 32.4.
32.4
STEP 5
(load)
(transfer)



(LIR, TIR, LDI, TDI, MBA, MAB, MSA, MAS,
MSB, MBR, ABR, ACR)

(TNB, TNW, TXB, TXW)
DO
DO DW, DO FW
DO RS

LIM, SIM, IAE, RAE
""
(Semafore functions: SED, SEE, TSC, TSG)

(IAI, RAI, ASM, UBE)

32 - 18





SFC 20 BLKMOV



SFC

SFC 39 ... SFC 42

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32. S5/S7-

32.4.3

.
,
(I/O) .
STEP 5
( STEP 5
),
S7- "Replace",
( , , "" ""
).
,
,
;
.
:

,
,
; ,
(, ,
).

:
Options -> Customize ( ->
) ,
"Editor" ("")
Symbolic Representation ( ).

: File -> Generate Source


File... ( -> ...)
.
,
.
.

, Symbols
"" S5 ""
S7.

,

.

32.4.4

DO MW DO DW STEP 7. ,
() STEP 7, ,
,
.

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 - 19

32. S5/S7-


- ,
-
,
. ,
STEP 7
.
STEP 7 ,
, .

,


.



( ).


"" AR1,
STW
Accu 1 Accu 2 (.
).

BR
.
.


(Jump functions)

(Shift functions)
TNB, TNW


SPL

,
Accum 2
SFC 20
BLKMOV "" ANY.

LIR, TIR

DO MW DO DW
, (load)
(transfer) STEP 7 -.
STEP 5
STEP 7 (
). (.
).

,
.

32 - 20

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32. S5/S7-


AR1 AR2 ( FC).

STEP 5,

.
32.5 ,
STEP 5,
, ;
.
.
,
,
(. ).
(
!).
.
AR1
2 , AR 2
1 ( ).

" " ("break criterion"),
STEP 5; STEP 7
LOOP.

32.4.5 " "


" " , , ,
255, STEP 5
.
,
(
LIR/TIR), BR ( LRW/TRW).
STEP 7
( )
8095 ( S7-300) 32767 ( S7-400).
,
STEP 7,
"" STL-.

32.4.6
,
STEP 5,
" " ,
BR-,
(transfer) .

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 - 21

32. S5/S7-

32.5
STEP 5
FB 174
Name : COMP

:L
:T
:L
:T
LOOP :L

KB
DW
KB
DW
IW

FUNCTION FC 4
NAME: COMP
VAR_TEMP
conv_accum1
conv_accum2
conv_stw
END_VAR
BEGIN
NETWORK

20
2
50
3
10

L
T
L
T
LOOP: L

VOID

FUNCTION FC 4 VOID
NAME: COMP

: dword;
: dword;
: word;
BEGIN

20;
DBW 4;
50;
DBW 6;
IW 10;

LAR1

P#40.0;

LAR2

P#50.0;

LOOP: L

IW 10;

T
conv_accum1;
L
STW;
T
conv_stw;
L
DBB 5;
SLW 4;
LAR1;
L
conv_stw;
T
STW;
L
conv_accum1;
:DO
:L
:>F

DW 2
DW 0

DBW[AR1,P#0.0];

>I;

DBW[AR1,P#0.0];

>I;

T
conv_accum1;
TAK;
T
conv_accum2;
L
STW;
T
conv_stw;
L
DBB 6;
SLW 5;
SRW 5;
L
DBB 7;
SLW 3;
OW;
LAR1;
L
conv_stw;
T
STW;
L
conv_accum2;
L
conv_accum1;

END

:DO
:=

DW 3
F 0.0

:L
:I
:T
:L
:>F
:JC
:L
:I
:T
:L
:<F
:JC
:L
:I
:T
:JU
:NOP
:BE

DW 2
1
DW 2
KB 100

32 - 22

=END
DL 3
1
DL 3
KB 8
=LOOP
DR 3
1
DW 3
=LOOP
0

M[AR1,P#0.0];

L
DBW 4;
INC 1;
T
DBW 4;
L
100;
>I;
JC END;
L
DBB 6;
INC 1;
T
DBB 6;
L
8;
<I;
JC LOOP;
L
DBB 7;
INC 1;
T
DBW 6;
JU LOOP;
END: NOP 0;
END_FUNCTION

M[AR2,P#0.0];

+AR1 P#2.0;
CAR1;
L
P#200.0;
>D;
JC END;
+AR2

P#0.1;

JU LOOP;
END: NOP 0;
END_FUNCTION

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32. S5/S7-

STEP 7; STEP
( "" ) .
" "
STEP 7 ""
. ,
.
BR- "
" , , " ".
SFC 20 BLKMOV S5-
(transfer).
,
.
,
"" ANY-
.

32.4.7
,
.
, ,
, .
:

(WORD):
.

(I/O):
.

(transfer) :
.

32.4.8
STEP 7 STL
(. . 32.6).
(, , ("page addressing"),
).

32.4.9

OV OS STEP 7
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

32 - 23

32. S5/S7-

32.6

115U

135U

155U

STEP 7


(Process condition
code byte)

110


(Process accumulators)

111-113

131-133


(Handle interrupts)

120-123

122
141-143

SFC 39 DIS_IRT, SFC 40 EN_IRT,


SFC 41 DIS_AIRT, SFC 42 EN_AIRT

151

151

SFC 28 SET_TINT, SFC 29 CAN_TINT,

(Activate a timer job)




(Handle a delay interrupt)

(Variable waiting time)

SFC 30 ACT_TINT, SFC 31 QRY_TINT


-

153

153

SFC 32 SRT_DINT, SFC 33 QRY_DINT,


SFC 34 CAN_DINT

160

SFC 43 WAIT


(Delete block)

124

: SFC 23 DEL_DB


(Create block)

125

125

: SFC 22 CREAT_DB


(Read block stack)

170

- -


(Test data block)

181

SFC 24 TEST_DB


(Data block access)

180

- -

183, 184

254, 255

254, 255

SFC 20 BLKMOV ( )

182

182

SFC 20 BLKMOV

190-193

190-193

150

121, 150

SFC 0 SET_CLK, SFC 1 READ_CLK


(Cycle statistics)

152

1,
SFC 6 RD_SINFO

228

(Copy data blocks)



(Copy data areas)


(Set & read time-of-day)

,
SFC 6 RD_SINFO

(Read status inf)

32 - 24

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32. S5/S7-

32.6 ()

135U

155U

200-205

200-205

: GD-

223

223

- -

224

GD-

221

CPU


(Cycle time triggering)

222

31, 222

SFC 43 RE_TRIGR


(Transfer process images)

254, 255

126

SFC 26 UPDAT_PI, SFC 27 UPDAT_PO

()

160-163


(Sign extension)

220

220


(Page accesses)

216-218

- -

226, 227

- -


(Process shift register)

240-248

- -


(Handling blocks)

230-237

SFC

251

250-251

250

(. "
")


(Multiprocessor
communications)

(Compare restart types)



(Transfer interprocessor
communication flags)

115U

STEP 7

(Set cycle time)

(Counter loop)

(System program access)

(PID algorithm)

(Execute system service)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

32 - 25

32. S5/S7-

STEP 5, .
OV OS,

(, ).
SFC
(
) RET_VAL.
STEP 7 :
- OB 121, OB 122
- OB 80 OB 87.
32.7 ,
STEP 5 STEP 7.
32.7
S5-115 S5-135 S5-155

S7

19

19

19

OB 121

I/O

23

23

23

OB 122

24

24

24

OB 122

25

25

OB 122

26

26

26

OB 80

27

27

27

(Conditional STOP)

28

IB 0

28

OB 85

29

STOP


/ (I/O)

29

OB 122

30

30

OB 122

31

32

32

32

OB 121

33

33

33

OB 80

34

OB 81

34

34

(SFC)

I/

35

OB 86

35

OB 84

(Self-test errors)

36

32 - 26

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33

STEP 7 Standard
Library,
:

();

(SFB);

IEC- ( IEC-);

S5-S7- (
);

TI-S7- (
);

- ( );

(DP-).

33.1 ()
(Prio = , )
OB

Prio

(Main program)

10

(Time-of-day interrupt 0)

11

(Time-of-day interrupt 1)

12

(Time-of-day interrupt 2)

13

(Time-of-day interrupt 3)

14

(Time-of-day interrupt 4)

15

(Time-of-day interrupt 5)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33 - 1

33.

OB

Prio

16

(Time-of-day interrupt 6)

17

(Time-of-day interrupt 7)

20

(Time-delay interrupt 0)

21

(Time-delay interrupt 1)

22

(Time-delay interrupt 2)

23

(Time-delay interrupt 3)

30

0 (5 )

(Watchdog interrupt 0 [5 s])

31

1 (2 )

(Watchdog interrupt 1 [2 s])

32

2 (1 )

(Watchdog interrupt 2 [1 s])

33

10

3 (500 )

(Watchdog interrupt 3 [500 ms])

34

11

4 (200 )

(Watchdog interrupt 4 [200 ms])

35

12

5 (100 )

(Watchdog interrupt 5 [100 ms])

36

13

6 (50 )

(Watchdog interrupt 6 [50 ms])

37

14

7 (20 )

(Watchdog interrupt 7 [20 ms])

38

15

8 (10 )

(Watchdog interrupt 8 [10 ms])

40

16

(Hardware interrupt 0)

41

17

(Hardware interrupt 1)

42

18

(Hardware interrupt 2)

43

19

(Hardware interrupt 3)

44

20

(Hardware interrupt 4)

45

21

(Hardware interrupt 5)

46

22

(Hardware interrupt 6)

47

23

(Hardware interrupt 7)

60

25

(Multiprocessor interrupt)

70

25

I/O

72

28

CPU

(CPU redundancy error)

73

25

(Communication redundancy error)

80

26

81

26

82

26

83

26

84

26

CPU

85

26

33 - 2

1)

(I/O redundancy error)

1)

(Time error)
1)

1)

1)

(Power supply fault)

1)

1)

(Diagnostics interrupt)
1)

1)

(Insert/remove-module interrupt)
(CPU hardware fault)

1)

1)

(Priority class error)

1)

1)

1)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33.

OB

Prio

86

26

DP-

87

26

90

29

(Background processing)

100

27

(Complete restart)

101

27

(Restart)

102

27

""

(Cold restart)

121

(Programming error)

122

I/O

(I/O access error)

1)

1)

(DP error)
1)

1)

(Communication error)

1)

Prio = 28 (Prio = , )

33.2 (SFB)
IEC- IEC-
SFB

CTU

(Up counter)

CTD

(Down counter)

CTUD

(Up/down counter)

TP

(Pulse)

TON

(On delay)

TOF

(Off delay)


SFB

USEND

(Uncoordinated send)

URVC

(Uncoordinated receive)

12

BSEND

(Block-oriented send)

13

BRVC

(Block-oriented receive)

14

GET

(Read data from partner)

15

PUT

(Write data to partner)

16

PRINT

(Write data to printer)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33 - 3

33.

()
SFB

19

START

(Initiate complete restart


in partner)

20

STOP

STOP

(Set partner to STOP)

21

RESUME

(Initiate restart in partner)

22

STATUS

(Check status of partner)

23

USTATUS

(Receive status of
partner)

SFC

62

CONTROL

(Check communications
status)

CPU 312/314/614
SFB

29

HS_COUNT

""

(High-speed counter)

30

FREQ_MES

(Frequency meter)

38

HSC_A_B

"A/B"

(Control "Counter A/B")

39

POS

(Control "Positioning")

41

CONT_C

(Continuous closed-loop
control)

42

CONT_S

(Step-action control)

43

PULSEGEN

(Generate pulse)

SFC

63

AB_CALL

(Call assembler block)


SFC

RD_SINFO

(Read start information)

51

RDSYSST


SYS ST

(Read SYS ST sublist)

52

WR_USMSG

(Entry in the diagnostics


buffer)

33 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33.

,
SFB

33

ALARM

(Messages with
acknowledgment display)

34

ALARM_8

(Messages without
accompanying values)

35

ALARM_8P

(Messages with
accompanying values)

36

NOTIFY

(Messages without
acknowledgment display)

37

AR_SEND

(Send archive data)

SFC

EN_MSG

(Enable messages)

10

DIS_MSG

(Disable messages)

17

ALARM_SQ

(Messages that can be


acknowledged)

18

ALARM_S

(Messages that are always


acknowledged)

19

ALARM_SC

(Determine
acknowledgment status)

CPU
SFC

SET_CLK

(Set clock)

READ_CLK

(Read clock)

SET_RTM

(Set run-time meter)

CTRL_RTM

(Modify run-time meter)

READ_RTM

(Read run-time meter)

48

SNC_RTCB


()

(Synchronize slave clocks)

64

TIME_TCK

(Read system time)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33 - 5

33.

Drum
SFC

32

DRUM

(Drum)


SFC

20

BLKMOV

(Copy data area)

21

FILL

(Pre-assign data area)

22

CREAT_DB

(Generate data block)

23

DEL_DB

(Delete data block)

24

TEST_DB

(Test data block)

25

COMPRESS

""

(Compress memory)

44

REPL_VAL

(Enter substitute value)

81

UBLKMOV

"
"

(Copy Data area without gaps)


SFC

GADR_LGC

(Determine logical address)

49

LGC_GADR

(Determine slot)

50

RD_LGADR

(Determine all logical


addresses)

(I/O)
SFC

DP_PRAL

(Initiate haidware interrupt)

11

DPSYN_FR

(SYNC/FREEZE)

12

D_ACT_DP

/
(slave) DP-

(Deactivate or activate DP
slave)

13

DPNRM_DG

(Read diagnostics data)

14

DPRD_DAT


(slave) DP-

(Read slave data)

15

DPWR_DAT

(slave)
DP-

(Write slave data)

33 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33.


SFC

43

RE_TRIGR

(Retrigger cycle time monitor)

46

STP

STOP

(Change to STOP state)

47

WAIT

(Wait for delay time)


SFC

54

RD_DPARM

(Read predefined parameter)

55

WR_PARM

(Write dynamic parameter)

56

WR_DPARM

(Write predefined parameter)

57

PARM_MOD

(Parameterize module)

58

WR_REC

(Write data record)

59

RD_REC

(Read data record)


SFC

26

UPDAT_PI

(Update process-image
input table)

27

UPDAT_PO

(Update process-image
output table)

79

SET

I/O

(Set I/O bit field)

80

RSET

I/O

(Reset I/O bit field)


SFC

28

SET_TINT

(Set time-of-day interrupt)

29

CAN_TINT

(Cancel time-of-day interrupt)

30

ACT_TINT

(Activate time-of day interrupt)

31

QRY_TINT

(Query time-of-day interrupt)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33 - 7

33.

()
SFC

32

SRT_DINT

(Start time-delay interrupt)

33

CAN_DINT

(Cancel time-delay interrupt)

34

QRY_DINT

(Query time-delay interrupt)

35

MP_ALM

(Trigger multiprocessor alarm)

36

MSK_FLT

(Mask synchronous errors)

37

DMSK_FLT

(Unmask synchronous errors)

38

READ_ERR

(Read event status register)

39

DIR_IRT

(Disable asynchronous errors)

40

EN_IRT

(Enable asynchronous errors)

41

DIS_AIRT

(Delay asynchronous errors)

42

EN_AIRT

(Enable asynchronous errors)


SFC

65

X_SEND

(Send data externally)

66

X_RCV

(Receive data externally)

67

X_GET

(Read data externally)

68

X_PUT

(Write data externally)

69

X_ABORT

72

I_GET

73

I_PUT

74

I_ABORT

33 - 8

(Abort external connection)


(Read data internally)
(Write data internally)
(Abort internal connection)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33.


SFC

60

GD_SND

GD-

(Send GD packet)

61

GD_RCV

GD-

(Receive GD packet)

SFC

90

H_CTRL


H-CPU

H CPU

(Control Operating Modes on


H-CPU)

33.3 IEC-

FC

EQ_DT

28

NE_DT

14

GT_DT

12

GE_DT

23

LT_DT

18

LE_DT

10

EQ_STRNG

29

NE_STRNG

15

GT_STRNG

13

GE_STRNG

24

LT_STRNG

19

LE_STRNG

DT

DT

DT
" "
DT
" "
DT
" "
DT
" "

STRING

STRING

STRING "
"

STRING "
"

STRING "
"

STRING "
"

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

(Compare DT for equal to)


(Compare DT for not equal to)
(Compare DT for greater than)
(Compare DT for greater than
or equal to)
(Compare DT for less than)
(Compare DT for less than or
equal to)
(Compare STRING for equal
to)
(Compare STRING for not
equal to)
(Compare STRING for greater
than)
(Compare STRING for greater
than or equal to)
(Compare STRING for less
than)
(Compare STRING for less
than or equal to)

33 - 9

33.


FC

D_TOD_DT

DATE
TOD DT

(Combine DATE and TOD to


DT)

DT_DATE


DATE DT

(Extract DATE from DT)

DT_DAY


DT

(Extract day-of-the-week from


DT)

DT_TOD


DT

(Extract TOD from DT)

33

S5TI_TIM


S5TIME TIME

(Convert S5TIME to TIME)

40

TIM_S5TI


TIME S5TIME

(Convert TIME to S5TIME)

AD_DT_TM


TIME DT

(Add TIME to DT)

35

SB_DT_TM


TIME DT

(Subtract TIME from DT)

34

SB_DT_DT

DT
DT

(Subtract DT from DT)


FC

22

LIMIT

(Limiter)

25

MAX

(Maximum selection)

27

MIN

(Minimum selection)

26

SEL

"
"

(Binary selection)

STRING
FC

21

LEN

(Length of a STRING)

20

LEFT

(Left section of a STRING)

32

RIGHT

(Right section of a STRING)

26

MID

(Middle section of a STRING)

CONCAT

""

(Concatenate STRINGS)

17

INSERT

(Insert STRING)

DELETE

(Delete STRING)

31

REPLACE

(Replace STRING)

33 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33.

STRING ()
FC

11

FIND

(Find STRING)

16

I_STRNG

INT
STRING

(Convert INT to STRING)

DI_STRNG


DINT STRING

(Convert DINT to STRING)

30

R_STRNG


REAL STRING

(Convert REAL to STRING)

38

STRNG_I


STRING INT

(Convert STRING to INT)

37

STRNG_DI


STRING DINT

(Convert STRING to DINT)

39

STRNG_R


STRING REAL

(Convert STRING to REAL)

33.4 S5-S7-

FC

61

GP_FPGP

62

GP_GPFP

63

GP_ADD

(Add floating-point numbers)

64

GP_SUB

(Subtract floating-point
numbers)

65

GP_MUL

(Multiply floating-point
numbers)

66

GP_DIV

(Divide floating-point numbers)

67

GP_VGL

(Compare floating-point
numbers)

68

GP_RAD

(Find the square root of a


floating-point number)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

(Convert fixed-point to floatingpoint)


(Convert floating-point to fixedpoint)

33 - 11

33.


FC

85

ADD_32

86

SUB_32

87

MUL_32

88

DIV_32

89

RAD_16

90

REG_SCHB

32-

32-

32-


32-


16-

91

REG_SCHW

(Wordwise shift register)

92

REG_FIFO

FIFO

(Buffer (FIFO))

93

REG_LIFO

LIFO

(Stack (LIFO))

94

DB_COPY1

(Copy data area (direct))

95

DB_COPY2

(Copy data area (indirect)

96

RETTEN

97

LADEN

98

COD_B8

99

COD_32

33 - 12


""
(S5-155U)

""
(S5-155U)

BCD ( 8
)

BCD ( 8
)

(32-bit fixed-point adder)

(32-bit fixed-point subtractor)

(32 bit fixed-point multipher)

(32-bit fixed-point divider)


(16-bit fixed point square root
extractor)
(Bitwise shift register)

(Save scratchpad memory


(S5-155U))
(Load scratchpad memory
(S5-155U))
(BCD-binary conversion 8
decades)
(Binary-BCD conversion 8
decades)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33.


FC

69

MLD_TG

(Clock pulse generator)

70

MLD_TGZ

71

MLD_EZW

72

MLD_EDW




()

()

(Clock pulse generator with


timer function)
(Initial value single blinking
wordwise)
(Initial value double blinking
wordwise)

73

MLD_SAMW

()

(Group signal wordwise)

74

MLD_SAM

(Group signal)

75

MLD_EZ

76

MLD_ED

77

MLD_EZWK

78

MLD_EZDK

79

MLD_EZK

80

MLD_EDK






(
)

(
)



(Initial value single blinking)


(Initial value double blinking)
(Initial value single blinking
(wordwise) memory bit)
(Initial value double blinking
(wordwise) memory bit)
(Initial value single blinking
memory bit)
(Initial value double blinking
memory bit)


FC

81

COD_B4

82

COD_16

83

MUL_16

84

DIV_16


BCD ( 4
)

BCD ( 4
)
16-


16-

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

(BCD-binary conversion 4
decades)
(Binary-BCD conversion 4
decades)
(16-bit fixed-point multipher)

(16-bit fixed-point divider)

33 - 13

33.


FC

100

AE_460_1

460

(Analog input module 460)

101

AR_460_2

460

(Analog input module 460)

102

AR_463_1

463

(Analog input module 463)

103

AE_463_2

463

(Analog input module 463)

104

AE_464_1

464

(Analog input module 464)

105

AE_464_2

464

(Analog input module 464)

106

AE_466_1

466

(Analog input module 466)

107

AE_466_2

466

(Analog input module 466)

108

RLG_AA1

(Analog output module)

109

RLG_AA2

(Analog output module)

110

PER_ET1

I/O ET 100

(ET 100 distributed I/O)

111

PER_ET2

I/O ET 100

(ET 100 distributed I/O)


FC

112

SINUS

(Sine)

113

COSINUS

(Cosine)

114

TANGENS

(Tangent)

115

COTANG

(Cotangent)

116

ARCSIN

(Arc sine)

117

ARCCOS

(Arc cosine)

118

ARCTAN

(Arc tangent)

119

ARCCOT

(Arc cotangent)

120

LN_X

(Natural logarithm)

121

LG_X

(Logarithm to base 10)

122

B_LOG_X

(Logarithm to any base)

123

E_H_N

(Exponential function with


base e)

124

ZEHN_H_N


10

(Exponential function with


base 10)

125

A2_H_A1

(Exponential function with any


base)

33 - 14

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33.

33.5 TI-S7-
FB

80

LEAD_LAG

"/"

(Lead/lag algorithm)

81

DCAT

(Dirscrete control time


interrupt)

82

MCAT

(Motor control time interrupt)

83

IMC

(Index matrix comparison)

84

SMC

(Matrix scanner)

85

DRUM

(Event maskable drum)

86

PACK

(Collect/distribute table data)

FC

80

TONR

(Latching ON delay)

81

IBLKMOV

(Transfer data area indirectly)

82

RSET

(Reset process image bit by


bit)

83

SET

(Set process image bit by bit)

84

ATT

(Enter value in table)

85

FIFO

(Output first value in table)

86

TBL_FIND

(Find value in table)

87

LIFO

(Output last value in table)

88

TBL

(Execute table operation)

89

TBL_WRD

(Copy value from the table)

90

WSR

(Save datum)

91

WRD_TBL

(Combine table element)

92

SHRB

(Shift bit in bit shift register)

93

SEG


7-

(Bit pattern for 7-segment


display)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

33 - 15

33.

FC

94

ATH

95

HTA

96

ENCO


ASCII



ASCII-

97

DECO

(Set bit in word)

98

BCDCPL

BCD

(Generate ten's complement)

99

BITSUM

(Count set bits)

100

RSETI


PQ

(Reset PQ byte by byte)

101

SETI


PQ

(Set PQ byte by byte)

102

DEV

(Calculate standard deviation)

103

CDT

(Correlated data tables)

104

TBL_TBL

(Table combination)

105

SCALE

(Scale values)

106

UNSCALE

(Unscale values)

33.6

(ASCII hexadecimal
conversion)
(Hexadecimal-ASCII
conversion)
(Least significant set bit)

FB

41

CONT_C

(Continuous control)

42

CONT_S

(Step control)

43

PULSGEN

(Generate pulse)

33.7
FC

DP_SEND

(Send data)

DP_RECV

(Receive data)

DP_DIAG

(Diagnostics)

DP_CTRL

(Control)

33 - 16

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

34 STL-

, ,
.
:

A I [doubleword]

MD

LD

DBD
DID

DB

A I [AR1,P#offset]


AR1

A I [AR2,P#offset]


AR2

A [AR1,P#offset]


AR1

A [AR2,P#offset]


AR2

A #name

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

34 - 1

34. STL-

34.1
34.1.1
A

(AND) "1"

AN

(AND) "0"

(OR) "1"

ON

XN

(OR) "0"
(Exclusive OR)
"1"
(Exclusive OR)
"0"

DBX

DIX

DB

==0

<>0

>0

>=0

<0

<=0

UO

OV

OS

BR

A(

(AND)

AN(

(AND)

O(

(OR)

ON(

(OR)

X(

(Exclusive OR)

XN(

(Exclusive OR)

(OR), (AND)

NOT

RLO

SET

RLO

CLR

RLO

SAVE

RLO BR

34 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

34. STL-

34.1.2
=

FP

FN

DBX

DIX

DB

34.1.3
L

(load)

(transfer)

IB

IW

ID

QB

QW

QD

MB

MW

MD

LB

LW

LD

DBB

DBW

DBD

DIB

DB

DIW

DB

DID

DB

STW

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

34 - 3

34. STL-

PIB

(load)

PIW

(load)

PID

(load)

PQB

(transfer)

PQW

(transfer)

PQD

(transfer)

""

LC

BCD-

""

LC

BCD-

const

(load)

P#..

(load)

P#var

(load)


PUSH

""

POP

""

ENT

2 3 ""

LEAVE

3 4 ""

TAK

1 2

CAW

0 1 1

CAD

34.1.4
SP

" "

SE

" "

SD

" "

SS

" "

SF

" "

FR

34 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

34. STL-

34.1.5
CU

" "

CD

" "

FR

34.2
34.2.1
==I

INT

<>I

INT

>I

INT " "

>=I

INT " "

<I

INT " "

<=I

INT " "

==D

DINT

<>D

DINT

>D

DINT " "

>=D

DINT " "

<D

DINT " "

<=D

DINT " "

==R

REAL

<>R

REAL

>R

REAL " "

>=R

REAL " "

<R

REAL " "

<=R

REAL " "

34.2.2
SIN

COS

TAN

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

34 - 5

34. STL-

ASIN

ACOS

ATAN

SQR

SQRT

EXP

LN

34.2.3
+I

INT

-I

INT

*I

INT

/I

INT

+D

DINT

-D

DINT

*D

DINT

/D

DINT ( )

MOD

DINT ()

+R

REAL

-R

REAL

*R

REAL

/R

REAL

const

P#..

DEC

INC

34.2.4
ITD

INT DINT

ITB

INT BCD

DTB

DINT DINT

DTR

DINT REAL

34 - 6

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

34. STL-

BTI

BCD INT

BTD

BCD DINT
REAL DINT,
:

RND+

RND-

RND

TRUNC

INVI

INT

INVD

DINT

NEGI

INT

NEGD

DINT

NEGR

REAL

ABS

REAL

34.2.5
SLW

SLD

SRW

SRD

SSI

SSD

RLD

RRD

, Accum 2

RLDA

CC1

RRDA

CC1

34.2.6
AW

(AND)

AD

(AND)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

34 - 7

34. STL-

OW

(OR)

OD

(OR)

XOW

(Exclusive OR)

XOD

(Exclusive OR)

const

Accum 2

34.3
34.3.1
JU

JC

RLO = "1"

JCB

RLO = "1" RLO

JCN

RLO = "0"

JNB

RLO = "0" RLO

JBI

BR = "1"

JNBI

BR = "0"
,

JZ

= "0"

JN

<> "0"

JP

> "0"

JPZ

>= "0"

JM

< "0"

JMZ

<= "0"

JUO

JO

JOS

JL

LOOP

34 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

34. STL-

34.3.2 MCR
MCRA

MCR

MCRD

MCR

MCR(

MCR

)MCR

MCR

34.3.3
CALL

FB

CALL

FC

CALL

SFB

CALL

SFC

UC

FB

CC

FB

UC

FC

CC

FC

BEU

BEC

BE

OPN

DB

OPN

DI

CDB

DBNO

(load)

DINO

(load)

DBLG

(load)

DILG

(load)

NOP

NOP

BLD

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

34 - 9

34. STL-

34.4
LAR1

AR1

LAR2

AR2

MD

LD

DBD

DID

LAR1

AR1 Accum 1

LAR2

AR2 Accum 1

LAR1

AR2

AR1 AR2

LAR1

P#..

AR1

LAR2

P#..

AR2

LAR1

P#var

AR1

LAR2

P#var

AR2

TAR1

AR1

TAR2

AR2

MD

LD

DBD

DID

TAR1

AR1 Accum 1

TAR2

AR2 Accum 1

TAR1

AR2

AR1 AR2

CAR

AR1 AR2

+AR1

Accum 1 AR1

+AR2

Accum 1 AR2

+AR1

P#..

AR1

+AR2

P#..

AR2

34 - 10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

35 SCL-

35.1

()

(, )

**

, ()

+, -

*,/,DIV,MOD

+, -

, ,
,

<, <=, >, >=

=, <>

( )

NOT

(AND)

AND, &


(Exclusive OR)

XOR

(OR)

OR

10

:=

11

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

35 - 1

35. SCL-

35.2
IF

CASE

,
(INT)

FOR


" "

WHILE

REPEAT

CONTINUE

()

EXIT

GOTO

RETURN

( )

35.3

FC

Variable := FCx(...);
Variable := FCname(...);

SFC

Variable := SFCx(...);
Variable := SFCname(...);

FC

FCx(...);
FCname(...);

FB

FBx.DBx(...);
FBname.DBname(...);

SFB

SFBx.DBx(...);
SFBname.DBname(...);

FB
SFB

localname(...);

(:

Variable
name

= ,
= ())

FC SFC
SFB.

35 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

35. SCL-

35.4 CSL
35.4.1

Time_BCD :=

WORD

Timer_function(

(. )

T_NO = Timer_address,

TIMER

= Start_input,

BOOL

TV

= Timer_duration,

S5TIME

= Reset,

BOOL

= Timer_status,

BOOL

BI

= Binary_time);

WORD

Timer_function
,
:
S_PULSE


(Pulse time)

S_PEXT


(Extended pulse)

S_ODT


(ON delay)

S_ODTS


(Latching OFF delay)

S_OFFDT


(Off delay)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

35 - 3

35. SCL-

35.4.2

BCD count value :=

WORD

S_CU(
C_NO := Count_address,

COUNTER

CU

:= Count_up,

BOOL

:= Set_input,

BOOL

PV

:= Count_value,

WORD

:= Reset,

BOOL

:= Counter_status,

BOOL

CV

:= Bin_count_val);

WORD


BCD count value :=

WORD

S_CD(
C_NO := Count_address,

COUNTER

CD

:= Count_down,

BOOL

:= Set_input,

BOOL

PV

:= Count_value,

WORD

:= Reset,

BOOL

:= Counter_status,

BOOL

CV

:= Bin_count_val);

WORD


/
BCD count value :=

WORD

S_CU(
C_NO := Count_address,

COUNTER

CU

:= Count_up,

BOOL

CD

:= Count_down,

BOOL

:= Set_input,

BOOL

PV

:= Count_value,

WORD

:= Reset,

BOOL

:= Counter_status,

BOOL

CV

:= Bin_count_val);

WORD

35 - 4

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

35. SCL-

35.4.3

:
-
BOOL_TO_BYTE
BOOL_TO_WORD

BOOL_TO_DWORD
BYTE_TO_WORD
BYTE_TO_DWORD
WORD_TO_DWORD
INT_TO_DINT

INT_TO_REAL
DINT_TO_REAL
CHAR_TO_STRING


:
-

BYTE_TO_BOOL

WORD_TO_BOOL

, ,

DWORD_TO_BOOL
WORD_TO_BYTE
DWORD_TO_BYTE
DWORD_TO_WORD
CHAR_TO_BYTE

BYTE_TO_CHAR

CHAR_TO_INT
INT_TO_CHAR
STRING_TO_CHAR

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

35 - 5

35. SCL-

()
:
-

WORD_TO_INT

DWORD_TO_DINT

INT_TO_WORD

( )

DINT_TO_DWORD
REAL_TO_DWORD
DWORD_TO_REAL
DINT_TO_INT

REAL_TO_DINT

INT DINT

REAL_TO_INT
TRUNC
ROUND


REAL DINT

DINT_TO_TIME

DINT_TO_TOD

DINT_TO_DATE
DATE_TO_DINT
TIME_TO_DINT
TOD_TO_DINT
BLOCK_DB_TO_WORD

WORD_TO_BLOCK_DB

35.4.4

Result :=

REAL

Math_function(

(. )

Input_value);

ANY_NUM

(:

35 - 6

Result
Math_function
Input_value

= ,
= ,
= )

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

35. SCL-


Math_function
:

SIN

COS

TAN

ASIN

ACOS

ATAN

EXP

EXPD

10

LN

LOG

SQR

SQRT

ABS


:
ABS

Result :=

ANY_NUM

ABS(Input_value);

ANY_NUM

(:

Result
Input_value

= ,

= )

35.4.5

Result :=

ANY_BIT

Shift_function(

(. )

IN := Input_value,

ANY_NUM

INT

:= Num_of_places);

(:

Result
Shift_function
Input_value
Num_of_places

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

= ,
= ,
= ,
= )

35 - 7

35. SCL-

35 - 8

Shift_function

SHL

SHR

ROL

ROR

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

(absolute addressing)

3-16

1-27

1-29

1-29

1-26

(addressing variables)

3-15

1-29

(hardware interrupts)

21-4

23-8

33-1

OR (OR status bit)

15-4

CC0, CC1 ( " ")

15-6

DB (Data blocks)

3-7

TI-S7-

33-15

33-16

3-5

DP- (DP Slave)

1-13

DP- (DP Master)

1-13

AS-i (AS-i Master)

1-17

(Station-External) SFC-

20-61

(Station-Internal) SFC-

20-57

(L)

1-11

(I)

1-10

(Q)

1-10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

36 - 1

(Master Control Relay - MCR)

17-1

(binary flags)

15-3

1-28

1-8

(load memory)

1-8

3-35

STL

3-21

25-13

ANY_BIT

27-9

ANY_INT

27-9

ANY_NUM

27-9

(communications)

1-18

33-16

23-11

(communications functions)

1-20

1-8

DP- (DP-master system)

1-12

SYNC/FREEZE

20-41

(indirect addressing)

3-18

3-18

3-18

3-18

20-4

SCL-

30-4

(M)

1-10

3-1

36 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

EN/ENO

29-15

20-12

SIMATIC S5

1-7

1-10

20-10

1-6

1-27

1-29

L-

1-29

1-29

1-29

CPU

1-8

1-29

1-29

20-8

23-1

21-1

3-1

SCL-

35-1

STL-

34-1

29-15

CASE

28-1

CONTINUE

28-1

EXIT

28-1

FOR

28-1

GOTO

28-1

IF

28-1

REPEAT

28-1

RETURN

28-1

WHILE

28-1

(control statements)

28-1

OB (organization blocks)

3-6

SIMATIC S7

3-3

20-1

CPU

23-10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

36 - 3

23-11

SIMATIC S7-400H

1-7

( )

1-31

(subprocess images)

20-8

()

23-9

23-8

23-10

23-2

CPU

23-11

23-11

1-8

22-15

(first check)

15-4

1-29

AS-

1-16

PROFIBUS-PA

1-15

1-18

1-19

Industrial Ethernet

1-20

MPI

1-20

PROFIBUS

1-20

PTP (" ")

1-20

(user blocks)

3-6

21-19

23-9

(time-of-day interrupts)

21-10

(time-delay interrupts)

21-15

3-3

15-10

3-35

3-37

STL

3-24

SCL

3-28

STL

3-20

(work memory)
36 - 4

1-8
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

I/O (/)

1-11

1-7

(RLO)

15-4

(retentivity)

22-6

(memory reset)

22-6

(global data communications)

1-24

1-6

1-19

(symbolic addressing)

3-18

23-2

DP-

1-12

DP- (multi master system)

1-13

DP- (mono master system)

1-12

23-12

(system memory)

1-10

(system blocks)

3-7

(SFB)

33-3

(background scanning)

20-12

(status word)

15-6

(communications service)

1-19

(connection)

1-20

PROFIBUS-DP/RS 232C (PROFIBUS-DP/RS 232C link)

1-18

(status)

15-4

(standard blocks)

3-7

(start Information)

20-15

1-8

1-8

1-8

STL-

3-20

SCL-

3-28

20-4

()

1-10

1-8

1-8

20-10

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

36 - 5

(watchdog interrupt)

21-6

()

1-10

(block types)

3-6

22-8

CPU: Cycle/clock memory (/ )

3-5

CPU: Cyclic Interrupts ( )

3-5

CPU: Diagnostics/Clock (/ )

3-5

CPU: Integrated I/O ( I/O)

3-5

CPU: Interrupts ()

3-5

CPU: Memory ()

3-5

CPU: Multicomputing ( )

3-5

CPU: Protection ( )

3-5

CPU: Retentive memory ( )

3-5

CPU: Sturtup ( )

3-4

CPU: Time-of-day Interrupts ( )

3-5

23-3

20-4

FC (functions)

3-6

IEC-

33-9

FB (function blocks)

3-6

1-6

(digital flags)

36 - 6

15-3

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

A
AS-

1-16

C
Communication Error ( )

23-11

CPU Hardware Fault ( CPU)

23-10

CPU Redundancy Errors ( CPU)

23-11

D
DP/AS- (DP/AS-Interface link)

1-17

DP/PA (DP/PA coupler)

1-15

DP/PA (DP/PA link)

1-16

F
FREEZE

20-41

H
Hardware interrupts ( )

21-4

I
I/O Redundancy Errors ( I/O)

23-11

IEC-

31-1

IEC- Date/Time-of-day

31-11

IEC- STRING

31-8

IEC-

31-2

IEC- DATE_AND_TIME

31-5

IEC- STRING

31-6

IEC-

30-4

IEC-

30-2

IEC-

31-14

Insert/Remove Module Interrupt ( / )

23-9

ISO transport ( ISO transport)

1-25

ISO-on-TSP ( ISO-on-TSP)

1-25

M
Main program ( )

20-1

Memory-indirect-addressing ( )

3-18

MPI-

1-29

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

36 - 7

P
PROFIBUS-FDL

1-25

PROFIBUS-FMS

1-25

PROFIBUS-PA

1-15

Program Execution Errors ( )

23-10

R
Rack Failure ( )

23-11

Register-indirect area-crossing addressing (


)

3-18

Register-indirect area-internal addressing (


)

3-18

S
S5/S7-

32-3

S7-

1-24

Scan cycle monitor ( )

20-10

Scan cycle watchdog ( )

20-10

SCL-

29-1

SCL- (Conversion Functions)

30-6

SCL- (Shifting) (Rotating)

30-5

SCL-

30-2

SCL-

30-1

SCL-

30-1

SFB 0 CTU

30-4

SFB 1 CTD

30-4

SFB 12 BSEND

20-70

SFB 13 BRCV

20-70

SFB 14 GET

20-73

SFB 15 PUT

20-73

SFB 16 PRINT

20-74

SFB 19 START

20-75

SFB 2 CTUD

30-4

SFB 20 STOP

20-75

SFB 21 RESUME

20-75

SFB 22 STATUS

20-77

SFB 23 USTATUS

20-77

SFB 3 TP

30-2

36 - 8

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

SFB 4 TON

30-2

SFB 5 TOF

30-2

SFB 8 USEND

20-70

SFB 9 URCV

20-70

SFB-

20-67

SFC 0 SET_CLK

20-17

SFC 1 READ_CLK

20-17

SFC 11 DPSYC_FR

20-42

SFC 12 D_ACT_DP

20-45

SFC 13 DPNRM_DG

20-29

SFC 14 DPRD_DAT

20-25

SFC 15 DPWR_DAT

20-25

SFC 2 SET_RTM

20-19

SFC 20 BLKMOV

6-14

SFC 21 FILL

6-15

SFC 25 COMPRESS

20-20

SFC 26 UPDAT_PI

20-10

SFC 27 UPDAT_PO

20-10

SFC 28 SET_TINT

21-13

SFC 29 CAN_TINT

21-13

SFC 3 CTRL_RTM

20-19

SFC 30 ACT_TINT

21-13

SFC 31 QRY_TINT

21-11

SFC 32 SRT_DINT

21-17

SFC 33 CAN_DINT

21-17

SFC 34 QRY_TINT

21-17

SFC 35 MP_ALM

20-22

SFC 36 MSK_FLT

23-3

SFC 37 DMSK_FLT

23-3

SFC 38 READ_ERR

23-3

SFC 39 DIS_IRT

21-2

SFC 4 READ_RTM

20-19

SFC 40 EN_IRT

21-2

SFC 41 DIS_AIRT

21-2

SFC 42 EN_AIRT

21-2

SFC 43 RE_TRIGR

20-11

SFC 46 STP

20-21

SFC 47 WAIT

20-21

SFC 48 SNC_RTCB

20-17

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

36 - 9

SFC 49 LGC_GADR

22-13

SFC 5 GADR_LGC

22-13

SFC 50 RD_LGADR

22-13

SFC 51 RDSYSST

23-15

SFC 52 WR_USMSG

23-13

SFC 54 RD_DPARM

22-15

SFC 55 WR_PARM

21-4

SFC 56 WR_DPARM

21-4

SFC 57 PARM_MOD

21-4

SFC 58 WR_REC

22-16

SFC 59 RD_REC

20-29

SFC 6 RD_SINFO

20-16

SFC 60 GD_SND

20-56

SFC 61 GD_RCV

20-56

SFC 62 CONTROL

20-77

SFC 64 TIME_TCK

20-19

SFC 65 X_SEND

20-64

SFC 66 X_RCV

20-64

SFC 67 X_GET

20-64

SFC 68 X_PUT

20-64

SFC 69 X_ABORT

20-64

SFC 7 DP_PRAL

20-45

SFC 72 I_GET

20-59

SFC 73 I_PUT

20-59

SFC 74 I_ABORT

20-59

SFC 79 SET

17-6

SFC 80 RSET

17-6

SFC 81 UBLKMOV

6-15

SFC-

20-57

SIMATIC DPM

1-16

SIMATIC Manager

1-1

SIMATIC NET

1-18

SIMATIC S7-

3-1

STEP 7

1-1

Supply Error ( )

23-9

SYNC

20-41

T
Time-of-day interrupts ( )
36 - 10

21-10
Automating with STEP 7 in STL and SCL
STEP 7
STL SCL

Timing Error ( )

23-8

U
UNFREEZE

20-41

UNSYNC

20-41

W
Watchdog interrupt ( )

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

21-6

36 - 11

36 - 12

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

AI

Analog Input

AO

Analog Output

AS

Automation System

ASI

Actuator-Sensor Interface

- "-"

BR

Binary Result

CFC

Continuous Function Chard

- " "

CP

Communication Processor

CPU

Cential Processor Unit

DB

Data Block

DI

Digital Input

DO

Digital Output

DP

Distributed I/O

- I/O

EPROM

Erasable Programmable ROM

FB

Function Block

FBD

Function Block Diagramm

- " -"

FC

Function

FEPROM

Flash Erasable Programmable ROM

- -

FM

Function Module

IM

Interface Module

LAD

Ladder Diagramm

- " "

MCR

Master Control Relay

MPI

Multi Point Interface

- ""

OB

Organization Block

OP

Operator Panel

PG

Programming Device

PS

Power Supply

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

37 - 1

RAM

Random Access Memory

RLO

Result of Logic Operation

SCL

Structured Control Language

SDB

System Data Block

SFB

System Function Block

SFC

System Function Call

SM

Signal Module

STL

Statement List

- " "

SSL

System Status List

UDT

User Data Type

VAT

Variable Table

37 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

STEP 7

- :

STEP 7 V 5.0

S7 SCL V4.01

S7 Giaph V4.0

S7
HiGraph
V4.01

CFC V4.02
""

-
MS
Internet

Adobe Acrobat Reader


Explorer

()
()

80486 Pentium

(RAM)
32 MB ( 64 MB)

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL

38 - 1

STEP 7


150 MB STEP 7 V 5.0 (
( ) - )
10 MB S7 SCL V4.01
20 MB S7 Giaph V4.0
9 MB S7 HiGiaph V4.01
31 MB CFC V4.02


Windows 95 / Windows 98 / Windows NT

()
- CD-,
.
STEP 7
, STEP 7
STEP 7 Mini ("full version" - " ").
, S7 SCL, S7 Giaph, S7
HiGraph CFC,
STEP 7 V 5.0. ,
,
STEP 7 V 5.0.

README.WRI CD.

, ,
.

(, )

CFC: . README

CD
,
SIMATIC.
Siemens ,

, , , ,

.

38 - 2

Automating with STEP 7 in STL and SCL


STEP 7
STL SCL