You are on page 1of 45

STEP 7

SIEMENS.
-
230106

2009

__________
______________________2009
:
_______________ . .

.
__________________ . .

___ ___________________ 2009.

___ ________________ 2009.

:
. ., .

,
, . .

STEP 7
, , .
, ,
.

. 6. . 45. .: 2.


_____
________________200__.

................................................................................................................................................. 4
1.
S7............................ 5
1.1.
CPU .................................................................................................................. 5
2.
STEP 7 ............................................ 8
2.1.
............................................................ 8
2.2.
STEP......................................................... 8
2.3.
............................................................................ 9
2.4.
......................................................................... 11
2.5.
.................................................................... 13
2.6.
............................ 14
3.
STEP 7 ........16
3.1
.............................. 16
3.2
............................................... 17
3.3
............................................ 18
3.4
................................................. 18
3.5
.............................. 19
3.6
..... 19
3.7

.............................................................................. 20
3.8
..................................................... 21
3.9
........................................... 21
3.10

........................................................................................... 22
3.11
STEP 7
. ....................................................................... 23
4.
............................................................. 41
5.
.......................................................................43
6.
........................................................................45
7.
.............................................................................................................. 45


- (-)

.


,
.

:
, ,
().

(). -
.

SIMENS,
STEP7.
STEP 7 ,

,
,

.
,
,

,
.
:
) ;
) ;
) ;
) ;
) .
, STEP 7, 1.

1 -

S7,
STEP 7,
STEP 7 , ,
,
.

1. S7
1.1.
CPU
CPU
CPU
.
CPU . CPU
:

: ( S7-300) ( S7-400)
, c , .

:
.

:
. , DB:
DB DB, DB DI.
DB , ( ) c
.

: ,
.

S7-CPU :

,
. RAM
FLASH EPROM.


( RAM) ,
S7- , .
.

- ,
c c .

(RAM)
, , . , c
, .

2 - S7-CPU


( 3).

3 -

:
MCR (Master Control Rela). -
Master Control Relay - " " ,
, ,
. STEP7 MCR-
, ..
.
( )

CPU.
,
.
/FC - First Check Bit -
.
, /FC = "".
/FC "" (=, R, S),
, RLO BR.
.
/FC:

/FC = "1",

,

RJLO.

/FC = "",
,
..
.
RLO - Result of Logic Operation -

. ,
1, , 0.
(RLO)
:


, RLO. ,
.. /F="1".

, .. /FC= "",
RLO, ..
.

RLO
. . RLO="1",
RLO"0".

, , - ..
STA - Status Bit -
(U, UN, , ON, X. XN)
.
, (=. R, S),
STA , ,
, .. , .
, , "1".
, ,
.

OR -
OR "" "".
"1", RLO "" =1.
"". OR.

OV - Overflow -
,
. OV
, (,
, ). OV
.
OS - Overflow Stored -
OS OV,
. OS
OV , ,
OV. . , , <>
. ""
, , SI'S (,
OS="1").
BR - Binary Result Bit -
BR .

.
, BR (FC)
(FB) STL. LAD. FB FC
STL. LAD, RLO BR ,
(ENO) LAD.
ENO ,
.
(SFC)
(SFB) , BR ,
SFC SFB:

. BR = "".

. BR = " 1".

, 1 - Condition Codes -
1
.

2. STEP 7
2.1.


:
(,
, . .).
EPROMe (Erasable Programmable Read Only Memory)
. ,
.
:
,
(). .
-
.
,
.
,

, ( ).
:

(OB, PB, SB, FB, FX, DB, DX);

( 0 255).
2.2.
STEP.
STEP
. .

() - STL.
.

- LAD.
.

FUP.
.
STL- (statement). -
.
CPU. 3.6 STL-.
STEP .
(
).

4 - STEP 7
) STL-; ) STEP 7

2.3.

1
SIMATIC S7, .
SIMATIC S7
:
1. . (
)
,

1.
,
, 1.
,
. 1
.
, .
1-

. :
(1),
:

(100),

(0-38),

(10-17),

(20-23),

(40-47, 80-87, 121, 122).



