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

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