.1
FC
. .
. ,
.


FB
.
. FB
STAT, .

(..
Instance
Data
Block, DI).
SFC

.
,
CPU.
.
SFB . FB, , SFC.
.2
DB
.
.
DI
.
. DB
, .
2. . (
)
,

1.
,
, 1.
,
. 1
.
, .
3. .
, , ,
. SIMATIC S7
. ,
, .
4. . ,

. .

SIMATIC
S7 .
5. .
- .
6. .

-

, ..

.
7. .
.
.
(. 2).
2 -

OB1
OB10 OB17
OB20 OB23

2
36

2 24
2 24

OB30 OB38
OB40 OB47
OB60
OB70,
OB72,
OB73
OB80 OB85
OB90
OB100
OB121, OB122

2.4.

7 15
2 24
16 23
2 24
25

25, 28, 25
2 28
26
2 26
29

27

SIMATIC S7 :
1.
( 32 )
a. :
(BOOL)
- , .
"0" (FALSE) "1" (TRUE).
(BYTE)
8 , 0 7 ( ).
. ,
8, : 0, 8, 16 .. Simatic S7
( ) ASCII-.
(WORD)
- , 16 .
, .
- . Simatic S7
( ), , , ..
(DWORD)
, - 32 4
. () () .
- . Simatic S7
, ,
IEEE ..
3 -

()
0 255
0 FF

(W)
0 65 535
o 0 FFFF

(D)
0 4 294 967 295
0 FFFF FFFF

-128+127
80 7F

-32 768 +32 767


8000 7FFF

-2 147 483 648 +2 147 483 647


8000 0000 7FFF FFFF

+1.175495-38 +3.402823+38
()
-1.175495-38 -3.402823+38
()

IEEE
32-

Char ()
CHAR (character, ) . CHAR
ASCII-, , ''.

,
.
b. :
INT ( )
INT (integer) (16- ). INT
.
.
0- 14- () . 15-
(sign, S).
DINT ( )
DINT (32-
). DINT-. 32 767 -32
768, L#.
DINT . 0-
30- . 31- .
REAL ()
REAL 32-
( ). REAL
.

. ,
10. STEP 7 REAL-
.
c. :
S5TIME
S5TIME STL, LAD FBD
SIMATIC. 16- 1 + 3 .
(hours), (minutes), (seconds) (milliseconds).
DATE ()
DATE
. , 01.01.1990.
, , .
TIME ()
TIME .
(d), (li), (), (s) (ms),
.
(ms) 32- .
TIME_OF_DAY ( )
TTMEOFDAY .
( 00:00)
. ,
, . , ,
. .
2.
( 32 )
STEP 7 :
DATE_AND_TIME (DT, ) ( BCD-);
STRING () 254 ;
ARRAY () - ( );

STRUCT () - (
).
:
STRING ( ), ARRAY STRUCT ().
3.
( 32 )
User data type - UDT ( ) ( ) .
,
, .
UDT ; ,
.
:

( )

( )

(OB, FB FC)

5 - STEP 7

2.5.

STEP 7
.

;
.

.
,
,
.
,
, , , .

Symbol 24 , ,
.
, 0 3,
I 0.0, I 0.1 ..
, 4 7, Q 4.0, Q 4.1 ..

.( [1]).
STEP 7 .

6 - STEP 7

2.6.

S7 ,
. ,
. .

. ,
.
S7
: - I
S7-200
.
, , :

I[ ]. [ ]
I0.1

I[(B)][ ]
IB4

I[(W)][ ]
IW4
I[(D)][ ]
ID4

: Q
S7-200 ,
, . ,
, :

Q[ ]. [ ]
Q[(B)][ ]
Q[(W)][ ]
Q[(D)][ ]

Q0.1
QB4
QW4
QD4

: V

, .
,
.
, , :

V[ ]. [ ]
V10.2

V[(B)][ ]
VB100

V[(W)][ ]
VW200
V[(D)][ ]
VD200
( ):
()
.
, , :

M[ ]. [ ]
M10.2

M[(B)][ ]
MB100

M[(W)][ ]
MW200
M[(D)][ ]
MD200

, .


[ ]
37

[ ]
5

[ ]
0

7 - ,

3. STEP 7
3.1
, 1 0.
, . 1 0
(binary digits) .
, , 1
, 0 .
1 0
. 1 0,
(RLO).

:
A

AN -
O

ON -
X

XN -
O


:
A(
AN(
O(
ON( -
X(
XN( -
)

:
=


:
NOT
RLO
SET
RLO 1
CLR
RLO 0
SAVE
RLO BR

R:
FN RL
FP RL
8

A:

AN:

O:

O:

ON: -

X:

A(:

8 -

3.2

1 (ACCU1) 2 (ACCU2)
:
== ACCU1 ACCU2
<> ACCU1 ACCU2
> ACCU1 ACCU2
< ACCU1 ACCU2
>= ACCU1 ACCU2
<= ACCU1 ACCU2

, RLO "1".
1 0
, .
:
? I : Integer (16-),
? D : Double Integer (32-),
? R : (32-).
3.3

STEP7
. , CPU.
16- .
STL 256 .
,
. , :
FR
L ACCU 1
LC BCD- ACCU 1(
)
R
S
CU
CD
3.4


,
.
LOOP .
.
, .
":" ,
.
:
JU
JL

(RLO)
:
JC RLO = 1
JCN RLO = 0
JCB RLO = 1 BR
JNB RLO = 0 BR

:
JZ
JN
JP
JM

JPZ
JMZ
JUO
3.5

(L) ()

- . CPU
, .. .
:
L
L STW ACCU 1
LAR1 AR2 1 (AR1) AR2
LAR1 <D> 1 (32 - )
LAR1 1 ACCU 1
LAR2 <D> (32 - )
LAR2 2 ACCU 1
T
T STW ACCU 1
TAR1 AR2 1 2
TAR1 <D> 1 (32-
)
TAR2 <D> 2 (32-
)
TAR1 1 ACCU 1
TAR2 1 ACCU 1
CAR 1 2

3.6

1
2. 1
2. , 1,
2 . CPU
, 3
2, 4 3.

4 . ,
(16 32 ):
+I ACCU 1 ACCU 2 Integer (16-)
-I ACCU 1 ACCU 2 Integer (16-)
*I ACCU 1 ACCU 2 Integer (16-)
/I ACCU 2 ACCU 1 Integer (16-)
+ Integer (16, 32 )
+D ACCU 1 ACCU 2 Double Integer (32-)
-D ACCU 1 ACCU 2 Double Integer (32-)
*D ACCU 1 ACCU 2 Double Integer (32-)
/D ACCU 2 ACCU 1 Double Integer (32-)
MOD Double Integer (32-)

.

10 -

3.7

1
2 . 1
2. , 1,
2 .
CPU
, 3 2,
4 3. 4 . IEEE
32- REAL.
32 IEEE :
+R ACCU 1 ACCU
-R ACCU 1 ACCU 2
*R ACCU 1 ACCU 2
/R ACCU 2 ACCU 1

32- IEEE :
ABS
SQR
SQRT
EXP
LN
S
COS
TAN
AS
ACOS
ATAN

3.8

(. CPU)
. n 2n; n
2n. ,
3 3 , 24.
16 2 ,

4. ,
, , 2,
, . ,
, (0
, 1 ). ,
, 1 . CC0 OV 0.
CC1 .
. , . RLO.
:
SSI
SSD
SLW
SRW
SLD
SRD

11 -

3.9
:
FR
L ACCU 1 Integer
LC ACCU 1 BCD -
R
SD
SE
SF
SP
SS
4 ,
STEP 7.

4 -

12 -

13 -

3.10

:
TAK ACCU 1 ACCU 2
PUSH CPU
PUSH CPU
POP CPU
POP CPU
ENT

LEAVE
INC ACCU 1-L-L
DEC ACCU 1-L-L
+AR1 ACCU 1 AR 1
+AR2 ACCU 1 AR 2
BLD
NOP 0
NOP 1
3.11 STEP 7
.
1:
14 ,
. : S1
S2 . : S3
S4 .
. S5 , , ,
.

14 - ()


,
14, ,
.
,
.
5 -

15-

16 -

2:
,
L T
:
MD4 = ((IW0 + DB5.W3) x 15) / MW2

17 -

STEP7 - ,

STEP 7, SIMATIC STEP 7, :

SIMATIC Manager;

LAD, STL, FDB Programming S7;

Memory Card Parameter Assignment;

NetPro Configuring Networks;

PID Control Parameter Assignment;

S7 SCL Programming S7 Blocks;

S7-GRAPH Programming Sequential Control System;

S7-PDIAG Configuring Process Diagnostic;

S7-PLCSIM Simulating Modules;

Setting the PG-PC Interface;

Configure SIMATIC Workspace.


STEP 7 SIMATIC Manager,
, , , ,
, ,
..
LAD, STL, FDB Programming S7 Blocks ,
,
. LAD Ladder Diagram ( )
, ,
, .. STL Statement List ( ) ,
. FDB Function Block Diagram ,
, ..
Memory Card Parameter Assignment
EPROM (
), , ,
.
NetPro Configuring Networks
, MPI, PROFIBUS Industrial Ethernet.
PID Control Parameter Assignment
-,
.
,
, :
SCL, ,
S7 SCL;
S7-GRAPH.
.
S7-PDIAG Configuring Process Diagnostic ,
.
S7-PLCSIM Simulating Modules
,
.
Setting the PG-PC Interface
, MPI.
Configure SIMATIC Workspace ,
.

5.1 SIMATIC MANAGER


SIMATIC Manager S7
(, , ,
). 16 .
SIMATIC Manager
File, PLC, View, Options, Window Help,
.
.
SIMATIC Manager,
17.
.
, 17.
, Windows Explorer. .
SIMATIC Manager
.
, (. 17) S7_Pro1,
. ,
.
. S7_Pro1
MPI(1), SIMATIC 300 Station.

18 - SIMATIC Manager

19 - SIMATIC Manager

, 18, ,
.
. 18
SIMATIC 300 Station,
CPU316-2DP(1).
Hardware.

20 - SIMATIC Manager

, CPU316-2DP(1) ,
S7 Program(1), Blocks
Sources. .
19 Blocks
, STEP 7, :
) , OB1,
;
) , FC1,
;
) , FB1,
, ,

;

) , DB1,
.

21 -

5.2 SIMATIC MANAGER


New Project
Wizard, File SIMATIC Manager.
, 2023.

22 -

, 20,
, , Finish,
, Next.
, 21,
() MPI-
(Multi Point Interface).

23 -

Next, ,
22.

24 -

,
, : OB1 Cycle Execution
; OB10 Time of Day Interrupt
, ; OB20 Time Delay Interrupt
, ; OB30
Cycle Interrupt ; OB40 Hardware
Interrupt 1 , ;
OB60 Multicomputing Interrupt ,
. , ,
, (OB80 Cycle Time Fault),
(OB81 Power Supply Fault), - (OB82 I/O Point Fault),
(OB84 CPU Fault), (OB85
OB Not Loaded Fault), (OB86 Loss of
Rack Fault), (OB87 Communication Fault).
: (OB100 Complete Restart);
(OB101 Restart); (OB102 Cold Restart).
(OB121 Programming Error)
(OB122 Module Access Error).

25 -

, , 22,
, STL ( ),
LAD ( ) FBD ( ).
, 23, .
New Project Wizard ,
Finish .
Insert.
,
.
5.3

Hardware Configuration. ,
, 18,
Hardware, , 24.

26 -

Hardware Configuration .
. .
-,
. ,
.
(Rack),
. , SIMATIC 300

SIMATIC 300 Rack-300


Rail. ,
drag & drop.
, 1
. SIMATIC 300 PS-300.
CPU CPU-300, 2.
S7-300 c 3 IM,
, 24 .

,
DM370 DUMMY SM-300\Special-300.
, .
8 (SM), (CP)
(FM).
, .
,
, .
, ,
View->Address Overview, ,
25. ,
, DI32xDC24V
DI4xNAMUR.
Type : I , Q
.
Addr. from Addr. to
, .
DI32xDC24V 32 , 4 0 3.
4 DI4xNAMUR.

27 -


, .
OB1.
R , S .
DI32xDC24V 4, DI4xNAMUR 5.
DP , IF ,

C++.

. ,

. ,
. General, 26,
, , , MPI
. ,
, Properties,
Adress.
27 Startup,
. S7-300
Warm restart. Cold restart.

28 - S7-300

Finished Message by Modules (ms)


.
, .

29 - S7-300

Transfer of Parameters to Modules


, .
Startup when expected/actual configuration differ
- DP S7400 ,
. .
S7-400
Reset outputs at hot restart
.
Retentive Memory ( )
,
STOP RUN. S7-300

, (OB, FC, FB, DB),


, , , ,
. ,
CPU.
28 Cycle/Clock Memory
.

30 - S7-300

Cycle/Clock Memory Scan Cycle


Monitoring Time (ms) . ,
STOP.
, ,
.
Cycle Load from Communication (%) ,
.
, .
, 20% ,
100 20 .
Clock Memory,
.
, .
Protection, 29,
.

31 - S7-300

Protection .
Keyswitch setting . ,
: 1 (STOP)
, (RUN) ; 2
, 3 ,

. , 2
3, Removable with password .
Diagnostic/Clock, 30,
Report cause of stop ,
( Synchronization)
( Correction factor). , 5 ,
Correction factor +5000 ms.

32 - . S7-300

, ,
Interrupts, Cyclic Interrupts, Time-of-Day Interrupts.
Interrupts 31.
, .. , .

Execution, , ,
Start Date Time of Day.

33 - Interrupts

1
, Station
Save. Save and Compile
DB . ,
Station -> Consistency Check.
, PLC -> Download,
STOP.
,
, .

5.4
STEP 7
: LAD ( ), STL ( ), FBD
( ).
34,
. LAD -, STL , FBD
-. , SIMATIC
Manager .

34 - STEP 7

,
, 21, .
Insert -> S7 Block
.
LAD/STL/FBD, 35.
: ; ;
.
.
.
, , ,
, networks.
.
, ,
, . ,
.
View ,
35.
: LAD, STL FBD.
.
LAD FBD
STL.
STL (,
STL, ).
STL LAD FBD .
, ,
STL.
.

35 - LAD/STL/FBD

FBD LAD
. ,
.

.
, .
New Network
, .
STL .

: Help -> Help on STL. :
Statement List Instructions ,
; Working with Statement List ( )
, , ,
.
STL
, .
, LAD/FBD.
,
.
.
, OB1, . ,
STL:
CALL FC 1
CALL FC 2
, . 5
PLC -> Download. ,
.
5.5
STEP 7 .
SIMATIC Manager,
Symbols,

LAD/STL/FBD, Options -> Symbol Table.


, 36.

36 -

.
.

.
Edit (. 36)
, : Search For ; Replace With
; Search Only ; From Cursor Down
; From Cursor Up
; Match Case
; Whole Word Only
; All ,
; Selection
.
*
, .
View
Filter, 37, ,
, (symbol properties).

37 - Filter

. ,
, .
: Name (), Address (), Data type ( ),
Comment (), Operator control and monitoring (
), Communication (), Message ().
: * ?.
, M*,
, M
.
SENSOR_?,
, SENSOR_ .
Valid Invalid
. ,
, View ->
Filter Invalid.
View -> Sort
.
, .
Symbol Table -> Export
,
. :
) ASCII Format (*.ASC) Notepad Word;
) Data Interchange Format (*.DIF) EXCEL;
) System Data Format (*.SDF) ACCESS;
) Assignment List (*.SEQ) STEP 5.
Symbol Table -> Import
, .
Symbol Table -> Import,
Import, Find in,
File Name OK.
Options -> Edit Symbols
Edit
Symbol
.
. , ,
. .

,
. SIMATIC Manager
Blocks, Properties Blocks.
Absolute Value ( ) Symbol ()
Priority ().
, , On = I 0.1,
On = I 1.0.
,
. I 0.0
I 1.0 .
, I 0.0.
,
, .
, I 0.0 ( On) I 1.0
. , I 0.0 I 1.0

. .
,
.
5.6 PLCSIM

S7-PLCSIM. ,
SIMATIC Manager.
Options Simulate Modules, S7PLCSIM, 38.
, S7PLCSIM, :
) IB ;
) QB ;
) MB ;
) T ;
) C ;
) Variable ;
) Stacks ;
) ACCUs ;
) Block Regs .

38 - PLCSIM

) ) . ,
, Tools -> Options -> Attach
Symbols, , 37.
Entry Point , , ,
S7 Program Symbols.

40.
.
SIMATIC Manager,
LAD/STL/FBD. ,
PLC -> Download. PLC ->
Download, .
S7-PLCSIM , PLC Power on.
STOP.
, ,
RUN ( ) RUN-P ( ).

, ,
.

39 - PLCSIM

40 - PLCSIM

4.
5.1

.
, ,
.

41 -


.

.

, ,
. ,
, , .

,
, ,
. :
,

, /
, ,
.

,
-
.
, .

,
.
.

,
.

. ,
.
, :
CPU
/


.

42 - ,

,
42 .
.
1. SIMATIC Manager, 18, File
-> New Project Wizard.
2. Next.
3. : CPU314, MPI , 2,
Next.
4. STL, OB1
Next.
5. Finish.
6. SIMATIC 300 STATION Hardware
.
7. CPU314.
SIMATIC 300 :
PS 307 2A PS-300; DI32xDC24V SM300\DI-300; DO32xDC24V/05A SM-300\\DO300.
8. Station > Save and Compile.
System Data.
9. SIMATIC Manager S7 Program(1)
Symbols.
10. Symbol Editor , 6.
.
6 -

Symbol
Main
Program
X1
X2
X3
X4
Y

Address

Data Type

OB 1

OB 1

I 0.0
I 0.1
I 0.2
I 0.3
Q 4.0

BOOL
BOOL
BOOL
BOOL
BOOL

Comment

11. SIMATIC Manager Blocks Insert - > S7


Block -> Function FC1 ,
STL OK .
12. SIMATIC Manager Blocks OB 1
LAD/STL/FBD.
13. CALL FC 1 .
14. SIMATIC Manager Blocks FC1
LAD/STL/FBD.
15. , (X1 X2) (X3
X4):
A(
O "X1"
O "X2"
)
A(
X "X3"
X "X4"
)
= "Y"
.
, : A ; O
; X , NOT .
, AN -.
16. S7-PLCSIM. Options
SIMATIC Manager Simulate Modules, S7PLCSIM.
17. SIMATIC Manager OB1 FC1
PLC Download.
18. Hadware PLC -> Download
.
19. S7-PLCSIM PLC Power on.
S7-PLCSIM, Tools>Options>Attach
Symbols. ,
Program, Symbols OK.
20. S7-PLCSIM : .
: X1, X2, X3, X4, Y
. .
,
, .
21. , , ,
CPU RUN. ,
.
, ,
.

5.
1-6
.
:
1. 80
.

2. ,
.
.
3. .
. :
.

. .
.
5
, , (
).
,

.

43 -

4. .
,
.
:

. 1. .
.
,
. ,
.
, .

44 -

5.
.
.
(9.00).
6. (.1).

. 60
.
:

: S1 S2 .
: S3 S4 .
.
;
.
;

;
40
.

45 -

6.
1. STEP 7,
. ?
2. SIMATIC Manager?
?
3. New Project Wizard.
4. SIMATIC
Manager?
5. Hardware
Configuration. S7-300?
6. , S7-300
S7-400.
7. STEP 7?
?
8. ?
.
9. ,
S7-PLCSIM.
10. S7PLCSIM?

7.
1. . STEP 7 STL SCL
SIMATIC S7-300/400. Siemens AG, ,
2001.
2. STEP 7 V5.3. 6ES7810-4CA07-8BW1.
Siemens AG, , 2004.